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