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..96ebdf8c01417a1d65ee648a9383d17110eb69b2 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())); |
@@ -863,54 +884,6 @@ TEST_F(TiledLayerTest, InvalidateFromPrepare) { |
EXPECT_EQ(1, layer->fake_layer_updater()->prepare_count()); |
} |
-TEST_F(TiledLayerTest, VerifyUpdateRectWhenContentBoundsAreScaled) { |
sky
2014/09/22 18:00:00
This test didn't seem worth keeping around.
danakj
2014/09/22 19:21:18
This is testing the Layer::update_rect_ is in laye
sky
2014/09/22 21:23:55
Yes, because it didn't update the scales explicitl
|
- // The update rect (that indicates what was actually painted) should be in |
- // layer space, not the content space. |
- scoped_refptr<FakeTiledLayerWithScaledBounds> layer = make_scoped_refptr( |
- new FakeTiledLayerWithScaledBounds(resource_manager_.get())); |
- |
- layer_tree_host_->root_layer()->AddChild(layer); |
- |
- gfx::Rect layer_bounds(0, 0, 300, 200); |
- gfx::Rect content_bounds(0, 0, 200, 250); |
- |
- layer->SetBounds(layer_bounds.size()); |
- layer->SetContentBounds(content_bounds.size()); |
- layer->draw_properties().visible_content_rect = content_bounds; |
- |
- // On first update, the update_rect includes all tiles, even beyond the |
- // boundaries of the layer. |
- // However, it should still be in layer space, not content space. |
- layer->InvalidateContentRect(content_bounds); |
- |
- layer->SetTexturePriorities(priority_calculator_); |
- 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()); |
- UpdateTextures(); |
- |
- // After the tiles are updated once, another invalidate only needs to update |
- // the bounds of the layer. |
- layer->SetTexturePriorities(priority_calculator_); |
- resource_manager_->PrioritizeTextures(); |
- layer->InvalidateContentRect(content_bounds); |
- layer->SavePaintProperties(); |
- layer->Update(queue_.get(), NULL); |
- EXPECT_FLOAT_RECT_EQ(gfx::RectF(layer_bounds), layer->update_rect()); |
- UpdateTextures(); |
- |
- // Partial re-paint should also be represented by the update rect in layer |
- // space, not content space. |
- gfx::Rect partial_damage(30, 100, 10, 10); |
- layer->InvalidateContentRect(partial_damage); |
- layer->SetTexturePriorities(priority_calculator_); |
- resource_manager_->PrioritizeTextures(); |
- layer->SavePaintProperties(); |
- layer->Update(queue_.get(), NULL); |
- EXPECT_FLOAT_RECT_EQ(gfx::RectF(45, 80, 15, 8), layer->update_rect()); |
-} |
- |
TEST_F(TiledLayerTest, VerifyInvalidationWhenContentsScaleChanges) { |
scoped_refptr<FakeTiledLayer> layer = |
make_scoped_refptr(new FakeTiledLayer(resource_manager_.get())); |
@@ -1692,7 +1665,9 @@ TEST_F(TiledLayerTest, NonIntegerContentsScaleIsNotDistortedDuringPaint) { |
layer->InvalidateContentRect(content_rect); |
layer->Update(queue_.get(), NULL); |
- EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
+ // Rounding errors may lead to an extra dip. |
+ EXPECT_RECT_NEAR( |
danakj
2014/09/22 19:21:18
Can you instead EXPECT_EQ and just explain in a co
sky
2014/09/22 21:23:55
It's the 1.5 scale. Previously we calculated the s
|
+ layer_rect, layer->tracking_layer_painter()->PaintedRect(), 1); |
} |
TEST_F(TiledLayerTest, |
@@ -1727,7 +1702,9 @@ TEST_F(TiledLayerTest, |
layer->SetNeedsDisplayRect(layer_rect); |
layer->Update(queue_.get(), NULL); |
- EXPECT_RECT_EQ(layer_rect, layer->tracking_layer_painter()->PaintedRect()); |
+ // Rounding errors may lead to an extra dip. |
+ EXPECT_RECT_NEAR( |
danakj
2014/09/22 19:21:18
Same comment.
|
+ layer_rect, layer->tracking_layer_painter()->PaintedRect(), 1); |
} |
} // namespace |