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

Unified Diff: cc/surfaces/surface_aggregator_unittest.cc

Issue 2485473003: Remove SurfaceFactory::Create and SurfaceFactory::Destroy (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/surfaces/surface_aggregator_unittest.cc
diff --git a/cc/surfaces/surface_aggregator_unittest.cc b/cc/surfaces/surface_aggregator_unittest.cc
index 0ee7a84ebb7e441ce31a71b5ce3bcfd6b6b8f932..0c76e605a97e9acb31bf581d9c42d7b36c58d5bc 100644
--- a/cc/surfaces/surface_aggregator_unittest.cc
+++ b/cc/surfaces/surface_aggregator_unittest.cc
@@ -81,12 +81,11 @@ class SurfaceAggregatorTest : public testing::Test {
TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
LocalFrameId local_frame_id(7, 0);
SurfaceId one_id(kArbitraryFrameSinkId, local_frame_id);
- factory_.Create(local_frame_id);
+ factory_.SubmitCompositorFrame(local_frame_id, CompositorFrame(),
+ SurfaceFactory::DrawCallback());
CompositorFrame frame = aggregator_.Aggregate(one_id);
EXPECT_TRUE(frame.render_pass_list.empty());
-
- factory_.Destroy(local_frame_id);
}
class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
@@ -102,13 +101,11 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
void SetUp() override {
SurfaceAggregatorTest::SetUp();
root_local_frame_id_ = allocator_.GenerateId();
- factory_.Create(root_local_frame_id_);
root_surface_ = manager_.GetSurfaceForId(
SurfaceId(factory_.frame_sink_id(), root_local_frame_id_));
}
void TearDown() override {
- factory_.Destroy(root_local_frame_id_);
SurfaceAggregatorTest::TearDown();
}
@@ -157,12 +154,13 @@ class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
}
void QueuePassAsFrame(std::unique_ptr<RenderPass> pass,
- const LocalFrameId& local_frame_id) {
+ const LocalFrameId& local_frame_id,
+ SurfaceFactory& factory) {
CompositorFrame child_frame;
child_frame.render_pass_list.push_back(std::move(pass));
- factory_.SubmitCompositorFrame(local_frame_id, std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ factory.SubmitCompositorFrame(local_frame_id, std::move(child_frame),
+ SurfaceFactory::DrawCallback());
}
protected:
@@ -195,18 +193,19 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) {
}
TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) {
+ SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId embedded_local_frame_id = allocator_.GenerateId();
SurfaceId embedded_surface_id(factory_.frame_sink_id(),
embedded_local_frame_id);
- factory_.Create(embedded_local_frame_id);
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SolidColorQuad(SK_ColorBLUE)};
test::Pass embedded_passes[] = {
test::Pass(embedded_quads, arraysize(embedded_quads))};
- SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes),
- embedded_local_frame_id);
+ SubmitCompositorFrame(&embedded_factory, embedded_passes,
+ arraysize(embedded_passes), embedded_local_frame_id);
test::Quad quads[] = {test::Quad::SurfaceQuad(embedded_surface_id, .5f)};
test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
@@ -229,8 +228,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, OpacityCopied) {
render_pass_list[1]->shared_quad_state_list);
ASSERT_EQ(1u, shared_quad_state_list2.size());
EXPECT_EQ(.5f, shared_quad_state_list2.ElementAt(0)->opacity);
-
- factory_.Destroy(embedded_local_frame_id);
}
TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) {
@@ -256,17 +253,18 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) {
// 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(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId embedded_local_frame_id = allocator_.GenerateId();
SurfaceId embedded_surface_id(factory_.frame_sink_id(),
embedded_local_frame_id);
- factory_.Create(embedded_local_frame_id);
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
test::Pass embedded_passes[] = {
test::Pass(embedded_quads, arraysize(embedded_quads))};
- SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes),
- embedded_local_frame_id);
+ SubmitCompositorFrame(&embedded_factory, embedded_passes,
+ arraysize(embedded_passes), embedded_local_frame_id);
test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
test::Quad::SurfaceQuad(embedded_surface_id, 1.f),
@@ -285,27 +283,26 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
SurfaceId ids[] = {root_surface_id, embedded_surface_id};
AggregateAndVerify(
expected_passes, arraysize(expected_passes), ids, arraysize(ids));
-
- factory_.Destroy(embedded_local_frame_id);
}
TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) {
+ SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId embedded_local_frame_id = allocator_.GenerateId();
SurfaceId embedded_surface_id(factory_.frame_sink_id(),
embedded_local_frame_id);
- factory_.Create(embedded_local_frame_id);
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
test::Pass embedded_passes[] = {
test::Pass(embedded_quads, arraysize(embedded_quads))};
- SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes),
- embedded_local_frame_id);
+ SubmitCompositorFrame(&embedded_factory, embedded_passes,
+ arraysize(embedded_passes), embedded_local_frame_id);
std::unique_ptr<CopyOutputRequest> copy_request(
CopyOutputRequest::CreateEmptyRequest());
CopyOutputRequest* copy_request_ptr = copy_request.get();
- factory_.RequestCopyOfSurface(embedded_local_frame_id,
- std::move(copy_request));
+ embedded_factory.RequestCopyOfSurface(embedded_local_frame_id,
+ std::move(copy_request));
test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
test::Quad::SurfaceQuad(embedded_surface_id, 1.f),
@@ -341,22 +338,22 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, CopyRequest) {
aggregator_.previous_contained_surfaces().end());
}
- factory_.Destroy(embedded_local_frame_id);
}
// Root surface may contain copy requests.
TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
+ SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId embedded_local_frame_id = allocator_.GenerateId();
SurfaceId embedded_surface_id(factory_.frame_sink_id(),
embedded_local_frame_id);
- factory_.Create(embedded_local_frame_id);
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
test::Pass embedded_passes[] = {
test::Pass(embedded_quads, arraysize(embedded_quads))};
- SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes),
- embedded_local_frame_id);
+ SubmitCompositorFrame(&embedded_factory, embedded_passes,
+ arraysize(embedded_passes), embedded_local_frame_id);
std::unique_ptr<CopyOutputRequest> copy_request(
CopyOutputRequest::CreateEmptyRequest());
CopyOutputRequest* copy_request_ptr = copy_request.get();
@@ -418,33 +415,33 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RootCopyRequest) {
ASSERT_EQ(2u, original_pass_list.size());
DCHECK(original_pass_list[0]->copy_requests.empty());
DCHECK(original_pass_list[1]->copy_requests.empty());
-
- factory_.Destroy(embedded_local_frame_id);
}
TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
+ SurfaceFactory embedded_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId embedded_local_frame_id = allocator_.GenerateId();
SurfaceId embedded_surface_id(factory_.frame_sink_id(),
embedded_local_frame_id);
SurfaceId nonexistent_surface_id(factory_.frame_sink_id(),
allocator_.GenerateId());
- factory_.Create(embedded_local_frame_id);
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
test::Pass embedded_passes[] = {
test::Pass(embedded_quads, arraysize(embedded_quads))};
- SubmitCompositorFrame(&factory_, embedded_passes, arraysize(embedded_passes),
- embedded_local_frame_id);
+ SubmitCompositorFrame(&embedded_factory, embedded_passes,
+ arraysize(embedded_passes), embedded_local_frame_id);
std::unique_ptr<CopyOutputRequest> copy_request(
CopyOutputRequest::CreateEmptyRequest());
CopyOutputRequest* copy_request_ptr = copy_request.get();
- factory_.RequestCopyOfSurface(embedded_local_frame_id,
- std::move(copy_request));
+ embedded_factory.RequestCopyOfSurface(embedded_local_frame_id,
+ std::move(copy_request));
LocalFrameId parent_local_frame_id = allocator_.GenerateId();
+ SurfaceFactory parent_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id);
- factory_.Create(parent_local_frame_id);
test::Quad parent_quads[] = {
test::Quad::SolidColorQuad(SK_ColorWHITE),
@@ -461,8 +458,9 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
frame.metadata.referenced_surfaces.push_back(embedded_surface_id);
- factory_.SubmitCompositorFrame(parent_local_frame_id, std::move(frame),
- SurfaceFactory::DrawCallback());
+ parent_factory.SubmitCompositorFrame(parent_local_frame_id,
+ std::move(frame),
+ SurfaceFactory::DrawCallback());
}
test::Quad root_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
@@ -510,9 +508,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, UnreferencedSurface) {
aggregator_.previous_contained_surfaces().find(surface_ids[i]) !=
aggregator_.previous_contained_surfaces().end());
}
-
- factory_.Destroy(parent_local_frame_id);
- factory_.Destroy(embedded_local_frame_id);
}
// This tests referencing a surface that has multiple render passes.
@@ -520,7 +515,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
LocalFrameId embedded_local_frame_id = child_allocator_.GenerateId();
SurfaceId embedded_surface_id(child_factory_.frame_sink_id(),
embedded_local_frame_id);
- child_factory_.Create(embedded_local_frame_id);
RenderPassId pass_ids[] = {RenderPassId(1, 1), RenderPassId(1, 2),
RenderPassId(1, 3)};
@@ -651,7 +645,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
EXPECT_EQ(actual_pass_ids[3],
fifth_pass_render_pass_draw_quad->render_pass_id);
}
- child_factory_.Destroy(embedded_local_frame_id);
}
// Tests an invalid surface reference in a frame. The surface quad should just
@@ -682,7 +675,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
LocalFrameId empty_local_frame_id = allocator_.GenerateId();
SurfaceId surface_with_no_frame_id(factory_.frame_sink_id(),
empty_local_frame_id);
- factory_.Create(empty_local_frame_id);
test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SurfaceQuad(surface_with_no_frame_id, 1.f),
@@ -700,7 +692,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
SurfaceId ids[] = {root_surface_id, surface_with_no_frame_id};
AggregateAndVerify(
expected_passes, arraysize(expected_passes), ids, arraysize(ids));
- factory_.Destroy(empty_local_frame_id);
}
// Tests a surface quad referencing itself, generating a trivial cycle.
@@ -724,9 +715,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) {
// Tests a more complex cycle with one intermediate surface.
TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
+ SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId child_local_frame_id = allocator_.GenerateId();
SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id);
- factory_.Create(child_local_frame_id);
test::Quad parent_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE),
test::Quad::SurfaceQuad(child_surface_id, 1.f),
@@ -743,7 +735,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
test::Quad::SolidColorQuad(SK_ColorMAGENTA)};
test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))};
- SubmitCompositorFrame(&factory_, child_passes, arraysize(child_passes),
+ SubmitCompositorFrame(&child_factory, child_passes, arraysize(child_passes),
child_local_frame_id);
// The child surface's reference to the root_surface_ will be dropped, so
@@ -761,15 +753,15 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
SurfaceId ids[] = {root_surface_id, child_surface_id};
AggregateAndVerify(
expected_passes, arraysize(expected_passes), ids, arraysize(ids));
- factory_.Destroy(child_local_frame_id);
}
// Tests that we map render pass IDs from different surfaces into a unified
// namespace and update RenderPassDrawQuad's id references to match.
TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
+ SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId child_local_frame_id = allocator_.GenerateId();
SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id);
- factory_.Create(child_local_frame_id);
RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)};
test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)},
@@ -778,8 +770,8 @@ 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(&factory_, surface_passes, arraysize(surface_passes),
- child_local_frame_id);
+ SubmitCompositorFrame(&child_factory, surface_passes,
+ arraysize(surface_passes), child_local_frame_id);
// Pass IDs from the parent surface may collide with ones from the child.
RenderPassId parent_pass_id[] = {RenderPassId(2, 1), RenderPassId(1, 2)};
@@ -823,7 +815,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
EXPECT_EQ(
actual_pass_ids[1],
RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id);
- factory_.Destroy(child_local_frame_id);
}
void AddSolidColorQuadWithBlendMode(const gfx::Size& size,
@@ -886,11 +877,19 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
SkXfermode::kDstIn_Mode, // 6
};
+ SurfaceFactory grandchild_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
+ SurfaceFactory child_one_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
+ SurfaceFactory child_two_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
RenderPassId pass_id(1, 1);
LocalFrameId grandchild_local_frame_id = allocator_.GenerateId();
SurfaceId grandchild_surface_id(factory_.frame_sink_id(),
grandchild_local_frame_id);
- factory_.Create(grandchild_local_frame_id);
+ grandchild_factory.SubmitCompositorFrame(grandchild_local_frame_id,
+ CompositorFrame(),
+ SurfaceFactory::DrawCallback());
std::unique_ptr<RenderPass> grandchild_pass = RenderPass::Create();
gfx::Rect output_rect(SurfaceSize());
gfx::Rect damage_rect(SurfaceSize());
@@ -899,12 +898,15 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
pass_id, output_rect, damage_rect, transform_to_root_target);
AddSolidColorQuadWithBlendMode(
SurfaceSize(), grandchild_pass.get(), blend_modes[2]);
- QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id);
+ QueuePassAsFrame(std::move(grandchild_pass), grandchild_local_frame_id,
+ grandchild_factory);
LocalFrameId child_one_local_frame_id = allocator_.GenerateId();
SurfaceId child_one_surface_id(factory_.frame_sink_id(),
child_one_local_frame_id);
- factory_.Create(child_one_local_frame_id);
+ child_one_factory.SubmitCompositorFrame(child_one_local_frame_id,
+ CompositorFrame(),
+ SurfaceFactory::DrawCallback());
std::unique_ptr<RenderPass> child_one_pass = RenderPass::Create();
child_one_pass->SetNew(
@@ -919,19 +921,23 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
grandchild_surface_id);
AddSolidColorQuadWithBlendMode(
SurfaceSize(), child_one_pass.get(), blend_modes[3]);
- QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id);
+ QueuePassAsFrame(std::move(child_one_pass), child_one_local_frame_id,
+ child_one_factory);
LocalFrameId child_two_local_frame_id = allocator_.GenerateId();
SurfaceId child_two_surface_id(factory_.frame_sink_id(),
child_two_local_frame_id);
- factory_.Create(child_two_local_frame_id);
+ child_two_factory.SubmitCompositorFrame(child_two_local_frame_id,
+ CompositorFrame(),
+ SurfaceFactory::DrawCallback());
std::unique_ptr<RenderPass> child_two_pass = RenderPass::Create();
child_two_pass->SetNew(
pass_id, output_rect, damage_rect, transform_to_root_target);
AddSolidColorQuadWithBlendMode(
SurfaceSize(), child_two_pass.get(), blend_modes[5]);
- QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id);
+ QueuePassAsFrame(std::move(child_two_pass), child_two_local_frame_id,
+ child_two_factory);
std::unique_ptr<RenderPass> root_pass = RenderPass::Create();
root_pass->SetNew(
@@ -956,7 +962,7 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
AddSolidColorQuadWithBlendMode(
SurfaceSize(), root_pass.get(), blend_modes[6]);
- QueuePassAsFrame(std::move(root_pass), root_local_frame_id_);
+ QueuePassAsFrame(std::move(root_pass), root_local_frame_id_, factory_);
SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
@@ -976,9 +982,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
EXPECT_EQ(blend_modes[iter.index()], iter->shared_quad_state->blend_mode)
<< iter.index();
}
- factory_.Destroy(child_one_local_frame_id);
- factory_.Destroy(child_two_local_frame_id);
- factory_.Destroy(grandchild_local_frame_id);
}
// This tests that when aggregating a frame with multiple render passes that we
@@ -1001,9 +1004,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
// affected.
TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
// Innermost child surface.
+ SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId child_local_frame_id = allocator_.GenerateId();
SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id);
- factory_.Create(child_local_frame_id);
{
RenderPassId child_pass_id[] = {RenderPassId(1, 1), RenderPassId(1, 2)};
test::Quad child_quads[][1] = {
@@ -1032,14 +1036,16 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
child_root_pass_sqs->is_clipped = true;
child_root_pass_sqs->clip_rect = gfx::Rect(0, 0, 5, 5);
- factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_factory.SubmitCompositorFrame(child_local_frame_id,
+ std::move(child_frame),
+ SurfaceFactory::DrawCallback());
}
// Middle child surface.
+ SurfaceFactory middle_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId middle_local_frame_id = allocator_.GenerateId();
SurfaceId middle_surface_id(factory_.frame_sink_id(), middle_local_frame_id);
- factory_.Create(middle_local_frame_id);
{
test::Quad middle_quads[] = {
test::Quad::SurfaceQuad(child_surface_id, 1.f)};
@@ -1058,9 +1064,9 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
middle_root_pass->shared_quad_state_list.front();
middle_root_pass_sqs->quad_to_target_transform.Scale(2, 3);
- factory_.SubmitCompositorFrame(middle_local_frame_id,
- std::move(middle_frame),
- SurfaceFactory::DrawCallback());
+ middle_factory.SubmitCompositorFrame(middle_local_frame_id,
+ std::move(middle_frame),
+ SurfaceFactory::DrawCallback());
}
// Root surface.
@@ -1162,13 +1168,14 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
aggregated_pass_list[1]
->shared_quad_state_list.ElementAt(1)
->clip_rect.ToString());
-
- factory_.Destroy(middle_local_frame_id);
- factory_.Destroy(child_local_frame_id);
}
// Tests that damage rects are aggregated correctly when surfaces change.
TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
+ SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
+ SurfaceFactory parent_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
test::Quad child_quads[] = {test::Quad::RenderPassQuad(RenderPassId(1, 1))};
test::Pass child_passes[] = {
test::Pass(child_quads, arraysize(child_quads), RenderPassId(1, 1))};
@@ -1184,9 +1191,9 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
LocalFrameId child_local_frame_id = allocator_.GenerateId();
SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id);
- factory_.Create(child_local_frame_id);
- factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_factory.SubmitCompositorFrame(child_local_frame_id,
+ std::move(child_frame),
+ SurfaceFactory::DrawCallback());
test::Quad parent_surface_quads[] = {
test::Quad::SurfaceQuad(child_surface_id, 1.f)};
@@ -1202,10 +1209,9 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
LocalFrameId parent_local_frame_id = allocator_.GenerateId();
SurfaceId parent_surface_id(factory_.frame_sink_id(), parent_local_frame_id);
- factory_.Create(parent_local_frame_id);
- factory_.SubmitCompositorFrame(parent_local_frame_id,
- std::move(parent_surface_frame),
- SurfaceFactory::DrawCallback());
+ parent_factory.SubmitCompositorFrame(parent_local_frame_id,
+ std::move(parent_surface_frame),
+ SurfaceFactory::DrawCallback());
test::Quad root_surface_quads[] = {
test::Quad::SurfaceQuad(parent_surface_id, 1.f)};
@@ -1254,8 +1260,9 @@ 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);
- factory_.SubmitCompositorFrame(child_local_frame_id, std::move(child_frame),
- SurfaceFactory::DrawCallback());
+ child_factory.SubmitCompositorFrame(child_local_frame_id,
+ std::move(child_frame),
+ SurfaceFactory::DrawCallback());
SurfaceId root_surface_id(factory_.frame_sink_id(), root_local_frame_id_);
CompositorFrame aggregated_frame = aggregator_.Aggregate(root_surface_id);
@@ -1339,13 +1346,12 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateDamageRect) {
EXPECT_TRUE(aggregated_pass_list[1]->damage_rect.Contains(
gfx::Rect(SurfaceSize())));
}
-
- factory_.Destroy(child_local_frame_id);
}
// Check that damage is correctly calculated for surfaces with
// SetPreviousFrameSurface.
TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
+ SurfaceFactory factory2(kArbitraryFrameSinkId, &manager_, &empty_client_);
test::Quad root_render_pass_quads[] = {test::Quad::SolidColorQuad(1)};
test::Pass root_passes[] = {test::Pass(root_render_pass_quads,
@@ -1391,11 +1397,10 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
root_frame.render_pass_list[0]->damage_rect = gfx::Rect(1, 2, 3, 4);
- factory_.Create(second_root_local_frame_id);
- factory_.SubmitCompositorFrame(second_root_local_frame_id,
+ factory2.SubmitCompositorFrame(second_root_local_frame_id,
std::move(root_frame),
SurfaceFactory::DrawCallback());
- factory_.SetPreviousFrameSurface(second_root_local_frame_id,
+ factory2.SetPreviousFrameSurface(second_root_local_frame_id,
root_local_frame_id_);
}
{
@@ -1423,7 +1428,6 @@ TEST_F(SurfaceAggregatorValidSurfaceTest, SwitchSurfaceDamage) {
// No new frame, so no new damage.
EXPECT_TRUE(aggregated_pass_list[0]->damage_rect.IsEmpty());
}
- factory_.Destroy(second_root_local_frame_id);
}
class SurfaceAggregatorPartialSwapTest
@@ -1435,9 +1439,10 @@ class SurfaceAggregatorPartialSwapTest
// Tests that quads outside the damage rect are ignored.
TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
+ SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_,
+ &empty_client_);
LocalFrameId child_local_frame_id = allocator_.GenerateId();
SurfaceId child_surface_id(factory_.frame_sink_id(), child_local_frame_id);
- factory_.Create(child_local_frame_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
// space), and one with a non-invertible transform.
@@ -1474,7 +1479,8 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
child_pass_list[2]->quad_list.ElementAt(0)->visible_rect =
gfx::Rect(0, 0, 2, 2);
- SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list);
+ SubmitPassListAsFrame(&child_factory, child_local_frame_id,
+ &child_pass_list);
}
{
@@ -1572,7 +1578,8 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
child_root_pass->copy_requests.push_back(
CopyOutputRequest::CreateEmptyRequest());
child_root_pass->damage_rect = gfx::Rect();
- SubmitPassListAsFrame(&factory_, child_local_frame_id, &child_pass_list);
+ SubmitPassListAsFrame(&child_factory, child_local_frame_id,
+ &child_pass_list);
}
{
@@ -1699,8 +1706,6 @@ TEST_F(SurfaceAggregatorPartialSwapTest, IgnoreOutside) {
EXPECT_EQ(gfx::Rect(10, 10, 2, 2), aggregated_pass_list[2]->damage_rect);
EXPECT_EQ(1u, aggregated_pass_list[2]->quad_list.size());
}
-
- factory_.Destroy(child_local_frame_id);
}
class SurfaceAggregatorWithResourcesTest : public testing::Test {
@@ -1795,7 +1800,6 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client);
LocalFrameId local_frame_id(7u, 0);
SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id);
- factory.Create(local_frame_id);
ResourceId ids[] = {11, 12, 13};
SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
@@ -1818,7 +1822,6 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeResourcesOneSurface) {
}
EXPECT_THAT(returned_ids,
testing::WhenSorted(testing::ElementsAreArray(ids)));
- factory.Destroy(local_frame_id);
}
TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
@@ -1826,7 +1829,6 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client);
LocalFrameId local_frame_id(7u, 0);
SurfaceId surface_id(kArbitraryFrameSinkId, local_frame_id);
- factory.Create(local_frame_id);
CompositorFrame frame;
std::unique_ptr<RenderPass> pass = RenderPass::Create();
@@ -1850,31 +1852,28 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TakeInvalidResources) {
surface_id);
ASSERT_EQ(1u, client.returned_resources().size());
EXPECT_EQ(11u, client.returned_resources()[0].id);
-
- factory.Destroy(local_frame_id);
}
TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) {
ResourceTrackingSurfaceFactoryClient client;
- SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client);
+ SurfaceFactory factory1(kArbitraryFrameSinkId, &manager_, &client);
+ SurfaceFactory factory2(kArbitraryFrameSinkId, &manager_, &client);
LocalFrameId local_frame1_id(7u, 0);
SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id);
- factory.Create(local_frame1_id);
LocalFrameId local_frame2_id(8u, 0);
SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id);
- factory.Create(local_frame2_id);
ResourceId ids[] = {11, 12, 13};
SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
- &factory, surface1_id);
+ &factory1, surface1_id);
ResourceId ids2[] = {14, 15, 16};
SubmitCompositorFrameWithResources(ids2, arraysize(ids2), true, SurfaceId(),
- &factory, surface2_id);
+ &factory2, surface2_id);
CompositorFrame frame = aggregator_->Aggregate(surface1_id);
- SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory,
+ SubmitCompositorFrameWithResources(NULL, 0, true, SurfaceId(), &factory1,
surface1_id);
// Nothing should be available to be returned yet.
@@ -1891,37 +1890,34 @@ TEST_F(SurfaceAggregatorWithResourcesTest, TwoSurfaces) {
EXPECT_THAT(returned_ids,
testing::WhenSorted(testing::ElementsAreArray(ids)));
EXPECT_EQ(3u, resource_provider_->num_resources());
- factory.Destroy(local_frame1_id);
- factory.Destroy(local_frame2_id);
}
// Ensure that aggregator completely ignores Surfaces that reference invalid
// resources.
TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) {
ResourceTrackingSurfaceFactoryClient client;
- SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client);
+ SurfaceFactory root_factory(kArbitraryFrameSinkId, &manager_, &client);
+ SurfaceFactory middle_factory(kArbitraryFrameSinkId, &manager_, &client);
+ SurfaceFactory child_factory(kArbitraryFrameSinkId, &manager_, &client);
LocalFrameId root_local_frame_id(7u, 1);
SurfaceId root_surface_id(kArbitraryFrameSinkId, root_local_frame_id);
- factory.Create(root_local_frame_id);
LocalFrameId middle_local_frame_id(8u, 1);
SurfaceId middle_surface_id(kArbitraryFrameSinkId, middle_local_frame_id);
- factory.Create(middle_local_frame_id);
LocalFrameId child_local_frame_id(9u, 1);
SurfaceId child_surface_id(kArbitraryFrameSinkId, child_local_frame_id);
- factory.Create(child_local_frame_id);
ResourceId ids[] = {14, 15, 16};
SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
- &factory, child_surface_id);
+ &child_factory, child_surface_id);
ResourceId ids2[] = {17, 18, 19};
SubmitCompositorFrameWithResources(ids2, arraysize(ids2), false,
- child_surface_id, &factory,
+ child_surface_id, &middle_factory,
middle_surface_id);
ResourceId ids3[] = {20, 21, 22};
SubmitCompositorFrameWithResources(ids3, arraysize(ids3), true,
- middle_surface_id, &factory,
+ middle_surface_id, &root_factory,
root_surface_id);
CompositorFrame frame;
@@ -1932,7 +1928,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, &factory,
+ child_surface_id, &middle_factory,
middle_surface_id);
frame = aggregator_->Aggregate(root_surface_id);
@@ -1941,26 +1937,21 @@ TEST_F(SurfaceAggregatorWithResourcesTest, InvalidChildSurface) {
ASSERT_EQ(1u, pass_list->size());
EXPECT_EQ(3u, pass_list->back()->shared_quad_state_list.size());
EXPECT_EQ(9u, pass_list->back()->quad_list.size());
-
- factory.Destroy(root_local_frame_id);
- factory.Destroy(child_local_frame_id);
- factory.Destroy(middle_local_frame_id);
}
TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
ResourceTrackingSurfaceFactoryClient client;
- SurfaceFactory factory(kArbitraryFrameSinkId, &manager_, &client);
+ SurfaceFactory factory1(kArbitraryFrameSinkId, &manager_, &client);
+ SurfaceFactory factory2(kArbitraryFrameSinkId, &manager_, &client);
LocalFrameId local_frame1_id(7u, 0);
SurfaceId surface1_id(kArbitraryFrameSinkId, local_frame1_id);
- factory.Create(local_frame1_id);
LocalFrameId local_frame2_id(8u, 0);
SurfaceId surface2_id(kArbitraryFrameSinkId, local_frame2_id);
- factory.Create(local_frame2_id);
ResourceId ids[] = {11, 12, 13};
SubmitCompositorFrameWithResources(ids, arraysize(ids), true, SurfaceId(),
- &factory, surface1_id);
+ &factory1, surface1_id);
CompositorFrame frame = aggregator_->Aggregate(surface1_id);
@@ -1975,6 +1966,7 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
sqs->opacity = 1.f;
SurfaceDrawQuad* surface_quad =
pass->CreateAndAppendDrawQuad<SurfaceDrawQuad>();
+
surface_quad->SetNew(sqs, gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1),
surface1_id);
pass->copy_requests.push_back(CopyOutputRequest::CreateEmptyRequest());
@@ -1982,8 +1974,8 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
CompositorFrame frame;
frame.render_pass_list.push_back(std::move(pass));
- factory.SubmitCompositorFrame(local_frame2_id, std::move(frame),
- SurfaceFactory::DrawCallback());
+ factory2.SubmitCompositorFrame(local_frame2_id, std::move(frame),
+ SurfaceFactory::DrawCallback());
}
frame = aggregator_->Aggregate(surface2_id);
@@ -2008,9 +2000,6 @@ TEST_F(SurfaceAggregatorWithResourcesTest, SecureOutputTexture) {
// Output is insecure, so texture should be drawn.
EXPECT_EQ(DrawQuad::SOLID_COLOR, render_pass->quad_list.back()->material);
-
- factory.Destroy(local_frame1_id);
- factory.Destroy(local_frame2_id);
}
} // namespace

Powered by Google App Engine
This is Rietveld 408576698