| Index: third_party/WebKit/Source/platform/graphics/ImageBufferSurface.cpp
|
| diff --git a/third_party/WebKit/Source/platform/graphics/ImageBufferSurface.cpp b/third_party/WebKit/Source/platform/graphics/ImageBufferSurface.cpp
|
| index 9bf60796d027bd4089bce72b1922b06ad77deb16..a5d67b7c2b0c4f5e7ca2a4ae1127bb2ea4d1e1aa 100644
|
| --- a/third_party/WebKit/Source/platform/graphics/ImageBufferSurface.cpp
|
| +++ b/third_party/WebKit/Source/platform/graphics/ImageBufferSurface.cpp
|
| @@ -33,6 +33,7 @@
|
| #include "platform/graphics/GraphicsContext.h"
|
| #include "platform/graphics/ImageBuffer.h"
|
| #include "platform/graphics/StaticBitmapImage.h"
|
| +#include "third_party/skia/include/core/SkColorFilter.h"
|
| #include "third_party/skia/include/core/SkImage.h"
|
|
|
| class SkPicture;
|
| @@ -60,7 +61,7 @@ void ImageBufferSurface::clear()
|
| // color. Can we have another way to manage this?
|
| if (isValid()) {
|
| if (m_opacityMode == Opaque) {
|
| - canvas()->clear(SK_ColorBLACK);
|
| + canvas()->clear(SK_ColorBLACK); // FIXME: not color correct.
|
| } else {
|
| canvas()->clear(SK_ColorTRANSPARENT);
|
| }
|
| @@ -68,12 +69,31 @@ void ImageBufferSurface::clear()
|
| }
|
| }
|
|
|
| -void ImageBufferSurface::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, SkXfermode::Mode op)
|
| +void ImageBufferSurface::draw(GraphicsContext& context, const FloatRect& destRect, const FloatRect& srcRect, SkXfermode::Mode op, SkColorFilter* transform)
|
| {
|
| RefPtr<SkImage> snapshot = newImageSnapshot(PreferNoAcceleration);
|
| if (!snapshot)
|
| return;
|
|
|
| + 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());
|
| +
|
| + SkISize size = SkISize::Make(width(), height());
|
| + snapshot = adoptRef(SkImage::NewFromPicture(recorded.get(), size, nullptr, nullptr));
|
| +
|
| RefPtr<Image> image = StaticBitmapImage::create(snapshot.release());
|
| context.drawImage(image.get(), destRect, srcRect, op);
|
| }
|
|
|