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

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 + test 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
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, OpaqueRegionForLayer)
1046 {
1047 SkBitmap bitmap;
danakj 2014/07/30 13:31:25 What makes the device clip not a Rect in this test
sohanjg 2014/07/30 13:41:54 This is still a Rect, i wonder how can we set devi
sohanjg 2014/07/31 15:44:34 Done.
1048 ASSERT_TRUE(bitmap.allocN32Pixels(100, 100));
1049 bitmap.eraseColor(0);
1050 SkCanvas canvas(bitmap);
1051
1052 GraphicsContext context(&canvas);
1053 context.setTrackOpaqueRegion(true);
1054
1055 Path path;
1056 Color opaque(1.0f, 0.0f, 0.0f, 1.0f);
1057
1058 // Set Opaque Rect.
1059 context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
1060 // Begin non-opaque-preserving layer.
1061 context.setCompositeOperation(CompositeSourceOut);
1062 context.beginTransparencyLayer(0.5);
1063
1064 context.endLayer();
1065 EXPECT_EQ_RECT(IntRect(), context.opaqueRegion().asRect());
1066 EXPECT_PIXELS_MATCH_EXACT(bitmap, context.opaqueRegion().asRect());
1067
1068 // Set Opaque Rect.
1069 context.fillRect(FloatRect(30, 30, 90, 90), opaque, CompositeSourceOver);
1070 // Begin opaque-preserving layer.
1071 context.setCompositeOperation(CompositeSourceOver);
1072 context.beginTransparencyLayer(0.5);
1073
1074 context.endLayer();
1075 EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), context.opaqueRegion().asRect());
1076 EXPECT_PIXELS_MATCH(bitmap, context.opaqueRegion().asRect());
1077 }
1078
1045 #define DISPATCH1(c1, c2, op, param1) do { c1.op(param1); c2.op(param1); } while (0); 1079 #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); 1080 #define DISPATCH2(c1, c2, op, param1, param2) do { c1.op(param1, param2); c2.op( param1, param2); } while (0);
1047 1081
1048 TEST(GraphicsContextTest, RecordingTotalMatrix) 1082 TEST(GraphicsContextTest, RecordingTotalMatrix)
1049 { 1083 {
1050 SkBitmap bitmap; 1084 SkBitmap bitmap;
1051 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400)); 1085 ASSERT_TRUE(bitmap.allocN32Pixels(400, 400));
1052 bitmap.eraseColor(0); 1086 bitmap.eraseColor(0);
1053 SkCanvas canvas(bitmap); 1087 SkCanvas canvas(bitmap);
1054 GraphicsContext context(&canvas); 1088 GraphicsContext context(&canvas);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1114 EXPECT_FALSE(pic); 1148 EXPECT_FALSE(pic);
1115 1149
1116 // endRecording finally makes the picture accessible 1150 // endRecording finally makes the picture accessible
1117 dl->endRecording(); 1151 dl->endRecording();
1118 pic = dl->picture(); 1152 pic = dl->picture();
1119 EXPECT_TRUE(pic); 1153 EXPECT_TRUE(pic);
1120 EXPECT_EQ(1, pic->getRefCnt()); 1154 EXPECT_EQ(1, pic->getRefCnt());
1121 } 1155 }
1122 1156
1123 } // namespace 1157 } // namespace
OLDNEW
« no previous file with comments | « no previous file | Source/platform/graphics/skia/OpaqueRegionSkia.cpp » ('j') | Source/platform/graphics/skia/OpaqueRegionSkia.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698