Chromium Code Reviews| 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" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 } | 59 } |
| 60 TestablePictureImageLayerImpl* layer = | 60 TestablePictureImageLayerImpl* layer = |
| 61 new TestablePictureImageLayerImpl(tree, id); | 61 new TestablePictureImageLayerImpl(tree, id); |
| 62 layer->SetBounds(gfx::Size(100, 200)); | 62 layer->SetBounds(gfx::Size(100, 200)); |
| 63 layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_, | 63 layer->tilings_.reset(new PictureLayerTilingSet(&tiling_client_, |
| 64 layer->bounds())); | 64 layer->bounds())); |
| 65 layer->pile_ = tiling_client_.pile(); | 65 layer->pile_ = tiling_client_.pile(); |
| 66 return make_scoped_ptr(layer); | 66 return make_scoped_ptr(layer); |
| 67 } | 67 } |
| 68 | 68 |
| 69 void UpdateDrawProperties() { | |
| 70 host_impl_.pending_tree()->UpdateDrawProperties(); | |
| 71 } | |
| 72 | |
| 73 protected: | 69 protected: |
| 74 FakeImplProxy proxy_; | 70 FakeImplProxy proxy_; |
| 75 FakeLayerTreeHostImpl host_impl_; | 71 FakeLayerTreeHostImpl host_impl_; |
| 76 TestSharedBitmapManager shared_bitmap_manager_; | 72 TestSharedBitmapManager shared_bitmap_manager_; |
| 77 FakePictureLayerTilingClient tiling_client_; | 73 FakePictureLayerTilingClient tiling_client_; |
| 78 }; | 74 }; |
| 79 | 75 |
| 80 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { | 76 TEST_F(PictureImageLayerImplTest, CalculateContentsScale) { |
| 81 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); | 77 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); |
| 82 layer->SetDrawsContent(true); | 78 layer->SetDrawsContent(true); |
| 83 | 79 |
| 84 float contents_scale_x; | 80 float contents_scale_x; |
| 85 float contents_scale_y; | 81 float contents_scale_y; |
| 86 gfx::Size content_bounds; | 82 gfx::Size content_bounds; |
| 87 layer->CalculateContentsScale(2.f, | 83 layer->CalculateContentsScale(2.f, |
| 88 3.f, | 84 3.f, |
| 89 4.f, | 85 4.f, |
| 90 1.f, | 86 1.f, |
| 91 false, | 87 false, |
| 92 &contents_scale_x, | 88 &contents_scale_x, |
| 93 &contents_scale_y, | 89 &contents_scale_y, |
| 94 &content_bounds); | 90 &content_bounds); |
| 95 EXPECT_FLOAT_EQ(1.f, contents_scale_x); | 91 EXPECT_FLOAT_EQ(1.f, contents_scale_x); |
| 96 EXPECT_FLOAT_EQ(1.f, contents_scale_y); | 92 EXPECT_FLOAT_EQ(1.f, contents_scale_y); |
| 97 EXPECT_EQ(layer->bounds(), content_bounds); | 93 EXPECT_EQ(layer->bounds(), content_bounds); |
| 98 } | 94 } |
| 99 | 95 |
| 100 TEST_F(PictureImageLayerImplTest, AreVisibleResourcesReady) { | |
| 101 scoped_ptr<TestablePictureImageLayerImpl> layer(CreateLayer(1, PENDING_TREE)); | |
| 102 layer->SetBounds(gfx::Size(100, 200)); | |
| 103 layer->SetDrawsContent(true); | |
| 104 | |
| 105 UpdateDrawProperties(); | |
|
danakj
2014/06/11 21:41:19
I did some related/unrelated blaming just now and
| |
| 106 | |
| 107 float contents_scale_x; | |
| 108 float contents_scale_y; | |
| 109 gfx::Size content_bounds; | |
| 110 layer->CalculateContentsScale(2.f, | |
| 111 3.f, | |
| 112 4.f, | |
| 113 1.f, | |
| 114 false, | |
| 115 &contents_scale_x, | |
| 116 &contents_scale_y, | |
| 117 &content_bounds); | |
| 118 layer->UpdateTilePriorities(); | |
| 119 | |
| 120 EXPECT_TRUE(layer->AreVisibleResourcesReady()); | |
| 121 } | |
| 122 | |
| 123 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { | 96 TEST_F(PictureImageLayerImplTest, IgnoreIdealContentScale) { |
| 124 scoped_ptr<TestablePictureImageLayerImpl> pending_layer( | 97 scoped_ptr<TestablePictureImageLayerImpl> pending_layer( |
| 125 CreateLayer(1, PENDING_TREE)); | 98 CreateLayer(1, PENDING_TREE)); |
| 126 pending_layer->SetDrawsContent(true); | 99 pending_layer->SetDrawsContent(true); |
| 127 | 100 |
| 128 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal | 101 // Set PictureLayerImpl::ideal_contents_scale_ to 2.f which is not equal |
| 129 // to the content scale used by PictureImageLayerImpl. | 102 // to the content scale used by PictureImageLayerImpl. |
| 130 const float suggested_ideal_contents_scale = 2.f; | 103 const float suggested_ideal_contents_scale = 2.f; |
| 131 const float device_scale_factor = 3.f; | 104 const float device_scale_factor = 3.f; |
| 132 const float page_scale_factor = 4.f; | 105 const float page_scale_factor = 4.f; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 active_layer->DidDraw(NULL); | 146 active_layer->DidDraw(NULL); |
| 174 | 147 |
| 175 EXPECT_EQ(DrawQuad::TILED_CONTENT, quad_culler.quad_list()[0]->material); | 148 EXPECT_EQ(DrawQuad::TILED_CONTENT, quad_culler.quad_list()[0]->material); |
| 176 | 149 |
| 177 // Tiles are ready at correct scale, so should not set had_incomplete_tile. | 150 // Tiles are ready at correct scale, so should not set had_incomplete_tile. |
| 178 EXPECT_FALSE(data.had_incomplete_tile); | 151 EXPECT_FALSE(data.had_incomplete_tile); |
| 179 } | 152 } |
| 180 | 153 |
| 181 } // namespace | 154 } // namespace |
| 182 } // namespace cc | 155 } // namespace cc |
| OLD | NEW |