summaryrefslogtreecommitdiffstats
path: root/WebCore
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-06-23 06:48:12 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-06-23 06:48:12 -0700
commit8611fc4db278833abc9e6691ea03248c0ae7b9b0 (patch)
tree6c59acc15b884a7d9e8d2091c66ad9b600e9b089 /WebCore
parent616ad0c2b4a8561fcf943605dd2b64725bc41145 (diff)
parente587935eabebbce97def3a6ea1ac7296d1d48654 (diff)
downloadexternal_webkit-8611fc4db278833abc9e6691ea03248c0ae7b9b0.zip
external_webkit-8611fc4db278833abc9e6691ea03248c0ae7b9b0.tar.gz
external_webkit-8611fc4db278833abc9e6691ea03248c0ae7b9b0.tar.bz2
Merge change 5069
* changes: remove references to deprecated porterduff
Diffstat (limited to 'WebCore')
-rw-r--r--WebCore/platform/graphics/android/GraphicsContextAndroid.cpp15
-rw-r--r--WebCore/platform/graphics/android/ImageAndroid.cpp4
-rw-r--r--WebCore/platform/graphics/skia/SkiaUtils.cpp34
-rw-r--r--WebCore/platform/graphics/skia/SkiaUtils.h2
4 files changed, 45 insertions, 10 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
index 3b4d9a9..0358a54 100644
--- a/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsContextAndroid.cpp
@@ -38,7 +38,6 @@
#include "SkDashPathEffect.h"
#include "SkDevice.h"
#include "SkPaint.h"
-#include "SkPorterDuff.h"
#include "PlatformGraphicsContext.h"
#include "TransformationMatrix.h"
@@ -66,7 +65,7 @@ template <typename T> T* deepCopyPtr(const T* src) {
/* TODO / questions
mAlpha: how does this interact with the alpha in Color? multiply them together?
- mPorterDuffMode: do I always respect this? If so, then
+ mMode: do I always respect this? If so, then
the rgb() & 0xFF000000 check will abort drawing too often
Is Color premultiplied or not? If it is, then I can't blindly pass it to paint.setColor()
*/
@@ -91,7 +90,7 @@ public:
float mStrokeThickness;
SkPaint::Cap mLineCap;
SkPaint::Join mLineJoin;
- SkPorterDuff::Mode mPorterDuffMode;
+ SkXfermode::Mode mMode;
int mDashRatio; //ratio of the length of a dash to its width
ShadowRec mShadow;
SkColor mFillColor;
@@ -106,7 +105,7 @@ public:
mStrokeThickness = 0.0f; // Same as default in GraphicsContextPrivate.h
mLineCap = SkPaint::kDefault_Cap;
mLineJoin = SkPaint::kDefault_Join;
- mPorterDuffMode = SkPorterDuff::kSrcOver_Mode;
+ mMode = SkXfermode::kSrcOver_Mode;
mDashRatio = 3;
mUseAA = true;
mShadow.mBlur = 0;
@@ -138,7 +137,7 @@ public:
if (mShadow.mBlur > 0) {
paint->setAntiAlias(true);
paint->setDither(true);
- paint->setPorterDuffXfermode(mPorterDuffMode);
+ paint->setXfermode(mMode);
paint->setColor(mShadow.mColor);
paint->setMaskFilter(SkBlurMaskFilter::Create(mShadow.mBlur,
SkBlurMaskFilter::kNormal_BlurStyle))->unref();
@@ -226,7 +225,7 @@ public:
void setup_paint_common(SkPaint* paint) const {
paint->setAntiAlias(mState->mUseAA);
paint->setDither(true);
- paint->setPorterDuffXfermode(mState->mPorterDuffMode);
+ paint->setXfermode(mState->mMode);
if (mState->mShadow.mBlur > 0) {
SkDrawLooper* looper = new SkBlurDrawLooper(mState->mShadow.mBlur,
mState->mShadow.mDx,
@@ -899,7 +898,7 @@ void GraphicsContext::setAlpha(float alpha)
void GraphicsContext::setCompositeOperation(CompositeOperator op)
{
- m_data->mState->mPorterDuffMode = WebCoreCompositeToSkiaComposite(op);
+ m_data->mState->mMode = WebCoreCompositeToSkiaMode(op);
}
void GraphicsContext::clearRect(const FloatRect& rect)
@@ -910,7 +909,7 @@ void GraphicsContext::clearRect(const FloatRect& rect)
SkPaint paint;
m_data->setup_paint_fill(&paint);
- paint.setPorterDuffXfermode(SkPorterDuff::kClear_Mode);
+ paint.setXfermode(SkXfermode::kClear_Mode);
GC2Canvas(this)->drawRect(rect, paint);
}
diff --git a/WebCore/platform/graphics/android/ImageAndroid.cpp b/WebCore/platform/graphics/android/ImageAndroid.cpp
index 5d81b56..f0b36fb 100644
--- a/WebCore/platform/graphics/android/ImageAndroid.cpp
+++ b/WebCore/platform/graphics/android/ImageAndroid.cpp
@@ -213,7 +213,7 @@ void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& dstRect,
ctxt->setupFillPaint(&paint); // need global alpha among other things
paint.setFilterBitmap(true);
- paint.setPorterDuffXfermode(WebCoreCompositeToSkiaComposite(compositeOp));
+ paint.setXfermode(WebCoreCompositeToSkiaMode(compositeOp));
canvas->drawBitmapRect(bitmap, &srcR, dstR, &paint);
#ifdef TRACE_SUBSAMPLED_BITMAPS
@@ -285,7 +285,7 @@ void Image::drawPattern(GraphicsContext* ctxt, const FloatRect& srcRect,
SkShader::kRepeat_TileMode);
paint.setShader(shader)->unref();
// now paint is the only owner of shader
- paint.setPorterDuffXfermode(WebCoreCompositeToSkiaComposite(compositeOp));
+ paint.setXfermode(WebCoreCompositeToSkiaMode(compositeOp));
paint.setFilterBitmap(true);
SkMatrix matrix(patternTransform);
diff --git a/WebCore/platform/graphics/skia/SkiaUtils.cpp b/WebCore/platform/graphics/skia/SkiaUtils.cpp
index 4242e7d..a7a266d 100644
--- a/WebCore/platform/graphics/skia/SkiaUtils.cpp
+++ b/WebCore/platform/graphics/skia/SkiaUtils.cpp
@@ -42,6 +42,40 @@
namespace WebCore {
+static const struct CompositOpToSkiaMode {
+ uint8_t mCompositOp;
+ uint8_t mMode;
+} gMapCompositOpsToSkiaModes[] = {
+ { 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 },
+ // need more details on the composite modes to be sure these are right
+ { CompositePlusDarker, SkXfermode::kDarken_Mode },
+ { CompositeHighlight, SkXfermode::kSrcOver_Mode }, // TODO
+ { CompositePlusLighter, SkXfermode::kPlus_Mode }
+};
+
+SkXfermode::Mode WebCoreCompositeToSkiaMode(CompositeOperator op)
+{
+ const CompositOpToSkiaMode* table = gMapCompositOpsToSkiaModes;
+
+ for (unsigned i = 0; i < SK_ARRAY_COUNT(gMapCompositOpsToSkiaModes); i++) {
+ if (table[i].mCompositOp == op)
+ return (SkXfermode::Mode)table[i].mMode;
+ }
+
+ SkDEBUGF(("GraphicsContext::setCompositeOperation uknown CompositeOperator %d\n", op));
+ return SkXfermode::kSrcOver_Mode; // fall-back
+}
+
static const struct CompositOpToPorterDuffMode {
uint8_t mCompositOp;
uint8_t mPorterDuffMode;
diff --git a/WebCore/platform/graphics/skia/SkiaUtils.h b/WebCore/platform/graphics/skia/SkiaUtils.h
index 0e68574..aa4cd4d 100644
--- a/WebCore/platform/graphics/skia/SkiaUtils.h
+++ b/WebCore/platform/graphics/skia/SkiaUtils.h
@@ -37,12 +37,14 @@
#include "GraphicsContext.h"
#include "SkPath.h"
#include "SkPorterDuff.h"
+#include "SkXfermode.h"
class SkCanvas;
class SkRegion;
namespace WebCore {
+SkXfermode::Mode WebCoreCompositeToSkiaMode(CompositeOperator);
SkPorterDuff::Mode WebCoreCompositeToSkiaComposite(CompositeOperator);
// move this guy into SkColor.h