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

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: review comments addressed. 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 SkBitmap bitmap;
1048 ASSERT_TRUE(bitmap.allocN32Pixels(100, 100));
1049 bitmap.eraseColor(0);
1050 SkCanvas canvas(bitmap);
1051
1052 GraphicsContext context(&canvas);
1053 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque);
1054 Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
1055
1056 context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
1057
1058 context.setCompositeOperation(CompositeSourceOver);
1059 context.beginTransparencyLayer(0.5);
1060
danakj 2014/08/07 12:49:55 nit: rm extra whitespace here
sohanjg 2014/08/07 14:05:20 Done.
1061 context.endLayer();
1062 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect());
1063
1064 Path path;
1065 path.moveTo(FloatPoint(0, 0));
1066 path.addLineTo(FloatPoint(50, 50));
1067
1068 // For opaque preserving mode and deviceClip is not rect
1069 // we will not alter opaque rect.
1070 context.clipPath(path, RULE_EVENODD);
1071
1072 context.setCompositeOperation(CompositeSourceOver);
1073 context.beginTransparencyLayer(0.5);
1074
danakj 2014/08/07 12:49:55 nit: rm extra whitespace here
sohanjg 2014/08/07 14:05:20 Done.
1075 context.endLayer();
1076 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect());
1077
1078 // For non-opaque preserving mode and deviceClip is not rect
1079 // we will mark opaque rect as empty.
1080 context.setCompositeOperation(CompositeSourceOut);
1081 context.beginTransparencyLayer(0.5);
1082
1083 context.endLayer();
1084 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
1085 }
1086
1087 TEST(GraphicsContextTest, OpaqueRegionForLayerWithRectDeviceClip)
1088 {
1089
1090 SkBitmap bitmap;
1091 ASSERT_TRUE(bitmap.allocN32Pixels(100, 100));
1092 bitmap.eraseColor(0);
1093 SkCanvas canvas(bitmap);
1094
1095 Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
1096
1097 GraphicsContext context(&canvas);
1098 context.setRegionTrackingMode(GraphicsContext::RegionTrackingOpaque);
1099
1100 context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
1101 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect());
1102
1103 // For non-opaque preserving mode and deviceClip is rect
1104 // we will mark device clip rect as non opaque.
1105 context.setCompositeOperation(CompositeSourceOut);
1106 context.beginTransparencyLayer(0.5);
1107
danakj 2014/08/07 12:49:55 nit: rm extra whitespace here
sohanjg 2014/08/07 14:05:20 Done.
1108 context.endLayer();
1109 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
1110 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
1111
1112 context.fillRect(FloatRect(30, 30, 100, 100), opaque, CompositeSourceOver);
1113
1114 // For opaque preserving mode and deviceClip is rect
1115 // we will intersect device clip rect with src opaque rect.
danakj 2014/08/07 12:49:56 You didn't set any device clip rect in this test,
sohanjg 2014/08/07 14:05:20 Done.
1116 context.setCompositeOperation(CompositeSourceOver);
1117 context.beginTransparencyLayer(0.5);
1118
danakj 2014/08/07 12:49:55 nit: rm extra whitespace here
sohanjg 2014/08/07 14:05:20 Done.
1119 context.endLayer();
1120 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect());
1121 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
1122 }
1123
1045 #define DISPATCH1(c1, c2, op, param1) do { c1.op(param1); c2.op(param1); } while (0); 1124 #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); 1125 #define DISPATCH2(c1, c2, op, param1, param2) do { c1.op(param1, param2); c2.op( param1, param2); } while (0);
1047 1126
1048 TEST(GraphicsContextTest, RecordingTotalMatrix) 1127 TEST(GraphicsContextTest, RecordingTotalMatrix)
1049 { 1128 {
1050 SkBitmap bitmap; 1129 SkBitmap bitmap;
1051 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400)); 1130 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400));
1052 bitmap.eraseColor(0); 1131 bitmap.eraseColor(0);
1053 SkCanvas canvas(bitmap); 1132 SkCanvas canvas(bitmap);
1054 GraphicsContext context(&canvas); 1133 GraphicsContext context(&canvas);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 EXPECT_FALSE(pic); 1193 EXPECT_FALSE(pic);
1115 1194
1116 // endRecording finally makes the picture accessible 1195 // endRecording finally makes the picture accessible
1117 dl->endRecording(); 1196 dl->endRecording();
1118 pic = dl->picture(); 1197 pic = dl->picture();
1119 EXPECT_TRUE(pic); 1198 EXPECT_TRUE(pic);
1120 EXPECT_EQ(1, pic->getRefCnt()); 1199 EXPECT_EQ(1, pic->getRefCnt());
1121 } 1200 }
1122 1201
1123 } // namespace 1202 } // 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