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" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 impl.quad_list(), occluded, &partially_occluded_count); | 61 impl.quad_list(), occluded, &partially_occluded_count); |
62 // The layer outputs one quad, which is partially occluded. | 62 // The layer outputs one quad, which is partially occluded. |
63 EXPECT_EQ(1u, impl.quad_list().size()); | 63 EXPECT_EQ(1u, impl.quad_list().size()); |
64 EXPECT_EQ(1u, partially_occluded_count); | 64 EXPECT_EQ(1u, partially_occluded_count); |
65 } | 65 } |
66 } | 66 } |
67 | 67 |
68 TEST(RenderSurfaceLayerImplTest, AppendQuadsWithScaledMask) { | 68 TEST(RenderSurfaceLayerImplTest, AppendQuadsWithScaledMask) { |
69 gfx::Size layer_size(1000, 1000); | 69 gfx::Size layer_size(1000, 1000); |
70 gfx::Size viewport_size(1000, 1000); | 70 gfx::Size viewport_size(1000, 1000); |
| 71 float scale_factor = 2; |
71 scoped_refptr<FakeRasterSource> raster_source = | 72 scoped_refptr<FakeRasterSource> raster_source = |
72 FakeRasterSource::CreateFilledSolidColor(layer_size); | 73 FakeRasterSource::CreateFilledSolidColor(layer_size); |
73 | 74 |
74 LayerTreeSettings settings; | 75 LayerTreeSettings settings; |
75 settings.layer_transforms_should_scale_layer_contents = true; | 76 settings.layer_transforms_should_scale_layer_contents = true; |
76 LayerTestCommon::LayerImplTest impl(settings); | 77 LayerTestCommon::LayerImplTest impl(settings); |
77 std::unique_ptr<LayerImpl> root = | 78 std::unique_ptr<LayerImpl> root = |
78 LayerImpl::Create(impl.host_impl()->active_tree(), 2); | 79 LayerImpl::Create(impl.host_impl()->active_tree(), 2); |
79 std::unique_ptr<LayerImpl> surface = | 80 std::unique_ptr<LayerImpl> surface = |
80 LayerImpl::Create(impl.host_impl()->active_tree(), 3); | 81 LayerImpl::Create(impl.host_impl()->active_tree(), 3); |
81 surface->SetBounds(layer_size); | 82 surface->SetBounds(layer_size); |
82 surface->test_properties()->force_render_surface = true; | 83 surface->test_properties()->force_render_surface = true; |
83 | 84 |
84 gfx::Transform scale; | 85 gfx::Transform scale; |
85 scale.Scale(2, 2); | 86 scale.Scale(scale_factor, scale_factor); |
86 surface->test_properties()->transform = scale; | 87 surface->test_properties()->transform = scale; |
87 | 88 |
88 surface->test_properties()->SetMaskLayer(FakeMaskLayerImpl::Create( | 89 std::unique_ptr<FakeMaskLayerImpl> mask_layer = FakeMaskLayerImpl::Create( |
89 impl.host_impl()->active_tree(), 4, raster_source, | 90 impl.host_impl()->active_tree(), 4, raster_source, |
90 Layer::LayerMaskType::SINGLE_TEXTURE_MASK)); | 91 Layer::LayerMaskType::SINGLE_TEXTURE_MASK); |
91 surface->test_properties()->mask_layer->SetDrawsContent(true); | 92 mask_layer->set_resource_size( |
92 surface->test_properties()->mask_layer->SetBounds(layer_size); | 93 gfx::ScaleToCeiledSize(layer_size, scale_factor)); |
| 94 mask_layer->SetDrawsContent(true); |
| 95 mask_layer->SetBounds(layer_size); |
| 96 surface->test_properties()->SetMaskLayer(std::move(mask_layer)); |
93 | 97 |
94 std::unique_ptr<LayerImpl> child = | 98 std::unique_ptr<LayerImpl> child = |
95 LayerImpl::Create(impl.host_impl()->active_tree(), 5); | 99 LayerImpl::Create(impl.host_impl()->active_tree(), 5); |
96 child->SetDrawsContent(true); | 100 child->SetDrawsContent(true); |
97 child->SetBounds(layer_size); | 101 child->SetBounds(layer_size); |
98 | 102 |
99 surface->test_properties()->AddChild(std::move(child)); | 103 surface->test_properties()->AddChild(std::move(child)); |
100 root->test_properties()->AddChild(std::move(surface)); | 104 root->test_properties()->AddChild(std::move(surface)); |
101 impl.host_impl()->active_tree()->SetRootLayerForTesting(std::move(root)); | 105 impl.host_impl()->active_tree()->SetRootLayerForTesting(std::move(root)); |
102 | 106 |
(...skipping 13 matching lines...) Expand all Loading... |
116 | 120 |
117 DCHECK(render_pass->quad_list.front()); | 121 DCHECK(render_pass->quad_list.front()); |
118 const RenderPassDrawQuad* quad = | 122 const RenderPassDrawQuad* quad = |
119 RenderPassDrawQuad::MaterialCast(render_pass->quad_list.front()); | 123 RenderPassDrawQuad::MaterialCast(render_pass->quad_list.front()); |
120 EXPECT_EQ(gfx::RectF(0, 0, 1, 1), quad->mask_uv_rect); | 124 EXPECT_EQ(gfx::RectF(0, 0, 1, 1), quad->mask_uv_rect); |
121 EXPECT_EQ(gfx::Vector2dF(2.f, 2.f), quad->filters_scale); | 125 EXPECT_EQ(gfx::Vector2dF(2.f, 2.f), quad->filters_scale); |
122 } | 126 } |
123 | 127 |
124 } // namespace | 128 } // namespace |
125 } // namespace cc | 129 } // namespace cc |
OLD | NEW |