summaryrefslogtreecommitdiffstats
path: root/cc
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-08 21:31:22 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-08 21:31:22 +0000
commit49304bde71a1acd64cb21cfde6314abb9c1710e1 (patch)
tree48add9e688cea95faee62d524227c950da1e0fb4 /cc
parentb7c0fb6db7ae85f1c9ce1190edf5176b2eaa371b (diff)
downloadchromium_src-49304bde71a1acd64cb21cfde6314abb9c1710e1.zip
chromium_src-49304bde71a1acd64cb21cfde6314abb9c1710e1.tar.gz
chromium_src-49304bde71a1acd64cb21cfde6314abb9c1710e1.tar.bz2
cc: Make Layer::Update return a bool
As part of an optimization to prevent needless commits, add a return value from Update to say whether or not any resources were updated as a part of the call. Other layer property updates (bounds changes, etc) that happen during Update are covered through the normal SetNeedsCommit mechanism. This will allow a future patch to make SetNeedsDisplay/SetScrollOffsetFromImplThread only cause an update but not necessarily cause a commit. R=danakj@chromium.org BUG=256381 Review URL: https://chromiumcodereview.appspot.com/18454003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210424 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
-rw-r--r--cc/layers/content_layer.cc5
-rw-r--r--cc/layers/content_layer.h2
-rw-r--r--cc/layers/contents_scaling_layer.cc5
-rw-r--r--cc/layers/contents_scaling_layer.h2
-rw-r--r--cc/layers/heads_up_display_layer.cc3
-rw-r--r--cc/layers/heads_up_display_layer.h2
-rw-r--r--cc/layers/image_layer.cc4
-rw-r--r--cc/layers/image_layer.h2
-rw-r--r--cc/layers/layer.cc5
-rw-r--r--cc/layers/layer.h5
-rw-r--r--cc/layers/nine_patch_layer.cc4
-rw-r--r--cc/layers/nine_patch_layer.h2
-rw-r--r--cc/layers/picture_layer.cc20
-rw-r--r--cc/layers/picture_layer.h2
-rw-r--r--cc/layers/scrollbar_layer.cc32
-rw-r--r--cc/layers/scrollbar_layer.h4
-rw-r--r--cc/layers/texture_layer.cc13
-rw-r--r--cc/layers/texture_layer.h2
-rw-r--r--cc/layers/tiled_layer.cc24
-rw-r--r--cc/layers/tiled_layer.h2
-rw-r--r--cc/resources/picture_pile.cc10
-rw-r--r--cc/resources/picture_pile.h3
-rw-r--r--cc/test/fake_content_layer.cc5
-rw-r--r--cc/test/fake_content_layer.h2
-rw-r--r--cc/test/fake_picture_layer.cc5
-rw-r--r--cc/test/fake_picture_layer.h2
-rw-r--r--cc/test/fake_scrollbar_layer.cc5
-rw-r--r--cc/test/fake_scrollbar_layer.h2
-rw-r--r--cc/trees/layer_tree_host.cc50
-rw-r--r--cc/trees/layer_tree_host.h16
-rw-r--r--cc/trees/layer_tree_host_unittest.cc12
-rw-r--r--cc/trees/layer_tree_host_unittest_occlusion.cc5
32 files changed, 152 insertions, 105 deletions
diff --git a/cc/layers/content_layer.cc b/cc/layers/content_layer.cc
index 1d1f8ef..c7999d5 100644
--- a/cc/layers/content_layer.cc
+++ b/cc/layers/content_layer.cc
@@ -81,7 +81,7 @@ void ContentLayer::SetTexturePriorities(
TiledLayer::SetTexturePriorities(priority_calc);
}
-void ContentLayer::Update(ResourceUpdateQueue* queue,
+bool ContentLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
{
base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_,
@@ -91,8 +91,9 @@ void ContentLayer::Update(ResourceUpdateQueue* queue,
UpdateCanUseLCDText();
}
- TiledLayer::Update(queue, occlusion);
+ bool updated = TiledLayer::Update(queue, occlusion);
needs_display_ = false;
+ return updated;
}
bool ContentLayer::NeedMoreUpdates() {
diff --git a/cc/layers/content_layer.h b/cc/layers/content_layer.h
index fc334c7..f49215b 100644
--- a/cc/layers/content_layer.h
+++ b/cc/layers/content_layer.h
@@ -44,7 +44,7 @@ class CC_EXPORT ContentLayer : public TiledLayer {
virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
virtual bool NeedMoreUpdates() OVERRIDE;
diff --git a/cc/layers/contents_scaling_layer.cc b/cc/layers/contents_scaling_layer.cc
index e7c4232..03a790b 100644
--- a/cc/layers/contents_scaling_layer.cc
+++ b/cc/layers/contents_scaling_layer.cc
@@ -35,17 +35,18 @@ void ContentsScalingLayer::CalculateContentsScale(
ideal_contents_scale);
}
-void ContentsScalingLayer::Update(
+bool ContentsScalingLayer::Update(
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
if (draw_properties().contents_scale_x == last_update_contents_scale_x_ &&
draw_properties().contents_scale_y == last_update_contents_scale_y_)
- return;
+ return false;
last_update_contents_scale_x_ = draw_properties().contents_scale_x;
last_update_contents_scale_y_ = draw_properties().contents_scale_y;
// Invalidate the whole layer if scale changed.
SetNeedsDisplayRect(gfx::Rect(paint_properties().bounds));
+ return false;
}
} // namespace cc
diff --git a/cc/layers/contents_scaling_layer.h b/cc/layers/contents_scaling_layer.h
index bb7ce79..a2648d1 100644
--- a/cc/layers/contents_scaling_layer.h
+++ b/cc/layers/contents_scaling_layer.h
@@ -23,7 +23,7 @@ class CC_EXPORT ContentsScalingLayer : public Layer {
float* contents_scale_y,
gfx::Size* content_bounds) OVERRIDE;
- virtual void Update(
+ virtual bool Update(
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
diff --git a/cc/layers/heads_up_display_layer.cc b/cc/layers/heads_up_display_layer.cc
index de44fac..c99bd32 100644
--- a/cc/layers/heads_up_display_layer.cc
+++ b/cc/layers/heads_up_display_layer.cc
@@ -22,7 +22,7 @@ HeadsUpDisplayLayer::HeadsUpDisplayLayer() : ContentsScalingLayer() {
HeadsUpDisplayLayer::~HeadsUpDisplayLayer() {}
-void HeadsUpDisplayLayer::Update(ResourceUpdateQueue*,
+bool HeadsUpDisplayLayer::Update(ResourceUpdateQueue*,
const OcclusionTracker*) {
gfx::Size device_viewport = layer_tree_host()->device_viewport_size();
float device_scale_factor = layer_tree_host()->device_scale_factor();
@@ -54,6 +54,7 @@ void HeadsUpDisplayLayer::Update(ResourceUpdateQueue*,
// The HudLayer used to show up with the wrong bounds for one frame.
// This call fixes that the bounds get passed to LayerImpl on the next commit.
SavePaintProperties();
+ return false;
}
bool HeadsUpDisplayLayer::DrawsContent() const { return true; }
diff --git a/cc/layers/heads_up_display_layer.h b/cc/layers/heads_up_display_layer.h
index 80106b1..f49fc6e 100644
--- a/cc/layers/heads_up_display_layer.h
+++ b/cc/layers/heads_up_display_layer.h
@@ -15,7 +15,7 @@ class CC_EXPORT HeadsUpDisplayLayer : public ContentsScalingLayer {
public:
static scoped_refptr<HeadsUpDisplayLayer> Create();
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* tracker) OVERRIDE;
virtual bool DrawsContent() const OVERRIDE;
diff --git a/cc/layers/image_layer.cc b/cc/layers/image_layer.cc
index b7b1578..e02fc62 100644
--- a/cc/layers/image_layer.cc
+++ b/cc/layers/image_layer.cc
@@ -40,7 +40,7 @@ void ImageLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) {
TiledLayer::SetTexturePriorities(priority_calc);
}
-void ImageLayer::Update(ResourceUpdateQueue* queue,
+bool ImageLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
CreateUpdaterIfNeeded();
if (needs_display_) {
@@ -49,7 +49,7 @@ void ImageLayer::Update(ResourceUpdateQueue* queue,
InvalidateContentRect(gfx::Rect(content_bounds()));
needs_display_ = false;
}
- TiledLayer::Update(queue, occlusion);
+ return TiledLayer::Update(queue, occlusion);
}
void ImageLayer::CreateUpdaterIfNeeded() {
diff --git a/cc/layers/image_layer.h b/cc/layers/image_layer.h
index a8a9a97..ae8383a 100644
--- a/cc/layers/image_layer.h
+++ b/cc/layers/image_layer.h
@@ -22,7 +22,7 @@ class CC_EXPORT ImageLayer : public TiledLayer {
virtual bool DrawsContent() const OVERRIDE;
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
virtual void CalculateContentsScale(float ideal_contents_scale,
float device_scale_factor,
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index e1d59b7..7fe86ac 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -786,6 +786,11 @@ void Layer::SavePaintProperties() {
paint_properties_.bounds = bounds_;
}
+bool Layer::Update(ResourceUpdateQueue* queue,
+ const OcclusionTracker* occlusion) {
+ return false;
+}
+
bool Layer::NeedMoreUpdates() {
return false;
}
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index ec0c7dc..602ebc0 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -280,8 +280,9 @@ class CC_EXPORT Layer : public base::RefCounted<Layer>,
// These methods typically need to be overwritten by derived classes.
virtual bool DrawsContent() const;
virtual void SavePaintProperties();
- virtual void Update(ResourceUpdateQueue* queue,
- const OcclusionTracker* occlusion) {}
+ // Returns true iff any resources were updated that need to be committed.
+ virtual bool Update(ResourceUpdateQueue* queue,
+ const OcclusionTracker* occlusion);
virtual bool NeedMoreUpdates();
virtual void SetIsMask(bool is_mask) {}
virtual void ReduceMemoryUsage() {}
diff --git a/cc/layers/nine_patch_layer.cc b/cc/layers/nine_patch_layer.cc
index d15e6f1..c75316a 100644
--- a/cc/layers/nine_patch_layer.cc
+++ b/cc/layers/nine_patch_layer.cc
@@ -54,7 +54,7 @@ void NinePatchLayer::SetBitmap(const SkBitmap& bitmap, gfx::Rect aperture) {
SetNeedsDisplay();
}
-void NinePatchLayer::Update(ResourceUpdateQueue* queue,
+bool NinePatchLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
CreateUpdaterIfNeeded();
@@ -68,7 +68,9 @@ void NinePatchLayer::Update(ResourceUpdateQueue* queue,
gfx::Vector2d());
queue->AppendFullUpload(upload);
bitmap_dirty_ = false;
+ return true;
}
+ return false;
}
void NinePatchLayer::CreateUpdaterIfNeeded() {
diff --git a/cc/layers/nine_patch_layer.h b/cc/layers/nine_patch_layer.h
index f1a98d4..35d0881 100644
--- a/cc/layers/nine_patch_layer.h
+++ b/cc/layers/nine_patch_layer.h
@@ -23,7 +23,7 @@ class CC_EXPORT NinePatchLayer : public Layer {
virtual bool DrawsContent() const OVERRIDE;
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
diff --git a/cc/layers/picture_layer.cc b/cc/layers/picture_layer.cc
index 23d5333..2235a3b 100644
--- a/cc/layers/picture_layer.cc
+++ b/cc/layers/picture_layer.cc
@@ -73,7 +73,7 @@ void PictureLayer::SetNeedsDisplayRect(const gfx::RectF& layer_rect) {
Layer::SetNeedsDisplayRect(layer_rect);
}
-void PictureLayer::Update(ResourceUpdateQueue*,
+bool PictureLayer::Update(ResourceUpdateQueue*,
const OcclusionTracker*) {
// Do not early-out of this function so that PicturePile::Update has a chance
// to record pictures due to changing visibility of this layer.
@@ -89,12 +89,18 @@ void PictureLayer::Update(ResourceUpdateQueue*,
visible_content_rect(), 1.f / contents_scale_x());
devtools_instrumentation::ScopedLayerTask paint_layer(
devtools_instrumentation::kPaintLayer, id());
- pile_->Update(client_,
- SafeOpaqueBackgroundColor(),
- contents_opaque(),
- pile_invalidation_,
- visible_layer_rect,
- rendering_stats_instrumentation());
+ bool updated = pile_->Update(client_,
+ SafeOpaqueBackgroundColor(),
+ contents_opaque(),
+ pile_invalidation_,
+ visible_layer_rect,
+ rendering_stats_instrumentation());
+ if (!updated) {
+ // If this invalidation did not affect the pile, then it can be cleared as
+ // an optimization.
+ pile_invalidation_.Clear();
+ }
+ return updated;
}
void PictureLayer::SetIsMask(bool is_mask) {
diff --git a/cc/layers/picture_layer.h b/cc/layers/picture_layer.h
index a5c0714..7264a2f 100644
--- a/cc/layers/picture_layer.h
+++ b/cc/layers/picture_layer.h
@@ -29,7 +29,7 @@ class CC_EXPORT PictureLayer : public ContentsScalingLayer {
virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
virtual void SetNeedsDisplayRect(const gfx::RectF& layer_rect) OVERRIDE;
- virtual void Update(
+ virtual bool Update(
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
virtual void SetIsMask(bool is_mask) OVERRIDE;
diff --git a/cc/layers/scrollbar_layer.cc b/cc/layers/scrollbar_layer.cc
index f2c46a8..5f9e785 100644
--- a/cc/layers/scrollbar_layer.cc
+++ b/cc/layers/scrollbar_layer.cc
@@ -207,24 +207,24 @@ void ScrollbarLayer::CreateUpdaterIfNeeded() {
}
}
-void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter,
+bool ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter,
LayerUpdater::Resource* resource,
gfx::Rect rect,
ResourceUpdateQueue* queue) {
if (layer_tree_host()->settings().solid_color_scrollbars)
- return;
+ return false;
// Skip painting and uploading if there are no invalidations and
// we already have valid texture data.
if (resource->texture()->have_backing_texture() &&
resource->texture()->size() == rect.size() &&
!is_dirty())
- return;
+ return false;
// We should always have enough memory for UI.
DCHECK(resource->texture()->can_acquire_backing_texture());
if (!resource->texture()->can_acquire_backing_texture())
- return;
+ return false;
// Paint and upload the entire part.
gfx::Rect painted_opaque_rect;
@@ -238,7 +238,7 @@ void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter,
TRACE_EVENT_INSTANT0("cc",
"ScrollbarLayer::UpdatePart no texture upload needed",
TRACE_EVENT_SCOPE_THREAD);
- return;
+ return false;
}
bool partial_updates_allowed =
@@ -248,6 +248,7 @@ void ScrollbarLayer::UpdatePart(CachingBitmapContentLayerUpdater* painter,
gfx::Vector2d dest_offset(0, 0);
resource->Update(queue, rect, dest_offset, partial_updates_allowed);
+ return true;
}
gfx::Rect ScrollbarLayer::ScrollbarLayerRectToContentRect(
@@ -289,12 +290,12 @@ void ScrollbarLayer::SetTexturePriorities(
}
}
-void ScrollbarLayer::Update(ResourceUpdateQueue* queue,
+bool ScrollbarLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
track_rect_ = scrollbar_->TrackRect();
if (layer_tree_host()->settings().solid_color_scrollbars)
- return;
+ return false;
{
base::AutoReset<bool> ignore_set_needs_commit(&ignore_set_needs_commit_,
@@ -304,32 +305,29 @@ void ScrollbarLayer::Update(ResourceUpdateQueue* queue,
dirty_rect_.Union(update_rect_);
if (content_bounds().IsEmpty())
- return;
+ return false;
if (visible_content_rect().IsEmpty())
- return;
+ return false;
CreateUpdaterIfNeeded();
gfx::Rect content_rect = ScrollbarLayerRectToContentRect(
gfx::Rect(scrollbar_->Location(), bounds()));
- UpdatePart(track_updater_.get(),
- track_.get(),
- content_rect,
- queue);
+ bool updated = UpdatePart(track_updater_.get(), track_.get(), content_rect,
+ queue);
if (scrollbar_->HasThumb()) {
thumb_thickness_ = scrollbar_->ThumbThickness();
thumb_length_ = scrollbar_->ThumbLength();
gfx::Rect origin_thumb_rect = OriginThumbRect();
if (!origin_thumb_rect.IsEmpty()) {
- UpdatePart(thumb_updater_.get(),
- thumb_.get(),
- origin_thumb_rect,
- queue);
+ updated |= UpdatePart(thumb_updater_.get(), thumb_.get(),
+ origin_thumb_rect, queue);
}
}
dirty_rect_ = gfx::RectF();
+ return updated;
}
gfx::Rect ScrollbarLayer::OriginThumbRect() const {
diff --git a/cc/layers/scrollbar_layer.h b/cc/layers/scrollbar_layer.h
index a6c4a01..f500dcc 100644
--- a/cc/layers/scrollbar_layer.h
+++ b/cc/layers/scrollbar_layer.h
@@ -35,7 +35,7 @@ class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer {
// Layer interface
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
virtual void SetLayerTreeHost(LayerTreeHost* host) OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
@@ -55,7 +55,7 @@ class CC_EXPORT ScrollbarLayer : public ContentsScalingLayer {
virtual ~ScrollbarLayer();
private:
- void UpdatePart(CachingBitmapContentLayerUpdater* painter,
+ bool UpdatePart(CachingBitmapContentLayerUpdater* painter,
LayerUpdater::Resource* resource,
gfx::Rect rect,
ResourceUpdateQueue* queue);
diff --git a/cc/layers/texture_layer.cc b/cc/layers/texture_layer.cc
index dd3b3fa..fad7b13 100644
--- a/cc/layers/texture_layer.cc
+++ b/cc/layers/texture_layer.cc
@@ -166,22 +166,31 @@ bool TextureLayer::DrawsContent() const {
!context_lost_ && Layer::DrawsContent();
}
-void TextureLayer::Update(ResourceUpdateQueue* queue,
+bool TextureLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
+ bool updated = false;
if (client_) {
if (uses_mailbox_) {
TextureMailbox mailbox;
- if (client_->PrepareTextureMailbox(&mailbox))
+ if (client_->PrepareTextureMailbox(&mailbox)) {
SetTextureMailbox(mailbox);
+ updated = true;
+ }
} else {
DCHECK(client_->Context3d());
texture_id_ = client_->PrepareTexture(queue);
context_lost_ = client_->Context3d() &&
client_->Context3d()->getGraphicsResetStatusARB() != GL_NO_ERROR;
+ updated = true;
}
}
needs_display_ = false;
+
+ // SetTextureMailbox could be called externally and the same mailbox used for
+ // different textures. Such callers notify this layer that the texture has
+ // changed by calling SetNeedsDisplay, so check for that here.
+ return updated || !update_rect_.IsEmpty();
}
void TextureLayer::PushPropertiesTo(LayerImpl* layer) {
diff --git a/cc/layers/texture_layer.h b/cc/layers/texture_layer.h
index e3132fd..d36eb7a 100644
--- a/cc/layers/texture_layer.h
+++ b/cc/layers/texture_layer.h
@@ -75,7 +75,7 @@ class CC_EXPORT TextureLayer : public Layer {
virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
virtual bool DrawsContent() const OVERRIDE;
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
virtual bool BlocksPendingCommit() const OVERRIDE;
diff --git a/cc/layers/tiled_layer.cc b/cc/layers/tiled_layer.cc
index 4ed9dee..8a7e661 100644
--- a/cc/layers/tiled_layer.cc
+++ b/cc/layers/tiled_layer.cc
@@ -323,7 +323,6 @@ bool TiledLayer::UpdateTiles(int left,
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion,
bool* did_paint) {
- *did_paint = false;
CreateUpdaterIfNeeded();
bool ignore_occlusions = !occlusion;
@@ -723,7 +722,7 @@ void TiledLayer::UpdateScrollPrediction() {
previous_visible_rect_ = visible_content_rect();
}
-void TiledLayer::Update(ResourceUpdateQueue* queue,
+bool TiledLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
DCHECK(!skips_draw_ && !failed_update_); // Did ResetUpdateState get skipped?
{
@@ -735,7 +734,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue,
}
if (tiler_->has_empty_bounds() || !DrawsContent())
- return;
+ return false;
bool did_paint = false;
@@ -751,14 +750,14 @@ void TiledLayer::Update(ResourceUpdateQueue* queue,
&bottom);
UpdateTiles(left, top, right, bottom, queue, NULL, &did_paint);
if (did_paint)
- return;
+ return did_paint;
// This was an attempt to paint the entire layer so if we fail it's okay,
// just fallback on painting visible etc. below.
failed_update_ = false;
}
if (predicted_visible_rect_.IsEmpty())
- return;
+ return did_paint;
// Visible painting. First occlude visible tiles and paint the non-occluded
// tiles.
@@ -771,18 +770,18 @@ void TiledLayer::Update(ResourceUpdateQueue* queue,
if (skips_draw_)
tiler_->reset();
if (skips_draw_ || did_paint)
- return;
+ return true;
// If we have already painting everything visible. Do some pre-painting while
// idle.
gfx::Rect idle_paint_content_rect = IdlePaintRect();
if (idle_paint_content_rect.IsEmpty())
- return;
+ return did_paint;
// Prepaint anything that was occluded but inside the layer's visible region.
if (!UpdateTiles(left, top, right, bottom, queue, NULL, &did_paint) ||
did_paint)
- return;
+ return did_paint;
int prepaint_left, prepaint_top, prepaint_right, prepaint_bottom;
tiler_->ContentRectToTileIndices(idle_paint_content_rect,
@@ -812,7 +811,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue,
if (!UpdateTiles(
left, bottom, right, bottom, queue, NULL, &did_paint) ||
did_paint)
- return;
+ return did_paint;
}
}
if (deltas[i].y() < 0) {
@@ -821,7 +820,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue,
if (!UpdateTiles(
left, top, right, top, queue, NULL, &did_paint) ||
did_paint)
- return;
+ return did_paint;
}
}
if (deltas[i].x() < 0) {
@@ -830,7 +829,7 @@ void TiledLayer::Update(ResourceUpdateQueue* queue,
if (!UpdateTiles(
left, top, left, bottom, queue, NULL, &did_paint) ||
did_paint)
- return;
+ return did_paint;
}
}
if (deltas[i].x() > 0) {
@@ -839,10 +838,11 @@ void TiledLayer::Update(ResourceUpdateQueue* queue,
if (!UpdateTiles(
right, top, right, bottom, queue, NULL, &did_paint) ||
did_paint)
- return;
+ return did_paint;
}
}
}
+ return did_paint;
}
bool TiledLayer::NeedsIdlePaint() {
diff --git a/cc/layers/tiled_layer.h b/cc/layers/tiled_layer.h
index ae527e7..8ad7df9 100644
--- a/cc/layers/tiled_layer.h
+++ b/cc/layers/tiled_layer.h
@@ -34,7 +34,7 @@ class CC_EXPORT TiledLayer : public ContentsScalingLayer {
virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
OVERRIDE;
virtual Region VisibleContentOpaqueRegion() const OVERRIDE;
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
protected:
diff --git a/cc/resources/picture_pile.cc b/cc/resources/picture_pile.cc
index 1cca7dd..18566c0 100644
--- a/cc/resources/picture_pile.cc
+++ b/cc/resources/picture_pile.cc
@@ -21,7 +21,7 @@ const float kResetThreshold = 0.7f;
// picture that intersects the visible layer rect expanded by this distance
// will be recorded.
const int kPixelDistanceToRecord = 8000;
-}
+} // namespace
namespace cc {
@@ -31,7 +31,7 @@ PicturePile::PicturePile() {
PicturePile::~PicturePile() {
}
-void PicturePile::Update(
+bool PicturePile::Update(
ContentLayerClient* painter,
SkColor background_color,
bool contents_opaque,
@@ -47,6 +47,7 @@ void PicturePile::Update(
-kPixelDistanceToRecord,
-kPixelDistanceToRecord,
-kPixelDistanceToRecord);
+ bool modified_pile = false;
for (Region::Iterator i(invalidation); i.has_rect(); i.next()) {
gfx::Rect invalidation = i.rect();
// Split this inflated invalidation across tile boundaries and apply it
@@ -59,6 +60,7 @@ void PicturePile::Update(
// This invalidation touches a tile outside the interest rect, so
// just remove the entire picture list.
picture_list_map_.erase(iter.index());
+ modified_pile = true;
continue;
}
@@ -80,6 +82,7 @@ void PicturePile::Update(
DCHECK_GE(tile_invalidation.height(), buffer_pixels() * 2 + 1);
InvalidateRect(pic_list, tile_invalidation);
+ modified_pile = true;
}
}
}
@@ -107,6 +110,7 @@ void PicturePile::Update(
for (PictureList::iterator pic = pic_list.begin();
pic != pic_list.end(); ++pic) {
if (!(*pic)->HasRecording()) {
+ modified_pile = true;
TRACE_EVENT0("cc", "PicturePile::Update recording loop");
for (int i = 0; i < repeat_count; i++)
(*pic)->Record(painter, tile_grid_info_, stats_instrumentation);
@@ -117,6 +121,8 @@ void PicturePile::Update(
}
UpdateRecordedRegion();
+
+ return modified_pile;
}
class FullyContainedPredicate {
diff --git a/cc/resources/picture_pile.h b/cc/resources/picture_pile.h
index 155b333..7830a9e 100644
--- a/cc/resources/picture_pile.h
+++ b/cc/resources/picture_pile.h
@@ -19,7 +19,8 @@ class CC_EXPORT PicturePile : public PicturePileBase {
// Re-record parts of the picture that are invalid.
// Invalidations are in layer space.
- void Update(
+ // Return true iff the pile was modified.
+ bool Update(
ContentLayerClient* painter,
SkColor background_color,
bool contents_opaque,
diff --git a/cc/test/fake_content_layer.cc b/cc/test/fake_content_layer.cc
index a30ea95..5d452ea 100644
--- a/cc/test/fake_content_layer.cc
+++ b/cc/test/fake_content_layer.cc
@@ -24,10 +24,11 @@ scoped_ptr<LayerImpl> FakeContentLayer::CreateLayerImpl(
return FakeContentLayerImpl::Create(tree_impl, layer_id_).PassAs<LayerImpl>();
}
-void FakeContentLayer::Update(ResourceUpdateQueue* queue,
+bool FakeContentLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
- ContentLayer::Update(queue, occlusion);
+ bool updated = ContentLayer::Update(queue, occlusion);
update_count_++;
+ return updated;
}
bool FakeContentLayer::HaveBackingAt(int i, int j) {
diff --git a/cc/test/fake_content_layer.h b/cc/test/fake_content_layer.h
index cf8066a..a824787 100644
--- a/cc/test/fake_content_layer.h
+++ b/cc/test/fake_content_layer.h
@@ -22,7 +22,7 @@ class FakeContentLayer : public ContentLayer {
size_t update_count() const { return update_count_; }
void reset_update_count() { update_count_ = 0; }
- virtual void Update(
+ virtual bool Update(
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
diff --git a/cc/test/fake_picture_layer.cc b/cc/test/fake_picture_layer.cc
index d166d12..3690f7c 100644
--- a/cc/test/fake_picture_layer.cc
+++ b/cc/test/fake_picture_layer.cc
@@ -23,10 +23,11 @@ scoped_ptr<LayerImpl> FakePictureLayer::CreateLayerImpl(
return FakePictureLayerImpl::Create(tree_impl, layer_id_).PassAs<LayerImpl>();
}
-void FakePictureLayer::Update(ResourceUpdateQueue* queue,
+bool FakePictureLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
- PictureLayer::Update(queue, occlusion);
+ bool updated = PictureLayer::Update(queue, occlusion);
update_count_++;
+ return updated;
}
} // namespace cc
diff --git a/cc/test/fake_picture_layer.h b/cc/test/fake_picture_layer.h
index 442ed64..7608644 100644
--- a/cc/test/fake_picture_layer.h
+++ b/cc/test/fake_picture_layer.h
@@ -23,7 +23,7 @@ class FakePictureLayer : public PictureLayer {
size_t update_count() const { return update_count_; }
void reset_update_count() { update_count_ = 0; }
- virtual void Update(
+ virtual bool Update(
ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
diff --git a/cc/test/fake_scrollbar_layer.cc b/cc/test/fake_scrollbar_layer.cc
index a75edd2..b3b6f2f 100644
--- a/cc/test/fake_scrollbar_layer.cc
+++ b/cc/test/fake_scrollbar_layer.cc
@@ -26,14 +26,15 @@ FakeScrollbarLayer::FakeScrollbarLayer(bool paint_during_update,
FakeScrollbarLayer::~FakeScrollbarLayer() {}
-void FakeScrollbarLayer::Update(ResourceUpdateQueue* queue,
+bool FakeScrollbarLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) {
size_t full = queue->FullUploadSize();
size_t partial = queue->PartialUploadSize();
- ScrollbarLayer::Update(queue, occlusion);
+ bool updated = ScrollbarLayer::Update(queue, occlusion);
update_count_++;
last_update_full_upload_size_ = queue->FullUploadSize() - full;
last_update_partial_upload_size_ = queue->PartialUploadSize() - partial;
+ return updated;
}
} // namespace cc
diff --git a/cc/test/fake_scrollbar_layer.h b/cc/test/fake_scrollbar_layer.h
index 8d0d624..2292210 100644
--- a/cc/test/fake_scrollbar_layer.h
+++ b/cc/test/fake_scrollbar_layer.h
@@ -28,7 +28,7 @@ class FakeScrollbarLayer : public ScrollbarLayer {
return last_update_partial_upload_size_;
}
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE;
private:
diff --git a/cc/trees/layer_tree_host.cc b/cc/trees/layer_tree_host.cc
index 27ece47..ba8aeb2 100644
--- a/cc/trees/layer_tree_host.cc
+++ b/cc/trees/layer_tree_host.cc
@@ -637,22 +637,22 @@ bool LayerTreeHost::InitializeOutputSurfaceIfNeeded() {
return !output_surface_lost_;
}
-void LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue,
+bool LayerTreeHost::UpdateLayers(ResourceUpdateQueue* queue,
size_t memory_allocation_limit_bytes) {
DCHECK(!output_surface_lost_);
if (!root_layer())
- return;
+ return false;
if (device_viewport_size().IsEmpty())
- return;
+ return false;
if (contents_texture_manager_ && memory_allocation_limit_bytes) {
contents_texture_manager_->SetMaxMemoryLimitBytes(
memory_allocation_limit_bytes);
}
- UpdateLayers(root_layer(), queue);
+ return UpdateLayers(root_layer(), queue);
}
static Layer* FindFirstScrollableLayer(Layer* layer) {
@@ -683,7 +683,7 @@ void LayerTreeHost::CalculateLCDTextMetricsCallback(Layer* layer) {
}
}
-void LayerTreeHost::UpdateLayers(Layer* root_layer,
+bool LayerTreeHost::UpdateLayers(Layer* root_layer,
ResourceUpdateQueue* queue) {
TRACE_EVENT1("cc", "LayerTreeHost::UpdateLayers",
"commit_number", commit_number());
@@ -734,7 +734,10 @@ void LayerTreeHost::UpdateLayers(Layer* root_layer,
// Reset partial texture update requests.
partial_texture_update_requests_ = 0;
- bool need_more_updates = PaintLayerContents(update_list, queue);
+ bool did_paint_content = false;
+ bool need_more_updates = false;
+ PaintLayerContents(
+ update_list, queue, &did_paint_content, &need_more_updates);
if (trigger_idle_updates_ && need_more_updates) {
TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::posting prepaint task");
prepaint_callback_.Reset(base::Bind(&LayerTreeHost::TriggerPrepaint,
@@ -747,6 +750,8 @@ void LayerTreeHost::UpdateLayers(Layer* root_layer,
for (size_t i = 0; i < update_list.size(); ++i)
update_list[i]->ClearRenderSurface();
+
+ return did_paint_content;
}
void LayerTreeHost::TriggerPrepaint() {
@@ -855,32 +860,35 @@ size_t LayerTreeHost::CalculateMemoryForRenderSurfaces(
return readback_bytes + max_background_texture_bytes + contents_texture_bytes;
}
-bool LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer,
- ResourceUpdateQueue* queue) {
+void LayerTreeHost::PaintMasksForRenderSurface(Layer* render_surface_layer,
+ ResourceUpdateQueue* queue,
+ bool* did_paint_content,
+ bool* need_more_updates) {
// Note: Masks and replicas only exist for layers that own render surfaces. If
// we reach this point in code, we already know that at least something will
// be drawn into this render surface, so the mask and replica should be
// painted.
- bool need_more_updates = false;
Layer* mask_layer = render_surface_layer->mask_layer();
if (mask_layer) {
- mask_layer->Update(queue, NULL);
- need_more_updates |= mask_layer->NeedMoreUpdates();
+ *did_paint_content |= mask_layer->Update(queue, NULL);
+ *need_more_updates |= mask_layer->NeedMoreUpdates();
}
Layer* replica_mask_layer =
render_surface_layer->replica_layer() ?
render_surface_layer->replica_layer()->mask_layer() : NULL;
if (replica_mask_layer) {
- replica_mask_layer->Update(queue, NULL);
- need_more_updates |= replica_mask_layer->NeedMoreUpdates();
+ *did_paint_content |= replica_mask_layer->Update(queue, NULL);
+ *need_more_updates |= replica_mask_layer->NeedMoreUpdates();
}
- return need_more_updates;
}
-bool LayerTreeHost::PaintLayerContents(
- const LayerList& render_surface_layer_list, ResourceUpdateQueue* queue) {
+void LayerTreeHost::PaintLayerContents(
+ const LayerList& render_surface_layer_list,
+ ResourceUpdateQueue* queue,
+ bool* did_paint_content,
+ bool* need_more_updates) {
// Use FrontToBack to allow for testing occlusion and performing culling
// during the tree walk.
typedef LayerIterator<Layer,
@@ -888,7 +896,6 @@ bool LayerTreeHost::PaintLayerContents(
RenderSurface,
LayerIteratorActions::FrontToBack> LayerIteratorType;
- bool need_more_updates = false;
bool record_metrics_for_frame =
settings_.show_overdraw_in_tracing &&
base::debug::TraceLog::GetInstance() &&
@@ -914,11 +921,12 @@ bool LayerTreeHost::PaintLayerContents(
if (it.represents_target_render_surface()) {
DCHECK(it->render_surface()->draw_opacity() ||
it->render_surface()->draw_opacity_is_animating());
- need_more_updates |= PaintMasksForRenderSurface(*it, queue);
+ PaintMasksForRenderSurface(
+ *it, queue, did_paint_content, need_more_updates);
} else if (it.represents_itself()) {
DCHECK(!it->paint_properties().bounds.IsEmpty());
- it->Update(queue, &occlusion_tracker);
- need_more_updates |= it->NeedMoreUpdates();
+ *did_paint_content |= it->Update(queue, &occlusion_tracker);
+ *need_more_updates |= it->NeedMoreUpdates();
}
occlusion_tracker.LeaveLayer(it);
@@ -927,8 +935,6 @@ bool LayerTreeHost::PaintLayerContents(
in_paint_layer_contents_ = false;
occlusion_tracker.overdraw_metrics()->RecordMetrics(this);
-
- return need_more_updates;
}
void LayerTreeHost::ApplyScrollAndScale(const ScrollAndScaleSet& info) {
diff --git a/cc/trees/layer_tree_host.h b/cc/trees/layer_tree_host.h
index b285604..3d114d5 100644
--- a/cc/trees/layer_tree_host.h
+++ b/cc/trees/layer_tree_host.h
@@ -128,7 +128,7 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) {
virtual void AcquireLayerTextures();
// Returns false if we should abort this frame due to initialization failure.
bool InitializeOutputSurfaceIfNeeded();
- void UpdateLayers(ResourceUpdateQueue* queue,
+ bool UpdateLayers(ResourceUpdateQueue* queue,
size_t contents_memory_limit_bytes);
LayerTreeHostClient* client() { return client_; }
@@ -263,11 +263,15 @@ class CC_EXPORT LayerTreeHost : NON_EXPORTED_BASE(public RateLimiterClient) {
private:
bool InitializeProxy(scoped_ptr<Proxy> proxy);
- bool PaintLayerContents(const LayerList& render_surface_layer_list,
- ResourceUpdateQueue* quue);
- bool PaintMasksForRenderSurface(Layer* render_surface_layer,
- ResourceUpdateQueue* queue);
- void UpdateLayers(Layer* root_layer, ResourceUpdateQueue* queue);
+ void PaintLayerContents(const LayerList& render_surface_layer_list,
+ ResourceUpdateQueue* queue,
+ bool* did_paint_content,
+ bool* need_more_updates);
+ void PaintMasksForRenderSurface(Layer* render_surface_layer,
+ ResourceUpdateQueue* queue,
+ bool* did_paint_content,
+ bool* need_more_updates);
+ bool UpdateLayers(Layer* root_layer, ResourceUpdateQueue* queue);
void UpdateHudLayer();
void TriggerPrepaint();
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index c2c0e99..9d4650c 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -921,10 +921,11 @@ class ContentLayerWithUpdateTracking : public ContentLayer {
int PaintContentsCount() { return paint_contents_count_; }
void ResetPaintContentsCount() { paint_contents_count_ = 0; }
- virtual void Update(ResourceUpdateQueue* queue,
+ virtual bool Update(ResourceUpdateQueue* queue,
const OcclusionTracker* occlusion) OVERRIDE {
- ContentLayer::Update(queue, occlusion);
+ bool updated = ContentLayer::Update(queue, occlusion);
paint_contents_count_++;
+ return updated;
}
private:
@@ -1583,7 +1584,7 @@ class EvictionTestLayer : public Layer {
return make_scoped_refptr(new EvictionTestLayer());
}
- virtual void Update(ResourceUpdateQueue*,
+ virtual bool Update(ResourceUpdateQueue*,
const OcclusionTracker*) OVERRIDE;
virtual bool DrawsContent() const OVERRIDE { return true; }
@@ -1643,16 +1644,17 @@ void EvictionTestLayer::SetTexturePriorities(const PriorityCalculator&) {
texture_->set_request_priority(PriorityCalculator::UIPriority(true));
}
-void EvictionTestLayer::Update(ResourceUpdateQueue* queue,
+bool EvictionTestLayer::Update(ResourceUpdateQueue* queue,
const OcclusionTracker*) {
CreateTextureIfNeeded();
if (!texture_)
- return;
+ return false;
gfx::Rect full_rect(0, 0, 10, 10);
ResourceUpdate upload = ResourceUpdate::Create(
texture_.get(), &bitmap_, full_rect, full_rect, gfx::Vector2d());
queue->AppendFullUpload(upload);
+ return true;
}
scoped_ptr<LayerImpl> EvictionTestLayer::CreateLayerImpl(
diff --git a/cc/trees/layer_tree_host_unittest_occlusion.cc b/cc/trees/layer_tree_host_unittest_occlusion.cc
index beaedc1..fa9b6fb 100644
--- a/cc/trees/layer_tree_host_unittest_occlusion.cc
+++ b/cc/trees/layer_tree_host_unittest_occlusion.cc
@@ -17,11 +17,11 @@ class TestLayer : public Layer {
return make_scoped_refptr(new TestLayer());
}
- virtual void Update(
+ virtual bool Update(
ResourceUpdateQueue* update_queue,
const OcclusionTracker* occlusion) OVERRIDE {
if (!occlusion)
- return;
+ return false;
// Gain access to internals of the OcclusionTracker.
const TestOcclusionTracker* test_occlusion =
@@ -29,6 +29,7 @@ class TestLayer : public Layer {
occlusion_ = UnionRegions(
test_occlusion->occlusion_from_inside_target(),
test_occlusion->occlusion_from_outside_target());
+ return false;
}
const Region& occlusion() const { return occlusion_; }