Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(870)

Side by Side Diff: Source/platform/graphics/GraphicsContextTest.cpp

Issue 417153002: Avoid passing uninitialized value to markRectAsNonOpaque. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: tests updated. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/platform/graphics/RegionTracker.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 1024 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 context.setFillColor(opaque); 1035 context.setFillColor(opaque);
1036 path.moveTo(FloatPoint(10, 10)); 1036 path.moveTo(FloatPoint(10, 10));
1037 path.addLineTo(FloatPoint(40, 40)); 1037 path.addLineTo(FloatPoint(40, 40));
1038 context.strokePath(path); 1038 context.strokePath(path);
1039 1039
1040 context.endLayer(); 1040 context.endLayer();
1041 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect()); 1041 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
1042 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect()); 1042 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
1043 } 1043 }
1044 1044
1045 TEST(GraphicsContextTest, OpaqueRegionForLayerWithNonRectDeviceClip)
1046 {
1047 // For non-opaque preserving mode and deviceClip is not rect
1048 // we will mark opaque rect as empty.
1049 Path path;
1050 path.moveTo(FloatPoint(0, 0));
1051 path.addLineTo(FloatPoint(50, 50));
1052
1053 SkCanvas canvas(400, 400);
1054 GraphicsContext context(&canvas);
1055
1056 Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
1057
1058 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque);
1059
1060 context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
1061 EXPECT_EQ_RECT(IntRect(30, 30, 90, 90), context.opaqueRegion().asRect());
1062
1063 context.clipPath(path, RULE_EVENODD);
1064 context.setCompositeOperation(CompositeSourceOut);
1065 context.beginTransparencyLayer(0.5);
1066
1067 context.endLayer();
1068 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
1069
1070 // For opaque preserving mode and deviceClip is not rect
1071 // we will not alter opaque rect.
1072 context.setCompositeOperation(CompositeSourceOver);
1073 context.beginTransparencyLayer(0.5);
1074
danakj 2014/08/06 13:53:34 If the clip was a rect, what about this begin/end
sohanjg 2014/08/06 14:09:26 yes, for rect clip, we would have got a non-empty
danakj 2014/08/06 14:17:28 I don't understand, the opaque rect is non-empty?
sohanjg 2014/08/06 14:30:07 hmm..once we set context.clipPath, it seems we can
danakj 2014/08/06 14:32:10 You can clipRect with kReplace_Op for instance?
sohanjg 2014/08/07 08:07:46 I have updated the test and used rect device clip
1075 context.endLayer();
1076 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
1077 }
1078
1079 TEST(GraphicsContextTest, OpaqueRegionForLayerWithRectDeviceClip)
1080 {
1081
1082 SkBitmap bitmap;
1083 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400));
1084 bitmap.eraseColor(0);
1085 SkCanvas canvas(bitmap);
1086
1087 Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
1088
1089 GraphicsContext context(&canvas);
1090 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque);
1091
1092 context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
1093 EXPECT_EQ_RECT(IntRect(30, 30, 90, 90), context.opaqueRegion().asRect());
1094
1095 // For non-opaque preserving mode and deviceClip is rect
1096 // we will mark device clip rect as non opaque.
1097 context.setCompositeOperation(CompositeSourceOut);
1098 context.beginTransparencyLayer(0.5);
1099
1100 context.endLayer();
1101 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
1102 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
1103
1104 context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
1105
1106 // For opaque preserving mode and deviceClip is rect
1107 // we will intersect device clip rect with src opaque rect.
danakj 2014/08/06 13:53:33 Can you change the inputs so that we see the inter
sohanjg 2014/08/07 08:07:46 Done.
1108 context.setCompositeOperation(CompositeSourceOver);
1109 context.beginTransparencyLayer(0.5);
1110
1111 context.endLayer();
1112 EXPECT_EQ_RECT(IntRect(30, 30, 90, 90), context.opaqueRegion().asRect());
1113 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
1114 }
1115
1045 #define DISPATCH1(c1, c2, op, param1) do { c1.op(param1); c2.op(param1); } while (0); 1116 #define DISPATCH1(c1, c2, op, param1) do { c1.op(param1); c2.op(param1); } while (0);
1046 #define DISPATCH2(c1, c2, op, param1, param2) do { c1.op(param1, param2); c2.op( param1, param2); } while (0); 1117 #define DISPATCH2(c1, c2, op, param1, param2) do { c1.op(param1, param2); c2.op( param1, param2); } while (0);
1047 1118
1048 TEST(GraphicsContextTest, RecordingTotalMatrix) 1119 TEST(GraphicsContextTest, RecordingTotalMatrix)
1049 { 1120 {
1050 SkBitmap bitmap; 1121 SkBitmap bitmap;
1051 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400)); 1122 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400));
1052 bitmap.eraseColor(0); 1123 bitmap.eraseColor(0);
1053 SkCanvas canvas(bitmap); 1124 SkCanvas canvas(bitmap);
1054 GraphicsContext context(&canvas); 1125 GraphicsContext context(&canvas);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 EXPECT_FALSE(pic); 1185 EXPECT_FALSE(pic);
1115 1186
1116 // endRecording finally makes the picture accessible 1187 // endRecording finally makes the picture accessible
1117 dl->endRecording(); 1188 dl->endRecording();
1118 pic = dl->picture(); 1189 pic = dl->picture();
1119 EXPECT_TRUE(pic); 1190 EXPECT_TRUE(pic);
1120 EXPECT_EQ(1, pic->getRefCnt()); 1191 EXPECT_EQ(1, pic->getRefCnt());
1121 } 1192 }
1122 1193
1123 } // namespace 1194 } // namespace
OLDNEW
« no previous file with comments | « no previous file | Source/platform/graphics/RegionTracker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698