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" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 // Verify quad rects | 54 // Verify quad rects |
55 const QuadList& quads = render_pass->quad_list; | 55 const QuadList& quads = render_pass->quad_list; |
56 EXPECT_EQ(expected_quad_size, quads.size()); | 56 EXPECT_EQ(expected_quad_size, quads.size()); |
57 } | 57 } |
58 | 58 |
59 TEST(UIResourceLayerImplTest, VerifyDrawQuads) { | 59 TEST(UIResourceLayerImplTest, VerifyDrawQuads) { |
60 FakeImplProxy proxy; | 60 FakeImplProxy proxy; |
61 TestSharedBitmapManager shared_bitmap_manager; | 61 TestSharedBitmapManager shared_bitmap_manager; |
62 TestTaskGraphRunner task_graph_runner; | 62 TestTaskGraphRunner task_graph_runner; |
| 63 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
63 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 64 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
64 &task_graph_runner); | 65 &task_graph_runner); |
65 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); | 66 host_impl.InitializeRenderer(output_surface.get()); |
66 | 67 |
67 // Make sure we're appending quads when there are valid values. | 68 // Make sure we're appending quads when there are valid values. |
68 gfx::Size bitmap_size(100, 100); | 69 gfx::Size bitmap_size(100, 100); |
69 gfx::Size layer_size(100, 100);; | 70 gfx::Size layer_size(100, 100);; |
70 size_t expected_quad_size = 1; | 71 size_t expected_quad_size = 1; |
71 bool opaque = true; | 72 bool opaque = true; |
72 UIResourceId uid = 1; | 73 UIResourceId uid = 1; |
73 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, | 74 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, |
74 bitmap_size, | 75 bitmap_size, |
75 layer_size, | 76 layer_size, |
(...skipping 23 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 FakeImplProxy proxy; | 107 FakeImplProxy proxy; |
107 TestSharedBitmapManager shared_bitmap_manager; | 108 TestSharedBitmapManager shared_bitmap_manager; |
108 TestTaskGraphRunner task_graph_runner; | 109 TestTaskGraphRunner task_graph_runner; |
| 110 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
109 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 111 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
110 &task_graph_runner); | 112 &task_graph_runner); |
111 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); | 113 host_impl.InitializeRenderer(output_surface.get()); |
112 | 114 |
113 gfx::Size bitmap_size(100, 100); | 115 gfx::Size bitmap_size(100, 100); |
114 gfx::Size layer_size(100, 100);; | 116 gfx::Size layer_size(100, 100);; |
115 bool opaque = false; | 117 bool opaque = false; |
116 UIResourceId uid = 1; | 118 UIResourceId uid = 1; |
117 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, | 119 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, |
118 bitmap_size, | 120 bitmap_size, |
119 layer_size, | 121 layer_size, |
120 opaque, | 122 opaque, |
121 uid); | 123 uid); |
122 gfx::Rect expected_opaque_bounds; | 124 gfx::Rect expected_opaque_bounds; |
123 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); | 125 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); |
124 | 126 |
125 opaque = true; | 127 opaque = true; |
126 layer = GenerateUIResourceLayer(&host_impl, | 128 layer = GenerateUIResourceLayer(&host_impl, |
127 bitmap_size, | 129 bitmap_size, |
128 layer_size, | 130 layer_size, |
129 opaque, | 131 opaque, |
130 uid); | 132 uid); |
131 expected_opaque_bounds = gfx::Rect(layer->bounds()); | 133 expected_opaque_bounds = gfx::Rect(layer->bounds()); |
132 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); | 134 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); |
133 } | 135 } |
134 | 136 |
135 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { | 137 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { |
136 FakeImplProxy proxy; | 138 FakeImplProxy proxy; |
137 TestSharedBitmapManager shared_bitmap_manager; | 139 TestSharedBitmapManager shared_bitmap_manager; |
138 TestTaskGraphRunner task_graph_runner; | 140 TestTaskGraphRunner task_graph_runner; |
| 141 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
139 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 142 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, |
140 &task_graph_runner); | 143 &task_graph_runner); |
141 host_impl.InitializeRenderer(FakeOutputSurface::Create3d()); | 144 host_impl.InitializeRenderer(output_surface.get()); |
142 | 145 |
143 gfx::Size bitmap_size(100, 100); | 146 gfx::Size bitmap_size(100, 100); |
144 gfx::Size layer_size(100, 100); | 147 gfx::Size layer_size(100, 100); |
145 bool skbitmap_opaque = false; | 148 bool skbitmap_opaque = false; |
146 UIResourceId uid = 1; | 149 UIResourceId uid = 1; |
147 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( | 150 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( |
148 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid); | 151 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid); |
149 layer->SetContentsOpaque(false); | 152 layer->SetContentsOpaque(false); |
150 gfx::Rect expected_opaque_bounds; | 153 gfx::Rect expected_opaque_bounds; |
151 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); | 154 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 LayerTestCommon::VerifyQuadsAreOccluded( | 209 LayerTestCommon::VerifyQuadsAreOccluded( |
207 impl.quad_list(), occluded, &partially_occluded_count); | 210 impl.quad_list(), occluded, &partially_occluded_count); |
208 // The layer outputs one quad, which is partially occluded. | 211 // The layer outputs one quad, which is partially occluded. |
209 EXPECT_EQ(1u, impl.quad_list().size()); | 212 EXPECT_EQ(1u, impl.quad_list().size()); |
210 EXPECT_EQ(1u, partially_occluded_count); | 213 EXPECT_EQ(1u, partially_occluded_count); |
211 } | 214 } |
212 } | 215 } |
213 | 216 |
214 } // namespace | 217 } // namespace |
215 } // namespace cc | 218 } // namespace cc |
OLD | NEW |