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