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/picture_image_layer_impl.h" | 5 #include "cc/layers/picture_image_layer_impl.h" |
6 | 6 |
7 #include "base/thread_task_runner_handle.h" | 7 #include "base/thread_task_runner_handle.h" |
8 #include "cc/layers/append_quads_data.h" | 8 #include "cc/layers/append_quads_data.h" |
9 #include "cc/quads/draw_quad.h" | 9 #include "cc/quads/draw_quad.h" |
10 #include "cc/test/fake_impl_proxy.h" | 10 #include "cc/test/fake_impl_proxy.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 public: | 36 public: |
37 PictureLayerImplImageTestSettings() { | 37 PictureLayerImplImageTestSettings() { |
38 layer_transforms_should_scale_layer_contents = true; | 38 layer_transforms_should_scale_layer_contents = true; |
39 } | 39 } |
40 }; | 40 }; |
41 | 41 |
42 class PictureImageLayerImplTest : public testing::Test { | 42 class PictureImageLayerImplTest : public testing::Test { |
43 public: | 43 public: |
44 PictureImageLayerImplTest() | 44 PictureImageLayerImplTest() |
45 : proxy_(base::ThreadTaskRunnerHandle::Get()), | 45 : proxy_(base::ThreadTaskRunnerHandle::Get()), |
| 46 output_surface_(FakeOutputSurface::Create3d()), |
46 host_impl_(PictureLayerImplImageTestSettings(), | 47 host_impl_(PictureLayerImplImageTestSettings(), |
47 &proxy_, | 48 &proxy_, |
48 &shared_bitmap_manager_, | 49 &shared_bitmap_manager_, |
49 &task_graph_runner_) { | 50 &task_graph_runner_) { |
50 host_impl_.CreatePendingTree(); | 51 host_impl_.CreatePendingTree(); |
51 host_impl_.InitializeRenderer(FakeOutputSurface::Create3d()); | 52 host_impl_.InitializeRenderer(output_surface_.get()); |
52 } | 53 } |
53 | 54 |
54 scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id, | 55 scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id, |
55 WhichTree which_tree) { | 56 WhichTree which_tree) { |
56 LayerTreeImpl* tree = nullptr; | 57 LayerTreeImpl* tree = nullptr; |
57 switch (which_tree) { | 58 switch (which_tree) { |
58 case ACTIVE_TREE: | 59 case ACTIVE_TREE: |
59 tree = host_impl_.active_tree(); | 60 tree = host_impl_.active_tree(); |
60 break; | 61 break; |
61 case PENDING_TREE: | 62 case PENDING_TREE: |
(...skipping 24 matching lines...) Expand all Loading... |
86 animating_transform_to_screen; | 87 animating_transform_to_screen; |
87 layer->draw_properties().visible_layer_rect = viewport_rect; | 88 layer->draw_properties().visible_layer_rect = viewport_rect; |
88 bool resourceless_software_draw = false; | 89 bool resourceless_software_draw = false; |
89 layer->UpdateTiles(resourceless_software_draw); | 90 layer->UpdateTiles(resourceless_software_draw); |
90 } | 91 } |
91 | 92 |
92 protected: | 93 protected: |
93 FakeImplProxy proxy_; | 94 FakeImplProxy proxy_; |
94 TestSharedBitmapManager shared_bitmap_manager_; | 95 TestSharedBitmapManager shared_bitmap_manager_; |
95 TestTaskGraphRunner task_graph_runner_; | 96 TestTaskGraphRunner task_graph_runner_; |
| 97 scoped_ptr<OutputSurface> output_surface_; |
96 FakeLayerTreeHostImpl host_impl_; | 98 FakeLayerTreeHostImpl host_impl_; |
97 }; | 99 }; |
98 | 100 |
99 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { | 101 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { |
100 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); | 102 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); |
101 layer->SetDrawsContent(true); | 103 layer->SetDrawsContent(true); |
102 | 104 |
103 gfx::Rect viewport(100, 200); | 105 gfx::Rect viewport(100, 200); |
104 SetupDrawPropertiesAndUpdateTiles( | 106 SetupDrawPropertiesAndUpdateTiles( |
105 layer.get(), 2.f, 3.f, 4.f, 1.f, false, viewport); | 107 layer.get(), 2.f, 3.f, 4.f, 1.f, false, viewport); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 active_layer->DidDraw(nullptr); | 159 active_layer->DidDraw(nullptr); |
158 | 160 |
159 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); | 161 EXPECT_EQ(DrawQuad::TILED_CONTENT, render_pass->quad_list.front()->material); |
160 | 162 |
161 // Tiles are ready at correct scale, so should not set had_incomplete_tile. | 163 // Tiles are ready at correct scale, so should not set had_incomplete_tile. |
162 EXPECT_EQ(0, data.num_incomplete_tiles); | 164 EXPECT_EQ(0, data.num_incomplete_tiles); |
163 } | 165 } |
164 | 166 |
165 } // namespace | 167 } // namespace |
166 } // namespace cc | 168 } // namespace cc |
OLD | NEW |