Index: Source/platform/graphics/skia/NativeImageSkia.cpp |
diff --git a/Source/platform/graphics/skia/NativeImageSkia.cpp b/Source/platform/graphics/skia/NativeImageSkia.cpp |
index f0db318605e4ca49e68ed556d327cfceab3492e5..df9ab4abcca6d88468a4e465110ec2e513fef3a8 100644 |
--- a/Source/platform/graphics/skia/NativeImageSkia.cpp |
+++ b/Source/platform/graphics/skia/NativeImageSkia.cpp |
@@ -36,9 +36,9 @@ |
#include "platform/geometry/FloatPoint.h" |
#include "platform/geometry/FloatRect.h" |
#include "platform/geometry/FloatSize.h" |
+#include "platform/graphics/DeferredImageDecoder.h" |
#include "platform/graphics/GraphicsContext.h" |
#include "platform/graphics/Image.h" |
-#include "platform/graphics/DeferredImageDecoder.h" |
#include "platform/graphics/skia/SkiaUtils.h" |
#include "skia/ext/image_operations.h" |
#include "third_party/skia/include/core/SkMatrix.h" |
@@ -347,12 +347,19 @@ static bool shouldDrawAntiAliased(GraphicsContext* context, const SkRect& destRe |
return destRect.width() * fabs(widthExpansion) < 1 || destRect.height() * fabs(heightExpansion) < 1; |
} |
-void NativeImageSkia::draw(GraphicsContext* context, const SkRect& srcRect, const SkRect& destRect, PassRefPtr<SkXfermode> compOp) const |
+void NativeImageSkia::draw(GraphicsContext* context, const SkRect& srcRect, const SkRect& destRect, PassRefPtr<SkXfermode> compOp, PassRefPtr<SkColorFilter> colorTransform) const |
{ |
TRACE_EVENT0("skia", "NativeImageSkia::draw"); |
SkPaint paint; |
paint.setXfermode(compOp.get()); |
- paint.setColorFilter(context->colorFilter()); |
+ // FIXME: GraphicsContext only supports one filter, and here we ignore it and use the |
+ // colorTransform argument instead (paint-time color correction). |
+ // -- GraphicsContext needs a new api, setColorSpaceFilter. |
+ // -- SkPaint needs a new api, paint.setColorSpaceFilter, to allow CSS or SVG |
+ // software filters to co-exist with the color space filter. |
Stephen White
2014/07/03 18:38:17
Actually I don't think CSS or SVG filters ever hit
|
+ // -- Skia can control the application of the filters, and in what order, which |
+ // is likely to be colorSpaceFilter first then colorFilter, during paint. |
+ paint.setColorFilter(colorTransform.get() ? colorTransform.get() : context->colorFilter()); |
paint.setAlpha(context->getNormalizedAlpha()); |
paint.setLooper(context->drawLooper()); |
paint.setAntiAlias(shouldDrawAntiAliased(context, destRect)); |
@@ -424,17 +431,10 @@ static SkBitmap createBitmapWithSpace(const SkBitmap& bitmap, int spaceWidth, in |
return result; |
} |
-void NativeImageSkia::drawPattern( |
- GraphicsContext* context, |
- const FloatRect& floatSrcRect, |
- const FloatSize& scale, |
- const FloatPoint& phase, |
- CompositeOperator compositeOp, |
- const FloatRect& destRect, |
- blink::WebBlendMode blendMode, |
- const IntSize& repeatSpacing) const |
+void NativeImageSkia::drawPattern(GraphicsContext* context, const FloatRect& srcRect, const FloatSize& scale, |
+ const FloatPoint& phase, CompositeOperator compositeOp, const FloatRect& destRect, blink::WebBlendMode blendMode, const IntSize& repeatSpacing, PassRefPtr<SkColorFilter> colorTransform) const |
{ |
- FloatRect normSrcRect = floatSrcRect; |
+ FloatRect normSrcRect = srcRect; |
normSrcRect.intersect(FloatRect(0, 0, bitmap().width(), bitmap().height())); |
if (destRect.isEmpty() || normSrcRect.isEmpty()) |
return; // nothing to draw |
@@ -527,7 +527,9 @@ void NativeImageSkia::drawPattern( |
SkPaint paint; |
paint.setShader(shader.get()); |
paint.setXfermode(WebCoreCompositeToSkiaComposite(compositeOp, blendMode).get()); |
- paint.setColorFilter(context->colorFilter()); |
+ // FIXME: GraphicsContext only supports one filter, and here we ignore it and use the |
+ // colorTransform argument instead (paint-time color correction). |
+ paint.setColorFilter(colorTransform.get() ? colorTransform.get() : context->colorFilter()); |
paint.setFilterLevel(convertToSkiaFilterLevel(useBicubicFilter, resampling)); |
if (isLazyDecoded) |