| Index: third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp b/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
|
| index 191cb3f1a7c5bac2805170bdb25460bb5352dbe1..befafa8da741b078949b1524fb0823e4038099e4 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/RecordingImageBufferSurface.cpp
|
| @@ -8,8 +8,10 @@
|
| #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
|
| #include "platform/graphics/GraphicsContext.h"
|
| #include "platform/graphics/ImageBuffer.h"
|
| +#include "platform/graphics/StaticBitmapImage.h"
|
| #include "public/platform/Platform.h"
|
| #include "third_party/skia/include/core/SkCanvas.h"
|
| +#include "third_party/skia/include/core/SkColorFilter.h"
|
| #include "third_party/skia/include/core/SkPictureRecorder.h"
|
| #include "wtf/PassOwnPtr.h"
|
| #include "wtf/PassRefPtr.h"
|
| @@ -203,19 +205,46 @@ bool RecordingImageBufferSurface::finalizeFrameInternal()
|
| return true;
|
| }
|
|
|
| -void RecordingImageBufferSurface::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, SkXfermode::Mode op)
|
| +void RecordingImageBufferSurface::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, SkXfermode::Mode op, SkColorFilter* transform)
|
| {
|
| if (m_fallbackSurface) {
|
| - m_fallbackSurface->draw(context, destRect, srcRect, op);
|
| + m_fallbackSurface->draw(context, destRect, srcRect, op, transform);
|
| return;
|
| }
|
|
|
| RefPtr<SkPicture> picture = getPicture();
|
| - if (picture) {
|
| - context.compositePicture(picture.get(), destRect, srcRect, op);
|
| - } else {
|
| - ImageBufferSurface::draw(context, destRect, srcRect, op);
|
| + if (!picture) {
|
| + ImageBufferSurface::draw(context, destRect, srcRect, op, transform);
|
| + return;
|
| + }
|
| +
|
| + const SkISize size = SkISize::Make(width(), height());
|
| + RefPtr<SkImage> snapshot = adoptRef(SkImage::NewFromPicture(picture.get(), size, nullptr, nullptr));
|
| +
|
| + // FIXME: why was this alternative path being used to draw the picture? Does it draw
|
| + // differently to the context.drawImage path that other surfaces use to draw?
|
| + // context.compositePicture(picture.get(), destRect, srcRect, op);
|
| +
|
| + if (!transform) {
|
| + RefPtr<Image> image = StaticBitmapImage::create(snapshot.release());
|
| + context.drawImage(image.get(), destRect, srcRect, op);
|
| + return;
|
| }
|
| +
|
| + SkPaint transformPaint;
|
| + transformPaint.setColorFilter(transform);
|
| + transformPaint.setXfermodeMode(SkXfermode::kSrc_Mode);
|
| +
|
| + SkPictureRecorder recorder;
|
| + FloatRect sourceRect = IntRect(0, 0, width(), height());
|
| + SkCanvas* canvas = recorder.beginRecording(sourceRect);
|
| + canvas->drawImage(snapshot.get(), 0, 0, &transformPaint);
|
| + RefPtr<SkPicture> recorded = adoptRef(recorder.endRecordingAsPicture());
|
| +
|
| + snapshot = adoptRef(SkImage::NewFromPicture(recorded.get(), size, nullptr, nullptr));
|
| +
|
| + RefPtr<Image> image = StaticBitmapImage::create(snapshot.release());
|
| + context.drawImage(image.get(), destRect, srcRect, op);
|
| }
|
|
|
| bool RecordingImageBufferSurface::isExpensiveToPaint()
|
|
|