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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "cc/layers/append_quads_data.h" | 7 #include "cc/layers/append_quads_data.h" |
8 #include "cc/layers/ui_resource_layer_impl.h" | 8 #include "cc/layers/ui_resource_layer_impl.h" |
9 #include "cc/quads/draw_quad.h" | 9 #include "cc/quads/draw_quad.h" |
10 #include "cc/resources/ui_resource_bitmap.h" | 10 #include "cc/resources/ui_resource_bitmap.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 // Verify quad rects | 55 // Verify quad rects |
56 const QuadList& quads = render_pass->quad_list; | 56 const QuadList& quads = render_pass->quad_list; |
57 EXPECT_EQ(expected_quad_size, quads.size()); | 57 EXPECT_EQ(expected_quad_size, quads.size()); |
58 } | 58 } |
59 | 59 |
60 TEST(UIResourceLayerImplTest, VerifyDrawQuads) { | 60 TEST(UIResourceLayerImplTest, VerifyDrawQuads) { |
61 FakeImplTaskRunnerProvider task_runner_provider; | 61 FakeImplTaskRunnerProvider task_runner_provider; |
62 TestSharedBitmapManager shared_bitmap_manager; | 62 TestSharedBitmapManager shared_bitmap_manager; |
63 TestTaskGraphRunner task_graph_runner; | 63 TestTaskGraphRunner task_graph_runner; |
64 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 64 std::unique_ptr<OutputSurface> output_surface = |
| 65 FakeOutputSurface::CreateDelegating3d(); |
65 FakeUIResourceLayerTreeHostImpl host_impl( | 66 FakeUIResourceLayerTreeHostImpl host_impl( |
66 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); | 67 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); |
67 host_impl.SetVisible(true); | 68 host_impl.SetVisible(true); |
68 host_impl.InitializeRenderer(output_surface.get()); | 69 host_impl.InitializeRenderer(output_surface.get()); |
69 | 70 |
70 // Make sure we're appending quads when there are valid values. | 71 // Make sure we're appending quads when there are valid values. |
71 gfx::Size bitmap_size(100, 100); | 72 gfx::Size bitmap_size(100, 100); |
72 gfx::Size layer_size(100, 100); | 73 gfx::Size layer_size(100, 100); |
73 size_t expected_quad_size = 1; | 74 size_t expected_quad_size = 1; |
74 bool opaque = true; | 75 bool opaque = true; |
(...skipping 24 matching lines...) Expand all Loading... |
99 const QuadList& quads = render_pass->quad_list; | 100 const QuadList& quads = render_pass->quad_list; |
100 EXPECT_GE(quads.size(), (size_t)0); | 101 EXPECT_GE(quads.size(), (size_t)0); |
101 gfx::Rect opaque_rect = quads.front()->opaque_rect; | 102 gfx::Rect opaque_rect = quads.front()->opaque_rect; |
102 EXPECT_EQ(expected_opaque_bounds, opaque_rect); | 103 EXPECT_EQ(expected_opaque_bounds, opaque_rect); |
103 } | 104 } |
104 | 105 |
105 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnSkBitmap) { | 106 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnSkBitmap) { |
106 FakeImplTaskRunnerProvider task_runner_provider; | 107 FakeImplTaskRunnerProvider task_runner_provider; |
107 TestSharedBitmapManager shared_bitmap_manager; | 108 TestSharedBitmapManager shared_bitmap_manager; |
108 TestTaskGraphRunner task_graph_runner; | 109 TestTaskGraphRunner task_graph_runner; |
109 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 110 std::unique_ptr<OutputSurface> output_surface = |
| 111 FakeOutputSurface::CreateDelegating3d(); |
110 FakeUIResourceLayerTreeHostImpl host_impl( | 112 FakeUIResourceLayerTreeHostImpl host_impl( |
111 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); | 113 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); |
112 host_impl.SetVisible(true); | 114 host_impl.SetVisible(true); |
113 host_impl.InitializeRenderer(output_surface.get()); | 115 host_impl.InitializeRenderer(output_surface.get()); |
114 | 116 |
115 gfx::Size bitmap_size(100, 100); | 117 gfx::Size bitmap_size(100, 100); |
116 gfx::Size layer_size(100, 100); | 118 gfx::Size layer_size(100, 100); |
117 bool opaque = false; | 119 bool opaque = false; |
118 UIResourceId uid = 1; | 120 UIResourceId uid = 1; |
119 std::unique_ptr<UIResourceLayerImpl> layer = | 121 std::unique_ptr<UIResourceLayerImpl> layer = |
120 GenerateUIResourceLayer(&host_impl, bitmap_size, layer_size, opaque, uid); | 122 GenerateUIResourceLayer(&host_impl, bitmap_size, layer_size, opaque, uid); |
121 gfx::Rect expected_opaque_bounds; | 123 gfx::Rect expected_opaque_bounds; |
122 OpaqueBoundsTest(std::move(layer), expected_opaque_bounds); | 124 OpaqueBoundsTest(std::move(layer), expected_opaque_bounds); |
123 | 125 |
124 opaque = true; | 126 opaque = true; |
125 layer = GenerateUIResourceLayer(&host_impl, | 127 layer = GenerateUIResourceLayer(&host_impl, |
126 bitmap_size, | 128 bitmap_size, |
127 layer_size, | 129 layer_size, |
128 opaque, | 130 opaque, |
129 uid); | 131 uid); |
130 expected_opaque_bounds = gfx::Rect(layer->bounds()); | 132 expected_opaque_bounds = gfx::Rect(layer->bounds()); |
131 OpaqueBoundsTest(std::move(layer), expected_opaque_bounds); | 133 OpaqueBoundsTest(std::move(layer), expected_opaque_bounds); |
132 } | 134 } |
133 | 135 |
134 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { | 136 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { |
135 FakeImplTaskRunnerProvider task_runner_provider; | 137 FakeImplTaskRunnerProvider task_runner_provider; |
136 TestSharedBitmapManager shared_bitmap_manager; | 138 TestSharedBitmapManager shared_bitmap_manager; |
137 TestTaskGraphRunner task_graph_runner; | 139 TestTaskGraphRunner task_graph_runner; |
138 std::unique_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 140 std::unique_ptr<OutputSurface> output_surface = |
| 141 FakeOutputSurface::CreateDelegating3d(); |
139 FakeUIResourceLayerTreeHostImpl host_impl( | 142 FakeUIResourceLayerTreeHostImpl host_impl( |
140 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); | 143 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); |
141 host_impl.SetVisible(true); | 144 host_impl.SetVisible(true); |
142 host_impl.InitializeRenderer(output_surface.get()); | 145 host_impl.InitializeRenderer(output_surface.get()); |
143 | 146 |
144 gfx::Size bitmap_size(100, 100); | 147 gfx::Size bitmap_size(100, 100); |
145 gfx::Size layer_size(100, 100); | 148 gfx::Size layer_size(100, 100); |
146 bool skbitmap_opaque = false; | 149 bool skbitmap_opaque = false; |
147 UIResourceId uid = 1; | 150 UIResourceId uid = 1; |
148 std::unique_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( | 151 std::unique_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 LayerTestCommon::VerifyQuadsAreOccluded( | 210 LayerTestCommon::VerifyQuadsAreOccluded( |
208 impl.quad_list(), occluded, &partially_occluded_count); | 211 impl.quad_list(), occluded, &partially_occluded_count); |
209 // The layer outputs one quad, which is partially occluded. | 212 // The layer outputs one quad, which is partially occluded. |
210 EXPECT_EQ(1u, impl.quad_list().size()); | 213 EXPECT_EQ(1u, impl.quad_list().size()); |
211 EXPECT_EQ(1u, partially_occluded_count); | 214 EXPECT_EQ(1u, partially_occluded_count); |
212 } | 215 } |
213 } | 216 } |
214 | 217 |
215 } // namespace | 218 } // namespace |
216 } // namespace cc | 219 } // namespace cc |
OLD | NEW |