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