| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "cc/layers/render_surface_impl.h" | 5 #include "cc/layers/render_surface_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "cc/layers/append_quads_data.h" | 9 #include "cc/layers/append_quads_data.h" |
| 10 #include "cc/quads/render_pass_draw_quad.h" | 10 #include "cc/quads/render_pass_draw_quad.h" |
| 11 #include "cc/test/fake_mask_layer_impl.h" | 11 #include "cc/test/fake_mask_layer_impl.h" |
| 12 #include "cc/test/fake_raster_source.h" | |
| 13 #include "cc/test/layer_test_common.h" | 12 #include "cc/test/layer_test_common.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 14 |
| 16 namespace cc { | 15 namespace cc { |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| 19 TEST(RenderSurfaceLayerImplTest, Occlusion) { | 18 TEST(RenderSurfaceLayerImplTest, Occlusion) { |
| 20 gfx::Size layer_size(1000, 1000); | 19 gfx::Size layer_size(1000, 1000); |
| 21 gfx::Size viewport_size(1000, 1000); | 20 gfx::Size viewport_size(1000, 1000); |
| 22 | 21 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 impl.quad_list(), occluded, &partially_occluded_count); | 61 impl.quad_list(), occluded, &partially_occluded_count); |
| 63 // The layer outputs one quad, which is partially occluded. | 62 // The layer outputs one quad, which is partially occluded. |
| 64 EXPECT_EQ(1u, impl.quad_list().size()); | 63 EXPECT_EQ(1u, impl.quad_list().size()); |
| 65 EXPECT_EQ(1u, partially_occluded_count); | 64 EXPECT_EQ(1u, partially_occluded_count); |
| 66 } | 65 } |
| 67 } | 66 } |
| 68 | 67 |
| 69 TEST(RenderSurfaceLayerImplTest, AppendQuadsWithScaledMask) { | 68 TEST(RenderSurfaceLayerImplTest, AppendQuadsWithScaledMask) { |
| 70 gfx::Size layer_size(1000, 1000); | 69 gfx::Size layer_size(1000, 1000); |
| 71 gfx::Size viewport_size(1000, 1000); | 70 gfx::Size viewport_size(1000, 1000); |
| 72 scoped_refptr<FakeRasterSource> raster_source = | |
| 73 FakeRasterSource::CreateFilledSolidColor(layer_size); | |
| 74 | 71 |
| 75 LayerTreeSettings settings; | 72 LayerTreeSettings settings; |
| 76 settings.layer_transforms_should_scale_layer_contents = true; | 73 settings.layer_transforms_should_scale_layer_contents = true; |
| 77 LayerTestCommon::LayerImplTest impl(settings); | 74 LayerTestCommon::LayerImplTest impl(settings); |
| 78 std::unique_ptr<LayerImpl> root = | 75 std::unique_ptr<LayerImpl> root = |
| 79 LayerImpl::Create(impl.host_impl()->active_tree(), 2); | 76 LayerImpl::Create(impl.host_impl()->active_tree(), 2); |
| 80 std::unique_ptr<LayerImpl> surface = | 77 std::unique_ptr<LayerImpl> surface = |
| 81 LayerImpl::Create(impl.host_impl()->active_tree(), 3); | 78 LayerImpl::Create(impl.host_impl()->active_tree(), 3); |
| 82 surface->SetBounds(layer_size); | 79 surface->SetBounds(layer_size); |
| 83 surface->test_properties()->force_render_surface = true; | 80 surface->test_properties()->force_render_surface = true; |
| 84 | 81 |
| 85 gfx::Transform scale; | 82 gfx::Transform scale; |
| 86 scale.Scale(2, 2); | 83 scale.Scale(2, 2); |
| 87 surface->test_properties()->transform = scale; | 84 surface->test_properties()->transform = scale; |
| 88 | 85 |
| 89 surface->test_properties()->SetMaskLayer(FakeMaskLayerImpl::Create( | 86 surface->test_properties()->SetMaskLayer( |
| 90 impl.host_impl()->active_tree(), 4, raster_source, | 87 FakeMaskLayerImpl::Create(impl.host_impl()->active_tree(), 4)); |
| 91 Layer::LayerMaskType::SINGLE_TEXTURE_MASK)); | |
| 92 surface->test_properties()->mask_layer->SetDrawsContent(true); | 88 surface->test_properties()->mask_layer->SetDrawsContent(true); |
| 93 surface->test_properties()->mask_layer->SetBounds(layer_size); | 89 surface->test_properties()->mask_layer->SetBounds(layer_size); |
| 94 | 90 |
| 95 std::unique_ptr<LayerImpl> child = | 91 std::unique_ptr<LayerImpl> child = |
| 96 LayerImpl::Create(impl.host_impl()->active_tree(), 5); | 92 LayerImpl::Create(impl.host_impl()->active_tree(), 5); |
| 97 child->SetDrawsContent(true); | 93 child->SetDrawsContent(true); |
| 98 child->SetBounds(layer_size); | 94 child->SetBounds(layer_size); |
| 99 | 95 |
| 100 surface->test_properties()->AddChild(std::move(child)); | 96 surface->test_properties()->AddChild(std::move(child)); |
| 101 root->test_properties()->AddChild(std::move(surface)); | 97 root->test_properties()->AddChild(std::move(surface)); |
| 102 impl.host_impl()->active_tree()->SetRootLayerForTesting(std::move(root)); | 98 impl.host_impl()->active_tree()->SetRootLayerForTesting(std::move(root)); |
| 103 | 99 |
| 104 impl.host_impl()->SetViewportSize(viewport_size); | 100 impl.host_impl()->SetViewportSize(viewport_size); |
| 105 impl.host_impl()->active_tree()->BuildLayerListAndPropertyTreesForTesting(); | 101 impl.host_impl()->active_tree()->BuildLayerListAndPropertyTreesForTesting(); |
| 106 impl.host_impl()->active_tree()->UpdateDrawProperties(false); | 102 impl.host_impl()->active_tree()->UpdateDrawProperties(false); |
| 107 | 103 |
| 108 LayerImpl* surface_raw = impl.host_impl() | 104 LayerImpl* surface_raw = impl.host_impl() |
| 109 ->active_tree() | 105 ->active_tree() |
| 110 ->root_layer_for_testing() | 106 ->root_layer_for_testing() |
| 111 ->test_properties() | 107 ->test_properties() |
| 112 ->children[0]; | 108 ->children[0]; |
| 113 RenderSurfaceImpl* render_surface_impl = surface_raw->GetRenderSurface(); | 109 RenderSurfaceImpl* render_surface_impl = surface_raw->GetRenderSurface(); |
| 114 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); | 110 std::unique_ptr<RenderPass> render_pass = RenderPass::Create(); |
| 115 AppendQuadsData append_quads_data; | 111 AppendQuadsData append_quads_data; |
| 116 render_surface_impl->AppendQuads(render_pass.get(), &append_quads_data); | 112 render_surface_impl->AppendQuads(render_pass.get(), &append_quads_data); |
| 117 | 113 |
| 118 DCHECK(render_pass->quad_list.front()); | |
| 119 const RenderPassDrawQuad* quad = | 114 const RenderPassDrawQuad* quad = |
| 120 RenderPassDrawQuad::MaterialCast(render_pass->quad_list.front()); | 115 RenderPassDrawQuad::MaterialCast(render_pass->quad_list.front()); |
| 121 EXPECT_EQ(gfx::RectF(0, 0, 1, 1), quad->mask_uv_rect); | 116 EXPECT_EQ(gfx::RectF(0, 0, 1.f, 1.f), quad->mask_uv_rect); |
| 122 EXPECT_EQ(gfx::Vector2dF(2.f, 2.f), quad->filters_scale); | 117 EXPECT_EQ(gfx::Vector2dF(2.f, 2.f), quad->filters_scale); |
| 123 } | 118 } |
| 124 | 119 |
| 125 } // namespace | 120 } // namespace |
| 126 } // namespace cc | 121 } // namespace cc |
| OLD | NEW |