Index: Source/platform/graphics/ImageBuffer.cpp |
diff --git a/Source/platform/graphics/ImageBuffer.cpp b/Source/platform/graphics/ImageBuffer.cpp |
index 12a631e173a4618d5632b44681869de5f3be4717..e69d87a7a380dab35bb8c7a9d3c98f886d313a58 100644 |
--- a/Source/platform/graphics/ImageBuffer.cpp |
+++ b/Source/platform/graphics/ImageBuffer.cpp |
@@ -78,6 +78,7 @@ PassOwnPtr<ImageBuffer> ImageBuffer::create(const IntSize& size, OpacityMode opa |
ImageBuffer::ImageBuffer(PassOwnPtr<ImageBufferSurface> surface) |
: m_surface(surface) |
, m_client(0) |
+ , m_snapshotState(InitialSnapshotState) |
{ |
m_surface->setImageBuffer(this); |
} |
@@ -149,6 +150,9 @@ void ImageBuffer::resetCanvas(SkCanvas* canvas) const |
PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot() const |
{ |
+ if (m_snapshotState == InitialSnapshotState) |
+ m_snapshotState = DidAcquireSnapshot; |
+ |
if (!isSurfaceValid()) |
return nullptr; |
return m_surface->newImageSnapshot(); |
@@ -156,14 +160,19 @@ PassRefPtr<SkImage> ImageBuffer::newSkImageSnapshot() const |
PassRefPtr<Image> ImageBuffer::newImageSnapshot() const |
{ |
- if (!isSurfaceValid()) |
- return nullptr; |
- RefPtr<SkImage> snapshot = m_surface->newImageSnapshot(); |
+ RefPtr<SkImage> snapshot = newSkImageSnapshot(); |
if (!snapshot) |
return nullptr; |
return StaticBitmapImage::create(snapshot); |
} |
+void ImageBuffer::didDraw(const FloatRect& rect) const |
+{ |
+ if (m_snapshotState == DidAcquireSnapshot) |
+ m_snapshotState = DrawnToAfterSnapshot; |
+ m_surface->didDraw(rect); |
+} |
+ |
WebLayer* ImageBuffer::platformLayer() const |
{ |
return m_surface->layer(); |