summaryrefslogtreecommitdiffstats
path: root/components/exo
diff options
context:
space:
mode:
authorreveman <reveman@chromium.org>2016-02-11 13:28:56 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-11 21:30:21 +0000
commit5c353d58cbf5461ca693cf517f791838cb973f81 (patch)
tree94d4e8c2a148b68615478d43669b1e301f97644e /components/exo
parentb5e852912bdd3f9c9351f9b6fbb8de26609545f3 (diff)
downloadchromium_src-5c353d58cbf5461ca693cf517f791838cb973f81.zip
chromium_src-5c353d58cbf5461ca693cf517f791838cb973f81.tar.gz
chromium_src-5c353d58cbf5461ca693cf517f791838cb973f81.tar.bz2
exo: Improve damage tracking.
This sends the exact damage region reported by clients to the compositor instead of a bounding box for the damage. BUG=549781 TEST=exo_unittests --gtest_filter=Surface.Damage Review URL: https://codereview.chromium.org/1688273002 Cr-Commit-Position: refs/heads/master@{#374996}
Diffstat (limited to 'components/exo')
-rw-r--r--components/exo/surface.cc9
-rw-r--r--components/exo/surface.h8
-rw-r--r--components/exo/surface_unittest.cc7
3 files changed, 15 insertions, 9 deletions
diff --git a/components/exo/surface.cc b/components/exo/surface.cc
index fc09e13..5639d18 100644
--- a/components/exo/surface.cc
+++ b/components/exo/surface.cc
@@ -138,7 +138,7 @@ void Surface::Attach(Buffer* buffer) {
void Surface::Damage(const gfx::Rect& damage) {
TRACE_EVENT1("exo", "Surface::Damage", "damage", damage.ToString());
- pending_damage_.Union(damage);
+ pending_damage_.op(gfx::RectToSkIRect(damage), SkRegion::kUnion_Op);
}
void Surface::RequestFrameCallback(const FrameCallback& callback) {
@@ -296,8 +296,11 @@ void Surface::CommitSurfaceHierarchy() {
}
// Schedule redraw of the damage region.
- layer()->SchedulePaint(pending_damage_);
- pending_damage_ = gfx::Rect();
+ for (SkRegion::Iterator it(pending_damage_); !it.done(); it.next())
+ layer()->SchedulePaint(gfx::SkIRectToRect(it.rect()));
+
+ // Reset damage.
+ pending_damage_.setEmpty();
}
ui::Compositor* compositor = layer()->GetCompositor();
diff --git a/components/exo/surface.h b/components/exo/surface.h
index 93396d0..d5377d3 100644
--- a/components/exo/surface.h
+++ b/components/exo/surface.h
@@ -101,7 +101,9 @@ class Surface : public aura::Window, public ui::CompositorObserver {
// Returns a trace value representing the state of the surface.
scoped_refptr<base::trace_event::TracedValue> AsTracedValue() const;
- bool HasPendingDamageForTesting() const { return !pending_damage_.IsEmpty(); }
+ bool HasPendingDamageForTesting(const gfx::Rect& damage) const {
+ return pending_damage_.contains(gfx::RectToSkIRect(damage));
+ }
// Overridden from ui::CompositorObserver:
void OnCompositingDidCommit(ui::Compositor* compositor) override;
@@ -128,9 +130,7 @@ class Surface : public aura::Window, public ui::CompositorObserver {
base::WeakPtr<Buffer> pending_buffer_;
// The damage region to schedule paint for when Commit() is called.
- // TODO(reveman): Use SkRegion here after adding a version of
- // ui::Layer::SchedulePaint that takes a SkRegion.
- gfx::Rect pending_damage_;
+ SkRegion pending_damage_;
// These lists contains the callbacks to notify the client when it is a good
// time to start producing a new frame. These callbacks move to
diff --git a/components/exo/surface_unittest.cc b/components/exo/surface_unittest.cc
index b1351a4..d8aba4a 100644
--- a/components/exo/surface_unittest.cc
+++ b/components/exo/surface_unittest.cc
@@ -56,10 +56,13 @@ TEST_F(SurfaceTest, Damage) {
// the surface to the buffer size.
surface->Attach(buffer.get());
- // Mark area inside the bounds of the surface as damaged. This should result
+ // Mark areas inside the bounds of the surface as damaged. This should result
// in pending damage.
surface->Damage(gfx::Rect(0, 0, 10, 10));
- EXPECT_TRUE(surface->HasPendingDamageForTesting());
+ surface->Damage(gfx::Rect(10, 10, 10, 10));
+ EXPECT_TRUE(surface->HasPendingDamageForTesting(gfx::Rect(0, 0, 10, 10)));
+ EXPECT_TRUE(surface->HasPendingDamageForTesting(gfx::Rect(10, 10, 10, 10)));
+ EXPECT_FALSE(surface->HasPendingDamageForTesting(gfx::Rect(5, 5, 10, 10)));
}
void SetFrameTime(base::TimeTicks* result, base::TimeTicks frame_time) {