2009-06-24 Nicolas Weber <thakis@chromium.org>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jun 2009 21:10:18 +0000 (21:10 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 24 Jun 2009 21:10:18 +0000 (21:10 +0000)
        Reviewed by Eric Seidel.

        https://bugs.webkit.org/show_bug.cgi?id=26685
        Accomodate for backwards-incompatible skia api changes.

        * platform/graphics/skia/GraphicsContextSkia.cpp:
        (WebCore::GraphicsContext::clearRect):
        (WebCore::GraphicsContext::setCompositeOperation):
        * platform/graphics/skia/ImageBufferSkia.cpp:
        (WebCore::ImageBuffer::ImageBuffer):
        * platform/graphics/skia/ImageSkia.cpp:
        (WebCore::paintSkBitmap):
        (WebCore::Image::drawPattern):
        * platform/graphics/skia/PlatformContextSkia.cpp:
        (PlatformContextSkia::State::State):
        (PlatformContextSkia::setupPaintCommon):
        (PlatformContextSkia::setXfermodeMode):
        (PlatformContextSkia::applyClipFromImage):
        * platform/graphics/skia/PlatformContextSkia.h:
        * platform/graphics/skia/SkiaUtils.cpp:
        (WebCore::):
        (WebCore::WebCoreCompositeToSkiaComposite):
        * platform/graphics/skia/SkiaUtils.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45103 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/platform/graphics/skia/GraphicsContextSkia.cpp
WebCore/platform/graphics/skia/ImageBufferSkia.cpp
WebCore/platform/graphics/skia/ImageSkia.cpp
WebCore/platform/graphics/skia/PlatformContextSkia.cpp
WebCore/platform/graphics/skia/PlatformContextSkia.h
WebCore/platform/graphics/skia/SkiaUtils.cpp
WebCore/platform/graphics/skia/SkiaUtils.h

index d085a92..cc09b30 100644 (file)
@@ -1,3 +1,29 @@
+2009-06-24  Nicolas Weber  <thakis@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        https://bugs.webkit.org/show_bug.cgi?id=26685
+        Accomodate for backwards-incompatible skia api changes.
+
+        * platform/graphics/skia/GraphicsContextSkia.cpp:
+        (WebCore::GraphicsContext::clearRect):
+        (WebCore::GraphicsContext::setCompositeOperation):
+        * platform/graphics/skia/ImageBufferSkia.cpp:
+        (WebCore::ImageBuffer::ImageBuffer):
+        * platform/graphics/skia/ImageSkia.cpp:
+        (WebCore::paintSkBitmap):
+        (WebCore::Image::drawPattern):
+        * platform/graphics/skia/PlatformContextSkia.cpp:
+        (PlatformContextSkia::State::State):
+        (PlatformContextSkia::setupPaintCommon):
+        (PlatformContextSkia::setXfermodeMode):
+        (PlatformContextSkia::applyClipFromImage):
+        * platform/graphics/skia/PlatformContextSkia.h:
+        * platform/graphics/skia/SkiaUtils.cpp:
+        (WebCore::):
+        (WebCore::WebCoreCompositeToSkiaComposite):
+        * platform/graphics/skia/SkiaUtils.h:
+
 2009-06-24  Jan Michael Alonzo  <jmalonzo@webkit.org>
 
         Gtk build fix. Add files that were added in r45093 and r45096
index 33ca23a..41c3195 100644 (file)
@@ -331,7 +331,7 @@ void GraphicsContext::clearRect(const FloatRect& rect)
 
     SkPaint paint;
     platformContext()->setupPaintForFilling(&paint);
-    paint.setPorterDuffXfermode(SkPorterDuff::kClear_Mode);
+    paint.setXfermodeMode(SkXfermode::kClear_Mode);
     platformContext()->canvas()->drawRect(r, paint);
 }
 
@@ -858,7 +858,7 @@ void GraphicsContext::setCompositeOperation(CompositeOperator op)
 {
     if (paintingDisabled())
         return;
-    platformContext()->setPorterDuffMode(WebCoreCompositeToSkiaComposite(op));
+    platformContext()->setXfermodeMode(WebCoreCompositeToSkiaComposite(op));
 }
 
 void GraphicsContext::setImageInterpolationQuality(InterpolationQuality)
index 600882d..0459f89 100644 (file)
@@ -71,7 +71,7 @@ ImageBuffer::ImageBuffer(const IntSize& size, bool grayScale, bool& success)
     // Make the background transparent. It would be nice if this wasn't
     // required, but the canvas is currently filled with the magic transparency
     // color. Can we have another way to manage this?
