| 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_task_runner_provider.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/test/test_task_graph_runner.h" |
| 17 #include "cc/trees/single_thread_proxy.h" | 17 #include "cc/trees/single_thread_proxy.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include "ui/gfx/transform.h" | 20 #include "ui/gfx/transform.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 | 50 |
| 51 AppendQuadsData data; | 51 AppendQuadsData data; |
| 52 layer->AppendQuads(render_pass.get(), &data); | 52 layer->AppendQuads(render_pass.get(), &data); |
| 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 FakeImplTaskRunnerProvider task_runner_provider; |
| 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 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 64 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 64 FakeUIResourceLayerTreeHostImpl host_impl( |
| 65 &task_graph_runner); | 65 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); |
| 66 host_impl.SetVisible(true); | 66 host_impl.SetVisible(true); |
| 67 host_impl.InitializeRenderer(output_surface.get()); | 67 host_impl.InitializeRenderer(output_surface.get()); |
| 68 | 68 |
| 69 // Make sure we're appending quads when there are valid values. | 69 // Make sure we're appending quads when there are valid values. |
| 70 gfx::Size bitmap_size(100, 100); | 70 gfx::Size bitmap_size(100, 100); |
| 71 gfx::Size layer_size(100, 100);; | 71 gfx::Size layer_size(100, 100);; |
| 72 size_t expected_quad_size = 1; | 72 size_t expected_quad_size = 1; |
| 73 bool opaque = true; | 73 bool opaque = true; |
| 74 UIResourceId uid = 1; | 74 UIResourceId uid = 1; |
| 75 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, | 75 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 98 layer->AppendQuads(render_pass.get(), &data); | 98 layer->AppendQuads(render_pass.get(), &data); |
| 99 | 99 |
| 100 // Verify quad rects | 100 // Verify quad rects |
| 101 const QuadList& quads = render_pass->quad_list; | 101 const QuadList& quads = render_pass->quad_list; |
| 102 EXPECT_GE(quads.size(), (size_t)0); | 102 EXPECT_GE(quads.size(), (size_t)0); |
| 103 gfx::Rect opaque_rect = quads.front()->opaque_rect; | 103 gfx::Rect opaque_rect = quads.front()->opaque_rect; |
| 104 EXPECT_EQ(expected_opaque_bounds, opaque_rect); | 104 EXPECT_EQ(expected_opaque_bounds, opaque_rect); |
| 105 } | 105 } |
| 106 | 106 |
| 107 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnSkBitmap) { | 107 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnSkBitmap) { |
| 108 FakeImplProxy proxy; | 108 FakeImplTaskRunnerProvider task_runner_provider; |
| 109 TestSharedBitmapManager shared_bitmap_manager; | 109 TestSharedBitmapManager shared_bitmap_manager; |
| 110 TestTaskGraphRunner task_graph_runner; | 110 TestTaskGraphRunner task_graph_runner; |
| 111 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 111 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 112 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 112 FakeUIResourceLayerTreeHostImpl host_impl( |
| 113 &task_graph_runner); | 113 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); |
| 114 host_impl.SetVisible(true); | 114 host_impl.SetVisible(true); |
| 115 host_impl.InitializeRenderer(output_surface.get()); | 115 host_impl.InitializeRenderer(output_surface.get()); |
| 116 | 116 |
| 117 gfx::Size bitmap_size(100, 100); | 117 gfx::Size bitmap_size(100, 100); |
| 118 gfx::Size layer_size(100, 100);; | 118 gfx::Size layer_size(100, 100);; |
| 119 bool opaque = false; | 119 bool opaque = false; |
| 120 UIResourceId uid = 1; | 120 UIResourceId uid = 1; |
| 121 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, | 121 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer(&host_impl, |
| 122 bitmap_size, | 122 bitmap_size, |
| 123 layer_size, | 123 layer_size, |
| 124 opaque, | 124 opaque, |
| 125 uid); | 125 uid); |
| 126 gfx::Rect expected_opaque_bounds; | 126 gfx::Rect expected_opaque_bounds; |
| 127 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); | 127 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); |
| 128 | 128 |
| 129 opaque = true; | 129 opaque = true; |
| 130 layer = GenerateUIResourceLayer(&host_impl, | 130 layer = GenerateUIResourceLayer(&host_impl, |
| 131 bitmap_size, | 131 bitmap_size, |
| 132 layer_size, | 132 layer_size, |
| 133 opaque, | 133 opaque, |
| 134 uid); | 134 uid); |
| 135 expected_opaque_bounds = gfx::Rect(layer->bounds()); | 135 expected_opaque_bounds = gfx::Rect(layer->bounds()); |
| 136 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); | 136 OpaqueBoundsTest(layer.Pass(), expected_opaque_bounds); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { | 139 TEST(UIResourceLayerImplTest, VerifySetOpaqueOnLayer) { |
| 140 FakeImplProxy proxy; | 140 FakeImplTaskRunnerProvider task_runner_provider; |
| 141 TestSharedBitmapManager shared_bitmap_manager; | 141 TestSharedBitmapManager shared_bitmap_manager; |
| 142 TestTaskGraphRunner task_graph_runner; | 142 TestTaskGraphRunner task_graph_runner; |
| 143 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); | 143 scoped_ptr<OutputSurface> output_surface = FakeOutputSurface::Create3d(); |
| 144 FakeUIResourceLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager, | 144 FakeUIResourceLayerTreeHostImpl host_impl( |
| 145 &task_graph_runner); | 145 &task_runner_provider, &shared_bitmap_manager, &task_graph_runner); |
| 146 host_impl.SetVisible(true); | 146 host_impl.SetVisible(true); |
| 147 host_impl.InitializeRenderer(output_surface.get()); | 147 host_impl.InitializeRenderer(output_surface.get()); |
| 148 | 148 |
| 149 gfx::Size bitmap_size(100, 100); | 149 gfx::Size bitmap_size(100, 100); |
| 150 gfx::Size layer_size(100, 100); | 150 gfx::Size layer_size(100, 100); |
| 151 bool skbitmap_opaque = false; | 151 bool skbitmap_opaque = false; |
| 152 UIResourceId uid = 1; | 152 UIResourceId uid = 1; |
| 153 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( | 153 scoped_ptr<UIResourceLayerImpl> layer = GenerateUIResourceLayer( |
| 154 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid); | 154 &host_impl, bitmap_size, layer_size, skbitmap_opaque, uid); |
| 155 layer->SetContentsOpaque(false); | 155 layer->SetContentsOpaque(false); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 LayerTestCommon::VerifyQuadsAreOccluded( | 212 LayerTestCommon::VerifyQuadsAreOccluded( |
| 213 impl.quad_list(), occluded, &partially_occluded_count); | 213 impl.quad_list(), occluded, &partially_occluded_count); |
| 214 // The layer outputs one quad, which is partially occluded. | 214 // The layer outputs one quad, which is partially occluded. |
| 215 EXPECT_EQ(1u, impl.quad_list().size()); | 215 EXPECT_EQ(1u, impl.quad_list().size()); |
| 216 EXPECT_EQ(1u, partially_occluded_count); | 216 EXPECT_EQ(1u, partially_occluded_count); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace | 220 } // namespace |
| 221 } // namespace cc | 221 } // namespace cc |
| OLD | NEW |