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

Side by Side Diff: cc/trees/layer_tree_host_pixeltest_masks.cc

Issue 1013463003: Update from https://crrev.com/320931 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 9 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 | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "build/build_config.h" 5 #include "build/build_config.h"
6 #include "cc/layers/content_layer_client.h" 6 #include "cc/layers/content_layer_client.h"
7 #include "cc/layers/picture_image_layer.h" 7 #include "cc/layers/picture_image_layer.h"
8 #include "cc/layers/picture_layer.h" 8 #include "cc/layers/picture_layer.h"
9 #include "cc/layers/solid_color_layer.h" 9 #include "cc/layers/solid_color_layer.h"
10 #include "cc/test/layer_tree_pixel_resource_test.h" 10 #include "cc/test/layer_tree_pixel_resource_test.h"
11 #include "cc/test/pixel_comparator.h" 11 #include "cc/test/pixel_comparator.h"
12 12
13 #if !defined(OS_ANDROID) 13 #if !defined(OS_ANDROID)
14 14
15 // TODO(enne): these time out on Windows. http://crbug.com/435632
16 #if !defined(OS_WIN)
17
18 namespace cc { 15 namespace cc {
19 namespace { 16 namespace {
20 17
21 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest; 18 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest;
22 19
23 INSTANTIATE_PIXEL_RESOURCE_TEST_CASE_P(LayerTreeHostMasksPixelTest); 20 INSTANTIATE_PIXEL_RESOURCE_TEST_CASE_P(LayerTreeHostMasksPixelTest);
24 21
25 class MaskContentLayerClient : public ContentLayerClient { 22 class MaskContentLayerClient : public ContentLayerClient {
26 public: 23 public:
27 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {} 24 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {}
(...skipping 27 matching lines...) Expand all
55 NOTIMPLEMENTED(); 52 NOTIMPLEMENTED();
56 return DisplayItemList::Create(); 53 return DisplayItemList::Create();
57 } 54 }
58 55
59 private: 56 private:
60 gfx::Size bounds_; 57 gfx::Size bounds_;
61 }; 58 };
62 59
63 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) { 60 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) {
64 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 61 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
65 gfx::Rect(200, 200), SK_ColorWHITE); 62 gfx::Rect(100, 100), SK_ColorWHITE);
66 63
67 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 64 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
68 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 65 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
69 background->AddChild(green); 66 background->AddChild(green);
70 67
71 gfx::Size mask_bounds(100, 100); 68 gfx::Size mask_bounds(50, 50);
72 MaskContentLayerClient client(mask_bounds); 69 MaskContentLayerClient client(mask_bounds);
73 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 70 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
74 mask->SetBounds(mask_bounds); 71 mask->SetBounds(mask_bounds);
75 mask->SetIsDrawable(true); 72 mask->SetIsDrawable(true);
76 mask->SetIsMask(true); 73 mask->SetIsMask(true);
77 green->SetMaskLayer(mask.get()); 74 green->SetMaskLayer(mask.get());
78 75
79 RunPixelResourceTest(background, 76 RunPixelResourceTest(background,
80 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png"))); 77 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png")));
81 } 78 }
82 79
83 TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { 80 TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) {
84 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 81 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
85 gfx::Rect(200, 200), SK_ColorWHITE); 82 gfx::Rect(100, 100), SK_ColorWHITE);
86 83
87 gfx::Size mask_bounds(100, 100); 84 gfx::Size mask_bounds(50, 50);
88 85
89 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); 86 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
90 mask->SetIsDrawable(true); 87 mask->SetIsDrawable(true);
91 mask->SetIsMask(true); 88 mask->SetIsMask(true);
92 mask->SetBounds(mask_bounds); 89 mask->SetBounds(mask_bounds);
93 90
94 SkBitmap bitmap; 91 SkBitmap bitmap;
95 bitmap.allocN32Pixels(400, 400); 92 bitmap.allocN32Pixels(200, 200);
96 SkCanvas canvas(bitmap); 93 SkCanvas canvas(bitmap);
97 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); 94 canvas.scale(SkIntToScalar(4), SkIntToScalar(4));
98 MaskContentLayerClient client(mask_bounds); 95 MaskContentLayerClient client(mask_bounds);
99 client.PaintContents(&canvas, gfx::Rect(mask_bounds), 96 client.PaintContents(&canvas, gfx::Rect(mask_bounds),
100 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL); 97 ContentLayerClient::PAINTING_BEHAVIOR_NORMAL);
101 mask->SetBitmap(bitmap); 98 mask->SetBitmap(bitmap);
102 99
103 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 100 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
104 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 101 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
105 green->SetMaskLayer(mask.get()); 102 green->SetMaskLayer(mask.get());
106 background->AddChild(green); 103 background->AddChild(green);
107 104
108 RunPixelResourceTest( 105 RunPixelResourceTest(
109 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png"))); 106 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png")));
110 } 107 }
111 108
112 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { 109 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) {
113 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 110 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
114 gfx::Rect(200, 200), SK_ColorWHITE); 111 gfx::Rect(100, 100), SK_ColorWHITE);
115 112
116 // Clip to the top half of the green layer. 113 // Clip to the top half of the green layer.
117 scoped_refptr<Layer> clip = Layer::Create(); 114 scoped_refptr<Layer> clip = Layer::Create();
118 clip->SetPosition(gfx::Point(0, 0)); 115 clip->SetPosition(gfx::Point(0, 0));
119 clip->SetBounds(gfx::Size(200, 100)); 116 clip->SetBounds(gfx::Size(100, 50));
120 clip->SetMasksToBounds(true); 117 clip->SetMasksToBounds(true);
121 background->AddChild(clip); 118 background->AddChild(clip);
122 119
123 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 120 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
124 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 121 gfx::Rect(25, 25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
125 clip->AddChild(green); 122 clip->AddChild(green);
126 123
127 gfx::Size mask_bounds(100, 100); 124 gfx::Size mask_bounds(50, 50);
128 MaskContentLayerClient client(mask_bounds); 125 MaskContentLayerClient client(mask_bounds);
129 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 126 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
130 mask->SetBounds(mask_bounds); 127 mask->SetBounds(mask_bounds);
131 mask->SetIsDrawable(true); 128 mask->SetIsDrawable(true);
132 mask->SetIsMask(true); 129 mask->SetIsMask(true);
133 green->SetMaskLayer(mask.get()); 130 green->SetMaskLayer(mask.get());
134 131
135 RunPixelResourceTest( 132 RunPixelResourceTest(
136 background, 133 background,
137 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); 134 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png")));
138 } 135 }
139 136
140 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) { 137 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) {
141 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 138 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
142 gfx::Rect(200, 200), SK_ColorWHITE); 139 gfx::Rect(100, 100), SK_ColorWHITE);
143 140
144 gfx::Size mask_bounds(100, 100); 141 gfx::Size mask_bounds(50, 50);
145 MaskContentLayerClient client(mask_bounds); 142 MaskContentLayerClient client(mask_bounds);
146 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 143 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
147 mask->SetBounds(mask_bounds); 144 mask->SetBounds(mask_bounds);
148 mask->SetIsDrawable(true); 145 mask->SetIsDrawable(true);
149 mask->SetIsMask(true); 146 mask->SetIsMask(true);
150 147
151 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 148 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
152 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 149 gfx::Rect(0, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
153 background->AddChild(green); 150 background->AddChild(green);
154 green->SetMaskLayer(mask.get()); 151 green->SetMaskLayer(mask.get());
155 152
156 gfx::Transform replica_transform; 153 gfx::Transform replica_transform;
157 replica_transform.Rotate(-90.0); 154 replica_transform.Rotate(-90.0);
158 155
159 scoped_refptr<Layer> replica = Layer::Create(); 156 scoped_refptr<Layer> replica = Layer::Create();
160 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); 157 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f));
161 replica->SetPosition(gfx::Point(100, 100)); 158 replica->SetPosition(gfx::Point(50, 50));
162 replica->SetTransform(replica_transform); 159 replica->SetTransform(replica_transform);
163 green->SetReplicaLayer(replica.get()); 160 green->SetReplicaLayer(replica.get());
164 161
165 RunPixelResourceTest( 162 RunPixelResourceTest(
166 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png"))); 163 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png")));
167 } 164 }
168 165
169 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { 166 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) {
170 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 167 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
171 gfx::Rect(200, 200), SK_ColorWHITE); 168 gfx::Rect(100, 100), SK_ColorWHITE);
172 169
173 gfx::Size mask_bounds(100, 100); 170 gfx::Size mask_bounds(50, 50);
174 MaskContentLayerClient client(mask_bounds); 171 MaskContentLayerClient client(mask_bounds);
175 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 172 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
176 mask->SetBounds(mask_bounds); 173 mask->SetBounds(mask_bounds);
177 mask->SetIsDrawable(true); 174 mask->SetIsDrawable(true);
178 mask->SetIsMask(true); 175 mask->SetIsMask(true);
179 176
180 // Clip to the bottom half of the green layer, and the left half of the 177 // Clip to the bottom half of the green layer, and the left half of the
181 // replica. 178 // replica.
182 scoped_refptr<Layer> clip = Layer::Create(); 179 scoped_refptr<Layer> clip = Layer::Create();
183 clip->SetPosition(gfx::Point(0, 50)); 180 clip->SetPosition(gfx::Point(0, 25));
184 clip->SetBounds(gfx::Size(150, 150)); 181 clip->SetBounds(gfx::Size(75, 75));
185 clip->SetMasksToBounds(true); 182 clip->SetMasksToBounds(true);
186 background->AddChild(clip); 183 background->AddChild(clip);
187 184
188 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 185 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
189 gfx::Rect(0, -50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 186 gfx::Rect(0, -25, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
190 clip->AddChild(green); 187 clip->AddChild(green);
191 green->SetMaskLayer(mask.get()); 188 green->SetMaskLayer(mask.get());
192 189
193 gfx::Transform replica_transform; 190 gfx::Transform replica_transform;
194 replica_transform.Rotate(-90.0); 191 replica_transform.Rotate(-90.0);
195 192
196 scoped_refptr<Layer> replica = Layer::Create(); 193 scoped_refptr<Layer> replica = Layer::Create();
197 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); 194 replica->SetTransformOrigin(gfx::Point3F(25.f, 25.f, 0.f));
198 replica->SetPosition(gfx::Point(100, 100)); 195 replica->SetPosition(gfx::Point(50, 50));
199 replica->SetTransform(replica_transform); 196 replica->SetTransform(replica_transform);
200 green->SetReplicaLayer(replica.get()); 197 green->SetReplicaLayer(replica.get());
201 198
202 RunPixelResourceTest(background, 199 RunPixelResourceTest(background,
203 base::FilePath(FILE_PATH_LITERAL( 200 base::FilePath(FILE_PATH_LITERAL(
204 "mask_with_replica_of_clipped_layer.png"))); 201 "mask_with_replica_of_clipped_layer.png")));
205 } 202 }
206 203
207 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) { 204 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) {
208 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 205 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
209 gfx::Rect(200, 200), SK_ColorWHITE); 206 gfx::Rect(100, 100), SK_ColorWHITE);
210 207
211 gfx::Size mask_bounds(100, 100); 208 gfx::Size mask_bounds(50, 50);
212 MaskContentLayerClient client(mask_bounds); 209 MaskContentLayerClient client(mask_bounds);
213 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 210 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
214 mask->SetBounds(mask_bounds); 211 mask->SetBounds(mask_bounds);
215 mask->SetIsDrawable(true); 212 mask->SetIsDrawable(true);
216 mask->SetIsMask(true); 213 mask->SetIsMask(true);
217 214
218 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 215 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
219 gfx::Rect(50, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 216 gfx::Rect(25, 0, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
220 background->AddChild(green); 217 background->AddChild(green);
221 218
222 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( 219 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer(
223 gfx::Rect(-50, 50, 50, 50), kCSSOrange); 220 gfx::Rect(-25, 25, 25, 25), kCSSOrange);
224 green->AddChild(orange); 221 green->AddChild(orange);
225 222
226 gfx::Transform replica_transform; 223 gfx::Transform replica_transform;
227 replica_transform.Rotate(180.0); 224 replica_transform.Rotate(180.0);
228 replica_transform.Translate(100.0, 0.0); 225 replica_transform.Translate(50.0, 0.0);
229 226
230 scoped_refptr<Layer> replica = Layer::Create(); 227 scoped_refptr<Layer> replica = Layer::Create();
231 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f)); 228 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
232 replica->SetPosition(gfx::Point()); 229 replica->SetPosition(gfx::Point());
233 replica->SetTransform(replica_transform); 230 replica->SetTransform(replica_transform);
234 replica->SetMaskLayer(mask.get()); 231 replica->SetMaskLayer(mask.get());
235 green->SetReplicaLayer(replica.get()); 232 green->SetReplicaLayer(replica.get());
236 233
237 RunPixelResourceTest( 234 RunPixelResourceTest(
238 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png"))); 235 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png")));
239 } 236 }
240 237
241 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { 238 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) {
242 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 239 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
243 gfx::Rect(200, 200), SK_ColorWHITE); 240 gfx::Rect(100, 100), SK_ColorWHITE);
244 241
245 gfx::Size mask_bounds(100, 100); 242 gfx::Size mask_bounds(50, 50);
246 MaskContentLayerClient client(mask_bounds); 243 MaskContentLayerClient client(mask_bounds);
247 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 244 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
248 mask->SetBounds(mask_bounds); 245 mask->SetBounds(mask_bounds);
249 mask->SetIsDrawable(true); 246 mask->SetIsDrawable(true);
250 mask->SetIsMask(true); 247 mask->SetIsMask(true);
251 248
252 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica. 249 // Clip to the bottom 3/4 of the green layer, and the top 3/4 of the replica.
253 scoped_refptr<Layer> clip = Layer::Create(); 250 scoped_refptr<Layer> clip = Layer::Create();
254 clip->SetPosition(gfx::Point(0, 25)); 251 clip->SetPosition(gfx::Point(0, 12));
255 clip->SetBounds(gfx::Size(200, 150)); 252 clip->SetBounds(gfx::Size(100, 75));
256 clip->SetMasksToBounds(true); 253 clip->SetMasksToBounds(true);
257 background->AddChild(clip); 254 background->AddChild(clip);
258 255
259 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 256 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
260 gfx::Rect(50, -25, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 257 gfx::Rect(25, -12, 50, 50), kCSSGreen, 1, SK_ColorBLACK);
261 clip->AddChild(green); 258 clip->AddChild(green);
262 259
263 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( 260 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer(
264 gfx::Rect(-50, 50, 50, 50), kCSSOrange); 261 gfx::Rect(-25, 25, 25, 25), kCSSOrange);
265 green->AddChild(orange); 262 green->AddChild(orange);
266 263
267 gfx::Transform replica_transform; 264 gfx::Transform replica_transform;
268 replica_transform.Rotate(180.0); 265 replica_transform.Rotate(180.0);
269 replica_transform.Translate(100.0, 0.0); 266 replica_transform.Translate(50.0, 0.0);
270 267
271 scoped_refptr<Layer> replica = Layer::Create(); 268 scoped_refptr<Layer> replica = Layer::Create();
272 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f)); 269 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
273 replica->SetPosition(gfx::Point()); 270 replica->SetPosition(gfx::Point());
274 replica->SetTransform(replica_transform); 271 replica->SetTransform(replica_transform);
275 replica->SetMaskLayer(mask.get()); 272 replica->SetMaskLayer(mask.get());
276 green->SetReplicaLayer(replica.get()); 273 green->SetReplicaLayer(replica.get());
277 274
278 RunPixelResourceTest(background, 275 RunPixelResourceTest(background,
279 base::FilePath(FILE_PATH_LITERAL( 276 base::FilePath(FILE_PATH_LITERAL(
280 "mask_of_replica_of_clipped_layer.png"))); 277 "mask_of_replica_of_clipped_layer.png")));
281 } 278 }
282 279
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 GL_ONE_COPY_RECT_STAGING_2D_DRAW, 358 GL_ONE_COPY_RECT_STAGING_2D_DRAW,
362 GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW, 359 GL_ONE_COPY_EXTERNAL_STAGING_2D_DRAW,
363 GL_ZERO_COPY_2D_DRAW, 360 GL_ZERO_COPY_2D_DRAW,
364 GL_ZERO_COPY_RECT_DRAW, 361 GL_ZERO_COPY_RECT_DRAW,
365 GL_ZERO_COPY_EXTERNAL_DRAW, 362 GL_ZERO_COPY_EXTERNAL_DRAW,
366 GL_ASYNC_UPLOAD_2D_DRAW)); 363 GL_ASYNC_UPLOAD_2D_DRAW));
367 364
368 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, 365 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
369 MaskOfLayerWithBackgroundFilter) { 366 MaskOfLayerWithBackgroundFilter) {
370 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 367 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
371 gfx::Rect(256, 256), SK_ColorWHITE); 368 gfx::Rect(100, 100), SK_ColorWHITE);
372 369
373 gfx::Size picture_bounds(256, 256); 370 gfx::Size picture_bounds(100, 100);
374 CheckerContentLayerClient picture_client(picture_bounds, SK_ColorGREEN, true); 371 CheckerContentLayerClient picture_client(picture_bounds, SK_ColorGREEN, true);
375 scoped_refptr<PictureLayer> picture = PictureLayer::Create(&picture_client); 372 scoped_refptr<PictureLayer> picture = PictureLayer::Create(&picture_client);
376 picture->SetBounds(picture_bounds); 373 picture->SetBounds(picture_bounds);
377 picture->SetIsDrawable(true); 374 picture->SetIsDrawable(true);
378 375
379 scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayer( 376 scoped_refptr<SolidColorLayer> blur = CreateSolidColorLayer(
380 gfx::Rect(256, 256), SK_ColorTRANSPARENT); 377 gfx::Rect(100, 100), SK_ColorTRANSPARENT);
381 background->AddChild(picture); 378 background->AddChild(picture);
382 background->AddChild(blur); 379 background->AddChild(blur);
383 380
384 FilterOperations filters; 381 FilterOperations filters;
385 filters.Append(FilterOperation::CreateBlurFilter(2.f)); 382 filters.Append(FilterOperation::CreateBlurFilter(1.5f));
386 blur->SetBackgroundFilters(filters); 383 blur->SetBackgroundFilters(filters);
387 384
388 gfx::Size mask_bounds(256, 256); 385 gfx::Size mask_bounds(100, 100);
389 CircleContentLayerClient mask_client(mask_bounds); 386 CircleContentLayerClient mask_client(mask_bounds);
390 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client); 387 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client);
391 mask->SetBounds(mask_bounds); 388 mask->SetBounds(mask_bounds);
392 mask->SetIsDrawable(true); 389 mask->SetIsDrawable(true);
393 mask->SetIsMask(true); 390 mask->SetIsMask(true);
394 blur->SetMaskLayer(mask.get()); 391 blur->SetMaskLayer(mask.get());
395 392
396 float percentage_pixels_large_error = 2.5f; // 2.5%, ~1600px / (256*256) 393 float percentage_pixels_large_error = 2.5f; // 2.5%, ~250px / (100*100)
397 float percentage_pixels_small_error = 0.0f; 394 float percentage_pixels_small_error = 0.0f;
398 float average_error_allowed_in_bad_pixels = 100.0f; 395 float average_error_allowed_in_bad_pixels = 100.0f;
399 int large_error_allowed = 256; 396 int large_error_allowed = 256;
400 int small_error_allowed = 0; 397 int small_error_allowed = 0;
401 pixel_comparator_.reset(new FuzzyPixelComparator( 398 pixel_comparator_.reset(new FuzzyPixelComparator(
402 true, // discard_alpha 399 true, // discard_alpha
403 percentage_pixels_large_error, 400 percentage_pixels_large_error,
404 percentage_pixels_small_error, 401 percentage_pixels_small_error,
405 average_error_allowed_in_bad_pixels, 402 average_error_allowed_in_bad_pixels,
406 large_error_allowed, 403 large_error_allowed,
407 small_error_allowed)); 404 small_error_allowed));
408 405
409 RunPixelResourceTest(background, 406 RunPixelResourceTest(background,
410 base::FilePath( 407 base::FilePath(
411 FILE_PATH_LITERAL("mask_of_background_filter.png"))); 408 FILE_PATH_LITERAL("mask_of_background_filter.png")));
412 } 409 }
413 410
414 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest, 411 TEST_P(LayerTreeHostMasksForBackgroundFiltersPixelTest,
415 MaskOfLayerWithBlend) { 412 MaskOfLayerWithBlend) {
416 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 413 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
417 gfx::Rect(256, 256), SK_ColorWHITE); 414 gfx::Rect(128, 128), SK_ColorWHITE);
418 415
419 gfx::Size picture_bounds(256, 256); 416 gfx::Size picture_bounds(128, 128);
420 CheckerContentLayerClient picture_client_vertical( 417 CheckerContentLayerClient picture_client_vertical(
421 picture_bounds, SK_ColorGREEN, true); 418 picture_bounds, SK_ColorGREEN, true);
422 scoped_refptr<PictureLayer> picture_vertical = 419 scoped_refptr<PictureLayer> picture_vertical =
423 PictureLayer::Create(&picture_client_vertical); 420 PictureLayer::Create(&picture_client_vertical);
424 picture_vertical->SetBounds(picture_bounds); 421 picture_vertical->SetBounds(picture_bounds);
425 picture_vertical->SetIsDrawable(true); 422 picture_vertical->SetIsDrawable(true);
426 423
427 CheckerContentLayerClient picture_client_horizontal( 424 CheckerContentLayerClient picture_client_horizontal(
428 picture_bounds, SK_ColorMAGENTA, false); 425 picture_bounds, SK_ColorMAGENTA, false);
429 scoped_refptr<PictureLayer> picture_horizontal = 426 scoped_refptr<PictureLayer> picture_horizontal =
430 PictureLayer::Create(&picture_client_horizontal); 427 PictureLayer::Create(&picture_client_horizontal);
431 picture_horizontal->SetBounds(picture_bounds); 428 picture_horizontal->SetBounds(picture_bounds);
432 picture_horizontal->SetIsDrawable(true); 429 picture_horizontal->SetIsDrawable(true);
433 picture_horizontal->SetContentsOpaque(false); 430 picture_horizontal->SetContentsOpaque(false);
434 picture_horizontal->SetBlendMode(SkXfermode::kMultiply_Mode); 431 picture_horizontal->SetBlendMode(SkXfermode::kMultiply_Mode);
435 432
436 background->AddChild(picture_vertical); 433 background->AddChild(picture_vertical);
437 background->AddChild(picture_horizontal); 434 background->AddChild(picture_horizontal);
438 435
439 gfx::Size mask_bounds(256, 256); 436 gfx::Size mask_bounds(128, 128);
440 CircleContentLayerClient mask_client(mask_bounds); 437 CircleContentLayerClient mask_client(mask_bounds);
441 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client); 438 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&mask_client);
442 mask->SetBounds(mask_bounds); 439 mask->SetBounds(mask_bounds);
443 mask->SetIsDrawable(true); 440 mask->SetIsDrawable(true);
444 mask->SetIsMask(true); 441 mask->SetIsMask(true);
445 picture_horizontal->SetMaskLayer(mask.get()); 442 picture_horizontal->SetMaskLayer(mask.get());
446 443
447 float percentage_pixels_large_error = 0.01f; // 0.01%, ~6px / (256*256) 444 float percentage_pixels_large_error = 0.04f; // 0.04%, ~6px / (128*128)
448 float percentage_pixels_small_error = 0.0f; 445 float percentage_pixels_small_error = 0.0f;
449 float average_error_allowed_in_bad_pixels = 256.0f; 446 float average_error_allowed_in_bad_pixels = 256.0f;
450 int large_error_allowed = 256; 447 int large_error_allowed = 256;
451 int small_error_allowed = 0; 448 int small_error_allowed = 0;
452 pixel_comparator_.reset(new FuzzyPixelComparator( 449 pixel_comparator_.reset(new FuzzyPixelComparator(
453 true, // discard_alpha 450 true, // discard_alpha
454 percentage_pixels_large_error, 451 percentage_pixels_large_error,
455 percentage_pixels_small_error, 452 percentage_pixels_small_error,
456 average_error_allowed_in_bad_pixels, 453 average_error_allowed_in_bad_pixels,
457 large_error_allowed, 454 large_error_allowed,
458 small_error_allowed)); 455 small_error_allowed));
459 456
460 RunPixelResourceTest(background, 457 RunPixelResourceTest(background,
461 base::FilePath( 458 base::FilePath(
462 FILE_PATH_LITERAL("mask_of_layer_with_blend.png"))); 459 FILE_PATH_LITERAL("mask_of_layer_with_blend.png")));
463 } 460 }
464 461
465 } // namespace 462 } // namespace
466 } // namespace cc 463 } // namespace cc
467 464
468 #endif // !defined(OS_WIN)
469 #endif // !defined(OS_ANDROID) 465 #endif // !defined(OS_ANDROID)
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698