diff options
Diffstat (limited to 'cc')
-rw-r--r-- | cc/contents_scaling_layer.cc | 19 | ||||
-rw-r--r-- | cc/contents_scaling_layer.h | 9 | ||||
-rw-r--r-- | cc/layer_tree_host_unittest_animation.cc | 4 | ||||
-rw-r--r-- | cc/scrollbar_layer.cc | 4 | ||||
-rw-r--r-- | cc/tiled_layer.cc | 3 | ||||
-rw-r--r-- | cc/tiled_layer_unittest.cc | 11 |
6 files changed, 43 insertions, 7 deletions
diff --git a/cc/contents_scaling_layer.cc b/cc/contents_scaling_layer.cc index 579af34..a9a8bef 100644 --- a/cc/contents_scaling_layer.cc +++ b/cc/contents_scaling_layer.cc @@ -11,7 +11,10 @@ gfx::Size ContentsScalingLayer::computeContentBoundsForScale(float scaleX, float return gfx::ToCeiledSize(gfx::ScaleSize(bounds(), scaleX, scaleY)); } -ContentsScalingLayer::ContentsScalingLayer() { +ContentsScalingLayer::ContentsScalingLayer() + : last_update_contents_scale_x_(0.f) + , last_update_contents_scale_y_(0.f) + { } ContentsScalingLayer::~ContentsScalingLayer() { @@ -35,4 +38,18 @@ void ContentsScalingLayer::didUpdateBounds() { contentsScaleY()); } +void ContentsScalingLayer::update( + ResourceUpdateQueue& queue, + const OcclusionTracker* occlusion, + RenderingStats& stats) { + if (drawProperties().contents_scale_x == last_update_contents_scale_x_ && + drawProperties().contents_scale_y == last_update_contents_scale_y_) + return; + + last_update_contents_scale_x_ = drawProperties().contents_scale_x; + last_update_contents_scale_y_ = drawProperties().contents_scale_y; + // Invalidate the whole layer if scale changed. + setNeedsDisplayRect(gfx::Rect(bounds())); +} + } // namespace cc diff --git a/cc/contents_scaling_layer.h b/cc/contents_scaling_layer.h index 81b51ff..c535d04 100644 --- a/cc/contents_scaling_layer.h +++ b/cc/contents_scaling_layer.h @@ -21,11 +21,20 @@ class CC_EXPORT ContentsScalingLayer : public Layer { gfx::Size* content_bounds) OVERRIDE; virtual void didUpdateBounds() OVERRIDE; + virtual void update( + ResourceUpdateQueue& queue, + const OcclusionTracker* occlusion, + RenderingStats& stats) OVERRIDE; + protected: ContentsScalingLayer(); virtual ~ContentsScalingLayer(); gfx::Size computeContentBoundsForScale(float scaleX, float scaleY) const; + + private: + float last_update_contents_scale_x_; + float last_update_contents_scale_y_; }; } // namespace cc diff --git a/cc/layer_tree_host_unittest_animation.cc b/cc/layer_tree_host_unittest_animation.cc index 384fbb3..8900c93 100644 --- a/cc/layer_tree_host_unittest_animation.cc +++ b/cc/layer_tree_host_unittest_animation.cc @@ -381,9 +381,9 @@ class LayerTreeHostAnimationTestDoNotSkipLayersWithAnimatedOpacity : } virtual void afterTest() OVERRIDE { - // update() should have been called once, proving that the layer was not + // update() should have been called, proving that the layer was not // skipped. - EXPECT_EQ(1, update_check_layer_->update_count()); + EXPECT_NE(0, update_check_layer_->update_count()); // clear update_check_layer_ so LayerTreeHost dies. update_check_layer_ = NULL; diff --git a/cc/scrollbar_layer.cc b/cc/scrollbar_layer.cc index 817ead8..c4e61ac 100644 --- a/cc/scrollbar_layer.cc +++ b/cc/scrollbar_layer.cc @@ -300,8 +300,10 @@ void ScrollbarLayer::setTexturePriorities(const PriorityCalculator&) } } -void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker*, RenderingStats& stats) +void ScrollbarLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) { + ContentsScalingLayer::update(queue, occlusion, stats); + if (contentBounds().IsEmpty()) return; diff --git a/cc/tiled_layer.cc b/cc/tiled_layer.cc index 67e6d8c..f69411f 100644 --- a/cc/tiled_layer.cc +++ b/cc/tiled_layer.cc @@ -633,6 +633,9 @@ void TiledLayer::updateScrollPrediction() void TiledLayer::update(ResourceUpdateQueue& queue, const OcclusionTracker* occlusion, RenderingStats& stats) { DCHECK(!m_skipsDraw && !m_failedUpdate); // Did resetUpdateState get skipped? + + ContentsScalingLayer::update(queue, occlusion, stats); + updateBounds(); if (m_tiler->hasEmptyBounds() || !drawsContent()) return; diff --git a/cc/tiled_layer_unittest.cc b/cc/tiled_layer_unittest.cc index 7fb252f..dd636ef 100644 --- a/cc/tiled_layer_unittest.cc +++ b/cc/tiled_layer_unittest.cc @@ -788,11 +788,12 @@ TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 0)); EXPECT_FALSE(layerImpl->hasResourceIdForTileAt(1, 1)); - // Change the contents scale and verify that the content rectangle requiring painting - // is not scaled. + layer->setNeedsDisplayRect(gfx::Rect()); + EXPECT_FLOAT_RECT_EQ(gfx::RectF(), layer->lastNeedsDisplayRect()); + + // Change the contents scale. layer->updateContentsScale(2); layer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 200, 200); - EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect()); // The impl side should get 2x2 tiles now. layer->setTexturePriorities(m_priorityCalculator); @@ -805,6 +806,10 @@ TEST_F(TiledLayerTest, verifyInvalidationWhenContentsScaleChanges) EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 0)); EXPECT_TRUE(layerImpl->hasResourceIdForTileAt(1, 1)); + // Verify that changing the contents scale caused invalidation, and + // that the layer-space rectangle requiring painting is not scaled. + EXPECT_FLOAT_RECT_EQ(gfx::RectF(0, 0, 100, 100), layer->lastNeedsDisplayRect()); + // Invalidate the entire layer again, but do not paint. All tiles should be gone now from the // impl side. layer->setNeedsDisplay(); |