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