Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: cc/layers/tiled_layer_unittest.cc

Issue 567743003: Fix bad scaling in TiledLayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge to trunk Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 // Invalidate the entire layer in layer space. When painting, the rect given 1746 // Invalidate the entire layer in layer space. When painting, the rect given
1726 // to webkit should match the layer's bounds. 1747 // to webkit should match the layer's bounds.
1727 layer->SetNeedsDisplayRect(layer_rect); 1748 layer->SetNeedsDisplayRect(layer_rect);
1728 layer->Update(queue_.get(), NULL); 1749 layer->Update(queue_.get(), NULL);
1729 1750
1730 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); 1751 EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect());
1731 } 1752 }
1732 1753
1733 } // namespace 1754 } // namespace
1734 } // namespace cc 1755 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698