OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/tiled_layer.h" | 5 #include "cc/layers/tiled_layer.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 layer->InvalidateContentRect(gfx::Rect(0, 0, 100, 200)); | 282 layer->InvalidateContentRect(gfx::Rect(0, 0, 100, 200)); |
283 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); | 283 layer->draw_properties().visible_content_rect = gfx::Rect(0, 0, 100, 100); |
284 UpdateAndPush(layer, layer_impl); | 284 UpdateAndPush(layer, layer_impl); |
285 | 285 |
286 // We should only have the first tile since the other tile was invalidated but | 286 // We should only have the first tile since the other tile was invalidated but |
287 // not painted. | 287 // not painted. |
288 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); | 288 EXPECT_TRUE(layer_impl->HasResourceIdForTileAt(0, 0)); |
289 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); | 289 EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1)); |
290 } | 290 } |
291 | 291 |
| 292 TEST_F(TiledLayerTest, Scale) { |
| 293 layer_tree_host_->SetDeviceScaleFactor(1.5); |
| 294 |
| 295 scoped_refptr<FakeTiledLayer> layer = |
| 296 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
| 297 scoped_ptr<FakeTiledLayerImpl> layer_impl = |
| 298 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); |
| 299 RenderSurfaceLayerList render_surface_layer_list; |
| 300 |
| 301 layer_tree_host_->root_layer()->AddChild(layer); |
| 302 |
| 303 layer->SetBounds(gfx::Size(100, 200)); |
| 304 CalcDrawProps(&render_surface_layer_list); |
| 305 |
| 306 // Change the width so that it doesn't divide cleanly by the scale. |
| 307 layer->SetBounds(gfx::Size(101, 200)); |
| 308 UpdateAndPush(layer, layer_impl); |
| 309 |
| 310 EXPECT_EQ(1.5, layer->fake_layer_updater()->last_contents_width_scale()); |
| 311 } |
| 312 |
292 TEST_F(TiledLayerTest, PushOccludedDirtyTiles) { | 313 TEST_F(TiledLayerTest, PushOccludedDirtyTiles) { |
293 scoped_refptr<FakeTiledLayer> layer = | 314 scoped_refptr<FakeTiledLayer> layer = |
294 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); | 315 make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
295 scoped_ptr<FakeTiledLayerImpl> layer_impl = | 316 scoped_ptr<FakeTiledLayerImpl> layer_impl = |
296 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); | 317 make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1)); |
297 TestOcclusionTracker occluded; | 318 TestOcclusionTracker occluded; |
298 occlusion_ = &occluded; | 319 occlusion_ = &occluded; |
299 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); | 320 layer_tree_host_->SetViewportSize(gfx::Size(1000, 1000)); |
300 | 321 |
301 layer_tree_host_->root_layer()->AddChild(layer); | 322 layer_tree_host_->root_layer()->AddChild(layer); |
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1815 // Invalidate the entire layer in layer space. When painting, the rect given | 1836 // Invalidate the entire layer in layer space. When painting, the rect given |
1816 // to webkit should match the layer's bounds. | 1837 // to webkit should match the layer's bounds. |
1817 layer->SetNeedsDisplayRect(layer_rect); | 1838 layer->SetNeedsDisplayRect(layer_rect); |
1818 layer->Update(queue_.get(), NULL); | 1839 layer->Update(queue_.get(), NULL); |
1819 | 1840 |
1820 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); | 1841 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
1821 } | 1842 } |
1822 | 1843 |
1823 } // namespace | 1844 } // namespace |
1824 } // namespace cc | 1845 } // namespace cc |
OLD | NEW |