Index: Source/platform/graphics/ImageBufferSurface.cpp |
diff --git a/Source/platform/graphics/ImageBufferSurface.cpp b/Source/platform/graphics/ImageBufferSurface.cpp |
index 038814f54a4b3e95155d4dcc69e7232acb6c3d10..d7d16d71d5d69e44c2feb93d74ccaf54f8a494eb 100644 |
--- a/Source/platform/graphics/ImageBufferSurface.cpp |
+++ b/Source/platform/graphics/ImageBufferSurface.cpp |
@@ -32,6 +32,8 @@ |
#include "platform/graphics/ImageBufferSurface.h" |
+#include "platform/graphics/BitmapImage.h" |
+#include "platform/graphics/GraphicsContext.h" |
#include "platform/graphics/ImageBuffer.h" |
#include "third_party/skia/include/core/SkCanvas.h" |
#include "third_party/skia/include/core/SkDevice.h" |
@@ -86,4 +88,28 @@ PassRefPtr<SkImage> ImageBufferSurface::newImageSnapshot() const |
return nullptr; |
} |
+static SkBitmap deepSkBitmapCopy(const SkBitmap& bitmap) |
+{ |
+ SkBitmap tmp; |
+ if (!bitmap.deepCopyTo(&tmp)) |
+ bitmap.copyTo(&tmp, bitmap.colorType()); |
+ |
+ return tmp; |
+} |
+ |
+void ImageBufferSurface::draw(GraphicsContext* context, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator op, WebBlendMode blendMode, bool needsCopy) |
+{ |
+ SkBitmap bmp = bitmap(); |
+ // For ImageBufferSurface that enables cachedBitmap, Use the cached bitmap for CPU side usage |
+ // if it is available, otherwise generate and use it. |
+ if (!context->isAccelerated() && isAccelerated() && cachedBitmapEnabled() && isValid()) { |
+ updateCachedBitmapIfNeeded(); |
+ bmp = cachedBitmap(); |
+ } |
+ |
+ RefPtr<Image> image = BitmapImage::create(NativeImageSkia::create(needsCopy ? deepSkBitmapCopy(bmp) : bmp)); |
+ |
+ context->drawImage(image.get(), destRect, srcRect, op, blendMode, DoNotRespectImageOrientation); |
+} |
+ |
} // namespace blink |