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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 // 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_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 namespace cc { 15 namespace cc {
16 namespace { 16 namespace {
17 17
18 class LayerTreeHostMasksPixelTest : public LayerTreePixelTest {}; 18 typedef ParameterizedPixelResourceTest LayerTreeHostMasksPixelTest;
19
20 INSTANTIATE_PIXEL_RESOURCE_TEST_CASE_P(LayerTreeHostMasksPixelTest);
19 21
20 class MaskContentLayerClient : public ContentLayerClient { 22 class MaskContentLayerClient : public ContentLayerClient {
21 public: 23 public:
22 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {} 24 explicit MaskContentLayerClient(const gfx::Size& bounds) : bounds_(bounds) {}
23 ~MaskContentLayerClient() override {} 25 ~MaskContentLayerClient() override {}
24 26
25 void DidChangeLayerCanUseLCDText() override {} 27 void DidChangeLayerCanUseLCDText() override {}
26 28
27 bool FillsBoundsCompletely() const override { return false; } 29 bool FillsBoundsCompletely() const override { return false; }
28 30
(...skipping 15 matching lines...) Expand all
44 inset_rect.width(), inset_rect.height()), 46 inset_rect.width(), inset_rect.height()),
45 paint); 47 paint);
46 inset_rect.Inset(3, 3, 2, 2); 48 inset_rect.Inset(3, 3, 2, 2);
47 } 49 }
48 } 50 }
49 51
50 private: 52 private:
51 gfx::Size bounds_; 53 gfx::Size bounds_;
52 }; 54 };
53 55
54 TEST_F(LayerTreeHostMasksPixelTest, MaskOfLayer) { 56 TEST_P(LayerTreeHostMasksPixelTest, MaskOfLayer) {
55 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 57 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
56 gfx::Rect(200, 200), SK_ColorWHITE); 58 gfx::Rect(200, 200), SK_ColorWHITE);
57 59
58 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 60 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
59 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 61 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
60 background->AddChild(green); 62 background->AddChild(green);
61 63
62 gfx::Size mask_bounds(100, 100); 64 gfx::Size mask_bounds(100, 100);
63 MaskContentLayerClient client(mask_bounds); 65 MaskContentLayerClient client(mask_bounds);
64 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 66 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
65 mask->SetBounds(mask_bounds); 67 mask->SetBounds(mask_bounds);
66 mask->SetIsDrawable(true); 68 mask->SetIsDrawable(true);
67 mask->SetIsMask(true); 69 mask->SetIsMask(true);
68 green->SetMaskLayer(mask.get()); 70 green->SetMaskLayer(mask.get());
69 71
70 RunPixelTest(PIXEL_TEST_GL, 72 RunPixelResourceTest(background,
71 background, 73 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png")));
72 base::FilePath(FILE_PATH_LITERAL("mask_of_layer.png")));
73 } 74 }
74 75
75 TEST_F(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) { 76 TEST_P(LayerTreeHostMasksPixelTest, ImageMaskOfLayer) {
76 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 77 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
77 gfx::Rect(200, 200), SK_ColorWHITE); 78 gfx::Rect(200, 200), SK_ColorWHITE);
78 79
79 gfx::Size mask_bounds(100, 100); 80 gfx::Size mask_bounds(100, 100);
80 81
81 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create(); 82 scoped_refptr<PictureImageLayer> mask = PictureImageLayer::Create();
82 mask->SetIsDrawable(true); 83 mask->SetIsDrawable(true);
83 mask->SetIsMask(true); 84 mask->SetIsMask(true);
84 mask->SetBounds(mask_bounds); 85 mask->SetBounds(mask_bounds);
85 86
86 SkBitmap bitmap; 87 SkBitmap bitmap;
87 bitmap.allocN32Pixels(400, 400); 88 bitmap.allocN32Pixels(400, 400);
88 SkCanvas canvas(bitmap); 89 SkCanvas canvas(bitmap);
89 canvas.scale(SkIntToScalar(4), SkIntToScalar(4)); 90 canvas.scale(SkIntToScalar(4), SkIntToScalar(4));
90 MaskContentLayerClient client(mask_bounds); 91 MaskContentLayerClient client(mask_bounds);
91 client.PaintContents(&canvas, 92 client.PaintContents(&canvas,
92 gfx::Rect(mask_bounds), 93 gfx::Rect(mask_bounds),
93 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED); 94 ContentLayerClient::GRAPHICS_CONTEXT_ENABLED);
94 mask->SetBitmap(bitmap); 95 mask->SetBitmap(bitmap);
95 96
96 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 97 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
97 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 98 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
98 green->SetMaskLayer(mask.get()); 99 green->SetMaskLayer(mask.get());
99 background->AddChild(green); 100 background->AddChild(green);
100 101
101 RunPixelTest(PIXEL_TEST_GL, 102 RunPixelResourceTest(
102 background, 103 background, base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png")));
103 base::FilePath(FILE_PATH_LITERAL("image_mask_of_layer.png")));
104 } 104 }
105 105
106 TEST_F(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) { 106 TEST_P(LayerTreeHostMasksPixelTest, MaskOfClippedLayer) {
107 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 107 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
108 gfx::Rect(200, 200), SK_ColorWHITE); 108 gfx::Rect(200, 200), SK_ColorWHITE);
109 109
110 // Clip to the top half of the green layer. 110 // Clip to the top half of the green layer.
111 scoped_refptr<Layer> clip = Layer::Create(); 111 scoped_refptr<Layer> clip = Layer::Create();
112 clip->SetPosition(gfx::Point(0, 0)); 112 clip->SetPosition(gfx::Point(0, 0));
113 clip->SetBounds(gfx::Size(200, 100)); 113 clip->SetBounds(gfx::Size(200, 100));
114 clip->SetMasksToBounds(true); 114 clip->SetMasksToBounds(true);
115 background->AddChild(clip); 115 background->AddChild(clip);
116 116
117 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 117 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
118 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 118 gfx::Rect(50, 50, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
119 clip->AddChild(green); 119 clip->AddChild(green);
120 120
121 gfx::Size mask_bounds(100, 100); 121 gfx::Size mask_bounds(100, 100);
122 MaskContentLayerClient client(mask_bounds); 122 MaskContentLayerClient client(mask_bounds);
123 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 123 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
124 mask->SetBounds(mask_bounds); 124 mask->SetBounds(mask_bounds);
125 mask->SetIsDrawable(true); 125 mask->SetIsDrawable(true);
126 mask->SetIsMask(true); 126 mask->SetIsMask(true);
127 green->SetMaskLayer(mask.get()); 127 green->SetMaskLayer(mask.get());
128 128
129 RunPixelTest(PIXEL_TEST_GL, 129 RunPixelResourceTest(
130 background, 130 background,
131 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png"))); 131 base::FilePath(FILE_PATH_LITERAL("mask_of_clipped_layer.png")));
132 } 132 }
133 133
134 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplica) { 134 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplica) {
135 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 135 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
136 gfx::Rect(200, 200), SK_ColorWHITE); 136 gfx::Rect(200, 200), SK_ColorWHITE);
137 137
138 gfx::Size mask_bounds(100, 100); 138 gfx::Size mask_bounds(100, 100);
139 MaskContentLayerClient client(mask_bounds); 139 MaskContentLayerClient client(mask_bounds);
140 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 140 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
141 mask->SetBounds(mask_bounds); 141 mask->SetBounds(mask_bounds);
142 mask->SetIsDrawable(true); 142 mask->SetIsDrawable(true);
143 mask->SetIsMask(true); 143 mask->SetIsMask(true);
144 144
145 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 145 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
146 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 146 gfx::Rect(0, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
147 background->AddChild(green); 147 background->AddChild(green);
148 green->SetMaskLayer(mask.get()); 148 green->SetMaskLayer(mask.get());
149 149
150 gfx::Transform replica_transform; 150 gfx::Transform replica_transform;
151 replica_transform.Rotate(-90.0); 151 replica_transform.Rotate(-90.0);
152 152
153 scoped_refptr<Layer> replica = Layer::Create(); 153 scoped_refptr<Layer> replica = Layer::Create();
154 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); 154 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
155 replica->SetPosition(gfx::Point(100, 100)); 155 replica->SetPosition(gfx::Point(100, 100));
156 replica->SetTransform(replica_transform); 156 replica->SetTransform(replica_transform);
157 green->SetReplicaLayer(replica.get()); 157 green->SetReplicaLayer(replica.get());
158 158
159 RunPixelTest(PIXEL_TEST_GL, 159 RunPixelResourceTest(
160 background, 160 background, base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png")));
161 base::FilePath(FILE_PATH_LITERAL("mask_with_replica.png")));
162 } 161 }
163 162
164 TEST_F(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) { 163 TEST_P(LayerTreeHostMasksPixelTest, MaskWithReplicaOfClippedLayer) {
165 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 164 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
166 gfx::Rect(200, 200), SK_ColorWHITE); 165 gfx::Rect(200, 200), SK_ColorWHITE);
167 166
168 gfx::Size mask_bounds(100, 100); 167 gfx::Size mask_bounds(100, 100);
169 MaskContentLayerClient client(mask_bounds); 168 MaskContentLayerClient client(mask_bounds);
170 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 169 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
171 mask->SetBounds(mask_bounds); 170 mask->SetBounds(mask_bounds);
172 mask->SetIsDrawable(true); 171 mask->SetIsDrawable(true);
173 mask->SetIsMask(true); 172 mask->SetIsMask(true);
174 173
(...skipping 12 matching lines...) Expand all
187 186
188 gfx::Transform replica_transform; 187 gfx::Transform replica_transform;
189 replica_transform.Rotate(-90.0); 188 replica_transform.Rotate(-90.0);
190 189
191 scoped_refptr<Layer> replica = Layer::Create(); 190 scoped_refptr<Layer> replica = Layer::Create();
192 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f)); 191 replica->SetTransformOrigin(gfx::Point3F(50.f, 50.f, 0.f));
193 replica->SetPosition(gfx::Point(100, 100)); 192 replica->SetPosition(gfx::Point(100, 100));
194 replica->SetTransform(replica_transform); 193 replica->SetTransform(replica_transform);
195 green->SetReplicaLayer(replica.get()); 194 green->SetReplicaLayer(replica.get());
196 195
197 RunPixelTest(PIXEL_TEST_GL, 196 RunPixelResourceTest(background,
198 background, 197 base::FilePath(FILE_PATH_LITERAL(
199 base::FilePath(FILE_PATH_LITERAL( 198 "mask_with_replica_of_clipped_layer.png")));
200 "mask_with_replica_of_clipped_layer.png")));
201 } 199 }
202 200
203 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplica) { 201 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplica) {
204 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 202 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
205 gfx::Rect(200, 200), SK_ColorWHITE); 203 gfx::Rect(200, 200), SK_ColorWHITE);
206 204
207 gfx::Size mask_bounds(100, 100); 205 gfx::Size mask_bounds(100, 100);
208 MaskContentLayerClient client(mask_bounds); 206 MaskContentLayerClient client(mask_bounds);
209 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 207 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
210 mask->SetBounds(mask_bounds); 208 mask->SetBounds(mask_bounds);
211 mask->SetIsDrawable(true); 209 mask->SetIsDrawable(true);
212 mask->SetIsMask(true); 210 mask->SetIsMask(true);
213 211
214 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder( 212 scoped_refptr<SolidColorLayer> green = CreateSolidColorLayerWithBorder(
215 gfx::Rect(50, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK); 213 gfx::Rect(50, 0, 100, 100), kCSSGreen, 1, SK_ColorBLACK);
216 background->AddChild(green); 214 background->AddChild(green);
217 215
218 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer( 216 scoped_refptr<SolidColorLayer> orange = CreateSolidColorLayer(
219 gfx::Rect(-50, 50, 50, 50), kCSSOrange); 217 gfx::Rect(-50, 50, 50, 50), kCSSOrange);
220 green->AddChild(orange); 218 green->AddChild(orange);
221 219
222 gfx::Transform replica_transform; 220 gfx::Transform replica_transform;
223 replica_transform.Rotate(180.0); 221 replica_transform.Rotate(180.0);
224 replica_transform.Translate(100.0, 0.0); 222 replica_transform.Translate(100.0, 0.0);
225 223
226 scoped_refptr<Layer> replica = Layer::Create(); 224 scoped_refptr<Layer> replica = Layer::Create();
227 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f)); 225 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f));
228 replica->SetPosition(gfx::Point()); 226 replica->SetPosition(gfx::Point());
229 replica->SetTransform(replica_transform); 227 replica->SetTransform(replica_transform);
230 replica->SetMaskLayer(mask.get()); 228 replica->SetMaskLayer(mask.get());
231 green->SetReplicaLayer(replica.get()); 229 green->SetReplicaLayer(replica.get());
232 230
233 RunPixelTest(PIXEL_TEST_GL, 231 RunPixelResourceTest(
234 background, 232 background, base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png")));
235 base::FilePath(FILE_PATH_LITERAL("mask_of_replica.png")));
236 } 233 }
237 234
238 TEST_F(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) { 235 TEST_P(LayerTreeHostMasksPixelTest, MaskOfReplicaOfClippedLayer) {
239 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer( 236 scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
240 gfx::Rect(200, 200), SK_ColorWHITE); 237 gfx::Rect(200, 200), SK_ColorWHITE);
241 238
242 gfx::Size mask_bounds(100, 100); 239 gfx::Size mask_bounds(100, 100);
243 MaskContentLayerClient client(mask_bounds); 240 MaskContentLayerClient client(mask_bounds);
244 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client); 241 scoped_refptr<PictureLayer> mask = PictureLayer::Create(&client);
245 mask->SetBounds(mask_bounds); 242 mask->SetBounds(mask_bounds);
246 mask->SetIsDrawable(true); 243 mask->SetIsDrawable(true);
247 mask->SetIsMask(true); 244 mask->SetIsMask(true);
248 245
(...skipping 16 matching lines...) Expand all
265 replica_transform.Rotate(180.0); 262 replica_transform.Rotate(180.0);
266 replica_transform.Translate(100.0, 0.0); 263 replica_transform.Translate(100.0, 0.0);
267 264
268 scoped_refptr<Layer> replica = Layer::Create(); 265 scoped_refptr<Layer> replica = Layer::Create();
269 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f)); 266 replica->SetTransformOrigin(gfx::Point3F(100.f, 100.f, 0.f));
270 replica->SetPosition(gfx::Point()); 267 replica->SetPosition(gfx::Point());
271 replica->SetTransform(replica_transform); 268 replica->SetTransform(replica_transform);
272 replica->SetMaskLayer(mask.get()); 269 replica->SetMaskLayer(mask.get());
273 green->SetReplicaLayer(replica.get()); 270 green->SetReplicaLayer(replica.get());
274 271
275 RunPixelTest(PIXEL_TEST_GL, 272 RunPixelResourceTest(background,
276 background, 273 base::FilePath(FILE_PATH_LITERAL(
277 base::FilePath( 274 "mask_of_replica_of_clipped_layer.png")));
278 FILE_PATH_LITERAL("mask_of_replica_of_clipped_layer.png")));
279 } 275 }
280 276
281 } // namespace 277 } // namespace
282 } // namespace cc 278 } // namespace cc
283 279
284 #endif // OS_ANDROID 280 #endif // OS_ANDROID
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698