-    m_data.m_canvas.drawARGB(0, 0, 0, 0, SkPorterDuff::kClear_Mode);
+    m_data.m_canvas.drawARGB(0, 0, 0, 0, SkXfermode::kClear_Mode);
     success = true;
 }
 
index cb089bb..45c3dcd 100644 (file)
@@ -220,10 +220,10 @@ static void drawResampledBitmap(SkCanvas& canvas, SkPaint& paint, const NativeIm
     }
 }
 
-static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImageSkia& bitmap, const SkIRect& srcRect, const SkRect& destRect, const SkPorterDuff::Mode& compOp)
+static void paintSkBitmap(PlatformContextSkia* platformContext, const NativeImageSkia& bitmap, const SkIRect& srcRect, const SkRect& destRect, const SkXfermode::Mode& compOp)
 {
     SkPaint paint;
-    paint.setPorterDuffXfermode(compOp);
+    paint.setXfermodeMode(compOp);
     paint.setFilterBitmap(true);
     int alpha = roundf(platformContext->getAlpha() * 256);
     if (alpha > 255)
@@ -379,7 +379,7 @@ void Image::drawPattern(GraphicsContext* context,
 
     SkPaint paint;
     paint.setShader(shader)->unref();
-    paint.setPorterDuffXfermode(WebCoreCompositeToSkiaComposite(compositeOp));
+    paint.setXfermodeMode(WebCoreCompositeToSkiaComposite(compositeOp));
     paint.setFilterBitmap(resampling == RESAMPLE_LINEAR);
 
     context->platformContext()->paintSkPaint(destRect, paint);
index 27c904d..1e6d20b 100644 (file)
@@ -57,7 +57,7 @@ struct PlatformContextSkia::State {
 
     // Common shader state.
     float m_alpha;
-    SkPorterDuff::Mode m_porterDuffMode;
+    SkXfermode::Mode m_xferMode;
     SkShader* m_gradient;
     SkShader* m_pattern;
     bool m_useAntialiasing;
@@ -98,7 +98,7 @@ private:
 // Note: Keep theses default values in sync with GraphicsContextState.
 PlatformContextSkia::State::State()
     : m_alpha(1)
-    , m_porterDuffMode(SkPorterDuff::kSrcOver_Mode)
+    , m_xferMode(SkXfermode::kSrcOver_Mode)
     , m_gradient(0)
     , m_pattern(0)
     , m_useAntialiasing(true)
@@ -118,7 +118,7 @@ PlatformContextSkia::State::State()
 
 PlatformContextSkia::State::State(const State& other)
     : m_alpha(other.m_alpha)
-    , m_porterDuffMode(other.m_porterDuffMode)
+    , m_xferMode(other.m_xferMode)
     , m_gradient(other.m_gradient)
     , m_pattern(other.m_pattern)
     , m_useAntialiasing(other.m_useAntialiasing)
@@ -299,7 +299,7 @@ void PlatformContextSkia::setupPaintCommon(SkPaint* paint) const
 #endif
 
     paint->setAntiAlias(m_state->m_useAntialiasing);
-    paint->setPorterDuffXfermode(m_state->m_porterDuffMode);
+    paint->setXfermodeMode(m_state->m_xferMode);
     paint->setLooper(m_state->m_looper);
 
     if (m_state->m_gradient)
@@ -382,9 +382,9 @@ void PlatformContextSkia::setLineJoin(SkPaint::Join lj)
     m_state->m_lineJoin = lj;
 }
 
-void PlatformContextSkia::setPorterDuffMode(SkPorterDuff::Mode pdm)
+void PlatformContextSkia::setXfermodeMode(SkXfermode::Mode pdm)
 {
-    m_state->m_porterDuffMode = pdm;
+    m_state->m_xferMode = pdm;
 }
 
 void PlatformContextSkia::setFillColor(SkColor color)
@@ -526,7 +526,7 @@ void PlatformContextSkia::applyClipFromImage(const WebCore::FloatRect& rect, con
     // NOTE: this assumes the image mask contains opaque black for the portions that are to be shown, as such we
     // only look at the alpha when compositing. I'm not 100% sure this is what WebKit expects for image clipping.
     SkPaint paint;
-    paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode);
+    paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
     m_canvas->drawBitmap(imageBuffer, SkFloatToScalar(rect.x()), SkFloatToScalar(rect.y()), &paint);
 }
 #endif
index 25495aa..30f8666 100644 (file)
@@ -115,7 +115,7 @@ public:
     void setLineCap(SkPaint::Cap);
     void setLineJoin(SkPaint::Join);
     void setFillRule(SkPath::FillType);
-    void setPorterDuffMode(SkPorterDuff::Mode);
+    void setXfermodeMode(SkXfermode::Mode);
     void setFillColor(SkColor);
     void setStrokeStyle(WebCore::StrokeStyle);
     void setStrokeColor(SkColor);
index 93eb832..d081ab1 100644 (file)
 
 namespace WebCore {
 
-static const struct CompositOpToPorterDuffMode {
+static const struct CompositOpToXfermodeMode {
     uint8_t mCompositOp;
-    uint8_t mPorterDuffMode;
-} gMapCompositOpsToPorterDuffModes[] = {
-    { CompositeClear,           SkPorterDuff::kClear_Mode },
-    { CompositeCopy,            SkPorterDuff::kSrc_Mode },
-    { CompositeSourceOver,      SkPorterDuff::kSrcOver_Mode },
-    { CompositeSourceIn,        SkPorterDuff::kSrcIn_Mode },
-    { CompositeSourceOut,       SkPorterDuff::kSrcOut_Mode },
-    { CompositeSourceAtop,      SkPorterDuff::kSrcATop_Mode },
-    { CompositeDestinationOver, SkPorterDuff::kDstOver_Mode },
-    { CompositeDestinationIn,   SkPorterDuff::kDstIn_Mode },
-    { CompositeDestinationOut,  SkPorterDuff::kDstOut_Mode },
-    { CompositeDestinationAtop, SkPorterDuff::kDstATop_Mode },
-    { CompositeXOR,             SkPorterDuff::kXor_Mode },
-    { CompositePlusDarker,      SkPorterDuff::kDarken_Mode },
-    { CompositeHighlight,       SkPorterDuff::kSrcOver_Mode },  // TODO
-    { CompositePlusLighter,     SkPorterDuff::kAdd_Mode }
+    uint8_t m_xfermodeMode;
+} gMapCompositOpsToXfermodeModes[] = {
+    { CompositeClear,           SkXfermode::kClear_Mode },
+    { CompositeCopy,            SkXfermode::kSrc_Mode },
+    { CompositeSourceOver,      SkXfermode::kSrcOver_Mode },
+    { CompositeSourceIn,        SkXfermode::kSrcIn_Mode },
+    { CompositeSourceOut,       SkXfermode::kSrcOut_Mode },
+    { CompositeSourceAtop,      SkXfermode::kSrcATop_Mode },
+    { CompositeDestinationOver, SkXfermode::kDstOver_Mode },
+    { CompositeDestinationIn,   SkXfermode::kDstIn_Mode },
+    { CompositeDestinationOut,  SkXfermode::kDstOut_Mode },
+    { CompositeDestinationAtop, SkXfermode::kDstATop_Mode },
+    { CompositeXOR,             SkXfermode::kXor_Mode },
+    { CompositePlusDarker,      SkXfermode::kDarken_Mode },
+    { CompositeHighlight,       SkXfermode::kSrcOver_Mode },  // TODO
+    { CompositePlusLighter,     SkXfermode::kPlus_Mode }
 };
 
-SkPorterDuff::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op)
+SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator op)
 {
-    const CompositOpToPorterDuffMode* table = gMapCompositOpsToPorterDuffModes;
+    const CompositOpToXfermodeMode* table = gMapCompositOpsToXfermodeModes;
     
-    for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToPorterDuffModes); i++) {
+    for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToXfermodeModes); i++) {
         if (table[i].mCompositOp == op)
-            return (SkPorterDuff::Mode)table[i].mPorterDuffMode;
+            return (SkXfermode::Mode)table[i].m_xfermodeMode;
     }
 
     SkDEBUGF(("GraphicsContext::setCompositeOperation uknown CompositeOperator %d\n", op));
-    return SkPorterDuff::kSrcOver_Mode; // fall-back
+    return SkXfermode::kSrcOver_Mode; // fall-back
 }
 
 static U8CPU InvScaleByte(U8CPU component, uint32_t scale)
index 0e68574..681dcd5 100644 (file)
 #include <wtf/MathExtras.h>
 #include "GraphicsContext.h"
 #include "SkPath.h"
-#include "SkPorterDuff.h"
+#include "SkXfermode.h"
 
 class SkCanvas;
 class SkRegion;
 
 namespace WebCore {
 
-SkPorterDuff::Mode WebCoreCompositeToSkiaComposite(CompositeOperator);
+SkXfermode::Mode WebCoreCompositeToSkiaComposite(CompositeOperator);
 
 // move this guy into SkColor.h
 SkColor SkPMColorToColor(SkPMColor);