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

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