diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp b/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp index df680eb..f285c9b 100644 --- a/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp +++ b/Source/WebCore/platform/graphics/skia/GraphicsContextSkia.cpp @@ -44,8 +44,10 @@ #include "PlatformContextSkia.h" #include "SkBitmap.h" -#include "SkBlurDrawLooper.h" +#include "SkBlurMaskFilter.h" +#include "SkColorFilter.h" #include "SkCornerPathEffect.h" +#include "SkLayerDrawLooper.h" #include "SkShader.h" #include "SkiaUtils.h" #include "skia/ext/platform_canvas.h" @@ -853,6 +855,7 @@ void GraphicsContext::fillRoundedRect(const IntRect& rect, SkPaint paint; platformContext()->setupPaintForFilling(&paint); + paint.setColor(color.rgb()); platformContext()->canvas()->drawPath(path, paint); } @@ -867,7 +870,7 @@ AffineTransform GraphicsContext::getCTM() const SkScalarToDouble(m.getTranslateY())); } -FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect) +FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect, RoundingMode) { return rect; } @@ -1043,16 +1046,15 @@ void GraphicsContext::setPlatformShadow(const FloatSize& size, double height = size.height(); double blur = blurFloat; - uint32_t blurFlags = SkBlurDrawLooper::kHighQuality_BlurFlag | - SkBlurDrawLooper::kOverrideColor_BlurFlag; + uint32_t mfFlags = SkBlurMaskFilter::kHighQuality_BlurFlag; if (m_state.shadowsIgnoreTransforms) { // Currently only the GraphicsContext associated with the // CanvasRenderingContext for HTMLCanvasElement have shadows ignore // Transforms. So with this flag set, we know this state is associated // with a CanvasRenderingContext. - blurFlags |= SkBlurDrawLooper::kIgnoreTransform_BlurFlag; - + mfFlags |= SkBlurMaskFilter::kIgnoreTransform_BlurFlag; + // CG uses natural orientation for Y axis, but the HTML5 canvas spec // does not. // So we now flip the height since it was flipped in @@ -1068,9 +1070,32 @@ void GraphicsContext::setPlatformShadow(const FloatSize& size, // TODO(tc): Should we have a max value for the blur? CG clamps at 1000.0 // for perf reasons. - SkDrawLooper* dl = new SkBlurDrawLooper(blur / 2, width, height, c, blurFlags); + + SkLayerDrawLooper* dl = new SkLayerDrawLooper; + SkAutoUnref aur(dl); + + // top layer, we just draw unchanged + dl->addLayer(); + + // lower layer contains our offset, blur, and colorfilter + SkLayerDrawLooper::LayerInfo info; + + info.fPaintBits |= SkLayerDrawLooper::kMaskFilter_Bit; // our blur + info.fPaintBits |= SkLayerDrawLooper::kColorFilter_Bit; + info.fColorMode = SkXfermode::kDst_Mode; + info.fOffset.set(width, height); + info.fPostTranslate = m_state.shadowsIgnoreTransforms; + + SkMaskFilter* mf = SkBlurMaskFilter::Create(blur / 2, SkBlurMaskFilter::kNormal_BlurStyle, mfFlags); + + SkColorFilter* cf = SkColorFilter::CreateModeFilter(c, SkXfermode::kSrcIn_Mode); + + SkPaint* paint = dl->addLayer(info); + SkSafeUnref(paint->setMaskFilter(mf)); + SkSafeUnref(paint->setColorFilter(cf)); + + // dl is now built, just install it platformContext()->setDrawLooper(dl); - dl->unref(); } void GraphicsContext::setPlatformStrokeColor(const Color& strokecolor, ColorSpace colorSpace) |