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

Unified Diff: cc/layers/picture_layer_impl_unittest.cc

Issue 294463002: cc: Reset raster scale if we didn't sync high res tiling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more comments Created 6 years, 7 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/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling_set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_layer_impl_unittest.cc
diff --git a/cc/layers/picture_layer_impl_unittest.cc b/cc/layers/picture_layer_impl_unittest.cc
index bdbe172213f67d122434c37a303c3dcd07c8a83e..9085a71a1e42c9e2febe59149a7b51553973da73 100644
--- a/cc/layers/picture_layer_impl_unittest.cc
+++ b/cc/layers/picture_layer_impl_unittest.cc
@@ -1727,6 +1727,60 @@ TEST_F(PictureLayerImplTest, SyncTilingAfterReleaseResource) {
EXPECT_EQ(HIGH_RESOLUTION, high_res->resolution());
}
+TEST_F(PictureLayerImplTest, HighResCreatedWhenBoundsShrink) {
+ SetupDefaultTrees(gfx::Size(10, 10));
+ host_impl_.active_tree()->UpdateDrawProperties();
+ EXPECT_FALSE(host_impl_.active_tree()->needs_update_draw_properties());
+
+ float result_scale_x;
+ float result_scale_y;
+ gfx::Size result_bounds;
+ active_layer_->CalculateContentsScale(0.5f,
+ 0.5f,
+ 0.5f,
+ 0.5f,
+ false,
+ &result_scale_x,
+ &result_scale_y,
+ &result_bounds);
+ active_layer_->tilings()->RemoveAllTilings();
+ PictureLayerTiling* tiling = active_layer_->tilings()->AddTiling(0.5f);
+ active_layer_->tilings()->AddTiling(1.5f);
+ active_layer_->tilings()->AddTiling(0.25f);
+ tiling->set_resolution(HIGH_RESOLUTION);
+
+ // Sanity checks.
+ ASSERT_EQ(3u, active_layer_->tilings()->num_tilings());
+ ASSERT_EQ(tiling, active_layer_->tilings()->TilingAtScale(0.5f));
+
+ // Now, set the bounds to be 1x1 (so that minimum contents scale becomes
+ // 1.0f). Note that we should also ensure that the pending layer needs post
+ // commit initialization, since this is what would happen during commit. In
+ // other words we want the pending layer to sync from the active layer.
+ pending_layer_->SetBounds(gfx::Size(1, 1));
+ pending_layer_->SetNeedsPostCommitInitialization();
+ pending_layer_->set_twin_layer(NULL);
+ active_layer_->set_twin_layer(NULL);
+ EXPECT_TRUE(pending_layer_->needs_post_commit_initialization());
+
+ // Update the draw properties: sync from active tree should happen here.
+ host_impl_.pending_tree()->UpdateDrawProperties();
+
+ // Another sanity check.
+ ASSERT_EQ(1.f, pending_layer_->MinimumContentsScale());
+
+ // Now we should've synced 1.5f tiling, since that's the only one that doesn't
+ // violate minimum contents scale. At the same time, we should've created a
+ // new high res tiling at scale 1.0f.
+ EXPECT_EQ(2u, pending_layer_->tilings()->num_tilings());
+ ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.0f));
+ EXPECT_EQ(HIGH_RESOLUTION,
+ pending_layer_->tilings()->TilingAtScale(1.0f)->resolution());
+ ASSERT_TRUE(pending_layer_->tilings()->TilingAtScale(1.5f));
+ EXPECT_EQ(NON_IDEAL_RESOLUTION,
+ pending_layer_->tilings()->TilingAtScale(1.5f)->resolution());
+}
+
TEST_F(PictureLayerImplTest, NoLowResTilingWithGpuRasterization) {
gfx::Size default_tile_size(host_impl_.settings().default_tile_size);
gfx::Size layer_bounds(default_tile_size.width() * 4,
« no previous file with comments | « cc/layers/picture_layer_impl.cc ('k') | cc/resources/picture_layer_tiling_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698