OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/append_quads_data.h" | 5 #include "cc/layers/append_quads_data.h" |
6 #include "cc/layers/ui_resource_layer_impl.h" | 6 #include "cc/layers/ui_resource_layer_impl.h" |
7 #include "cc/quads/draw_quad.h" | 7 #include "cc/quads/draw_quad.h" |
8 #include "cc/resources/ui_resource_bitmap.h" | 8 #include "cc/resources/ui_resource_bitmap.h" |
9 #include "cc/resources/ui_resource_client.h" | 9 #include "cc/resources/ui_resource_client.h" |
10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
11 #include "cc/test/fake_layer_tree_host_impl.h" | 11 #include "cc/test/fake_layer_tree_host_impl.h" |
12 #include "cc/test/fake_output_surface.h" | 12 #include "cc/test/fake_output_surface.h" |
13 #include "cc/test/fake_ui_resource_layer_tree_host_impl.h" | 13 #include "cc/test/fake_ui_resource_layer_tree_host_impl.h" |
14 #include "cc/test/layer_test_common.h" | 14 #include "cc/test/layer_test_common.h" |
15 #include "cc/test/test_shared_bitmap_manager.h" | 15 #include "cc/test/test_shared_bitmap_manager.h" |
| 16 #include "cc/test/test_task_graph_runner.h" |
16 #include "cc/trees/single_thread_proxy.h" | 17 #include "cc/trees/single_thread_proxy.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
20 | 21 |
21 namespace cc { | 22 namespace cc { |
22 namespace { | 23 namespace { |
23 | 24 |
24 scoped_ptr<UIResourceLayerImpl> GenerateUIResourceLayer( | 25 scoped_ptr<UIResourceLayerImpl> GenerateUIResourceLayer( |
25 FakeUIResourceLayerTreeHostImpl* host_impl, | 26 FakeUIResourceLayerTreeHostImpl* host_impl, |
(...skipping 26 matching lines...) Expand all Loading... |
52 layer->AppendQuads(render_pass.get(), &data); | 53 layer->AppendQuads(render_pass.get(), &data); |
53 | 54 |
54 // Verify quad rects | 55 // Verify quad rects |
55 const QuadList& quads = render_pass->quad_list; | 56 const QuadList& quads = render_pass->quad_list; |
56 EXPECT_EQ(expected_quad_size, quads.size()); | 57 EXPECT_EQ(expected_quad_size, quads.size()); |
57 } | 58 } |
58 | 59 |
59 TEST(UIResourceLayerImplTest, VerifyDrawQuads) { | 60 TEST(UIResourceLayerImplTest, VerifyDrawQuads) { |
60 FakeImplProxy proxy; | 61 FakeImplProxy proxy; |
61 TestSharedBitmapManager shared_bitmap_manager; | 62 TestSharedBitmapManager shared_bitmap_manager; |
62 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 63 TestTaskGraphRunner task_graph_runner; |
| 64 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 65 &task_graph_runner); |
63 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); | 66 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); |
64 | 67 |
65 // Make sure we're appending quads when there are valid values. | 68 // Make sure we're appending quads when there are valid values. |
66 gfx::Size bitmap_size(100, 100); | 69 gfx::Size bitmap_size(100, 100); |
67 gfx::Size layer_size(100, 100);; | 70 gfx::Size layer_size(100, 100);; |
68 size_t expected_quad_size = 1; | 71 size_t expected_quad_size = 1; |
69 bool opaque = true; | 72 bool opaque = true; |
70 UIResourceId uid = 1; | 73 UIResourceId uid = 1; |
71 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, | 74 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, |
72 bitmap_size, | 75 bitmap_size, |
(...skipping 23 matching lines...) Expand all Loading... |
96 // Verify quad rects | 99 // Verify quad rects |
97 const QuadList& quads = render_pass->quad_list; | 100 const QuadList& quads = render_pass->quad_list; |
98 EXPECT_GE(quads.size(), (size_t)0); | 101 EXPECT_GE(quads.size(), (size_t)0); |
99 gfx::Rect opaque_rect = quads.front()->opaque_rect; | 102 gfx::Rect opaque_rect = quads.front()->opaque_rect; |
100 EXPECT_EQ(expected_opaque_bounds, opaque_rect); | 103 EXPECT_EQ(expected_opaque_bounds, opaque_rect); |
101 } | 104 } |
102 | 105 |
103 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnSkBitmap) { | 106 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnSkBitmap) { |
104 FakeImplProxy proxy; | 107 FakeImplProxy proxy; |
105 TestSharedBitmapManager shared_bitmap_manager; | 108 TestSharedBitmapManager shared_bitmap_manager; |
106 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 109 TestTaskGraphRunner task_graph_runner; |
| 110 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 111 &task_graph_runner); |
107 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); | 112 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); |
108 | 113 |
109 gfx::Size bitmap_size(100, 100); | 114 gfx::Size bitmap_size(100, 100); |
110 gfx::Size layer_size(100, 100);; | 115 gfx::Size layer_size(100, 100);; |
111 bool opaque = false; | 116 bool opaque = false; |
112 UIResourceId uid = 1; | 117 UIResourceId uid = 1; |
113 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, | 118 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, |
114 bitmap_size, | 119 bitmap_size, |
115 layer_size, | 120 layer_size, |
116 opaque, | 121 opaque, |
117 uid); | 122 uid); |
118 gfx::Rect expected_opaque_bounds; | 123 gfx::Rect expected_opaque_bounds; |
119 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); | 124 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); |
120 | 125 |
121 opaque = true; | 126 opaque = true; |
122 layer = GenerateUIResourceLayer(&host_impl, | 127 layer = GenerateUIResourceLayer(&host_impl, |
123 bitmap_size, | 128 bitmap_size, |
124 layer_size, | 129 layer_size, |
125 opaque, | 130 opaque, |
126 uid); | 131 uid); |
127 expected_opaque_bounds = gfx::Rect(layer->bounds()); | 132 expected_opaque_bounds = gfx::Rect(layer->bounds()); |
128 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); | 133 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); |
129 } | 134 } |
130 | 135 |
131 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { | 136 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { |
132 FakeImplProxy proxy; | 137 FakeImplProxy proxy; |
133 TestSharedBitmapManager shared_bitmap_manager; | 138 TestSharedBitmapManager shared_bitmap_manager; |
134 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager); | 139 TestTaskGraphRunner task_graph_runner; |
| 140 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
| 141 &task_graph_runner); |
135 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); | 142 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); |
136 | 143 |
137 gfx::Size bitmap_size(100, 100); | 144 gfx::Size bitmap_size(100, 100); |
138 gfx::Size layer_size(100, 100); | 145 gfx::Size layer_size(100, 100); |
139 bool skbitmap_opaque = false; | 146 bool skbitmap_opaque = false; |
140 UIResourceId uid = 1; | 147 UIResourceId uid = 1; |
141 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( | 148 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( |
142 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid); | 149 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid); |
143 layer->SetContentsOpaque(false); | 150 layer->SetContentsOpaque(false); |
144 gfx::Rect expected_opaque_bounds; | 151 gfx::Rect expected_opaque_bounds; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 LayerTestCommon::VerifyQuadsAreOccluded( | 208 LayerTestCommon::VerifyQuadsAreOccluded( |
202 impl.quad_list(), occluded, &partially_occluded_count); | 209 impl.quad_list(), occluded, &partially_occluded_count); |
203 // The layer outputs one quad, which is partially occluded. | 210 // The layer outputs one quad, which is partially occluded. |
204 EXPECT_EQ(1u, impl.quad_list().size()); | 211 EXPECT_EQ(1u, impl.quad_list().size()); |
205 EXPECT_EQ(1u, partially_occluded_count); | 212 EXPECT_EQ(1u, partially_occluded_count); |
206 } | 213 } |
207 } | 214 } |
208 | 215 |
209 } // namespace | 216 } // namespace |
210 } // namespace cc | 217 } // namespace cc |
OLD | NEW |