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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layers/tiled_layer.cc ('k') | cc/resources/bitmap_content_layer_updater.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/tiled_layer_unittest.cc
diff --git a/cc/layers/tiled_layer_unittest.cc b/cc/layers/tiled_layer_unittest.cc
index beeb878137e2c3abeed294a41cc38169d9a04610..4a6f5f6157fa4cdf68b1d2d901c1cec6d280880e 100644
--- a/cc/layers/tiled_layer_unittest.cc
+++ b/cc/layers/tiled_layer_unittest.cc
@@ -289,6 +289,27 @@ TEST_F(TiledLayerTest, PushDirtyTiles) {
EXPECT_FALSE(layer_impl->HasResourceIdForTileAt(0, 1));
}
+TEST_F(TiledLayerTest, Scale) {
+ layer_tree_host_->SetDeviceScaleFactor(1.5);
+
+ scoped_refptr<FakeTiledLayer> layer =
+ make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
+ scoped_ptr<FakeTiledLayerImpl> layer_impl =
+ make_scoped_ptr(new FakeTiledLayerImpl(host_impl_->active_tree(), 1));
+ RenderSurfaceLayerList render_surface_layer_list;
+
+ layer_tree_host_->root_layer()->AddChild(layer);
+
+ layer->SetBounds(gfx::Size(100, 200));
+ CalcDrawProps(&render_surface_layer_list);
+
+ // Change the width so that it doesn't divide cleanly by the scale.
+ layer->SetBounds(gfx::Size(101, 200));
+ UpdateAndPush(layer, layer_impl);
+
+ EXPECT_EQ(1.5, layer->fake_layer_updater()->last_contents_width_scale());
+}
+
TEST_F(TiledLayerTest, PushOccludedDirtyTiles) {
scoped_refptr<FakeTiledLayer> layer =
make_scoped_refptr(new FakeTiledLayer(resource_manager_.get()));
@@ -872,11 +893,13 @@ TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) {
layer_tree_host_->root_layer()->AddChild(layer);
gfx::Rect layer_bounds(0, 0, 300, 200);
- gfx::Rect content_bounds(0, 0, 200, 250);
+ gfx::Rect content_bounds(0, 0, 150, 250);
layer->SetBounds(layer_bounds.size());
layer->SetContentBounds(content_bounds.size());
layer->draw_properties().visible_content_rect = content_bounds;
+ layer->draw_properties().contents_scale_x = .5f;
+ layer->draw_properties().contents_scale_y = 1.25f;
// On first update, the update_rect includes all tiles, even beyond the
// boundaries of the layer.
@@ -887,7 +910,9 @@ TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) {
resource_manager_->PrioritizeTextures();
layer->SavePaintProperties();
layer->Update(queue_.get(), NULL);
- EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 300, 300 * 0.8), layer->update_rect());
+
+ // Update rect is 200x300 (tile size of 100x100). Scaled this gives 400x240.
+ EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 400, 240), layer->update_rect());
UpdateTextures();
// After the tiles are updated once, another invalidate only needs to update
@@ -908,7 +933,7 @@ TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) {
resource_manager_->PrioritizeTextures();
layer->SavePaintProperties();
layer->Update(queue_.get(), NULL);
- EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect());
+ EXPECT_FLOAT_RECT_EQ(gfx::RectF(60, 80, 20, 8), layer->update_rect());
}
TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) {
@@ -1692,7 +1717,11 @@ TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) {
layer->InvalidateContentRect(content_rect);
layer->Update(queue_.get(), NULL);
- EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect());
+ // Rounding leads to an extra pixel.
+ gfx::Rect expanded_layer_rect(layer_rect);
+ expanded_layer_rect.set_height(32);
+ EXPECT_RECT_EQ(expanded_layer_rect,
+ layer->tracking_layer_painter()->PaintedRect());
}
TEST_F(TiledLayerTest,
@@ -1727,7 +1756,11 @@ TEST_F(TiledLayerTest,
layer->SetNeedsDisplayRect(layer_rect);
layer->Update(queue_.get(), NULL);
- EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect());
+ // Rounding leads to an extra pixel.
+ gfx::Rect expanded_layer_rect(layer_rect);
+ expanded_layer_rect.set_height(32);
+ EXPECT_RECT_EQ(expanded_layer_rect,
+ layer->tracking_layer_painter()->PaintedRect());
}
} // namespace
« no previous file with comments | « cc/layers/tiled_layer.cc ('k') | cc/resources/bitmap_content_layer_updater.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698