Chromium Code Reviews| Index: cc/layers/surface_layer_impl_unittest.cc |
| diff --git a/cc/layers/surface_layer_impl_unittest.cc b/cc/layers/surface_layer_impl_unittest.cc |
| index ea556d8dae165f109aa62c55536b2e1ab792abc7..c07e0ac438f55a2db0a22353db50558338cbc4db 100644 |
| --- a/cc/layers/surface_layer_impl_unittest.cc |
| +++ b/cc/layers/surface_layer_impl_unittest.cc |
| @@ -6,6 +6,7 @@ |
| #include <stddef.h> |
| +#include "cc/layers/append_quads_data.h" |
| #include "cc/test/layer_test_common.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -66,5 +67,57 @@ TEST(SurfaceLayerImplTest, Occlusion) { |
| } |
| } |
| +TEST(SurfaceLayerImplTest, LayerBoundsDiffFromSurfaceLayerSize) { |
| + LayerTestCommon::LayerImplTest impl; |
| + SurfaceLayerImpl* surface_layer_impl = |
| + impl.AddChildToRoot<SurfaceLayerImpl>(); |
| + const LocalFrameId kArbitraryLocalFrameId(9, |
| + base::UnguessableToken::Create()); |
| + |
| + // Given condition |
|
danakj
2016/11/28 22:26:23
what is interesting about the given condition? her
xlai (Olivia)
2016/12/13 17:29:18
Done.
|
| + gfx::Size layer_size(400, 100); |
| + gfx::Size surface_size(300, 300); |
| + float surface_scale = 1.f; |
| + gfx::Transform target_space_transform( |
| + surface_layer_impl->draw_properties().target_space_transform); |
| + |
| + // Surface_layer_impl will be set after PushProperties. |
|
danakj
2016/11/28 22:26:22
Does this mean to say the below is mimicing the be
xlai (Olivia)
2016/12/13 17:29:18
Done.
|
| + surface_layer_impl->SetBounds(layer_size); |
| + surface_layer_impl->SetDrawsContent(true); |
| + SurfaceId surface_id(kArbitraryFrameSinkId, kArbitraryLocalFrameId); |
| + surface_layer_impl->SetSurfaceId(surface_id); |
| + surface_layer_impl->SetSurfaceScale(surface_scale); |
| + surface_layer_impl->SetSurfaceSize(surface_size); |
| + surface_layer_impl->SetScaleLayerBoundsWithSurfaceSize(true); |
| + |
| + // Calling test function AppendQuads. |
|
danakj
2016/11/28 22:26:23
This comment isn't adding value
xlai (Olivia)
2016/12/13 17:29:18
Done.
|
| + std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| + AppendQuadsData data; |
| + surface_layer_impl->AppendQuads(render_pass.get(), &data); |
| + |
| + const QuadList& quads = render_pass->quad_list; |
| + ASSERT_EQ(1u, quads.size()); |
| + const SharedQuadState* shared_quad_state = quads.front()->shared_quad_state; |
| + |
|
danakj
2016/11/28 22:26:23
A comment explaining the math below is helpful in
xlai (Olivia)
2016/12/13 17:29:18
Done.
|
| + gfx::Transform transform(target_space_transform); |
|
danakj
2016/11/28 22:26:23
expected_transform is a helpful name
xlai (Olivia)
2016/12/13 17:29:18
Done.
|
| + float scale_x = ((float)surface_size.width()) / layer_size.width(); |
|
danakj
2016/11/28 22:26:23
static_cast not c-style https://google.github.io/s
xlai (Olivia)
2016/12/13 17:29:18
Done.
|
| + float scale_y = ((float)surface_size.height()) / layer_size.height(); |
| + transform.Scale(SK_MScalar1 / scale_x, SK_MScalar1 / scale_y); |
| + EXPECT_EQ(transform, shared_quad_state->quad_to_target_transform); |
| + |
| + // Obtain quad rect in target space by applying SQS->quad_to_target_transform |
| + // to quad_rect |
| + gfx::RectF quad_rect(quads.front()->rect); |
| + transform.TransformRect(&quad_rect); |
|
danakj
2016/11/28 22:26:22
Don't use gfx::Transform::TransformRect in cc/. In
|
| + |
| + // Obtain layer rect in target space by applying target_space_transform on |
| + // layer rect. |
| + gfx::RectF layer_rect((float)layer_size.width(), (float)layer_size.height()); |
|
danakj
2016/11/28 22:26:23
no c-style casts. you shouldn't need any cast here
xlai (Olivia)
2016/12/13 17:29:18
Done.
|
| + target_space_transform.TransformRect(&layer_rect); |
|
danakj
2016/11/28 22:26:22
Don't use gfx::Transform::TransformRect in cc/. In
xlai (Olivia)
2016/12/13 17:29:18
Done.
|
| + |
| + // Check if quad rect in target space matches layer rect in target space |
| + EXPECT_EQ(quad_rect, layer_rect); |
| +} |
| + |
| } // namespace |
| } // namespace cc |