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 "cc/layers/append_quads_data.h" | 7 #include "cc/layers/append_quads_data.h" |
8 #include "cc/resources/tile_priority.h" | 8 #include "cc/resources/tile_priority.h" |
9 #include "cc/test/fake_impl_proxy.h" | 9 #include "cc/test/fake_impl_proxy.h" |
10 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
11 #include "cc/test/fake_output_surface.h" | 11 #include "cc/test/fake_output_surface.h" |
12 #include "cc/test/fake_picture_layer_tiling_client.h" | 12 #include "cc/test/fake_picture_layer_tiling_client.h" |
13 #include "cc/test/impl_side_painting_settings.h" | 13 #include "cc/test/impl_side_painting_settings.h" |
14 #include "cc/test/mock_quad_culler.h" | 14 #include "cc/test/mock_quad_culler.h" |
| 15 #include "cc/test/test_shared_bitmap_manager.h" |
15 #include "cc/trees/layer_tree_impl.h" | 16 #include "cc/trees/layer_tree_impl.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 namespace { | 20 namespace { |
20 | 21 |
21 class TestablePictureImageLayerImpl : public PictureImageLayerImpl { | 22 class TestablePictureImageLayerImpl : public PictureImageLayerImpl { |
22 public: | 23 public: |
23 TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id) | 24 TestablePictureImageLayerImpl(LayerTreeImpl* tree_impl, int id) |
24 : PictureImageLayerImpl(tree_impl, id) { | 25 : PictureImageLayerImpl(tree_impl, id) { |
25 } | 26 } |
26 | 27 |
27 PictureLayerTilingSet* tilings() { return tilings_.get(); } | 28 PictureLayerTilingSet* tilings() { return tilings_.get(); } |
28 | 29 |
29 friend class PictureImageLayerImplTest; | 30 friend class PictureImageLayerImplTest; |
30 }; | 31 }; |
31 | 32 |
32 class PictureImageLayerImplTest : public testing::Test { | 33 class PictureImageLayerImplTest : public testing::Test { |
33 public: | 34 public: |
34 PictureImageLayerImplTest() | 35 PictureImageLayerImplTest() |
35 : proxy_(base::MessageLoopProxy::current()), | 36 : proxy_(base::MessageLoopProxy::current()), |
36 host_impl_(ImplSidePaintingSettings(), &proxy_) { | 37 host_impl_(ImplSidePaintingSettings(), |
| 38 &proxy_, |
| 39 &shared_bitmap_manager_) { |
37 tiling_client_.SetTileSize(ImplSidePaintingSettings().default_tile_size); | 40 tiling_client_.SetTileSize(ImplSidePaintingSettings().default_tile_size); |
38 host_impl_.CreatePendingTree(); | 41 host_impl_.CreatePendingTree(); |
39 host_impl_.InitializeRenderer( | 42 host_impl_.InitializeRenderer( |
40 FakeOutputSurface::Create3d().PassAs<OutputSurface>()); | 43 FakeOutputSurface::Create3d().PassAs<OutputSurface>()); |
41 } | 44 } |
42 | 45 |
43 scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id, | 46 scoped_ptr<TestablePictureImageLayerImpl> CreateLayer(int id, |
44 WhichTree which_tree) { | 47 WhichTree which_tree) { |
45 LayerTreeImpl* tree = NULL; | 48 LayerTreeImpl* tree = NULL; |
46 switch (which_tree) { | 49 switch (which_tree) { |
(...skipping 16 matching lines...) Expand all Loading... |
63 return make_scoped_ptr(layer); | 66 return make_scoped_ptr(layer); |
64 } | 67 } |
65 | 68 |
66 void UpdateDrawProperties() { | 69 void UpdateDrawProperties() { |
67 host_impl_.pending_tree()->UpdateDrawProperties(); | 70 host_impl_.pending_tree()->UpdateDrawProperties(); |
68 } | 71 } |
69 | 72 |
70 protected: | 73 protected: |
71 FakeImplProxy proxy_; | 74 FakeImplProxy proxy_; |
72 FakeLayerTreeHostImpl host_impl_; | 75 FakeLayerTreeHostImpl host_impl_; |
| 76 TestSharedBitmapManager shared_bitmap_manager_; |
73 FakePictureLayerTilingClient tiling_client_; | 77 FakePictureLayerTilingClient tiling_client_; |
74 }; | 78 }; |
75 | 79 |
76 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { | 80 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { |
77 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); | 81 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); |
78 layer->SetDrawsContent(true); | 82 layer->SetDrawsContent(true); |
79 | 83 |
80 float contents_scale_x; | 84 float contents_scale_x; |
81 float contents_scale_y; | 85 float contents_scale_y; |
82 gfx::Size content_bounds; | 86 gfx::Size content_bounds; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 active_layer->DidDraw(NULL); | 161 active_layer->DidDraw(NULL); |
158 | 162 |
159 EXPECT_EQ(DrawQuad::TILED_CONTENT, quad_culler.quad_list()[0]->material); | 163 EXPECT_EQ(DrawQuad::TILED_CONTENT, quad_culler.quad_list()[0]->material); |
160 | 164 |
161 // Tiles are ready at correct scale, so should not set had_incomplete_tile. | 165 // Tiles are ready at correct scale, so should not set had_incomplete_tile. |
162 EXPECT_FALSE(data.had_incomplete_tile); | 166 EXPECT_FALSE(data.had_incomplete_tile); |
163 } | 167 } |
164 | 168 |
165 } // namespace | 169 } // namespace |
166 } // namespace cc | 170 } // namespace cc |
OLD | NEW |