summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Aina <emanuele.aina@collabora.com>2015-02-19 18:40:16 (GMT)
committerEmanuele Aina <emanuele.aina@collabora.com>2015-04-03 00:50:13 (GMT)
commit3c8febb190b0ebf8e82705cb1baa009de4e77bc1 (patch)
tree530bbfa02a9ead319c37838944d52d9412b6c5ee
parent83fc6501c18e307346b6fdf99240b86b7a467cfa (diff)
downloadWebKit-3c8febb190b0ebf8e82705cb1baa009de4e77bc1.tar.gz
WebKit-3c8febb190b0ebf8e82705cb1baa009de4e77bc1.tar.xz
[TBS] Try to update the most complex tiles first to reduce waits
Add an heuristic to update tiles starting from the most likely to cause waits (eg. bigger area to be redrawn, more complex operations): this way longer operations can start earlier and hopefully finish at the same time as the faster ones, thus reducing the total wait time. We've tried different predictors, but the area to be redrawn has always proved to be the most accurate one despite its extreme simplicity.
-rw-r--r--Source/WebCore/platform/graphics/Tile.h1
-rw-r--r--Source/WebCore/platform/graphics/TiledBackingStore.cpp7
-rw-r--r--Source/WebCore/platform/graphics/cairo/TileCairo.cpp5
-rw-r--r--Source/WebCore/platform/graphics/cairo/TileCairo.h1
4 files changed, 14 insertions, 0 deletions
diff --git a/Source/WebCore/platform/graphics/Tile.h b/Source/WebCore/platform/graphics/Tile.h
index fa25ca2..b4d5c1d 100644
--- a/Source/WebCore/platform/graphics/Tile.h
+++ b/Source/WebCore/platform/graphics/Tile.h
@@ -47,6 +47,7 @@ public:
virtual const Tile::Coordinate& coordinate() const = 0;
virtual const IntRect& rect() const = 0;
virtual void resize(const WebCore::IntSize&) = 0;
+ virtual unsigned updatePriority() = 0;
};
}
diff --git a/Source/WebCore/platform/graphics/TiledBackingStore.cpp b/Source/WebCore/platform/graphics/TiledBackingStore.cpp
index 74994b4..51db9c1 100644
--- a/Source/WebCore/platform/graphics/TiledBackingStore.cpp
+++ b/Source/WebCore/platform/graphics/TiledBackingStore.cpp
@@ -180,6 +180,13 @@ void TiledBackingStore::updateTileBuffers()
return;
}
+ // Try to update the most complex tiles first to reduce waits when doing
+ // async/parallel updates
+ auto highToLowPriority = [](const RefPtr<Tile> & a, const RefPtr<Tile> & b) {
+ return a->updatePriority() > b->updatePriority();
+ };
+ std::stable_sort(dirtyTiles.begin(), dirtyTiles.end(), highToLowPriority);
+
// Tile back buffers can be updated asynchronously one by one and then
// swapped to front in one go. This can minimize the time spent blocking
// on tile updates.
diff --git a/Source/WebCore/platform/graphics/cairo/TileCairo.cpp b/Source/WebCore/platform/graphics/cairo/TileCairo.cpp
index 1057e9f..b1bce8e 100644
--- a/Source/WebCore/platform/graphics/cairo/TileCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/TileCairo.cpp
@@ -84,6 +84,11 @@ Region TileCairo::copyRegion() const
return m_doubleBuffered ? subtract(m_backDirtyRegion, m_frontDirtyRegion) : Region();
}
+unsigned TileCairo::updatePriority()
+{
+ return paintRegion().totalArea();
+}
+
bool TileCairo::isDirty() const
{
return !frontBuffer() || !m_frontDirtyRegion.isEmpty();
diff --git a/Source/WebCore/platform/graphics/cairo/TileCairo.h b/Source/WebCore/platform/graphics/cairo/TileCairo.h
index dfea45b..a8c953d 100644
--- a/Source/WebCore/platform/graphics/cairo/TileCairo.h
+++ b/Source/WebCore/platform/graphics/cairo/TileCairo.h
@@ -63,6 +63,7 @@ public:
virtual const Tile::Coordinate& coordinate() const { return m_coordinate; }
virtual const IntRect& rect() const { return m_rect; }
virtual void resize(const WebCore::IntSize&);
+ virtual unsigned updatePriority();
protected:
class QueuedUpdate {