summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmanuele Aina <emanuele.aina@collabora.com>2015-03-11 12:52:09 (GMT)
committerEmanuele Aina <emanuele.aina@collabora.com>2015-03-11 18:21:10 (GMT)
commit83fc6501c18e307346b6fdf99240b86b7a467cfa (patch)
tree085a9dbb6342a51243f2ab7d4273950d6e85460f
parent64b2b287d3106a64d005eefb6b28f25217c346a6 (diff)
downloadWebKit-83fc6501c18e307346b6fdf99240b86b7a467cfa.tar.gz
WebKit-83fc6501c18e307346b6fdf99240b86b7a467cfa.tar.xz
[TBS] Make buffer creation idempotent
-rw-r--r--Source/WebCore/platform/graphics/cairo/TileCairo.cpp27
-rw-r--r--Source/WebCore/platform/graphics/cairo/TileCairo.h2
2 files changed, 17 insertions, 12 deletions
diff --git a/Source/WebCore/platform/graphics/cairo/TileCairo.cpp b/Source/WebCore/platform/graphics/cairo/TileCairo.cpp
index 9c874aa..1057e9f 100644
--- a/Source/WebCore/platform/graphics/cairo/TileCairo.cpp
+++ b/Source/WebCore/platform/graphics/cairo/TileCairo.cpp
@@ -100,17 +100,24 @@ void TileCairo::invalidate(const IntRect& dirtyRect)
m_frontDirtyRegion.unite(Region(tileDirtyRect));
}
-static PassRefPtr<cairo_surface_t> createBackBuffer(TiledBackingStore *tiledBackingStore, int width, int height)
+void TileCairo::ensureBackBuffer()
{
- OwnPtr<GraphicsContext> context = tiledBackingStore->client()->targetContext();
- if (!context)
- return adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height));
+ if (m_backBuffer)
+ return;
+
+ m_backDirtyRegion = Region(m_rect);
+
+ OwnPtr<GraphicsContext> context = m_backingStore->client()->targetContext();
+ if (!context) {
+ m_backBuffer = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, m_rect.width(), m_rect.height()));
+ return;
+ }
cairo_format_t format = context->platformContext()->format();
cairo_t* cr = context->platformContext()->cr();
cairo_surface_t *target = cairo_get_target(cr);
- return adoptRef(cairo_surface_create_similar_image(target, format, width, height));
+ m_backBuffer = adoptRef(cairo_surface_create_similar_image(target, format, m_rect.width(), m_rect.height()));
}
static void paintClippedSurface(PassRefPtr<cairo_t> cr, const Region& clip, PassRefPtr<cairo_surface_t> surface, const IntPoint& location)
@@ -148,11 +155,8 @@ Vector<IntRect> TileCairo::updateBackBuffer()
if (backBuffer() && !isDirty())
return Vector<IntRect>();
- if (!backBuffer()) {
- m_backDirtyRegion = Region(m_rect);
- if (!m_threadedUpdate)
- m_backBuffer = createBackBuffer(m_backingStore, m_rect.width(), m_rect.height());
- }
+ if (!m_threadedUpdate)
+ ensureBackBuffer();
RefPtr<cairo_surface_t> surface;
if (m_threadedUpdate)
@@ -192,8 +196,7 @@ Vector<IntRect> TileCairo::updateBackBuffer()
void TileCairo::paintToBackBuffer(PassRefPtr<cairo_surface_t> surface, const Region& region)
{
- if (!backBuffer())
- m_backBuffer = createBackBuffer(m_backingStore, m_rect.width(), m_rect.height());
+ ensureBackBuffer();
RefPtr<cairo_t> replay = adoptRef(cairo_create(backBuffer().get()));
IntSize offset(toIntSize(-m_rect.location()));
diff --git a/Source/WebCore/platform/graphics/cairo/TileCairo.h b/Source/WebCore/platform/graphics/cairo/TileCairo.h
index 1b62ead..dfea45b 100644
--- a/Source/WebCore/platform/graphics/cairo/TileCairo.h
+++ b/Source/WebCore/platform/graphics/cairo/TileCairo.h
@@ -121,6 +121,8 @@ protected:
PassRefPtr<cairo_surface_t> backBuffer() const;
PassRefPtr<cairo_surface_t> frontBuffer() const;
+ void ensureBackBuffer();
+
Region paintRegion() const;
Region copyRegion() const;