This source file includes following definitions.
- TEST_F
- TEST_F
- AggregateAndVerify
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- AddSolidColorQuadWithBlendMode
- TEST_F
- TEST_F
#include "cc/output/compositor_frame.h"
#include "cc/output/delegated_frame_data.h"
#include "cc/quads/render_pass.h"
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/solid_color_draw_quad.h"
#include "cc/quads/surface_draw_quad.h"
#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_aggregator.h"
#include "cc/surfaces/surface_aggregator_test_helpers.h"
#include "cc/surfaces/surface_manager.h"
#include "cc/test/render_pass_test_common.h"
#include "cc/test/render_pass_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkColor.h"
namespace cc {
namespace {
const int kInvalidSurfaceId = -1;
class SurfaceAggregatorTest : public testing::Test {
public:
SurfaceAggregatorTest() : aggregator_(&manager_) {}
protected:
SurfaceManager manager_;
SurfaceAggregator aggregator_;
};
TEST_F(SurfaceAggregatorTest, InvalidSurfaceId) {
scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(kInvalidSurfaceId);
EXPECT_FALSE(frame);
}
TEST_F(SurfaceAggregatorTest, ValidSurfaceNoFrame) {
Surface one(&manager_, NULL, gfx::Size(5, 5));
scoped_ptr<CompositorFrame> frame = aggregator_.Aggregate(one.surface_id());
EXPECT_FALSE(frame);
}
class SurfaceAggregatorValidSurfaceTest : public SurfaceAggregatorTest {
public:
SurfaceAggregatorValidSurfaceTest()
: root_surface_(&manager_, NULL, gfx::Size(5, 5)) {}
void AggregateAndVerify(test::Pass* expected_passes,
size_t expected_pass_count) {
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_.surface_id());
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
DelegatedFrameData* frame_data =
aggregated_frame->delegated_frame_data.get();
TestPassesMatchExpectations(
expected_passes, expected_pass_count, &frame_data->render_pass_list);
}
protected:
Surface root_surface_;
};
TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleFrame) {
test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorRED),
test::Quad::SolidColorQuad(SK_ColorBLUE)};
test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
SubmitFrame(passes, arraysize(passes), &root_surface_);
AggregateAndVerify(passes, arraysize(passes));
}
TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSimpleFrame) {
test::Quad quads[][2] = {{test::Quad::SolidColorQuad(SK_ColorWHITE),
test::Quad::SolidColorQuad(SK_ColorLTGRAY)},
{test::Quad::SolidColorQuad(SK_ColorGRAY),
test::Quad::SolidColorQuad(SK_ColorDKGRAY)}};
test::Pass passes[] = {test::Pass(quads[0], arraysize(quads[0])),
test::Pass(quads[1], arraysize(quads[1]))};
SubmitFrame(passes, arraysize(passes), &root_surface_);
AggregateAndVerify(passes, arraysize(passes));
}
TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleSurfaceReference) {
gfx::Size surface_size(5, 5);
Surface embedded_surface(&manager_, NULL, surface_size);
test::Quad embedded_quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN)};
test::Pass embedded_passes[] = {
test::Pass(embedded_quads, arraysize(embedded_quads))};
SubmitFrame(embedded_passes, arraysize(embedded_passes), &embedded_surface);
test::Quad root_quads[] = {
test::Quad::SolidColorQuad(SK_ColorWHITE),
test::Quad::SurfaceQuad(embedded_surface.surface_id()),
test::Quad::SolidColorQuad(SK_ColorBLACK)};
test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
SubmitFrame(root_passes, arraysize(root_passes), &root_surface_);
test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorWHITE),
test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SolidColorQuad(SK_ColorBLACK)};
test::Pass expected_passes[] = {
test::Pass(expected_quads, arraysize(expected_quads))};
AggregateAndVerify(expected_passes, arraysize(expected_passes));
}
TEST_F(SurfaceAggregatorValidSurfaceTest, MultiPassSurfaceReference) {
gfx::Size surface_size(5, 5);
Surface embedded_surface(&manager_, NULL, surface_size);
RenderPass::Id pass_ids[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2),
RenderPass::Id(1, 3)};
test::Quad embedded_quads[][2] = {
{test::Quad::SolidColorQuad(1), test::Quad::SolidColorQuad(2)},
{test::Quad::SolidColorQuad(3), test::Quad::RenderPassQuad(pass_ids[0])},
{test::Quad::SolidColorQuad(4), test::Quad::RenderPassQuad(pass_ids[1])}};
test::Pass embedded_passes[] = {
test::Pass(embedded_quads[0], arraysize(embedded_quads[0]), pass_ids[0]),
test::Pass(embedded_quads[1], arraysize(embedded_quads[1]), pass_ids[1]),
test::Pass(embedded_quads[2], arraysize(embedded_quads[2]), pass_ids[2])};
SubmitFrame(embedded_passes, arraysize(embedded_passes), &embedded_surface);
test::Quad root_quads[][2] = {
{test::Quad::SolidColorQuad(5), test::Quad::SolidColorQuad(6)},
{test::Quad::SurfaceQuad(embedded_surface.surface_id()),
test::Quad::RenderPassQuad(pass_ids[0])},
{test::Quad::SolidColorQuad(7), test::Quad::RenderPassQuad(pass_ids[1])}};
test::Pass root_passes[] = {
test::Pass(root_quads[0], arraysize(root_quads[0]), pass_ids[0]),
test::Pass(root_quads[1], arraysize(root_quads[1]), pass_ids[1]),
test::Pass(root_quads[2], arraysize(root_quads[2]), pass_ids[2])};
SubmitFrame(root_passes, arraysize(root_passes), &root_surface_);
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_.surface_id());
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
ASSERT_EQ(5u, aggregated_pass_list.size());
RenderPass::Id actual_pass_ids[] = {
aggregated_pass_list[0]->id, aggregated_pass_list[1]->id,
aggregated_pass_list[2]->id, aggregated_pass_list[3]->id,
aggregated_pass_list[4]->id};
for (size_t i = 0; i < 5; ++i) {
for (size_t j = 0; j < i; ++j) {
EXPECT_NE(actual_pass_ids[i], actual_pass_ids[j]);
}
}
{
SCOPED_TRACE("First pass");
TestPassMatchesExpectations(root_passes[0], aggregated_pass_list[0]);
}
{
SCOPED_TRACE("Second pass");
TestPassMatchesExpectations(embedded_passes[0], aggregated_pass_list[1]);
}
{
SCOPED_TRACE("Third pass");
const QuadList& third_pass_quad_list = aggregated_pass_list[2]->quad_list;
ASSERT_EQ(2u, third_pass_quad_list.size());
TestQuadMatchesExpectations(embedded_quads[1][0],
third_pass_quad_list.at(0u));
ASSERT_EQ(DrawQuad::RENDER_PASS, third_pass_quad_list.at(1u)->material);
const RenderPassDrawQuad* third_pass_render_pass_draw_quad =
RenderPassDrawQuad::MaterialCast(third_pass_quad_list.at(1u));
EXPECT_EQ(actual_pass_ids[1],
third_pass_render_pass_draw_quad->render_pass_id);
}
{
SCOPED_TRACE("Fourth pass");
const QuadList& fourth_pass_quad_list = aggregated_pass_list[3]->quad_list;
ASSERT_EQ(3u, fourth_pass_quad_list.size());
TestQuadMatchesExpectations(embedded_quads[2][0],
fourth_pass_quad_list.at(0u));
ASSERT_EQ(DrawQuad::RENDER_PASS, fourth_pass_quad_list.at(1u)->material);
const RenderPassDrawQuad* fourth_pass_first_render_pass_draw_quad =
RenderPassDrawQuad::MaterialCast(fourth_pass_quad_list.at(1u));
EXPECT_EQ(actual_pass_ids[2],
fourth_pass_first_render_pass_draw_quad->render_pass_id);
ASSERT_EQ(DrawQuad::RENDER_PASS, fourth_pass_quad_list.at(2u)->material);
const RenderPassDrawQuad* fourth_pass_second_render_pass_draw_quad =
RenderPassDrawQuad::MaterialCast(fourth_pass_quad_list.at(2u));
EXPECT_EQ(actual_pass_ids[0],
fourth_pass_second_render_pass_draw_quad->render_pass_id);
}
{
SCOPED_TRACE("Fifth pass");
const QuadList& fifth_pass_quad_list = aggregated_pass_list[4]->quad_list;
ASSERT_EQ(2u, fifth_pass_quad_list.size());
TestQuadMatchesExpectations(root_quads[2][0], fifth_pass_quad_list.at(0));
ASSERT_EQ(DrawQuad::RENDER_PASS, fifth_pass_quad_list.at(1u)->material);
const RenderPassDrawQuad* fifth_pass_render_pass_draw_quad =
RenderPassDrawQuad::MaterialCast(fifth_pass_quad_list.at(1u));
EXPECT_EQ(actual_pass_ids[3],
fifth_pass_render_pass_draw_quad->render_pass_id);
}
}
TEST_F(SurfaceAggregatorValidSurfaceTest, InvalidSurfaceReference) {
test::Quad quads[] = {test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SurfaceQuad(kInvalidSurfaceId),
test::Quad::SolidColorQuad(SK_ColorBLUE)};
test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
SubmitFrame(passes, arraysize(passes), &root_surface_);
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))};
AggregateAndVerify(expected_passes, arraysize(expected_passes));
}
TEST_F(SurfaceAggregatorValidSurfaceTest, ValidSurfaceReferenceWithNoFrame) {
Surface surface_with_no_frame(&manager_, NULL, gfx::Size(5, 5));
test::Quad quads[] = {
test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SurfaceQuad(surface_with_no_frame.surface_id()),
test::Quad::SolidColorQuad(SK_ColorBLUE)};
test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
SubmitFrame(passes, arraysize(passes), &root_surface_);
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))};
AggregateAndVerify(expected_passes, arraysize(expected_passes));
}
TEST_F(SurfaceAggregatorValidSurfaceTest, SimpleCyclicalReference) {
test::Quad quads[] = {test::Quad::SurfaceQuad(root_surface_.surface_id()),
test::Quad::SolidColorQuad(SK_ColorYELLOW)};
test::Pass passes[] = {test::Pass(quads, arraysize(quads))};
SubmitFrame(passes, arraysize(passes), &root_surface_);
test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorYELLOW)};
test::Pass expected_passes[] = {
test::Pass(expected_quads, arraysize(expected_quads))};
AggregateAndVerify(expected_passes, arraysize(expected_passes));
}
TEST_F(SurfaceAggregatorValidSurfaceTest, TwoSurfaceCyclicalReference) {
gfx::Size surface_size(5, 5);
Surface child_surface(&manager_, NULL, surface_size);
test::Quad parent_quads[] = {
test::Quad::SolidColorQuad(SK_ColorBLUE),
test::Quad::SurfaceQuad(child_surface.surface_id()),
test::Quad::SolidColorQuad(SK_ColorCYAN)};
test::Pass parent_passes[] = {
test::Pass(parent_quads, arraysize(parent_quads))};
SubmitFrame(parent_passes, arraysize(parent_passes), &root_surface_);
test::Quad child_quads[] = {
test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SurfaceQuad(root_surface_.surface_id()),
test::Quad::SolidColorQuad(SK_ColorMAGENTA)};
test::Pass child_passes[] = {test::Pass(child_quads, arraysize(child_quads))};
SubmitFrame(child_passes, arraysize(child_passes), &child_surface);
test::Quad expected_quads[] = {test::Quad::SolidColorQuad(SK_ColorBLUE),
test::Quad::SolidColorQuad(SK_ColorGREEN),
test::Quad::SolidColorQuad(SK_ColorMAGENTA),
test::Quad::SolidColorQuad(SK_ColorCYAN)};
test::Pass expected_passes[] = {
test::Pass(expected_quads, arraysize(expected_quads))};
AggregateAndVerify(expected_passes, arraysize(expected_passes));
}
TEST_F(SurfaceAggregatorValidSurfaceTest, RenderPassIdMapping) {
gfx::Size surface_size(5, 5);
Surface child_surface(&manager_, NULL, surface_size);
RenderPass::Id child_pass_id[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2)};
test::Quad child_quad[][1] = {{test::Quad::SolidColorQuad(SK_ColorGREEN)},
{test::Quad::RenderPassQuad(child_pass_id[0])}};
test::Pass surface_passes[] = {
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])};
SubmitFrame(surface_passes, arraysize(surface_passes), &child_surface);
RenderPass::Id parent_pass_id[] = {RenderPass::Id(2, 1),
RenderPass::Id(1, 2)};
test::Quad parent_quad[][1] = {
{test::Quad::SurfaceQuad(child_surface.surface_id())},
{test::Quad::RenderPassQuad(parent_pass_id[0])}};
test::Pass parent_passes[] = {
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])};
SubmitFrame(parent_passes, arraysize(parent_passes), &root_surface_);
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_.surface_id());
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
ASSERT_EQ(3u, aggregated_pass_list.size());
RenderPass::Id actual_pass_ids[] = {aggregated_pass_list[0]->id,
aggregated_pass_list[1]->id,
aggregated_pass_list[2]->id};
for (size_t i = 0; i < 3; ++i) {
for (size_t j = 0; j < i; ++j) {
EXPECT_NE(actual_pass_ids[j], actual_pass_ids[i]) << "pass ids " << i
<< " and " << j;
}
}
DrawQuad* render_pass_quads[] = {aggregated_pass_list[1]->quad_list[0],
aggregated_pass_list[2]->quad_list[0]};
ASSERT_EQ(render_pass_quads[0]->material, DrawQuad::RENDER_PASS);
EXPECT_EQ(
actual_pass_ids[0],
RenderPassDrawQuad::MaterialCast(render_pass_quads[0])->render_pass_id);
ASSERT_EQ(render_pass_quads[1]->material, DrawQuad::RENDER_PASS);
EXPECT_EQ(
actual_pass_ids[1],
RenderPassDrawQuad::MaterialCast(render_pass_quads[1])->render_pass_id);
}
void AddSolidColorQuadWithBlendMode(const gfx::Size& size,
RenderPass* pass,
const SkXfermode::Mode blend_mode) {
const gfx::Transform content_to_target_transform;
const gfx::Size content_bounds(size);
const gfx::Rect visible_content_rect(size);
const gfx::Rect clip_rect(size);
bool is_clipped = false;
float opacity = 1.f;
bool force_anti_aliasing_off = false;
scoped_ptr<SharedQuadState> sqs = SharedQuadState::Create();
sqs->SetAll(content_to_target_transform,
content_bounds,
visible_content_rect,
clip_rect,
is_clipped,
opacity,
blend_mode);
pass->shared_quad_state_list.push_back(sqs.Pass());
scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create();
color_quad->SetNew(pass->shared_quad_state_list.back(),
visible_content_rect,
visible_content_rect,
SK_ColorGREEN,
force_anti_aliasing_off);
pass->quad_list.push_back(color_quad.PassAs<DrawQuad>());
}
TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateSharedQuadStateProperties) {
gfx::Size surface_size(5, 5);
const SkXfermode::Mode blend_modes[] = {SkXfermode::kClear_Mode,
SkXfermode::kSrc_Mode,
SkXfermode::kDst_Mode,
SkXfermode::kSrcOver_Mode,
SkXfermode::kDstOver_Mode,
SkXfermode::kSrcIn_Mode,
SkXfermode::kDstIn_Mode,
};
RenderPass::Id pass_id(1, 1);
Surface grandchild_surface(&manager_, NULL, surface_size);
scoped_ptr<RenderPass> grandchild_pass = RenderPass::Create();
gfx::Rect output_rect(surface_size);
gfx::RectF damage_rect(surface_size);
gfx::Transform transform_to_root_target;
grandchild_pass->SetNew(
pass_id, output_rect, damage_rect, transform_to_root_target);
AddSolidColorQuadWithBlendMode(
surface_size, grandchild_pass.get(), blend_modes[2]);
test::QueuePassAsFrame(grandchild_pass.Pass(), &grandchild_surface);
Surface child_one_surface(&manager_, NULL, surface_size);
scoped_ptr<RenderPass> child_one_pass = RenderPass::Create();
child_one_pass->SetNew(
pass_id, output_rect, damage_rect, transform_to_root_target);
AddSolidColorQuadWithBlendMode(
surface_size, child_one_pass.get(), blend_modes[1]);
scoped_ptr<SurfaceDrawQuad> grandchild_surface_quad =
SurfaceDrawQuad::Create();
grandchild_surface_quad->SetNew(child_one_pass->shared_quad_state_list.back(),
gfx::Rect(surface_size),
gfx::Rect(surface_size),
grandchild_surface.surface_id());
child_one_pass->quad_list.push_back(
grandchild_surface_quad.PassAs<DrawQuad>());
AddSolidColorQuadWithBlendMode(
surface_size, child_one_pass.get(), blend_modes[3]);
test::QueuePassAsFrame(child_one_pass.Pass(), &child_one_surface);
Surface child_two_surface(&manager_, NULL, surface_size);
scoped_ptr<RenderPass> child_two_pass = RenderPass::Create();
child_two_pass->SetNew(
pass_id, output_rect, damage_rect, transform_to_root_target);
AddSolidColorQuadWithBlendMode(
surface_size, child_two_pass.get(), blend_modes[5]);
test::QueuePassAsFrame(child_two_pass.Pass(), &child_two_surface);
scoped_ptr<RenderPass> root_pass = RenderPass::Create();
root_pass->SetNew(
pass_id, output_rect, damage_rect, transform_to_root_target);
AddSolidColorQuadWithBlendMode(surface_size, root_pass.get(), blend_modes[0]);
scoped_ptr<SurfaceDrawQuad> child_one_surface_quad =
SurfaceDrawQuad::Create();
child_one_surface_quad->SetNew(root_pass->shared_quad_state_list.back(),
gfx::Rect(surface_size),
gfx::Rect(surface_size),
child_one_surface.surface_id());
root_pass->quad_list.push_back(child_one_surface_quad.PassAs<DrawQuad>());
AddSolidColorQuadWithBlendMode(surface_size, root_pass.get(), blend_modes[4]);
scoped_ptr<SurfaceDrawQuad> child_two_surface_quad =
SurfaceDrawQuad::Create();
child_two_surface_quad->SetNew(root_pass->shared_quad_state_list.back(),
gfx::Rect(surface_size),
gfx::Rect(surface_size),
child_two_surface.surface_id());
root_pass->quad_list.push_back(child_two_surface_quad.PassAs<DrawQuad>());
AddSolidColorQuadWithBlendMode(surface_size, root_pass.get(), blend_modes[6]);
test::QueuePassAsFrame(root_pass.Pass(), &root_surface_);
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_.surface_id());
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
ASSERT_EQ(1u, aggregated_pass_list.size());
const QuadList& aggregated_quad_list = aggregated_pass_list[0]->quad_list;
ASSERT_EQ(7u, aggregated_quad_list.size());
for (size_t i = 0; i < aggregated_quad_list.size(); ++i) {
DrawQuad* quad = aggregated_quad_list[i];
EXPECT_EQ(blend_modes[i], quad->shared_quad_state->blend_mode) << i;
}
}
TEST_F(SurfaceAggregatorValidSurfaceTest, AggregateMultiplePassWithTransform) {
gfx::Size surface_size(5, 5);
Surface child_surface(&manager_, NULL, surface_size);
RenderPass::Id child_pass_id[] = {RenderPass::Id(1, 1), RenderPass::Id(1, 2)};
test::Quad child_quads[][1] = {
{test::Quad::SolidColorQuad(SK_ColorGREEN)},
{test::Quad::RenderPassQuad(child_pass_id[0])}};
test::Pass child_passes[] = {
test::Pass(child_quads[0], arraysize(child_quads[0]), child_pass_id[0]),
test::Pass(child_quads[1], arraysize(child_quads[1]), child_pass_id[1])};
RenderPassList child_pass_list;
AddPasses(&child_pass_list,
gfx::Rect(surface_size),
child_passes,
arraysize(child_passes));
RenderPass* child_nonroot_pass = child_pass_list.at(0u);
child_nonroot_pass->transform_to_root_target.Translate(8, 0);
SharedQuadState* child_nonroot_pass_sqs =
child_nonroot_pass->shared_quad_state_list[0];
child_nonroot_pass_sqs->content_to_target_transform.Translate(5, 0);
RenderPass* child_root_pass = child_pass_list.at(1u);
SharedQuadState* child_root_pass_sqs =
child_root_pass->shared_quad_state_list[0];
child_root_pass_sqs->content_to_target_transform.Translate(8, 0);
scoped_ptr<DelegatedFrameData> child_frame_data(new DelegatedFrameData);
child_pass_list.swap(child_frame_data->render_pass_list);
scoped_ptr<CompositorFrame> child_frame(new CompositorFrame);
child_frame->delegated_frame_data = child_frame_data.Pass();
child_surface.QueueFrame(child_frame.Pass());
test::Quad root_quads[] = {
test::Quad::SolidColorQuad(1),
test::Quad::SurfaceQuad(child_surface.surface_id())};
test::Pass root_passes[] = {test::Pass(root_quads, arraysize(root_quads))};
RenderPassList root_pass_list;
AddPasses(&root_pass_list,
gfx::Rect(surface_size),
root_passes,
arraysize(root_passes));
root_pass_list.at(0)
->shared_quad_state_list[0]
->content_to_target_transform.Translate(0, 7);
root_pass_list.at(0)
->shared_quad_state_list[1]
->content_to_target_transform.Translate(0, 10);
scoped_ptr<DelegatedFrameData> root_frame_data(new DelegatedFrameData);
root_pass_list.swap(root_frame_data->render_pass_list);
scoped_ptr<CompositorFrame> root_frame(new CompositorFrame);
root_frame->delegated_frame_data = root_frame_data.Pass();
root_surface_.QueueFrame(root_frame.Pass());
scoped_ptr<CompositorFrame> aggregated_frame =
aggregator_.Aggregate(root_surface_.surface_id());
ASSERT_TRUE(aggregated_frame);
ASSERT_TRUE(aggregated_frame->delegated_frame_data);
DelegatedFrameData* frame_data = aggregated_frame->delegated_frame_data.get();
const RenderPassList& aggregated_pass_list = frame_data->render_pass_list;
ASSERT_EQ(2u, aggregated_pass_list.size());
ASSERT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size());
EXPECT_EQ(1u, aggregated_pass_list[0]->shared_quad_state_list.size());
EXPECT_EQ(2u, aggregated_pass_list[1]->shared_quad_state_list.size());
SharedQuadState* aggregated_first_pass_sqs =
aggregated_pass_list[0]->shared_quad_state_list.front();
gfx::Transform expected_aggregated_first_pass_sqs_transform;
expected_aggregated_first_pass_sqs_transform.Translate(5, 0);
EXPECT_EQ(expected_aggregated_first_pass_sqs_transform.ToString(),
aggregated_first_pass_sqs->content_to_target_transform.ToString());
gfx::Transform expected_first_pass_transform_to_root_target;
expected_first_pass_transform_to_root_target.Translate(8, 10);
EXPECT_EQ(expected_first_pass_transform_to_root_target.ToString(),
aggregated_pass_list[0]->transform_to_root_target.ToString());
ASSERT_EQ(2u, aggregated_pass_list[1]->quad_list.size());
gfx::Transform expected_root_pass_quad_transforms[2];
expected_root_pass_quad_transforms[0].Translate(0, 7);
expected_root_pass_quad_transforms[1].Translate(8, 10);
for (size_t i = 0; i < 2; ++i) {
DrawQuad* quad = aggregated_pass_list[1]->quad_list.at(i);
EXPECT_EQ(expected_root_pass_quad_transforms[i].ToString(),
quad->quadTransform().ToString())
<< i;
}
}
}
}