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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp

Issue 2808413002: Rename Layer::screen_space_transform to Layer::ScreenSpaceTransform (Closed)
Patch Set: Created 3 years, 8 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/layers/layer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/graphics/compositing/PaintArtifactCompositor.h" 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/test/test_simple_task_runner.h" 9 #include "base/test/test_simple_task_runner.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 TestPaintArtifact artifact; 160 TestPaintArtifact artifact;
161 artifact.Chunk(DefaultPaintChunkProperties()) 161 artifact.Chunk(DefaultPaintChunkProperties())
162 .RectDrawing(FloatRect(50, -50, 100, 100), Color::kWhite); 162 .RectDrawing(FloatRect(50, -50, 100, 100), Color::kWhite);
163 Update(artifact.Build()); 163 Update(artifact.Build());
164 164
165 ASSERT_EQ(1u, ContentLayerCount()); 165 ASSERT_EQ(1u, ContentLayerCount());
166 const cc::Layer* child = ContentLayerAt(0); 166 const cc::Layer* child = ContentLayerAt(0);
167 EXPECT_THAT( 167 EXPECT_THAT(
168 child->GetPicture(), 168 child->GetPicture(),
169 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kWhite))); 169 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kWhite)));
170 EXPECT_EQ(Translation(50, -50), child->screen_space_transform()); 170 EXPECT_EQ(Translation(50, -50), child->ScreenSpaceTransform());
171 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); 171 EXPECT_EQ(gfx::Size(100, 100), child->bounds());
172 } 172 }
173 173
174 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) { 174 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneTransform) {
175 // A 90 degree clockwise rotation about (100, 100). 175 // A 90 degree clockwise rotation about (100, 100).
176 RefPtr<TransformPaintPropertyNode> transform = 176 RefPtr<TransformPaintPropertyNode> transform =
177 TransformPaintPropertyNode::Create( 177 TransformPaintPropertyNode::Create(
178 TransformPaintPropertyNode::Root(), TransformationMatrix().Rotate(90), 178 TransformPaintPropertyNode::Root(), TransformationMatrix().Rotate(90),
179 FloatPoint3D(100, 100, 0), false, 0, kCompositingReason3DTransform); 179 FloatPoint3D(100, 100, 0), false, 0, kCompositingReason3DTransform);
180 180
(...skipping 18 matching lines...) Expand all
199 199
200 Vector<RectWithColor> rects_with_color; 200 Vector<RectWithColor> rects_with_color;
201 rects_with_color.push_back( 201 rects_with_color.push_back(
202 RectWithColor(FloatRect(0, 0, 100, 100), Color::kWhite)); 202 RectWithColor(FloatRect(0, 0, 100, 100), Color::kWhite));
203 rects_with_color.push_back( 203 rects_with_color.push_back(
204 RectWithColor(FloatRect(100, 100, 200, 100), Color::kBlack)); 204 RectWithColor(FloatRect(100, 100, 200, 100), Color::kBlack));
205 205
206 EXPECT_THAT(layer->GetPicture(), 206 EXPECT_THAT(layer->GetPicture(),
207 Pointee(DrawsRectangles(rects_with_color))); 207 Pointee(DrawsRectangles(rects_with_color)));
208 gfx::RectF mapped_rect(0, 0, 100, 100); 208 gfx::RectF mapped_rect(0, 0, 100, 100);
209 layer->screen_space_transform().TransformRect(&mapped_rect); 209 layer->ScreenSpaceTransform().TransformRect(&mapped_rect);
210 EXPECT_EQ(gfx::RectF(100, 0, 100, 100), mapped_rect); 210 EXPECT_EQ(gfx::RectF(100, 0, 100, 100), mapped_rect);
211 } 211 }
212 { 212 {
213 const cc::Layer* layer = ContentLayerAt(1); 213 const cc::Layer* layer = ContentLayerAt(1);
214 EXPECT_THAT( 214 EXPECT_THAT(
215 layer->GetPicture(), 215 layer->GetPicture(),
216 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kGray))); 216 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kGray)));
217 EXPECT_EQ(gfx::Transform(), layer->screen_space_transform()); 217 EXPECT_EQ(gfx::Transform(), layer->ScreenSpaceTransform());
218 } 218 }
219 } 219 }
220 220
221 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) { 221 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, TransformCombining) {
222 // A translation by (5, 5) within a 2x scale about (10, 10). 222 // A translation by (5, 5) within a 2x scale about (10, 10).
223 RefPtr<TransformPaintPropertyNode> transform1 = 223 RefPtr<TransformPaintPropertyNode> transform1 =
224 TransformPaintPropertyNode::Create( 224 TransformPaintPropertyNode::Create(
225 TransformPaintPropertyNode::Root(), TransformationMatrix().Scale(2), 225 TransformPaintPropertyNode::Root(), TransformationMatrix().Scale(2),
226 FloatPoint3D(10, 10, 0), false, 0, kCompositingReason3DTransform); 226 FloatPoint3D(10, 10, 0), false, 0, kCompositingReason3DTransform);
227 RefPtr<TransformPaintPropertyNode> transform2 = 227 RefPtr<TransformPaintPropertyNode> transform2 =
(...skipping 12 matching lines...) Expand all
240 .RectDrawing(FloatRect(0, 0, 300, 200), Color::kBlack); 240 .RectDrawing(FloatRect(0, 0, 300, 200), Color::kBlack);
241 Update(artifact.Build()); 241 Update(artifact.Build());
242 242
243 ASSERT_EQ(2u, ContentLayerCount()); 243 ASSERT_EQ(2u, ContentLayerCount());
244 { 244 {
245 const cc::Layer* layer = ContentLayerAt(0); 245 const cc::Layer* layer = ContentLayerAt(0);
246 EXPECT_THAT( 246 EXPECT_THAT(
247 layer->GetPicture(), 247 layer->GetPicture(),
248 Pointee(DrawsRectangle(FloatRect(0, 0, 300, 200), Color::kWhite))); 248 Pointee(DrawsRectangle(FloatRect(0, 0, 300, 200), Color::kWhite)));
249 gfx::RectF mapped_rect(0, 0, 300, 200); 249 gfx::RectF mapped_rect(0, 0, 300, 200);
250 layer->screen_space_transform().TransformRect(&mapped_rect); 250 layer->ScreenSpaceTransform().TransformRect(&mapped_rect);
251 EXPECT_EQ(gfx::RectF(-10, -10, 600, 400), mapped_rect); 251 EXPECT_EQ(gfx::RectF(-10, -10, 600, 400), mapped_rect);
252 } 252 }
253 { 253 {
254 const cc::Layer* layer = ContentLayerAt(1); 254 const cc::Layer* layer = ContentLayerAt(1);
255 EXPECT_THAT( 255 EXPECT_THAT(
256 layer->GetPicture(), 256 layer->GetPicture(),
257 Pointee(DrawsRectangle(FloatRect(0, 0, 300, 200), Color::kBlack))); 257 Pointee(DrawsRectangle(FloatRect(0, 0, 300, 200), Color::kBlack)));
258 gfx::RectF mapped_rect(0, 0, 300, 200); 258 gfx::RectF mapped_rect(0, 0, 300, 200);
259 layer->screen_space_transform().TransformRect(&mapped_rect); 259 layer->ScreenSpaceTransform().TransformRect(&mapped_rect);
260 EXPECT_EQ(gfx::RectF(0, 0, 600, 400), mapped_rect); 260 EXPECT_EQ(gfx::RectF(0, 0, 600, 400), mapped_rect);
261 } 261 }
262 EXPECT_NE(ContentLayerAt(0)->transform_tree_index(), 262 EXPECT_NE(ContentLayerAt(0)->transform_tree_index(),
263 ContentLayerAt(1)->transform_tree_index()); 263 ContentLayerAt(1)->transform_tree_index());
264 } 264 }
265 265
266 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, 266 TEST_F(PaintArtifactCompositorTestWithPropertyTrees,
267 FlattensInheritedTransform) { 267 FlattensInheritedTransform) {
268 for (bool transform_is_flattened : {true, false}) { 268 for (bool transform_is_flattened : {true, false}) {
269 SCOPED_TRACE(transform_is_flattened); 269 SCOPED_TRACE(transform_is_flattened);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 EXPECT_EQ(transform_is_flattened, 306 EXPECT_EQ(transform_is_flattened,
307 transform_node3->flattens_inherited_transform); 307 transform_node3->flattens_inherited_transform);
308 308
309 // Given this, we should expect the correct screen space transform for 309 // Given this, we should expect the correct screen space transform for
310 // each case. If the transform was flattened, we should see it getting 310 // each case. If the transform was flattened, we should see it getting
311 // an effective horizontal scale of 1/sqrt(2) each time, thus it gets 311 // an effective horizontal scale of 1/sqrt(2) each time, thus it gets
312 // half as wide. If the transform was not flattened, we should see an 312 // half as wide. If the transform was not flattened, we should see an
313 // empty rectangle (as the total 90 degree rotation makes it 313 // empty rectangle (as the total 90 degree rotation makes it
314 // perpendicular to the viewport). 314 // perpendicular to the viewport).
315 gfx::RectF rect(0, 0, 100, 100); 315 gfx::RectF rect(0, 0, 100, 100);
316 layer->screen_space_transform().TransformRect(&rect); 316 layer->ScreenSpaceTransform().TransformRect(&rect);
317 if (transform_is_flattened) 317 if (transform_is_flattened)
318 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 100), rect); 318 EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 50, 100), rect);
319 else 319 else
320 EXPECT_TRUE(rect.IsEmpty()); 320 EXPECT_TRUE(rect.IsEmpty());
321 } 321 }
322 } 322 }
323 323
324 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) { 324 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, SortingContextID) {
325 // Has no 3D rendering context. 325 // Has no 3D rendering context.
326 RefPtr<TransformPaintPropertyNode> transform1 = 326 RefPtr<TransformPaintPropertyNode> transform1 =
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 .Chunk(TransformPaintPropertyNode::Root(), clip, 417 .Chunk(TransformPaintPropertyNode::Root(), clip,
418 EffectPaintPropertyNode::Root()) 418 EffectPaintPropertyNode::Root())
419 .RectDrawing(FloatRect(220, 80, 300, 200), Color::kBlack); 419 .RectDrawing(FloatRect(220, 80, 300, 200), Color::kBlack);
420 Update(artifact.Build()); 420 Update(artifact.Build());
421 421
422 ASSERT_EQ(1u, ContentLayerCount()); 422 ASSERT_EQ(1u, ContentLayerCount());
423 const cc::Layer* layer = ContentLayerAt(0); 423 const cc::Layer* layer = ContentLayerAt(0);
424 EXPECT_THAT( 424 EXPECT_THAT(
425 layer->GetPicture(), 425 layer->GetPicture(),
426 Pointee(DrawsRectangle(FloatRect(0, 0, 300, 200), Color::kBlack))); 426 Pointee(DrawsRectangle(FloatRect(0, 0, 300, 200), Color::kBlack)));
427 EXPECT_EQ(Translation(220, 80), layer->screen_space_transform()); 427 EXPECT_EQ(Translation(220, 80), layer->ScreenSpaceTransform());
428 428
429 const cc::ClipNode* clip_node = 429 const cc::ClipNode* clip_node =
430 GetPropertyTrees().clip_tree.Node(layer->clip_tree_index()); 430 GetPropertyTrees().clip_tree.Node(layer->clip_tree_index());
431 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clip_node->clip_type); 431 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clip_node->clip_type);
432 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clip_node->clip); 432 EXPECT_EQ(gfx::RectF(100, 100, 300, 200), clip_node->clip);
433 } 433 }
434 434
435 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) { 435 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, NestedClips) {
436 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::Create( 436 RefPtr<ClipPaintPropertyNode> clip1 = ClipPaintPropertyNode::Create(
437 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), 437 ClipPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(),
(...skipping 22 matching lines...) Expand all
460 EffectPaintPropertyNode::Root()) 460 EffectPaintPropertyNode::Root())
461 .RectDrawing(FloatRect(300, 350, 100, 100), Color::kBlack); 461 .RectDrawing(FloatRect(300, 350, 100, 100), Color::kBlack);
462 Update(artifact.Build()); 462 Update(artifact.Build());
463 463
464 ASSERT_EQ(4u, ContentLayerCount()); 464 ASSERT_EQ(4u, ContentLayerCount());
465 465
466 const cc::Layer* white_layer = ContentLayerAt(0); 466 const cc::Layer* white_layer = ContentLayerAt(0);
467 EXPECT_THAT( 467 EXPECT_THAT(
468 white_layer->GetPicture(), 468 white_layer->GetPicture(),
469 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kWhite))); 469 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kWhite)));
470 EXPECT_EQ(Translation(300, 350), white_layer->screen_space_transform()); 470 EXPECT_EQ(Translation(300, 350), white_layer->ScreenSpaceTransform());
471 471
472 const cc::Layer* light_gray_layer = ContentLayerAt(1); 472 const cc::Layer* light_gray_layer = ContentLayerAt(1);
473 EXPECT_THAT( 473 EXPECT_THAT(
474 light_gray_layer->GetPicture(), 474 light_gray_layer->GetPicture(),
475 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kLightGray))); 475 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kLightGray)));
476 EXPECT_EQ(Translation(300, 350), light_gray_layer->screen_space_transform()); 476 EXPECT_EQ(Translation(300, 350), light_gray_layer->ScreenSpaceTransform());
477 477
478 const cc::Layer* dark_gray_layer = ContentLayerAt(2); 478 const cc::Layer* dark_gray_layer = ContentLayerAt(2);
479 EXPECT_THAT( 479 EXPECT_THAT(
480 dark_gray_layer->GetPicture(), 480 dark_gray_layer->GetPicture(),
481 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kDarkGray))); 481 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kDarkGray)));
482 EXPECT_EQ(Translation(300, 350), dark_gray_layer->screen_space_transform()); 482 EXPECT_EQ(Translation(300, 350), dark_gray_layer->ScreenSpaceTransform());
483 483
484 const cc::Layer* black_layer = ContentLayerAt(3); 484 const cc::Layer* black_layer = ContentLayerAt(3);
485 EXPECT_THAT( 485 EXPECT_THAT(
486 black_layer->GetPicture(), 486 black_layer->GetPicture(),
487 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kBlack))); 487 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kBlack)));
488 EXPECT_EQ(Translation(300, 350), black_layer->screen_space_transform()); 488 EXPECT_EQ(Translation(300, 350), black_layer->ScreenSpaceTransform());
489 489
490 EXPECT_EQ(white_layer->clip_tree_index(), dark_gray_layer->clip_tree_index()); 490 EXPECT_EQ(white_layer->clip_tree_index(), dark_gray_layer->clip_tree_index());
491 const cc::ClipNode* outer_clip = 491 const cc::ClipNode* outer_clip =
492 GetPropertyTrees().clip_tree.Node(white_layer->clip_tree_index()); 492 GetPropertyTrees().clip_tree.Node(white_layer->clip_tree_index());
493 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, outer_clip->clip_type); 493 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, outer_clip->clip_type);
494 EXPECT_EQ(gfx::RectF(100, 100, 700, 700), outer_clip->clip); 494 EXPECT_EQ(gfx::RectF(100, 100, 700, 700), outer_clip->clip);
495 495
496 EXPECT_EQ(light_gray_layer->clip_tree_index(), 496 EXPECT_EQ(light_gray_layer->clip_tree_index(),
497 black_layer->clip_tree_index()); 497 black_layer->clip_tree_index());
498 const cc::ClipNode* inner_clip = 498 const cc::ClipNode* inner_clip =
(...skipping 18 matching lines...) Expand all
517 EffectPaintPropertyNode::Root()) 517 EffectPaintPropertyNode::Root())
518 .RectDrawing(FloatRect(0, 0, 200, 200), Color::kWhite); 518 .RectDrawing(FloatRect(0, 0, 200, 200), Color::kWhite);
519 Update(artifact.Build()); 519 Update(artifact.Build());
520 520
521 // Check the drawing layer. 521 // Check the drawing layer.
522 ASSERT_EQ(1u, ContentLayerCount()); 522 ASSERT_EQ(1u, ContentLayerCount());
523 const cc::Layer* drawing_layer = ContentLayerAt(0); 523 const cc::Layer* drawing_layer = ContentLayerAt(0);
524 EXPECT_THAT( 524 EXPECT_THAT(
525 drawing_layer->GetPicture(), 525 drawing_layer->GetPicture(),
526 Pointee(DrawsRectangle(FloatRect(0, 0, 200, 200), Color::kWhite))); 526 Pointee(DrawsRectangle(FloatRect(0, 0, 200, 200), Color::kWhite)));
527 EXPECT_EQ(gfx::Transform(), drawing_layer->screen_space_transform()); 527 EXPECT_EQ(gfx::Transform(), drawing_layer->ScreenSpaceTransform());
528 528
529 // Check the clip nodes. 529 // Check the clip nodes.
530 const cc::ClipNode* clip_node = 530 const cc::ClipNode* clip_node =
531 GetPropertyTrees().clip_tree.Node(drawing_layer->clip_tree_index()); 531 GetPropertyTrees().clip_tree.Node(drawing_layer->clip_tree_index());
532 for (auto it = clips.rbegin(); it != clips.rend(); ++it) { 532 for (auto it = clips.rbegin(); it != clips.rend(); ++it) {
533 const ClipPaintPropertyNode* paint_clip_node = it->Get(); 533 const ClipPaintPropertyNode* paint_clip_node = it->Get();
534 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clip_node->clip_type); 534 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, clip_node->clip_type);
535 EXPECT_EQ(paint_clip_node->ClipRect().Rect(), clip_node->clip); 535 EXPECT_EQ(paint_clip_node->ClipRect().Rect(), clip_node->clip);
536 clip_node = GetPropertyTrees().clip_tree.Node(clip_node->parent_id); 536 clip_node = GetPropertyTrees().clip_tree.Node(clip_node->parent_id);
537 } 537 }
(...skipping 19 matching lines...) Expand all
557 .Chunk(TransformPaintPropertyNode::Root(), clip2, 557 .Chunk(TransformPaintPropertyNode::Root(), clip2,
558 EffectPaintPropertyNode::Root()) 558 EffectPaintPropertyNode::Root())
559 .RectDrawing(FloatRect(0, 0, 640, 480), Color::kBlack); 559 .RectDrawing(FloatRect(0, 0, 640, 480), Color::kBlack);
560 Update(artifact.Build()); 560 Update(artifact.Build());
561 ASSERT_EQ(2u, ContentLayerCount()); 561 ASSERT_EQ(2u, ContentLayerCount());
562 562
563 const cc::Layer* white_layer = ContentLayerAt(0); 563 const cc::Layer* white_layer = ContentLayerAt(0);
564 EXPECT_THAT( 564 EXPECT_THAT(
565 white_layer->GetPicture(), 565 white_layer->GetPicture(),
566 Pointee(DrawsRectangle(FloatRect(0, 0, 640, 480), Color::kWhite))); 566 Pointee(DrawsRectangle(FloatRect(0, 0, 640, 480), Color::kWhite)));
567 EXPECT_EQ(gfx::Transform(), white_layer->screen_space_transform()); 567 EXPECT_EQ(gfx::Transform(), white_layer->ScreenSpaceTransform());
568 const cc::ClipNode* white_clip = 568 const cc::ClipNode* white_clip =
569 GetPropertyTrees().clip_tree.Node(white_layer->clip_tree_index()); 569 GetPropertyTrees().clip_tree.Node(white_layer->clip_tree_index());
570 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, white_clip->clip_type); 570 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, white_clip->clip_type);
571 ASSERT_EQ(gfx::RectF(0, 0, 400, 600), white_clip->clip); 571 ASSERT_EQ(gfx::RectF(0, 0, 400, 600), white_clip->clip);
572 572
573 const cc::Layer* black_layer = ContentLayerAt(1); 573 const cc::Layer* black_layer = ContentLayerAt(1);
574 EXPECT_THAT( 574 EXPECT_THAT(
575 black_layer->GetPicture(), 575 black_layer->GetPicture(),
576 Pointee(DrawsRectangle(FloatRect(0, 0, 640, 480), Color::kBlack))); 576 Pointee(DrawsRectangle(FloatRect(0, 0, 640, 480), Color::kBlack)));
577 EXPECT_EQ(gfx::Transform(), black_layer->screen_space_transform()); 577 EXPECT_EQ(gfx::Transform(), black_layer->ScreenSpaceTransform());
578 const cc::ClipNode* black_clip = 578 const cc::ClipNode* black_clip =
579 GetPropertyTrees().clip_tree.Node(black_layer->clip_tree_index()); 579 GetPropertyTrees().clip_tree.Node(black_layer->clip_tree_index());
580 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, black_clip->clip_type); 580 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, black_clip->clip_type);
581 ASSERT_EQ(gfx::RectF(400, 0, 400, 600), black_clip->clip); 581 ASSERT_EQ(gfx::RectF(400, 0, 400, 600), black_clip->clip);
582 582
583 EXPECT_EQ(white_clip->parent_id, black_clip->parent_id); 583 EXPECT_EQ(white_clip->parent_id, black_clip->parent_id);
584 const cc::ClipNode* common_clip_node = 584 const cc::ClipNode* common_clip_node =
585 GetPropertyTrees().clip_tree.Node(white_clip->parent_id); 585 GetPropertyTrees().clip_tree.Node(white_clip->parent_id);
586 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP, 586 EXPECT_EQ(cc::ClipNode::ClipType::APPLIES_LOCAL_CLIP,
587 common_clip_node->clip_type); 587 common_clip_node->clip_type);
(...skipping 16 matching lines...) Expand all
604 EffectPaintPropertyNode::Root()) 604 EffectPaintPropertyNode::Root())
605 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kGray); 605 .RectDrawing(FloatRect(0, 0, 100, 100), Color::kGray);
606 606
607 const PaintArtifact& artifact = test_artifact.Build(); 607 const PaintArtifact& artifact = test_artifact.Build();
608 ASSERT_EQ(3u, artifact.PaintChunks().size()); 608 ASSERT_EQ(3u, artifact.PaintChunks().size());
609 Update(artifact); 609 Update(artifact);
610 610
611 ASSERT_EQ(3u, ContentLayerCount()); 611 ASSERT_EQ(3u, ContentLayerCount());
612 EXPECT_EQ(layer, ContentLayerAt(1)); 612 EXPECT_EQ(layer, ContentLayerAt(1));
613 EXPECT_EQ(gfx::Size(400, 300), layer->bounds()); 613 EXPECT_EQ(gfx::Size(400, 300), layer->bounds());
614 EXPECT_EQ(Translation(50, 60), layer->screen_space_transform()); 614 EXPECT_EQ(Translation(50, 60), layer->ScreenSpaceTransform());
615 } 615 }
616 616
617 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) { 617 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EffectTreeConversion) {
618 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::Create( 618 RefPtr<EffectPaintPropertyNode> effect1 = EffectPaintPropertyNode::Create(
619 EffectPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(), 619 EffectPaintPropertyNode::Root(), TransformPaintPropertyNode::Root(),
620 ClipPaintPropertyNode::Root(), kColorFilterNone, 620 ClipPaintPropertyNode::Root(), kColorFilterNone,
621 CompositorFilterOperations(), 0.5, SkBlendMode::kSrcOver, 621 CompositorFilterOperations(), 0.5, SkBlendMode::kSrcOver,
622 kCompositingReasonAll); 622 kCompositingReasonAll);
623 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::Create( 623 RefPtr<EffectPaintPropertyNode> effect2 = EffectPaintPropertyNode::Create(
624 effect1, TransformPaintPropertyNode::Root(), 624 effect1, TransformPaintPropertyNode::Root(),
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 artifact 1712 artifact
1713 .Chunk(TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(), 1713 .Chunk(TransformPaintPropertyNode::Root(), ClipPaintPropertyNode::Root(),
1714 masking.Get()) 1714 masking.Get())
1715 .RectDrawing(FloatRect(150, 150, 100, 100), Color::kWhite); 1715 .RectDrawing(FloatRect(150, 150, 100, 100), Color::kWhite);
1716 Update(artifact.Build()); 1716 Update(artifact.Build());
1717 ASSERT_EQ(2u, ContentLayerCount()); 1717 ASSERT_EQ(2u, ContentLayerCount());
1718 1718
1719 const cc::Layer* masked_layer = ContentLayerAt(0); 1719 const cc::Layer* masked_layer = ContentLayerAt(0);
1720 EXPECT_THAT(masked_layer->GetPicture(), 1720 EXPECT_THAT(masked_layer->GetPicture(),
1721 Pointee(DrawsRectangle(FloatRect(0, 0, 200, 200), Color::kGray))); 1721 Pointee(DrawsRectangle(FloatRect(0, 0, 200, 200), Color::kGray)));
1722 EXPECT_EQ(Translation(100, 100), masked_layer->screen_space_transform()); 1722 EXPECT_EQ(Translation(100, 100), masked_layer->ScreenSpaceTransform());
1723 EXPECT_EQ(gfx::Size(200, 200), masked_layer->bounds()); 1723 EXPECT_EQ(gfx::Size(200, 200), masked_layer->bounds());
1724 const cc::EffectNode* masked_group = 1724 const cc::EffectNode* masked_group =
1725 GetPropertyTrees().effect_tree.Node(masked_layer->effect_tree_index()); 1725 GetPropertyTrees().effect_tree.Node(masked_layer->effect_tree_index());
1726 EXPECT_TRUE(masked_group->has_render_surface); 1726 EXPECT_TRUE(masked_group->has_render_surface);
1727 1727
1728 const cc::Layer* masking_layer = ContentLayerAt(1); 1728 const cc::Layer* masking_layer = ContentLayerAt(1);
1729 EXPECT_THAT( 1729 EXPECT_THAT(
1730 masking_layer->GetPicture(), 1730 masking_layer->GetPicture(),
1731 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kWhite))); 1731 Pointee(DrawsRectangle(FloatRect(0, 0, 100, 100), Color::kWhite)));
1732 EXPECT_EQ(Translation(150, 150), masking_layer->screen_space_transform()); 1732 EXPECT_EQ(Translation(150, 150), masking_layer->ScreenSpaceTransform());
1733 EXPECT_EQ(gfx::Size(100, 100), masking_layer->bounds()); 1733 EXPECT_EQ(gfx::Size(100, 100), masking_layer->bounds());
1734 const cc::EffectNode* masking_group = 1734 const cc::EffectNode* masking_group =
1735 GetPropertyTrees().effect_tree.Node(masking_layer->effect_tree_index()); 1735 GetPropertyTrees().effect_tree.Node(masking_layer->effect_tree_index());
1736 EXPECT_TRUE(masking_group->has_render_surface); 1736 EXPECT_TRUE(masking_group->has_render_surface);
1737 EXPECT_EQ(masked_group->id, masking_group->parent_id); 1737 EXPECT_EQ(masked_group->id, masking_group->parent_id);
1738 ASSERT_EQ(1u, masking_group->filters.size()); 1738 ASSERT_EQ(1u, masking_group->filters.size());
1739 EXPECT_EQ(cc::FilterOperation::REFERENCE, 1739 EXPECT_EQ(cc::FilterOperation::REFERENCE,
1740 masking_group->filters.at(0).type()); 1740 masking_group->filters.at(0).type());
1741 } 1741 }
1742 1742
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 Update(artifact.Build(), composited_element_ids); 2069 Update(artifact.Build(), composited_element_ids);
2070 2070
2071 EXPECT_EQ(2u, composited_element_ids.size()); 2071 EXPECT_EQ(2u, composited_element_ids.size());
2072 EXPECT_TRUE( 2072 EXPECT_TRUE(
2073 composited_element_ids.Contains(transform->GetCompositorElementId())); 2073 composited_element_ids.Contains(transform->GetCompositorElementId()));
2074 EXPECT_TRUE( 2074 EXPECT_TRUE(
2075 composited_element_ids.Contains(effect->GetCompositorElementId())); 2075 composited_element_ids.Contains(effect->GetCompositorElementId()));
2076 } 2076 }
2077 2077
2078 } // namespace blink 2078 } // namespace blink
OLDNEW
« no previous file with comments | « cc/layers/layer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698