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