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

Side by Side Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 368403003: Use RenderPass to create DrawQuad in unittests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@layerrawptrDQ
Patch Set: address review comments Created 6 years, 5 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/quads/render_pass_unittest.cc ('k') | cc/surfaces/surfaces_pixeltest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/output/compositor_frame.h" 5 #include "cc/output/compositor_frame.h"
6 #include "cc/output/delegated_frame_data.h" 6 #include "cc/output/delegated_frame_data.h"
7 #include "cc/quads/render_pass.h" 7 #include "cc/quads/render_pass.h"
8 #include "cc/quads/render_pass_draw_quad.h" 8 #include "cc/quads/render_pass_draw_quad.h"
9 #include "cc/quads/solid_color_draw_quad.h" 9 #include "cc/quads/solid_color_draw_quad.h"
10 #include "cc/quads/surface_draw_quad.h" 10 #include "cc/quads/surface_draw_quad.h"
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 481 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
482 sqs->SetAll(content_to_target_transform, 482 sqs->SetAll(content_to_target_transform,
483 content_bounds, 483 content_bounds,
484 visible_content_rect, 484 visible_content_rect,
485 clip_rect, 485 clip_rect,
486 is_clipped, 486 is_clipped,
487 opacity, 487 opacity,
488 blend_mode, 488 blend_mode,
489 0); 489 0);
490 490
491 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); 491 SolidColorDrawQuad* color_quad =
492 pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
492 color_quad->SetNew(pass->shared_quad_state_list.back(), 493 color_quad->SetNew(pass->shared_quad_state_list.back(),
493 visible_content_rect, 494 visible_content_rect,
494 visible_content_rect, 495 visible_content_rect,
495 SK_ColorGREEN, 496 SK_ColorGREEN,
496 force_anti_aliasing_off); 497 force_anti_aliasing_off);
497 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>());
498 } 498 }
499 499
500 // This tests that we update shared quad state pointers correctly within 500 // This tests that we update shared quad state pointers correctly within
501 // aggregated passes. The shared quad state list on the aggregated pass will 501 // aggregated passes. The shared quad state list on the aggregated pass will
502 // include the shared quad states from each pass in one list so the quads will 502 // include the shared quad states from each pass in one list so the quads will
503 // end up pointed to shared quad state objects at different offsets. This test 503 // end up pointed to shared quad state objects at different offsets. This test
504 // uses the blend_mode value stored on the shared quad state to track the shared 504 // uses the blend_mode value stored on the shared quad state to track the shared
505 // quad state, but anything saved on the shared quad state would work. 505 // quad state, but anything saved on the shared quad state would work.
506 // 506 //
507 // This test has 4 surfaces in the following structure: 507 // This test has 4 surfaces in the following structure:
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 QueuePassAsFrame(grandchild_pass.Pass(), grandchild_surface_id); 548 QueuePassAsFrame(grandchild_pass.Pass(), grandchild_surface_id);
549 549
550 SurfaceId child_one_surface_id = allocator_.GenerateId(); 550 SurfaceId child_one_surface_id = allocator_.GenerateId();
551 factory_.Create(child_one_surface_id, SurfaceSize()); 551 factory_.Create(child_one_surface_id, SurfaceSize());
552 552
553 scoped_ptr<RenderPass> child_one_pass = RenderPass::Create(); 553 scoped_ptr<RenderPass> child_one_pass = RenderPass::Create();
554 child_one_pass->SetNew( 554 child_one_pass->SetNew(
555 pass_id, output_rect, damage_rect, transform_to_root_target); 555 pass_id, output_rect, damage_rect, transform_to_root_target);
556 AddSolidColorQuadWithBlendMode( 556 AddSolidColorQuadWithBlendMode(
557 SurfaceSize(), child_one_pass.get(), blend_modes[1]); 557 SurfaceSize(), child_one_pass.get(), blend_modes[1]);
558 scoped_ptr<SurfaceDrawQuad> grandchild_surface_quad = 558 SurfaceDrawQuad* grandchild_surface_quad =
559 SurfaceDrawQuad::Create(); 559 child_one_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
560 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(), 560 grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(),
561 gfx::Rect(SurfaceSize()), 561 gfx::Rect(SurfaceSize()),
562 gfx::Rect(SurfaceSize()), 562 gfx::Rect(SurfaceSize()),
563 grandchild_surface_id); 563 grandchild_surface_id);
564 child_one_pass->quad_list.push_back(
565 grandchild_surface_quad.PassAs<DrawQuad>());
566 AddSolidColorQuadWithBlendMode( 564 AddSolidColorQuadWithBlendMode(
567 SurfaceSize(), child_one_pass.get(), blend_modes[3]); 565 SurfaceSize(), child_one_pass.get(), blend_modes[3]);
568 QueuePassAsFrame(child_one_pass.Pass(), child_one_surface_id); 566 QueuePassAsFrame(child_one_pass.Pass(), child_one_surface_id);
569 567
570 SurfaceId child_two_surface_id = allocator_.GenerateId(); 568 SurfaceId child_two_surface_id = allocator_.GenerateId();
571 factory_.Create(child_two_surface_id, SurfaceSize()); 569 factory_.Create(child_two_surface_id, SurfaceSize());
572 570
573 scoped_ptr<RenderPass> child_two_pass = RenderPass::Create(); 571 scoped_ptr<RenderPass> child_two_pass = RenderPass::Create();
574 child_two_pass->SetNew( 572 child_two_pass->SetNew(
575 pass_id, output_rect, damage_rect, transform_to_root_target); 573 pass_id, output_rect, damage_rect, transform_to_root_target);
576 AddSolidColorQuadWithBlendMode( 574 AddSolidColorQuadWithBlendMode(
577 SurfaceSize(), child_two_pass.get(), blend_modes[5]); 575 SurfaceSize(), child_two_pass.get(), blend_modes[5]);
578 QueuePassAsFrame(child_two_pass.Pass(), child_two_surface_id); 576 QueuePassAsFrame(child_two_pass.Pass(), child_two_surface_id);
579 577
580 scoped_ptr<RenderPass> root_pass = RenderPass::Create(); 578 scoped_ptr<RenderPass> root_pass = RenderPass::Create();
581 root_pass->SetNew( 579 root_pass->SetNew(
582 pass_id, output_rect, damage_rect, transform_to_root_target); 580 pass_id, output_rect, damage_rect, transform_to_root_target);
583 581
584 AddSolidColorQuadWithBlendMode( 582 AddSolidColorQuadWithBlendMode(
585 SurfaceSize(), root_pass.get(), blend_modes[0]); 583 SurfaceSize(), root_pass.get(), blend_modes[0]);
586 scoped_ptr<SurfaceDrawQuad> child_one_surface_quad = 584 SurfaceDrawQuad* child_one_surface_quad =
587 SurfaceDrawQuad::Create(); 585 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
588 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), 586 child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(),
589 gfx::Rect(SurfaceSize()), 587 gfx::Rect(SurfaceSize()),
590 gfx::Rect(SurfaceSize()), 588 gfx::Rect(SurfaceSize()),
591 child_one_surface_id); 589 child_one_surface_id);
592 root_pass->quad_list.push_back(child_one_surface_quad.PassAs<DrawQuad>());
593 AddSolidColorQuadWithBlendMode( 590 AddSolidColorQuadWithBlendMode(
594 SurfaceSize(), root_pass.get(), blend_modes[4]); 591 SurfaceSize(), root_pass.get(), blend_modes[4]);
595 scoped_ptr<SurfaceDrawQuad> child_two_surface_quad = 592 SurfaceDrawQuad* child_two_surface_quad =
596 SurfaceDrawQuad::Create(); 593 root_pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
597 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(), 594 child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(),
598 gfx::Rect(SurfaceSize()), 595 gfx::Rect(SurfaceSize()),
599 gfx::Rect(SurfaceSize()), 596 gfx::Rect(SurfaceSize()),
600 child_two_surface_id); 597 child_two_surface_id);
601 root_pass->quad_list.push_back(child_two_surface_quad.PassAs<DrawQuad>());
602 AddSolidColorQuadWithBlendMode( 598 AddSolidColorQuadWithBlendMode(
603 SurfaceSize(), root_pass.get(), blend_modes[6]); 599 SurfaceSize(), root_pass.get(), blend_modes[6]);
604 600
605 QueuePassAsFrame(root_pass.Pass(), root_surface_id_); 601 QueuePassAsFrame(root_pass.Pass(), root_surface_id_);
606 602
607 scoped_ptr<CompositorFrame> aggregated_frame = 603 scoped_ptr<CompositorFrame> aggregated_frame =
608 aggregator_.Aggregate(root_surface_id_); 604 aggregator_.Aggregate(root_surface_id_);
609 605
610 ASSERT_TRUE(aggregated_frame); 606 ASSERT_TRUE(aggregated_frame);
611 ASSERT_TRUE(aggregated_frame->delegated_frame_data); 607 ASSERT_TRUE(aggregated_frame->delegated_frame_data);
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 SurfaceFactory* factory, 813 SurfaceFactory* factory,
818 SurfaceId surface_id) { 814 SurfaceId surface_id) {
819 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData); 815 scoped_ptr<DelegatedFrameData> frame_data(new DelegatedFrameData);
820 scoped_ptr<RenderPass> pass = RenderPass::Create(); 816 scoped_ptr<RenderPass> pass = RenderPass::Create();
821 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState(); 817 SharedQuadState* sqs = pass->CreateAndAppendSharedQuadState();
822 for (size_t i = 0u; i < num_resource_ids; ++i) { 818 for (size_t i = 0u; i < num_resource_ids; ++i) {
823 TransferableResource resource; 819 TransferableResource resource;
824 resource.id = resource_ids[i]; 820 resource.id = resource_ids[i];
825 resource.is_software = true; 821 resource.is_software = true;
826 frame_data->resource_list.push_back(resource); 822 frame_data->resource_list.push_back(resource);
827 scoped_ptr<TextureDrawQuad> quad(TextureDrawQuad::Create()); 823 TextureDrawQuad* quad = pass->CreateAndAppendDrawQuad<TextureDrawQuad>();
828 const gfx::Rect rect; 824 const gfx::Rect rect;
829 const gfx::Rect opaque_rect; 825 const gfx::Rect opaque_rect;
830 const gfx::Rect visible_rect; 826 const gfx::Rect visible_rect;
831 bool needs_blending = false; 827 bool needs_blending = false;
832 bool premultiplied_alpha = false; 828 bool premultiplied_alpha = false;
833 const gfx::PointF uv_top_left; 829 const gfx::PointF uv_top_left;
834 const gfx::PointF uv_bottom_right; 830 const gfx::PointF uv_bottom_right;
835 SkColor background_color = SK_ColorGREEN; 831 SkColor background_color = SK_ColorGREEN;
836 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f}; 832 const float vertex_opacity[4] = {0.f, 0.f, 1.f, 1.f};
837 bool flipped = false; 833 bool flipped = false;
838 quad->SetAll(sqs, 834 quad->SetAll(sqs,
839 rect, 835 rect,
840 opaque_rect, 836 opaque_rect,
841 visible_rect, 837 visible_rect,
842 needs_blending, 838 needs_blending,
843 resource_ids[i], 839 resource_ids[i],
844 premultiplied_alpha, 840 premultiplied_alpha,
845 uv_top_left, 841 uv_top_left,
846 uv_bottom_right, 842 uv_bottom_right,
847 background_color, 843 background_color,
848 vertex_opacity, 844 vertex_opacity,
849 flipped); 845 flipped);
850 846
851 quad->shared_quad_state = sqs; 847 quad->shared_quad_state = sqs;
852 pass->quad_list.push_back(quad.PassAs<DrawQuad>());
853 } 848 }
854 frame_data->render_pass_list.push_back(pass.Pass()); 849 frame_data->render_pass_list.push_back(pass.Pass());
855 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 850 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
856 frame->delegated_frame_data = frame_data.Pass(); 851 frame->delegated_frame_data = frame_data.Pass();
857 factory->SubmitFrame(surface_id, frame.Pass()); 852 factory->SubmitFrame(surface_id, frame.Pass());
858 } 853 }
859 854
860 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) { 855 TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
861 ResourceTrackingSurfaceFactoryClient client; 856 ResourceTrackingSurfaceFactoryClient client;
862 SurfaceFactory factory(&manager_, &client); 857 SurfaceFactory factory(&manager_, &client);
(...skipping 18 matching lines...) Expand all
881 returned_ids[i] = client.returned_resources()[i].id; 876 returned_ids[i] = client.returned_resources()[i].id;
882 } 877 }
883 EXPECT_THAT(returned_ids, 878 EXPECT_THAT(returned_ids,
884 testing::WhenSorted(testing::ElementsAreArray(ids))); 879 testing::WhenSorted(testing::ElementsAreArray(ids)));
885 factory.Destroy(surface_id); 880 factory.Destroy(surface_id);
886 } 881 }
887 882
888 } // namespace 883 } // namespace
889 } // namespace cc 884 } // namespace cc
890 885
OLDNEW
« no previous file with comments | « cc/quads/render_pass_unittest.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698