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

Side by Side Diff: cc/delegated_renderer_layer_impl_unittest.cc

Issue 11871008: cc: Stop using drawableContentRect for occlusion. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « cc/delegated_renderer_layer_impl.cc ('k') | cc/draw_quad.h » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "cc/delegated_renderer_layer_impl.h" 5 #include "cc/delegated_renderer_layer_impl.h"
6 6
7 #include "cc/append_quads_data.h" 7 #include "cc/append_quads_data.h"
8 #include "cc/layer_tree_host_impl.h" 8 #include "cc/layer_tree_host_impl.h"
9 #include "cc/layer_tree_impl.h" 9 #include "cc/layer_tree_impl.h"
10 #include "cc/quad_sink.h" 10 #include "cc/quad_sink.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 gfx::Rect childPassRect(20, 20, 7, 7); 415 gfx::Rect childPassRect(20, 20, 7, 7);
416 gfx::Transform childPassTransform; 416 gfx::Transform childPassTransform;
417 childPassTransform.Scale(0.8, 0.8); 417 childPassTransform.Scale(0.8, 0.8);
418 childPassTransform.Translate(9.0, 9.0); 418 childPassTransform.Translate(9.0, 9.0);
419 419
420 { 420 {
421 TestRenderPass* pass = addRenderPass(delegatedRenderPasses, RenderPa ss::Id(10, 7), childPassRect, gfx::Transform()); 421 TestRenderPass* pass = addRenderPass(delegatedRenderPasses, RenderPa ss::Id(10, 7), childPassRect, gfx::Transform());
422 MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_lis t); 422 MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_lis t);
423 AppendQuadsData data(pass->id); 423 AppendQuadsData data(pass->id);
424 SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQua dState::Create()); 424 SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQua dState::Create());
425 sharedState->SetAll(childPassTransform, childPassRect, childPassRect , childPassRect, false, 1); 425 sharedState->SetAll(childPassTransform, childPassRect, childPassRect , false, 1);
426 scoped_ptr<SolidColorDrawQuad> colorQuad; 426 scoped_ptr<SolidColorDrawQuad> colorQuad;
427 427
428 colorQuad = SolidColorDrawQuad::Create(); 428 colorQuad = SolidColorDrawQuad::Create();
429 colorQuad->SetNew(sharedState, gfx::Rect(20, 20, 3, 7), 1u); 429 colorQuad->SetNew(sharedState, gfx::Rect(20, 20, 3, 7), 1u);
430 quadSink.append(colorQuad.PassAs<DrawQuad>(), data); 430 quadSink.append(colorQuad.PassAs<DrawQuad>(), data);
431 431
432 colorQuad = SolidColorDrawQuad::Create(); 432 colorQuad = SolidColorDrawQuad::Create();
433 colorQuad->SetNew(sharedState, gfx::Rect(23, 20, 4, 7), 1u); 433 colorQuad->SetNew(sharedState, gfx::Rect(23, 20, 4, 7), 1u);
434 quadSink.append(colorQuad.PassAs<DrawQuad>(), data); 434 quadSink.append(colorQuad.PassAs<DrawQuad>(), data);
435 } 435 }
436 436
437 gfx::Rect passRect(0, 0, 50, 50); 437 gfx::Rect passRect(0, 0, 50, 50);
438 gfx::Transform passTransform; 438 gfx::Transform passTransform;
439 passTransform.Scale(1.5, 1.5); 439 passTransform.Scale(1.5, 1.5);
440 passTransform.Translate(7.0, 7.0); 440 passTransform.Translate(7.0, 7.0);
441 441
442 TestRenderPass* pass = addRenderPass(delegatedRenderPasses, RenderPass:: Id(9, 6), passRect, gfx::Transform()); 442 TestRenderPass* pass = addRenderPass(delegatedRenderPasses, RenderPass:: Id(9, 6), passRect, gfx::Transform());
443 MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list); 443 MockQuadCuller quadSink(pass->quad_list, pass->shared_quad_state_list);
444 AppendQuadsData data(pass->id); 444 AppendQuadsData data(pass->id);
445 SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQuadSta te::Create()); 445 SharedQuadState* sharedState = quadSink.useSharedQuadState(SharedQuadSta te::Create());
446 sharedState->SetAll(passTransform, passRect, passRect, passRect, false, 1); 446 sharedState->SetAll(passTransform, passRect, passRect, false, 1);
447 scoped_ptr<SolidColorDrawQuad> colorQuad; 447 scoped_ptr<SolidColorDrawQuad> colorQuad;
448 448
449 scoped_ptr<RenderPassDrawQuad> renderPassQuad = RenderPassDrawQuad::Crea te(); 449 scoped_ptr<RenderPassDrawQuad> renderPassQuad = RenderPassDrawQuad::Crea te();
450 renderPassQuad->SetNew( 450 renderPassQuad->SetNew(
451 sharedState, 451 sharedState,
452 gfx::Rect(5, 5, 7, 7), 452 gfx::Rect(5, 5, 7, 7),
453 RenderPass::Id(10, 7), 453 RenderPass::Id(10, 7),
454 false, // is_replica 454 false, // is_replica
455 0, // mask_resource_id 455 0, // mask_resource_id
456 childPassRect, // contents_changed_since_last_frame 456 childPassRect, // contents_changed_since_last_frame
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 EXPECT_EQ(rootSharedState, rootQuadList[4]->shared_quad_state); 524 EXPECT_EQ(rootSharedState, rootQuadList[4]->shared_quad_state);
525 525
526 EXPECT_NE(rootQuadList[0]->shared_quad_state, contribQuadList[0]->shared_qua d_state); 526 EXPECT_NE(rootQuadList[0]->shared_quad_state, contribQuadList[0]->shared_qua d_state);
527 527
528 // The state should be transformed only once. 528 // The state should be transformed only once.
529 529
530 // The x/y values are: position (20) + transform (8 * 2) = 36 530 // The x/y values are: position (20) + transform (8 * 2) = 36
531 // 36 - (width / 2) = 36 - 30 / 2 = 21 531 // 36 - (width / 2) = 36 - 30 / 2 = 21
532 // The size is 100 scaled to fit inside the layer's bounds at 30x30 from a f rame at 50x50. 532 // The size is 100 scaled to fit inside the layer's bounds at 30x30 from a f rame at 50x50.
533 // 100 * 30 / 50 = 60. 533 // 100 * 30 / 50 = 60.
534 EXPECT_RECT_EQ(gfx::Rect(21, 21, 60, 60), rootSharedState->clipped_rect_in_t arget);
535 EXPECT_RECT_EQ(gfx::Rect(21, 21, 60, 60), rootSharedState->clip_rect); 534 EXPECT_RECT_EQ(gfx::Rect(21, 21, 60, 60), rootSharedState->clip_rect);
536 gfx::Transform expected; 535 gfx::Transform expected;
537 // This is the transform from the layer's space to its target. 536 // This is the transform from the layer's space to its target.
538 // The position (20) - the width / scale (30 / 2) = 20 - 15 = 5 537 // The position (20) - the width / scale (30 / 2) = 20 - 15 = 5
539 expected.Translate(5.0, 5.0); 538 expected.Translate(5.0, 5.0);
540 expected.Scale(2.0, 2.0); 539 expected.Scale(2.0, 2.0);
541 expected.Translate(8.0, 8.0); 540 expected.Translate(8.0, 8.0);
542 // The frame has size 50x50 but the layer's bounds are 30x30. 541 // The frame has size 50x50 but the layer's bounds are 30x30.
543 expected.Scale(30.0 / 50.0, 30.0 / 50.0); 542 expected.Scale(30.0 / 50.0, 30.0 / 50.0);
544 // This is the transform within the source frame. 543 // This is the transform within the source frame.
545 expected.Scale(1.5, 1.5); 544 expected.Scale(1.5, 1.5);
546 expected.Translate(7.0, 7.0); 545 expected.Translate(7.0, 7.0);
547 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, rootSharedState->content_to_target _transform); 546 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, rootSharedState->content_to_target _transform);
548 547
549 // The contributing render pass should not be transformed from its input. 548 // The contributing render pass should not be transformed from its input.
550 EXPECT_RECT_EQ(gfx::Rect(20, 20, 7, 7), contribSharedState->clipped_rect_in_ target);
551 EXPECT_RECT_EQ(gfx::Rect(20, 20, 7, 7), contribSharedState->clip_rect); 549 EXPECT_RECT_EQ(gfx::Rect(20, 20, 7, 7), contribSharedState->clip_rect);
552 expected.MakeIdentity(); 550 expected.MakeIdentity();
553 expected.Scale(0.8, 0.8); 551 expected.Scale(0.8, 0.8);
554 expected.Translate(9.0, 9.0); 552 expected.Translate(9.0, 9.0);
555 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, contribSharedState->content_to_tar get_transform); 553 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, contribSharedState->content_to_tar get_transform);
556 554
557 m_hostImpl->drawLayers(frame); 555 m_hostImpl->drawLayers(frame);
558 m_hostImpl->didDrawAllLayers(frame); 556 m_hostImpl->didDrawAllLayers(frame);
559 } 557 }
560 558
561 TEST_F(DelegatedRendererLayerImplTestSharedData, DisplaySize) 559 TEST_F(DelegatedRendererLayerImplTestSharedData, DisplaySize)
562 { 560 {
563 // Cause the layer to scale its output to be larger than its bounds. 561 // Cause the layer to scale its output to be larger than its bounds.
564 m_delegatedRendererLayerPtr->setDisplaySize(gfx::Size(40, 40)); 562 m_delegatedRendererLayerPtr->setDisplaySize(gfx::Size(40, 40));
565 EXPECT_LT(m_delegatedRendererLayerPtr->bounds().width(), 40); 563 EXPECT_LT(m_delegatedRendererLayerPtr->bounds().width(), 40);
566 EXPECT_LT(m_delegatedRendererLayerPtr->bounds().height(), 40); 564 EXPECT_LT(m_delegatedRendererLayerPtr->bounds().height(), 40);
567 565
568 LayerTreeHostImpl::FrameData frame; 566 LayerTreeHostImpl::FrameData frame;
569 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 567 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
570 568
571 ASSERT_EQ(2u, frame.renderPasses.size()); 569 ASSERT_EQ(2u, frame.renderPasses.size());
572 570
573 const QuadList& rootQuadList = frame.renderPasses[1]->quad_list; 571 const QuadList& rootQuadList = frame.renderPasses[1]->quad_list;
574 ASSERT_EQ(5u, rootQuadList.size()); 572 ASSERT_EQ(5u, rootQuadList.size());
575 573
576 const SharedQuadState* rootSharedState = rootQuadList[0]->shared_quad_state; 574 const SharedQuadState* rootSharedState = rootQuadList[0]->shared_quad_state;
577 575
578 // The results are similar to the SharedData test, but are scaled up by disp laySize/bounds, which is 40/30. 576 // The results are similar to the SharedData test, but are scaled up by disp laySize/bounds, which is 40/30.
579 EXPECT_RECT_EQ(gfx::Rect(21, 21, 80, 80), rootSharedState->clipped_rect_in_t arget);
580 EXPECT_RECT_EQ(gfx::Rect(21, 21, 80, 80), rootSharedState->clip_rect); 577 EXPECT_RECT_EQ(gfx::Rect(21, 21, 80, 80), rootSharedState->clip_rect);
581 gfx::Transform expected; 578 gfx::Transform expected;
582 // This is the transform from the layer's space to its target. 579 // This is the transform from the layer's space to its target.
583 // The position (20) - the width / scale (30 / 2) = 20 - 15 = 5 580 // The position (20) - the width / scale (30 / 2) = 20 - 15 = 5
584 expected.Translate(5.0, 5.0); 581 expected.Translate(5.0, 5.0);
585 expected.Scale(2.0, 2.0); 582 expected.Scale(2.0, 2.0);
586 expected.Translate(8.0, 8.0); 583 expected.Translate(8.0, 8.0);
587 // The frame has size 50x50 but the layer's bounds are 30x30. 584 // The frame has size 50x50 but the layer's bounds are 30x30.
588 expected.Scale(30.0 / 50.0, 30.0 / 50.0); 585 expected.Scale(30.0 / 50.0, 30.0 / 50.0);
589 // The display size is 40x40 but the bounds are 30x30. 586 // The display size is 40x40 but the bounds are 30x30.
590 expected.Scale(40.0 / 30.0, 40.0 / 30.0); 587 expected.Scale(40.0 / 30.0, 40.0 / 30.0);
591 // This is the transform within the source frame. 588 // This is the transform within the source frame.
592 expected.Scale(1.5, 1.5); 589 expected.Scale(1.5, 1.5);
593 expected.Translate(7.0, 7.0); 590 expected.Translate(7.0, 7.0);
594 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, rootSharedState->content_to_target _transform); 591 EXPECT_TRANSFORMATION_MATRIX_EQ(expected, rootSharedState->content_to_target _transform);
595 592
596 m_hostImpl->drawLayers(frame); 593 m_hostImpl->drawLayers(frame);
597 m_hostImpl->didDrawAllLayers(frame); 594 m_hostImpl->didDrawAllLayers(frame);
598 } 595 }
599 596
600 } // namespace 597 } // namespace
601 } // namespace cc 598 } // namespace cc
OLDNEW
« no previous file with comments | « cc/delegated_renderer_layer_impl.cc ('k') | cc/draw_quad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698