| Index: cc/surfaces/surface_aggregator_unittest.cc
|
| diff --git a/cc/surfaces/surface_aggregator_unittest.cc b/cc/surfaces/surface_aggregator_unittest.cc
|
| index 0e4e133ae7beb2db1ec84a16e4ae47ab2feee39d..04cca7989e7cee96fc4d59208829e0697fce9b30 100644
|
| --- a/cc/surfaces/surface_aggregator_unittest.cc
|
| +++ b/cc/surfaces/surface_aggregator_unittest.cc
|
| @@ -18,11 +18,11 @@
|
| #include "cc/quads/surface_draw_quad.h"
|
| #include "cc/quads/texture_draw_quad.h"
|
| #include "cc/resources/shared_bitmap_manager.h"
|
| +#include "cc/surfaces/compositor_frame_sink_support.h"
|
| #include "cc/surfaces/local_surface_id_allocator.h"
|
| #include "cc/surfaces/surface.h"
|
| -#include "cc/surfaces/surface_factory.h"
|
| -#include "cc/surfaces/surface_factory_client.h"
|
| #include "cc/surfaces/surface_manager.h"
|
| +#include "cc/test/fake_compositor_frame_sink_support_client.h"
|
| #include "cc/test/fake_resource_provider.h"
|
| #include "cc/test/render_pass_test_utils.h"
|
| #include "cc/test/surface_aggregator_test_helpers.h"
|
| @@ -35,10 +35,16 @@ namespace cc {
|
| namespace {
|
|
|
| constexpr FrameSinkId kArbitraryRootFrameSinkId(1, 1);
|
| -constexpr FrameSinkId kArbitraryChildFrameSinkId1(2, 2);
|
| -constexpr FrameSinkId kArbitraryChildFrameSinkId2(3, 3);
|
| +constexpr FrameSinkId kArbitraryFrameSinkId1(2, 2);
|
| +constexpr FrameSinkId kArbitraryFrameSinkId2(3, 3);
|
| constexpr FrameSinkId kArbitraryMiddleFrameSinkId(4, 4);
|
| +constexpr FrameSinkId kArbitraryReservedFrameSinkId(5, 5);
|
| +constexpr FrameSinkId kArbitraryFrameSinkId3(6, 6);
|
| const base::UnguessableToken kArbitraryToken = base::UnguessableToken::Create();
|
| +constexpr bool kRootIsRoot = true;
|
| +constexpr bool kChildIsRoot = false;
|
| +constexpr bool kHandlesFrameSinkIdInvalidation = true;
|
| +constexpr bool kNeedsSyncPoints = false;
|
|
|
| SurfaceId InvalidSurfaceId() {
|
| static SurfaceId invalid(FrameSinkId(),
|
| @@ -51,47 +57,36 @@ gfx::Size SurfaceSize() {
|
| return size;
|
| }
|
|
|
| -class EmptySurfaceFactoryClient : public SurfaceFactoryClient {
|
| - public:
|
| - void ReturnResources(const ReturnedResourceArray& resources) override {}
|
| -
|
| - void WillDrawSurface(const LocalSurfaceId& id,
|
| - const gfx::Rect& damage_rect) override {
|
| - last_local_surface_id_ = id;
|
| - last_damage_rect_ = damage_rect;
|
| - }
|
| -
|
| - void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {}
|
| -
|
| - gfx::Rect last_damage_rect_;
|
| - LocalSurfaceId last_local_surface_id_;
|
| -};
|
| -
|
| class SurfaceAggregatorTest : public testing::Test {
|
| public:
|
| explicit SurfaceAggregatorTest(bool use_damage_rect)
|
| - : factory_(kArbitraryRootFrameSinkId, &manager_, &empty_client_),
|
| + : support_(
|
| + CompositorFrameSinkSupport::Create(&fake_client_,
|
| + &manager_,
|
| + kArbitraryRootFrameSinkId,
|
| + kRootIsRoot,
|
| + kHandlesFrameSinkIdInvalidation,
|
| + kNeedsSyncPoints)),
|
| aggregator_(&manager_, NULL, use_damage_rect) {}
|
|
|
| SurfaceAggregatorTest() : SurfaceAggregatorTest(false) {}
|
|
|
| void TearDown() override {
|
| - factory_.EvictSurface();
|
| + support_->EvictFrame();
|
| testing::Test::TearDown();
|
| }
|
|
|
| protected:
|
| SurfaceManager manager_;
|
| - EmptySurfaceFactoryClient empty_client_;
|
| - SurfaceFactory factory_;
|
| + FakeCompositorFrameSinkSupportClient fake_client_;
|
| + std::unique_ptr<CompositorFrameSinkSupport> support_;
|
| SurfaceAggregator aggregator_;
|
| };
|
|
|
| TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
|
| LocalSurfaceId local_surface_id(7, base::UnguessableToken::Create());
|
| SurfaceId one_id(kArbitraryRootFrameSinkId, local_surface_id);
|
| - factory_.SubmitCompositorFrame(local_surface_id, CompositorFrame(),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(local_surface_id, CompositorFrame());
|
|
|
| CompositorFrame frame = aggregator_.Aggregate(one_id);
|
| EXPECT_TRUE(frame.render_pass_list.empty());
|
| @@ -101,9 +96,13 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
|
| public:
|
| explicit SurfaceAggregatorValidSurfaceTest(bool use_damage_rect)
|
| : SurfaceAggregatorTest(use_damage_rect),
|
| - child_factory_(kArbitraryChildFrameSinkId1,
|
| - &manager_,
|
| - &empty_child_client_) {}
|
| + child_support_(
|
| + CompositorFrameSinkSupport::Create(nullptr,
|
| + &manager_,
|
| + kArbitraryReservedFrameSinkId,
|
| + kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation,
|
| + kNeedsSyncPoints)) {}
|
| SurfaceAggregatorValidSurfaceTest()
|
| : SurfaceAggregatorValidSurfaceTest(false) {}
|
|
|
| @@ -111,11 +110,11 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
|
| SurfaceAggregatorTest::SetUp();
|
| root_local_surface_id_ = allocator_.GenerateId();
|
| root_surface_ = manager_.GetSurfaceForId(
|
| - SurfaceId(factory_.frame_sink_id(), root_local_surface_id_));
|
| + SurfaceId(support_->frame_sink_id(), root_local_surface_id_));
|
| }
|
|
|
| void TearDown() override {
|
| - child_factory_.EvictSurface();
|
| + child_support_->EvictFrame();
|
| SurfaceAggregatorTest::TearDown();
|
| }
|
|
|
| @@ -124,7 +123,7 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
|
| SurfaceId* surface_ids,
|
| size_t expected_surface_count) {
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(
|
| - SurfaceId(factory_.frame_sink_id(), root_local_surface_id_));
|
| + SurfaceId(support_->frame_sink_id(), root_local_surface_id_));
|
|
|
| TestPassesMatchExpectations(expected_passes, expected_pass_count,
|
| &aggregated_frame.render_pass_list);
|
| @@ -144,41 +143,38 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
|
| }
|
| }
|
|
|
| - void SubmitPassListAsFrame(SurfaceFactory* factory,
|
| + void SubmitPassListAsFrame(CompositorFrameSinkSupport* support,
|
| const LocalSurfaceId& local_surface_id,
|
| RenderPassList* pass_list) {
|
| CompositorFrame frame;
|
| pass_list->swap(frame.render_pass_list);
|
|
|
| - factory->SubmitCompositorFrame(local_surface_id, std::move(frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support->SubmitCompositorFrame(local_surface_id, std::move(frame));
|
| }
|
|
|
| - void SubmitCompositorFrame(SurfaceFactory* factory,
|
| + void SubmitCompositorFrame(CompositorFrameSinkSupport* support,
|
| test::Pass* passes,
|
| size_t pass_count,
|
| const LocalSurfaceId& local_surface_id) {
|
| RenderPassList pass_list;
|
| AddPasses(&pass_list, gfx::Rect(SurfaceSize()), passes, pass_count);
|
| - SubmitPassListAsFrame(factory, local_surface_id, &pass_list);
|
| + SubmitPassListAsFrame(support, local_surface_id, &pass_list);
|
| }
|
|
|
| void QueuePassAsFrame(std::unique_ptr<RenderPass> pass,
|
| const LocalSurfaceId& local_surface_id,
|
| - SurfaceFactory* factory) {
|
| + CompositorFrameSinkSupport* support) {
|
| CompositorFrame child_frame;
|
| child_frame.render_pass_list.push_back(std::move(pass));
|
|
|
| - factory->SubmitCompositorFrame(local_surface_id, std::move(child_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support->SubmitCompositorFrame(local_surface_id, std::move(child_frame));
|
| }
|
|
|
| protected:
|
| LocalSurfaceId root_local_surface_id_;
|
| Surface* root_surface_;
|
| LocalSurfaceIdAllocator allocator_;
|
| - EmptySurfaceFactoryClient empty_child_client_;
|
| - SurfaceFactory child_factory_;
|
| + std::unique_ptr<CompositorFrameSinkSupport> child_support_;
|
| LocalSurfaceIdAllocator child_allocator_;
|
| };
|
|
|
| @@ -189,24 +185,26 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) {
|
| test::Quad::SolidColorQuad(SK_ColorBLUE)};
|
| test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| SurfaceId ids[] = {root_surface_id};
|
|
|
| AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids));
|
|
|
| // Check that WillDrawSurface was called.
|
| - EXPECT_EQ(gfx::Rect(SurfaceSize()), empty_client_.last_damage_rect_);
|
| - EXPECT_EQ(root_local_surface_id_, empty_client_.last_local_surface_id_);
|
| + EXPECT_EQ(gfx::Rect(SurfaceSize()), fake_client_.last_damage_rect());
|
| + EXPECT_EQ(root_local_surface_id_, fake_client_.last_local_surface_id());
|
| }
|
|
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) {
|
| - SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> embedded_support(
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId1, kRootIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints));
|
| LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(),
|
| + SurfaceId embedded_surface_id(embedded_support->frame_sink_id(),
|
| embedded_local_surface_id);
|
|
|
| test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
|
| @@ -214,17 +212,17 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) {
|
| test::Pass embedded_passes[] = {
|
| test::Pass(embedded_quads, arraysize(embedded_quads))};
|
|
|
| - SubmitCompositorFrame(&embedded_factory, embedded_passes,
|
| + SubmitCompositorFrame(embedded_support.get(), embedded_passes,
|
| arraysize(embedded_passes), embedded_local_surface_id);
|
|
|
| test::Quad quads[] = {
|
| test::Quad::SurfaceQuad(embedded_surface_id, InvalidSurfaceId(), .5f)};
|
| test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| RenderPassList& render_pass_list(aggregated_frame.render_pass_list);
|
| @@ -240,7 +238,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) {
|
| ASSERT_EQ(1u, shared_quad_state_list2.size());
|
| EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity);
|
|
|
| - embedded_factory.EvictSurface();
|
| + embedded_support->EvictFrame();
|
| }
|
|
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) {
|
| @@ -251,10 +249,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) {
|
| test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 1),
|
| test::Pass(quads[1], arraysize(quads[1]), 2)};
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| SurfaceId ids[] = {root_surface_id};
|
|
|
| AggregateAndVerify(passes, arraysize(passes), ids, arraysize(ids));
|
| @@ -269,10 +267,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassDeallocation) {
|
| test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0]), 2),
|
| test::Pass(quads[1], arraysize(quads[1]), 1)};
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
|
|
| CompositorFrame aggregated_frame;
|
| aggregated_frame = aggregator_.Aggregate(surface_id);
|
| @@ -288,7 +286,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassDeallocation) {
|
| test::Pass passes2[] = {test::Pass(quads[0], arraysize(quads[0]), 3),
|
| test::Pass(quads[1], arraysize(quads[1]), 1)};
|
|
|
| - SubmitCompositorFrame(&factory_, passes2, arraysize(passes2),
|
| + SubmitCompositorFrame(support_.get(), passes2, arraysize(passes2),
|
| root_local_surface_id_);
|
|
|
| // The RenderPass that still exists should keep the same ID.
|
| @@ -298,7 +296,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassDeallocation) {
|
| EXPECT_NE(id2, id0);
|
| EXPECT_EQ(id1, aggregated_frame.render_pass_list[1]->id);
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| // |id1| didn't exist in the previous frame, so it should be
|
| @@ -316,17 +314,19 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassDeallocation) {
|
| // embedded_surface has a frame containing only a solid color quad. The solid
|
| // color quad should be aggregated into the final frame.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
|
| - SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> embedded_support(
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId1, kRootIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints));
|
| LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(),
|
| + SurfaceId embedded_surface_id(embedded_support->frame_sink_id(),
|
| embedded_local_surface_id);
|
|
|
| test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
|
| test::Pass embedded_passes[] = {
|
| test::Pass(embedded_quads, arraysize(embedded_quads))};
|
|
|
| - SubmitCompositorFrame(&embedded_factory, embedded_passes,
|
| + SubmitCompositorFrame(embedded_support.get(), embedded_passes,
|
| arraysize(embedded_passes), embedded_local_surface_id);
|
|
|
| test::Quad root_quads[] = {
|
| @@ -335,7 +335,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
|
| test::Quad::SolidColorQuad(SK_ColorBLACK)};
|
| test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes),
|
| + SubmitCompositorFrame(support_.get(), root_passes, arraysize(root_passes),
|
| root_local_surface_id_);
|
|
|
| test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
|
| @@ -343,28 +343,32 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
|
| test::Quad::SolidColorQuad(SK_ColorBLACK)};
|
| test::Pass expected_passes[] = {
|
| test::Pass(expected_quads, arraysize(expected_quads))};
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| SurfaceId ids[] = {root_surface_id, embedded_surface_id};
|
| AggregateAndVerify(
|
| expected_passes, arraysize(expected_passes), ids, arraysize(ids));
|
|
|
| - embedded_factory.EvictSurface();
|
| + embedded_support->EvictFrame();
|
| }
|
|
|
| // This test verifies that in the absence of a primary Surface,
|
| // SurfaceAggregator will embed a fallback Surface, if available. If the primary
|
| // Surface is available, though, the fallback will not be used.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) {
|
| - SurfaceFactory primary_child_factory(kArbitraryChildFrameSinkId1, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> primary_child_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId primary_child_surface_id(primary_child_factory.frame_sink_id(),
|
| + SurfaceId primary_child_surface_id(primary_child_support->frame_sink_id(),
|
| primary_child_local_surface_id);
|
|
|
| - SurfaceFactory fallback_child_factory(kArbitraryChildFrameSinkId2, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> fallback_child_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId fallback_child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId fallback_child_surface_id(fallback_child_factory.frame_sink_id(),
|
| + SurfaceId fallback_child_surface_id(fallback_child_support->frame_sink_id(),
|
| fallback_child_local_surface_id);
|
|
|
| test::Quad fallback_child_quads[] = {test::Quad::SolidColorQuad(SK_ColorRED)};
|
| @@ -373,7 +377,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) {
|
|
|
| // Submit a CompositorFrame to the fallback Surface containing a red
|
| // SolidColorDrawQuad.
|
| - SubmitCompositorFrame(&fallback_child_factory, fallback_child_passes,
|
| + SubmitCompositorFrame(fallback_child_support.get(), fallback_child_passes,
|
| arraysize(fallback_child_passes),
|
| fallback_child_local_surface_id);
|
|
|
| @@ -383,7 +387,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) {
|
| primary_child_surface_id, fallback_child_surface_id, 1.f)};
|
| test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes),
|
| + SubmitCompositorFrame(support_.get(), root_passes, arraysize(root_passes),
|
| root_local_surface_id_);
|
|
|
| // There is no CompositorFrame submitted to |primary_child_surface_id| and so
|
| @@ -393,7 +397,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) {
|
| test::Pass expected_passes1[] = {
|
| test::Pass(expected_quads1, arraysize(expected_quads1))};
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| SurfaceId ids[] = {root_surface_id, primary_child_surface_id,
|
| fallback_child_surface_id};
|
| AggregateAndVerify(expected_passes1, arraysize(expected_passes1), ids,
|
| @@ -406,7 +410,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) {
|
|
|
| // Submit a CompositorFrame to the primary Surface containing a green
|
| // SolidColorDrawQuad.
|
| - SubmitCompositorFrame(&primary_child_factory, primary_child_passes,
|
| + SubmitCompositorFrame(primary_child_support.get(), primary_child_passes,
|
| arraysize(primary_child_passes),
|
| primary_child_local_surface_id);
|
|
|
| @@ -419,17 +423,19 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReference) {
|
| AggregateAndVerify(expected_passes2, arraysize(expected_passes2), ids,
|
| arraysize(ids));
|
|
|
| - primary_child_factory.EvictSurface();
|
| - fallback_child_factory.EvictSurface();
|
| + primary_child_support->EvictFrame();
|
| + fallback_child_support->EvictFrame();
|
| }
|
|
|
| // This test verifies that in the presence of both primary Surface and fallback
|
| // Surface, the fallback will not be used.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) {
|
| - SurfaceFactory primary_child_factory(kArbitraryChildFrameSinkId1, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> primary_child_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId primary_child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId primary_child_surface_id(primary_child_factory.frame_sink_id(),
|
| + SurfaceId primary_child_surface_id(primary_child_support->frame_sink_id(),
|
| primary_child_local_surface_id);
|
| test::Quad primary_child_quads[] = {
|
| test::Quad::SolidColorQuad(SK_ColorGREEN)};
|
| @@ -438,14 +444,16 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) {
|
|
|
| // Submit a CompositorFrame to the primary Surface containing a green
|
| // SolidColorDrawQuad.
|
| - SubmitCompositorFrame(&primary_child_factory, primary_child_passes,
|
| + SubmitCompositorFrame(primary_child_support.get(), primary_child_passes,
|
| arraysize(primary_child_passes),
|
| primary_child_local_surface_id);
|
|
|
| - SurfaceFactory fallback_child_factory(kArbitraryChildFrameSinkId2, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> fallback_child_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId fallback_child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId fallback_child_surface_id(fallback_child_factory.frame_sink_id(),
|
| + SurfaceId fallback_child_surface_id(fallback_child_support->frame_sink_id(),
|
| fallback_child_local_surface_id);
|
|
|
| test::Quad fallback_child_quads[] = {test::Quad::SolidColorQuad(SK_ColorRED)};
|
| @@ -454,7 +462,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) {
|
|
|
| // Submit a CompositorFrame to the fallback Surface containing a red
|
| // SolidColorDrawQuad.
|
| - SubmitCompositorFrame(&fallback_child_factory, fallback_child_passes,
|
| + SubmitCompositorFrame(fallback_child_support.get(), fallback_child_passes,
|
| arraysize(fallback_child_passes),
|
| fallback_child_local_surface_id);
|
|
|
| @@ -464,7 +472,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) {
|
| primary_child_surface_id, fallback_child_surface_id, 1.f)};
|
| test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes),
|
| + SubmitCompositorFrame(support_.get(), root_passes, arraysize(root_passes),
|
| root_local_surface_id_);
|
|
|
| // The CompositorFrame is submitted to |primary_child_surface_id|, so
|
| @@ -474,33 +482,35 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, FallbackSurfaceReferenceWithPrimary) {
|
| test::Pass expected_passes1[] = {
|
| test::Pass(expected_quads1, arraysize(expected_quads1))};
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| SurfaceId ids[] = {root_surface_id, primary_child_surface_id,
|
| fallback_child_surface_id};
|
| AggregateAndVerify(expected_passes1, arraysize(expected_passes1), ids,
|
| arraysize(ids));
|
|
|
| - primary_child_factory.EvictSurface();
|
| - fallback_child_factory.EvictSurface();
|
| + primary_child_support->EvictFrame();
|
| + fallback_child_support->EvictFrame();
|
| }
|
|
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) {
|
| - SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> embedded_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(),
|
| + SurfaceId embedded_surface_id(embedded_support->frame_sink_id(),
|
| embedded_local_surface_id);
|
|
|
| test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
|
| test::Pass embedded_passes[] = {
|
| test::Pass(embedded_quads, arraysize(embedded_quads))};
|
|
|
| - SubmitCompositorFrame(&embedded_factory, embedded_passes,
|
| + SubmitCompositorFrame(embedded_support.get(), embedded_passes,
|
| arraysize(embedded_passes), embedded_local_surface_id);
|
| std::unique_ptr<CopyOutputRequest> copy_request(
|
| CopyOutputRequest::CreateEmptyRequest());
|
| CopyOutputRequest* copy_request_ptr = copy_request.get();
|
| - embedded_factory.RequestCopyOfSurface(std::move(copy_request));
|
| + embedded_support->RequestCopyOfSurface(std::move(copy_request));
|
|
|
| test::Quad root_quads[] = {
|
| test::Quad::SolidColorQuad(SK_ColorWHITE),
|
| @@ -508,10 +518,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) {
|
| test::Quad::SolidColorQuad(SK_ColorBLACK)};
|
| test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes),
|
| + SubmitCompositorFrame(support_.get(), root_passes, arraysize(root_passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| test::Quad expected_quads[] = {
|
| @@ -537,22 +547,24 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) {
|
| aggregator_.previous_contained_surfaces().end());
|
| }
|
|
|
| - embedded_factory.EvictSurface();
|
| + embedded_support->EvictFrame();
|
| }
|
|
|
| // Root surface may contain copy requests.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
|
| - SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> embedded_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(),
|
| + SurfaceId embedded_surface_id(embedded_support->frame_sink_id(),
|
| embedded_local_surface_id);
|
|
|
| test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
|
| test::Pass embedded_passes[] = {
|
| test::Pass(embedded_quads, arraysize(embedded_quads))};
|
|
|
| - SubmitCompositorFrame(&embedded_factory, embedded_passes,
|
| + SubmitCompositorFrame(embedded_support.get(), embedded_passes,
|
| arraysize(embedded_passes), embedded_local_surface_id);
|
| std::unique_ptr<CopyOutputRequest> copy_request(
|
| CopyOutputRequest::CreateEmptyRequest());
|
| @@ -577,11 +589,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
|
| frame.render_pass_list[1]->copy_requests.push_back(
|
| std::move(copy_request2));
|
|
|
| - factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(root_local_surface_id_, std::move(frame));
|
| }
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
|
| @@ -617,33 +628,37 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
|
| DCHECK(original_pass_list[0]->copy_requests.empty());
|
| DCHECK(original_pass_list[1]->copy_requests.empty());
|
|
|
| - embedded_factory.EvictSurface();
|
| + embedded_support->EvictFrame();
|
| }
|
|
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
|
| - SurfaceFactory embedded_factory(kArbitraryChildFrameSinkId1, &manager_,
|
| - &empty_client_);
|
| - SurfaceFactory parent_factory(kArbitraryRootFrameSinkId, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> embedded_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| + std::unique_ptr<CompositorFrameSinkSupport> parent_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId2, kRootIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId embedded_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId embedded_surface_id(embedded_factory.frame_sink_id(),
|
| + SurfaceId embedded_surface_id(embedded_support->frame_sink_id(),
|
| embedded_local_surface_id);
|
| - SurfaceId nonexistent_surface_id(factory_.frame_sink_id(),
|
| + SurfaceId nonexistent_surface_id(support_->frame_sink_id(),
|
| allocator_.GenerateId());
|
|
|
| test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
|
| test::Pass embedded_passes[] = {
|
| test::Pass(embedded_quads, arraysize(embedded_quads))};
|
|
|
| - SubmitCompositorFrame(&embedded_factory, embedded_passes,
|
| + SubmitCompositorFrame(embedded_support.get(), embedded_passes,
|
| arraysize(embedded_passes), embedded_local_surface_id);
|
| std::unique_ptr<CopyOutputRequest> copy_request(
|
| CopyOutputRequest::CreateEmptyRequest());
|
| CopyOutputRequest* copy_request_ptr = copy_request.get();
|
| - embedded_factory.RequestCopyOfSurface(std::move(copy_request));
|
| + embedded_support->RequestCopyOfSurface(std::move(copy_request));
|
|
|
| LocalSurfaceId parent_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId parent_surface_id(parent_factory.frame_sink_id(),
|
| + SurfaceId parent_surface_id(parent_support->frame_sink_id(),
|
| parent_local_surface_id);
|
|
|
| test::Quad parent_quads[] = {
|
| @@ -661,9 +676,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
|
|
|
| frame.metadata.referenced_surfaces.push_back(embedded_surface_id);
|
|
|
| - parent_factory.SubmitCompositorFrame(parent_local_surface_id,
|
| - std::move(frame),
|
| - SurfaceFactory::DrawCallback());
|
| + parent_support->SubmitCompositorFrame(parent_local_surface_id,
|
| + std::move(frame));
|
| }
|
|
|
| test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
|
| @@ -680,11 +694,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
|
| // included in previous_contained_surfaces, but otherwise ignored.
|
| frame.metadata.referenced_surfaces.push_back(nonexistent_surface_id);
|
|
|
| - factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(root_local_surface_id_, std::move(frame));
|
| }
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| // First pass should come from surface that had a copy request but was not
|
| @@ -702,7 +715,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
|
| aggregated_frame.render_pass_list[0]->copy_requests[0].get());
|
|
|
| SurfaceId surface_ids[] = {
|
| - SurfaceId(factory_.frame_sink_id(), root_local_surface_id_),
|
| + SurfaceId(support_->frame_sink_id(), root_local_surface_id_),
|
| parent_surface_id, embedded_surface_id, nonexistent_surface_id};
|
| EXPECT_EQ(arraysize(surface_ids),
|
| aggregator_.previous_contained_surfaces().size());
|
| @@ -712,14 +725,14 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
|
| aggregator_.previous_contained_surfaces().end());
|
| }
|
|
|
| - embedded_factory.EvictSurface();
|
| - parent_factory.EvictSurface();
|
| + embedded_support->EvictFrame();
|
| + parent_support->EvictFrame();
|
| }
|
|
|
| // This tests referencing a surface that has multiple render passes.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
|
| LocalSurfaceId embedded_local_surface_id = child_allocator_.GenerateId();
|
| - SurfaceId embedded_surface_id(child_factory_.frame_sink_id(),
|
| + SurfaceId embedded_surface_id(child_support_->frame_sink_id(),
|
| embedded_local_surface_id);
|
|
|
| int pass_ids[] = {1, 2, 3};
|
| @@ -733,7 +746,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
|
| test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]),
|
| test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])};
|
|
|
| - SubmitCompositorFrame(&child_factory_, embedded_passes,
|
| + SubmitCompositorFrame(child_support_.get(), embedded_passes,
|
| arraysize(embedded_passes), embedded_local_surface_id);
|
|
|
| test::Quad root_quads[][2] = {
|
| @@ -746,10 +759,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
|
| test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]),
|
| test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])};
|
|
|
| - SubmitCompositorFrame(&factory_, root_passes, arraysize(root_passes),
|
| + SubmitCompositorFrame(support_.get(), root_passes, arraysize(root_passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -861,14 +874,14 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) {
|
| test::Quad::SolidColorQuad(SK_ColorBLUE)};
|
| test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
|
| test::Quad::SolidColorQuad(SK_ColorBLUE)};
|
| test::Pass expected_passes[] = {
|
| test::Pass(expected_quads, arraysize(expected_quads))};
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| SurfaceId ids[] = {root_surface_id, InvalidSurfaceId()};
|
|
|
| AggregateAndVerify(
|
| @@ -879,7 +892,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) {
|
| // should also just be dropped.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
|
| LocalSurfaceId empty_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(),
|
| + SurfaceId surface_with_no_frame_id(support_->frame_sink_id(),
|
| empty_local_surface_id);
|
|
|
| test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
|
| @@ -888,14 +901,14 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
|
| test::Quad::SolidColorQuad(SK_ColorBLUE)};
|
| test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
|
| test::Quad::SolidColorQuad(SK_ColorBLUE)};
|
| test::Pass expected_passes[] = {
|
| test::Pass(expected_quads, arraysize(expected_quads))};
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id};
|
| AggregateAndVerify(
|
| expected_passes, arraysize(expected_passes), ids, arraysize(ids));
|
| @@ -904,13 +917,13 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
|
| // Tests a surface quad referencing itself, generating a trivial cycle.
|
| // The quad creating the cycle should be dropped from the final frame.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) {
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| test::Quad quads[] = {
|
| test::Quad::SurfaceQuad(root_surface_id, InvalidSurfaceId(), 1.f),
|
| test::Quad::SolidColorQuad(SK_ColorYELLOW)};
|
| test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)};
|
| @@ -924,7 +937,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) {
|
| // Tests a more complex cycle with one intermediate surface.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
|
| LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId child_surface_id(child_factory_.frame_sink_id(),
|
| + SurfaceId child_surface_id(child_support_->frame_sink_id(),
|
| child_local_surface_id);
|
|
|
| test::Quad parent_quads[] = {
|
| @@ -934,18 +947,18 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
|
| test::Pass parent_passes[] = {
|
| test::Pass(parent_quads, arraysize(parent_quads))};
|
|
|
| - SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes),
|
| + SubmitCompositorFrame(support_.get(), parent_passes, arraysize(parent_passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| test::Quad child_quads[] = {
|
| test::Quad::SolidColorQuad(SK_ColorGREEN),
|
| test::Quad::SurfaceQuad(root_surface_id, InvalidSurfaceId(), 1.f),
|
| test::Quad::SolidColorQuad(SK_ColorMAGENTA)};
|
| test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))};
|
|
|
| - SubmitCompositorFrame(&child_factory_, child_passes, arraysize(child_passes),
|
| - child_local_surface_id);
|
| + SubmitCompositorFrame(child_support_.get(), child_passes,
|
| + arraysize(child_passes), child_local_surface_id);
|
|
|
| // The child surface's reference to the root_surface_ will be dropped, so
|
| // we'll end up with:
|
| @@ -968,7 +981,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
|
| // namespace and update RenderPassDrawQuad's id references to match.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
|
| LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId child_surface_id(child_factory_.frame_sink_id(),
|
| + SurfaceId child_surface_id(child_support_->frame_sink_id(),
|
| child_local_surface_id);
|
|
|
| int child_pass_id[] = {1, 2};
|
| @@ -978,7 +991,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
|
| test::Pass(child_quad[0], arraysize(child_quad[0]), child_pass_id[0]),
|
| test::Pass(child_quad[1], arraysize(child_quad[1]), child_pass_id[1])};
|
|
|
| - SubmitCompositorFrame(&child_factory_, surface_passes,
|
| + SubmitCompositorFrame(child_support_.get(), surface_passes,
|
| arraysize(surface_passes), child_local_surface_id);
|
|
|
| // Pass IDs from the parent surface may collide with ones from the child.
|
| @@ -990,10 +1003,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
|
| test::Pass(parent_quad[0], arraysize(parent_quad[0]), parent_pass_id[0]),
|
| test::Pass(parent_quad[1], arraysize(parent_quad[1]), parent_pass_id[1])};
|
|
|
| - SubmitCompositorFrame(&factory_, parent_passes, arraysize(parent_passes),
|
| + SubmitCompositorFrame(support_.get(), parent_passes, arraysize(parent_passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1085,20 +1098,24 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
|
| SkBlendMode::kSrcIn, // 5
|
| SkBlendMode::kDstIn, // 6
|
| };
|
| -
|
| - SurfaceFactory grandchild_factory(FrameSinkId(2, 2), &manager_,
|
| - &empty_client_);
|
| - SurfaceFactory child_one_factory(FrameSinkId(3, 3), &manager_,
|
| - &empty_client_);
|
| - SurfaceFactory child_two_factory(FrameSinkId(4, 4), &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> grandchild_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| + std::unique_ptr<CompositorFrameSinkSupport> child_one_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId2, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| + std::unique_ptr<CompositorFrameSinkSupport> child_two_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId3, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| int pass_id = 1;
|
| LocalSurfaceId grandchild_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId grandchild_surface_id(grandchild_factory.frame_sink_id(),
|
| + SurfaceId grandchild_surface_id(grandchild_support->frame_sink_id(),
|
| grandchild_local_surface_id);
|
| - grandchild_factory.SubmitCompositorFrame(grandchild_local_surface_id,
|
| - CompositorFrame(),
|
| - SurfaceFactory::DrawCallback());
|
| + grandchild_support->SubmitCompositorFrame(grandchild_local_surface_id,
|
| + CompositorFrame());
|
| std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create();
|
| gfx::Rect output_rect(SurfaceSize());
|
| gfx::Rect damage_rect(SurfaceSize());
|
| @@ -1108,14 +1125,13 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
|
| AddSolidColorQuadWithBlendMode(
|
| SurfaceSize(), grandchild_pass.get(), blend_modes[2]);
|
| QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_surface_id,
|
| - &grandchild_factory);
|
| + grandchild_support.get());
|
|
|
| LocalSurfaceId child_one_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId child_one_surface_id(child_one_factory.frame_sink_id(),
|
| + SurfaceId child_one_surface_id(child_one_support->frame_sink_id(),
|
| child_one_local_surface_id);
|
| - child_one_factory.SubmitCompositorFrame(child_one_local_surface_id,
|
| - CompositorFrame(),
|
| - SurfaceFactory::DrawCallback());
|
| + child_one_support->SubmitCompositorFrame(child_one_local_surface_id,
|
| + CompositorFrame());
|
|
|
| std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create();
|
| child_one_pass->SetNew(pass_id, output_rect, damage_rect,
|
| @@ -1131,14 +1147,13 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
|
| AddSolidColorQuadWithBlendMode(
|
| SurfaceSize(), child_one_pass.get(), blend_modes[3]);
|
| QueuePassAsFrame(std::move(child_one_pass), child_one_local_surface_id,
|
| - &child_one_factory);
|
| + child_one_support.get());
|
|
|
| LocalSurfaceId child_two_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId child_two_surface_id(child_two_factory.frame_sink_id(),
|
| + SurfaceId child_two_surface_id(child_two_support->frame_sink_id(),
|
| child_two_local_surface_id);
|
| - child_two_factory.SubmitCompositorFrame(child_two_local_surface_id,
|
| - CompositorFrame(),
|
| - SurfaceFactory::DrawCallback());
|
| + child_two_support->SubmitCompositorFrame(child_two_local_surface_id,
|
| + CompositorFrame());
|
|
|
| std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create();
|
| child_two_pass->SetNew(pass_id, output_rect, damage_rect,
|
| @@ -1146,7 +1161,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
|
| AddSolidColorQuadWithBlendMode(
|
| SurfaceSize(), child_two_pass.get(), blend_modes[5]);
|
| QueuePassAsFrame(std::move(child_two_pass), child_two_local_surface_id,
|
| - &child_two_factory);
|
| + child_two_support.get());
|
|
|
| std::unique_ptr<RenderPass> root_pass = RenderPass::Create();
|
| root_pass->SetNew(pass_id, output_rect, damage_rect,
|
| @@ -1171,9 +1186,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
|
| AddSolidColorQuadWithBlendMode(
|
| SurfaceSize(), root_pass.get(), blend_modes[6]);
|
|
|
| - QueuePassAsFrame(std::move(root_pass), root_local_surface_id_, &factory_);
|
| + QueuePassAsFrame(std::move(root_pass), root_local_surface_id_,
|
| + support_.get());
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1192,9 +1208,9 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
|
| << iter.index();
|
| }
|
|
|
| - grandchild_factory.EvictSurface();
|
| - child_one_factory.EvictSurface();
|
| - child_two_factory.EvictSurface();
|
| + grandchild_support->EvictFrame();
|
| + child_one_support->EvictFrame();
|
| + child_two_support->EvictFrame();
|
| }
|
|
|
| // This tests that when aggregating a frame with multiple render passes that we
|
| @@ -1216,11 +1232,13 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
|
| // contributing render pass' transform in the aggregate frame should not be
|
| // affected.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
|
| - SurfaceFactory middle_factory(kArbitraryMiddleFrameSinkId, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> middle_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| // Innermost child surface.
|
| LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId child_surface_id(child_factory_.frame_sink_id(),
|
| + SurfaceId child_surface_id(child_support_->frame_sink_id(),
|
| child_local_surface_id);
|
| {
|
| int child_pass_id[] = {1, 2};
|
| @@ -1250,14 +1268,13 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
|
| child_root_pass_sqs->is_clipped = true;
|
| child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5);
|
|
|
| - child_factory_.SubmitCompositorFrame(child_local_surface_id,
|
| - std::move(child_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + child_support_->SubmitCompositorFrame(child_local_surface_id,
|
| + std::move(child_frame));
|
| }
|
|
|
| // Middle child surface.
|
| LocalSurfaceId middle_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId middle_surface_id(middle_factory.frame_sink_id(),
|
| + SurfaceId middle_surface_id(middle_support->frame_sink_id(),
|
| middle_local_surface_id);
|
| {
|
| test::Quad middle_quads[] = {
|
| @@ -1277,9 +1294,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
|
| middle_root_pass->shared_quad_state_list.front();
|
| middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3);
|
|
|
| - middle_factory.SubmitCompositorFrame(middle_local_surface_id,
|
| - std::move(middle_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + middle_support->SubmitCompositorFrame(middle_local_surface_id,
|
| + std::move(middle_frame));
|
| }
|
|
|
| // Root surface.
|
| @@ -1306,10 +1322,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
|
|
|
| root_frame.render_pass_list[0]->transform_to_root_target.Translate(10, 5);
|
|
|
| - factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(root_local_surface_id_,
|
| + std::move(root_frame));
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1382,13 +1398,15 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
|
| ->shared_quad_state_list.ElementAt(1)
|
| ->clip_rect.ToString());
|
|
|
| - middle_factory.EvictSurface();
|
| + middle_support->EvictFrame();
|
| }
|
|
|
| // Tests that damage rects are aggregated correctly when surfaces change.
|
| TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
| - SurfaceFactory parent_factory(kArbitraryMiddleFrameSinkId, &manager_,
|
| - &empty_client_);
|
| + std::unique_ptr<CompositorFrameSinkSupport> parent_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| test::Quad child_quads[] = {test::Quad::RenderPassQuad(1)};
|
| test::Pass child_passes[] = {
|
| test::Pass(child_quads, arraysize(child_quads), 1)};
|
| @@ -1403,11 +1421,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
| child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
|
|
|
| LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId child_surface_id(child_factory_.frame_sink_id(),
|
| + SurfaceId child_surface_id(child_support_->frame_sink_id(),
|
| child_local_surface_id);
|
| - child_factory_.SubmitCompositorFrame(child_local_surface_id,
|
| - std::move(child_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + child_support_->SubmitCompositorFrame(child_local_surface_id,
|
| + std::move(child_frame));
|
|
|
| test::Quad parent_surface_quads[] = {
|
| test::Quad::SurfaceQuad(child_surface_id, InvalidSurfaceId(), 1.f)};
|
| @@ -1421,11 +1438,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
| parent_surface_passes, arraysize(parent_surface_passes));
|
|
|
| LocalSurfaceId parent_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId parent_surface_id(parent_factory.frame_sink_id(),
|
| + SurfaceId parent_surface_id(parent_support->frame_sink_id(),
|
| parent_local_surface_id);
|
| - parent_factory.SubmitCompositorFrame(parent_local_surface_id,
|
| - std::move(parent_surface_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + parent_support->SubmitCompositorFrame(parent_local_surface_id,
|
| + std::move(parent_surface_frame));
|
|
|
| test::Quad root_surface_quads[] = {
|
| test::Quad::SurfaceQuad(parent_surface_id, InvalidSurfaceId(), 1.f)};
|
| @@ -1445,10 +1461,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
| root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 10, 10);
|
| root_frame.render_pass_list[1]->damage_rect = gfx::Rect(5, 5, 100, 100);
|
|
|
| - factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(root_local_surface_id_,
|
| + std::move(root_frame));
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1471,11 +1487,11 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
| child_root_pass_sqs->quad_to_target_transform.Translate(8, 0);
|
| child_root_pass->damage_rect = gfx::Rect(10, 10, 10, 10);
|
|
|
| - child_factory_.SubmitCompositorFrame(child_local_surface_id,
|
| - std::move(child_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + child_support_->SubmitCompositorFrame(child_local_surface_id,
|
| + std::move(child_frame));
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(),
|
| + root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1499,9 +1515,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
| ->quad_to_target_transform.Translate(0, 10);
|
| root_frame.render_pass_list[0]->damage_rect = gfx::Rect(0, 0, 1, 1);
|
|
|
| - factory_.SubmitCompositorFrame(root_local_surface_id_,
|
| - std::move(root_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(root_local_surface_id_,
|
| + std::move(root_frame));
|
| }
|
|
|
| {
|
| @@ -1514,11 +1529,11 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
| ->quad_to_target_transform.Translate(0, 10);
|
| root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 1, 1, 1);
|
|
|
| - factory_.SubmitCompositorFrame(root_local_surface_id_,
|
| - std::move(root_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(root_local_surface_id_,
|
| + std::move(root_frame));
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(),
|
| + root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1534,7 +1549,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
|
|
| // No Surface changed, so no damage should be given.
|
| {
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(),
|
| + root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1560,7 +1576,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
|
| gfx::Rect(SurfaceSize())));
|
| }
|
|
|
| - parent_factory.EvictSurface();
|
| + parent_support->EvictFrame();
|
| }
|
|
|
| // Check that damage is correctly calculated for surfaces.
|
| @@ -1576,11 +1592,12 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
|
|
|
| root_frame.render_pass_list[0]->damage_rect = gfx::Rect(5, 5, 100, 100);
|
|
|
| - factory_.SubmitCompositorFrame(root_local_surface_id_, std::move(root_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(root_local_surface_id_,
|
| + std::move(root_frame));
|
|
|
| {
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(),
|
| + root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1594,7 +1611,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
|
| }
|
|
|
| LocalSurfaceId second_root_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId second_root_surface_id(factory_.frame_sink_id(),
|
| + SurfaceId second_root_surface_id(support_->frame_sink_id(),
|
| second_root_local_surface_id);
|
| {
|
| test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)};
|
| @@ -1608,9 +1625,8 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
|
|
|
| root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4);
|
|
|
| - factory_.SubmitCompositorFrame(second_root_local_surface_id,
|
| - std::move(root_frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support_->SubmitCompositorFrame(second_root_local_surface_id,
|
| + std::move(root_frame));
|
| }
|
| {
|
| CompositorFrame aggregated_frame =
|
| @@ -1647,7 +1663,7 @@ class SurfaceAggregatorPartialSwapTest
|
| // Tests that quads outside the damage rect are ignored.
|
| TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
|
| LocalSurfaceId child_local_surface_id = allocator_.GenerateId();
|
| - SurfaceId child_surface_id(child_factory_.frame_sink_id(),
|
| + SurfaceId child_surface_id(child_support_->frame_sink_id(),
|
| child_local_surface_id);
|
| // The child surface has three quads, one with a visible rect of 13,13 4x4 and
|
| // the other other with a visible rect of 10,10 2x2 (relative to root target
|
| @@ -1685,7 +1701,7 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
|
| child_pass_list[2]->quad_list.ElementAt(0)->visible_rect =
|
| gfx::Rect(0, 0, 2, 2);
|
|
|
| - SubmitPassListAsFrame(&child_factory_, child_local_surface_id,
|
| + SubmitPassListAsFrame(child_support_.get(), child_local_surface_id,
|
| &child_pass_list);
|
| }
|
|
|
| @@ -1704,10 +1720,11 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
|
| ->quad_to_target_transform.Translate(10, 10);
|
| root_pass->damage_rect = gfx::Rect(0, 0, 1, 1);
|
|
|
| - SubmitPassListAsFrame(&factory_, root_local_surface_id_, &root_pass_list);
|
| + SubmitPassListAsFrame(support_.get(), root_local_surface_id_,
|
| + &root_pass_list);
|
| }
|
|
|
| - SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId root_surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
| CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
|
|
|
| const RenderPassList& aggregated_pass_list =
|
| @@ -1736,7 +1753,8 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
|
| root_pass->shared_quad_state_list.front()
|
| ->quad_to_target_transform.Translate(10, 10);
|
| root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
|
| - SubmitPassListAsFrame(&factory_, root_local_surface_id_, &root_pass_list);
|
| + SubmitPassListAsFrame(support_.get(), root_local_surface_id_,
|
| + &root_pass_list);
|
| }
|
|
|
| {
|
| @@ -1786,7 +1804,7 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
|
| child_root_pass->copy_requests.push_back(
|
| CopyOutputRequest::CreateEmptyRequest());
|
| child_root_pass->damage_rect = gfx::Rect();
|
| - SubmitPassListAsFrame(&child_factory_, child_local_surface_id,
|
| + SubmitPassListAsFrame(child_support_.get(), child_local_surface_id,
|
| &child_pass_list);
|
| }
|
|
|
| @@ -1846,7 +1864,8 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
|
| RenderPass* root_pass = root_pass_list[2].get();
|
| filter_pass->filters.Append(FilterOperation::CreateBlurFilter(2));
|
| root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
|
| - SubmitPassListAsFrame(&factory_, root_local_surface_id_, &root_pass_list);
|
| + SubmitPassListAsFrame(support_.get(), root_local_surface_id_,
|
| + &root_pass_list);
|
| }
|
|
|
| {
|
| @@ -1894,7 +1913,8 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
|
| ->quad_to_target_transform.Translate(10, 10);
|
| pass->background_filters.Append(FilterOperation::CreateBlurFilter(2));
|
| root_pass->damage_rect = gfx::Rect(10, 10, 2, 2);
|
| - SubmitPassListAsFrame(&factory_, root_local_surface_id_, &root_pass_list);
|
| + SubmitPassListAsFrame(support_.get(), root_local_surface_id_,
|
| + &root_pass_list);
|
| }
|
|
|
| {
|
| @@ -1938,32 +1958,11 @@ class SurfaceAggregatorWithResourcesTest : public testing::Test {
|
| std::unique_ptr<SurfaceAggregator> aggregator_;
|
| };
|
|
|
| -class ResourceTrackingSurfaceFactoryClient : public SurfaceFactoryClient {
|
| - public:
|
| - ResourceTrackingSurfaceFactoryClient() {}
|
| - ~ResourceTrackingSurfaceFactoryClient() override {}
|
| -
|
| - void ReturnResources(const ReturnedResourceArray& resources) override {
|
| - returned_resources_ = resources;
|
| - }
|
| -
|
| - ReturnedResourceArray returned_resources() const {
|
| - return returned_resources_;
|
| - }
|
| -
|
| - void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {}
|
| -
|
| - private:
|
| - ReturnedResourceArray returned_resources_;
|
| -
|
| - DISALLOW_COPY_AND_ASSIGN(ResourceTrackingSurfaceFactoryClient);
|
| -};
|
| -
|
| void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
|
| size_t num_resource_ids,
|
| bool valid,
|
| SurfaceId child_id,
|
| - SurfaceFactory* factory,
|
| + CompositorFrameSinkSupport* support,
|
| SurfaceId surface_id) {
|
| CompositorFrame frame;
|
| std::unique_ptr<RenderPass> pass = RenderPass::Create();
|
| @@ -2002,27 +2001,29 @@ void SubmitCompositorFrameWithResources(ResourceId* resource_ids,
|
| nearest_neighbor, secure_output_only);
|
| }
|
| frame.render_pass_list.push_back(std::move(pass));
|
| - factory->SubmitCompositorFrame(surface_id.local_surface_id(),
|
| - std::move(frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support->SubmitCompositorFrame(surface_id.local_surface_id(),
|
| + std::move(frame));
|
| }
|
|
|
| TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
|
| - ResourceTrackingSurfaceFactoryClient client;
|
| - SurfaceFactory factory(kArbitraryRootFrameSinkId, &manager_, &client);
|
| + FakeCompositorFrameSinkSupportClient client;
|
| + std::unique_ptr<CompositorFrameSinkSupport> support =
|
| + CompositorFrameSinkSupport::Create(
|
| + &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create());
|
| - SurfaceId surface_id(factory.frame_sink_id(), local_surface_id);
|
| + SurfaceId surface_id(support->frame_sink_id(), local_surface_id);
|
|
|
| ResourceId ids[] = {11, 12, 13};
|
| SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
|
| - &factory, surface_id);
|
| + support.get(), surface_id);
|
|
|
| CompositorFrame frame = aggregator_->Aggregate(surface_id);
|
|
|
| // Nothing should be available to be returned yet.
|
| EXPECT_TRUE(client.returned_resources().empty());
|
|
|
| - SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), &factory,
|
| + SubmitCompositorFrameWithResources(NULL, 0u, true, SurfaceId(), support.get(),
|
| surface_id);
|
|
|
| frame = aggregator_->Aggregate(surface_id);
|
| @@ -2035,14 +2036,17 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
|
| EXPECT_THAT(returned_ids,
|
| testing::WhenSorted(testing::ElementsAreArray(ids)));
|
|
|
| - factory.EvictSurface();
|
| + support->EvictFrame();
|
| }
|
|
|
| TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
|
| - ResourceTrackingSurfaceFactoryClient client;
|
| - SurfaceFactory factory(kArbitraryRootFrameSinkId, &manager_, &client);
|
| + FakeCompositorFrameSinkSupportClient client;
|
| + std::unique_ptr<CompositorFrameSinkSupport> support =
|
| + CompositorFrameSinkSupport::Create(
|
| + &client, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId local_surface_id(7u, base::UnguessableToken::Create());
|
| - SurfaceId surface_id(factory.frame_sink_id(), local_surface_id);
|
| + SurfaceId surface_id(support->frame_sink_id(), local_surface_id);
|
|
|
| CompositorFrame frame;
|
| std::unique_ptr<RenderPass> pass = RenderPass::Create();
|
| @@ -2054,42 +2058,47 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
|
| resource.is_software = false;
|
| frame.resource_list.push_back(resource);
|
| frame.render_pass_list.push_back(std::move(pass));
|
| - factory.SubmitCompositorFrame(local_surface_id, std::move(frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support->SubmitCompositorFrame(local_surface_id, std::move(frame));
|
|
|
| CompositorFrame returned_frame = aggregator_->Aggregate(surface_id);
|
|
|
| // Nothing should be available to be returned yet.
|
| EXPECT_TRUE(client.returned_resources().empty());
|
|
|
| - SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory,
|
| + SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), support.get(),
|
| surface_id);
|
| ASSERT_EQ(1u, client.returned_resources().size());
|
| EXPECT_EQ(11u, client.returned_resources()[0].id);
|
|
|
| - factory.EvictSurface();
|
| + support->EvictFrame();
|
| }
|
|
|
| TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) {
|
| - ResourceTrackingSurfaceFactoryClient client;
|
| - SurfaceFactory factory1(FrameSinkId(1, 1), &manager_, &client);
|
| - SurfaceFactory factory2(FrameSinkId(2, 2), &manager_, &client);
|
| + FakeCompositorFrameSinkSupportClient client;
|
| + std::unique_ptr<CompositorFrameSinkSupport> support1 =
|
| + CompositorFrameSinkSupport::Create(
|
| + &client, &manager_, FrameSinkId(1, 1), kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| + std::unique_ptr<CompositorFrameSinkSupport> support2 =
|
| + CompositorFrameSinkSupport::Create(
|
| + &client, &manager_, FrameSinkId(2, 2), kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId local_frame1_id(7u, base::UnguessableToken::Create());
|
| - SurfaceId surface1_id(factory1.frame_sink_id(), local_frame1_id);
|
| + SurfaceId surface1_id(support1->frame_sink_id(), local_frame1_id);
|
|
|
| LocalSurfaceId local_frame2_id(8u, base::UnguessableToken::Create());
|
| - SurfaceId surface2_id(factory2.frame_sink_id(), local_frame2_id);
|
| + SurfaceId surface2_id(support2->frame_sink_id(), local_frame2_id);
|
|
|
| ResourceId ids[] = {11, 12, 13};
|
| SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
|
| - &factory1, surface1_id);
|
| + support1.get(), surface1_id);
|
| ResourceId ids2[] = {14, 15, 16};
|
| SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(),
|
| - &factory2, surface2_id);
|
| + support2.get(), surface2_id);
|
|
|
| CompositorFrame frame = aggregator_->Aggregate(surface1_id);
|
|
|
| - SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory1,
|
| + SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), support1.get(),
|
| surface1_id);
|
|
|
| // Nothing should be available to be returned yet.
|
| @@ -2107,40 +2116,47 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) {
|
| testing::WhenSorted(testing::ElementsAreArray(ids)));
|
| EXPECT_EQ(3u, resource_provider_->num_resources());
|
|
|
| - factory1.EvictSurface();
|
| - factory2.EvictSurface();
|
| + support1->EvictFrame();
|
| + support2->EvictFrame();
|
| }
|
|
|
| // Ensure that aggregator completely ignores Surfaces that reference invalid
|
| // resources.
|
| TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) {
|
| - ResourceTrackingSurfaceFactoryClient client;
|
| - SurfaceFactory root_factory(kArbitraryRootFrameSinkId, &manager_, &client);
|
| - SurfaceFactory middle_factory(kArbitraryMiddleFrameSinkId, &manager_,
|
| - &client);
|
| - SurfaceFactory child_factory(kArbitraryChildFrameSinkId1, &manager_, &client);
|
| + std::unique_ptr<CompositorFrameSinkSupport> root_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryRootFrameSinkId, kRootIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| + std::unique_ptr<CompositorFrameSinkSupport> middle_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryMiddleFrameSinkId, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| + std::unique_ptr<CompositorFrameSinkSupport> child_support =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, kArbitraryFrameSinkId1, kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId root_local_surface_id(7u, kArbitraryToken);
|
| - SurfaceId root_surface_id(root_factory.frame_sink_id(),
|
| + SurfaceId root_surface_id(root_support->frame_sink_id(),
|
| root_local_surface_id);
|
| LocalSurfaceId middle_local_surface_id(8u, kArbitraryToken);
|
| - SurfaceId middle_surface_id(middle_factory.frame_sink_id(),
|
| + SurfaceId middle_surface_id(middle_support->frame_sink_id(),
|
| middle_local_surface_id);
|
| LocalSurfaceId child_local_surface_id(9u, kArbitraryToken);
|
| - SurfaceId child_surface_id(child_factory.frame_sink_id(),
|
| + SurfaceId child_surface_id(child_support->frame_sink_id(),
|
| child_local_surface_id);
|
|
|
| ResourceId ids[] = {14, 15, 16};
|
| SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
|
| - &child_factory, child_surface_id);
|
| + child_support.get(), child_surface_id);
|
|
|
| ResourceId ids2[] = {17, 18, 19};
|
| SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false,
|
| - child_surface_id, &middle_factory,
|
| + child_surface_id, middle_support.get(),
|
| middle_surface_id);
|
|
|
| ResourceId ids3[] = {20, 21, 22};
|
| SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true,
|
| - middle_surface_id, &root_factory,
|
| + middle_surface_id, root_support.get(),
|
| root_surface_id);
|
|
|
| CompositorFrame frame;
|
| @@ -2151,7 +2167,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) {
|
| EXPECT_EQ(1u, pass_list->back()->shared_quad_state_list.size());
|
| EXPECT_EQ(3u, pass_list->back()->quad_list.size());
|
| SubmitCompositorFrameWithResources(ids2, arraysize(ids), true,
|
| - child_surface_id, &middle_factory,
|
| + child_surface_id, middle_support.get(),
|
| middle_surface_id);
|
|
|
| frame = aggregator_->Aggregate(root_surface_id);
|
| @@ -2161,24 +2177,29 @@ TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) {
|
| EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size());
|
| EXPECT_EQ(9u, pass_list->back()->quad_list.size());
|
|
|
| - root_factory.EvictSurface();
|
| - middle_factory.EvictSurface();
|
| - child_factory.EvictSurface();
|
| + root_support->EvictFrame();
|
| + middle_support->EvictFrame();
|
| + child_support->EvictFrame();
|
| }
|
|
|
| TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
|
| - ResourceTrackingSurfaceFactoryClient client;
|
| - SurfaceFactory factory1(FrameSinkId(1, 1), &manager_, &client);
|
| - SurfaceFactory factory2(FrameSinkId(2, 2), &manager_, &client);
|
| + std::unique_ptr<CompositorFrameSinkSupport> support1 =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, FrameSinkId(1, 1), kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| + std::unique_ptr<CompositorFrameSinkSupport> support2 =
|
| + CompositorFrameSinkSupport::Create(
|
| + nullptr, &manager_, FrameSinkId(2, 2), kChildIsRoot,
|
| + kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
|
| LocalSurfaceId local_frame1_id(7u, base::UnguessableToken::Create());
|
| - SurfaceId surface1_id(factory1.frame_sink_id(), local_frame1_id);
|
| + SurfaceId surface1_id(support1->frame_sink_id(), local_frame1_id);
|
|
|
| LocalSurfaceId local_frame2_id(8u, base::UnguessableToken::Create());
|
| - SurfaceId surface2_id(factory2.frame_sink_id(), local_frame2_id);
|
| + SurfaceId surface2_id(support2->frame_sink_id(), local_frame2_id);
|
|
|
| ResourceId ids[] = {11, 12, 13};
|
| SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
|
| - &factory1, surface1_id);
|
| + support1.get(), surface1_id);
|
|
|
| CompositorFrame frame = aggregator_->Aggregate(surface1_id);
|
|
|
| @@ -2201,8 +2222,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
|
| CompositorFrame frame;
|
| frame.render_pass_list.push_back(std::move(pass));
|
|
|
| - factory2.SubmitCompositorFrame(local_frame2_id, std::move(frame),
|
| - SurfaceFactory::DrawCallback());
|
| + support2->SubmitCompositorFrame(local_frame2_id, std::move(frame));
|
| }
|
|
|
| frame = aggregator_->Aggregate(surface2_id);
|
| @@ -2228,8 +2248,8 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
|
| // Output is insecure, so texture should be drawn.
|
| EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material);
|
|
|
| - factory1.EvictSurface();
|
| - factory2.EvictSurface();
|
| + support1->EvictFrame();
|
| + support2->EvictFrame();
|
| }
|
|
|
| // Ensure that the render passes have correct color spaces.
|
| @@ -2244,10 +2264,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, ColorSpaceTest) {
|
| gfx::ColorSpace color_space2 = gfx::ColorSpace::CreateSRGB();
|
| gfx::ColorSpace color_space3 = gfx::ColorSpace::CreateSCRGBLinear();
|
|
|
| - SubmitCompositorFrame(&factory_, passes, arraysize(passes),
|
| + SubmitCompositorFrame(support_.get(), passes, arraysize(passes),
|
| root_local_surface_id_);
|
|
|
| - SurfaceId surface_id(factory_.frame_sink_id(), root_local_surface_id_);
|
| + SurfaceId surface_id(support_->frame_sink_id(), root_local_surface_id_);
|
|
|
| CompositorFrame aggregated_frame;
|
| aggregator_.SetOutputColorSpace(color_space1, color_space1);
|
|
|