diff --git a/Makefile b/Makefile index bb10843a9..cce996a1d 100644 --- a/Makefile +++ b/Makefile @@ -132,8 +132,8 @@ skimage: $(SKIMAGE_OBJS) out/libskia.a ############################################################################## -GM_SRCS := gmmain.cpp xfermodes.cpp gradients.cpp tilemodes.cpp -GM_SRCS := $(addprefix gm/, $(GM_SRCS)) +include gm/gm_files.mk +GM_SRCS := $(addprefix gm/, $(SOURCE)) GM_OBJS := $(GM_SRCS:.cpp=.o) GM_OBJS := $(addprefix out/, $(GM_OBJS)) diff --git a/gm/bitmapfilters.cpp b/gm/bitmapfilters.cpp new file mode 100644 index 000000000..0487fe695 --- /dev/null +++ b/gm/bitmapfilters.cpp @@ -0,0 +1,116 @@ +#include "gm.h" + +namespace skiagm { + +static void make_bm(SkBitmap* bm) { + const SkColor colors[] = { + SK_ColorRED, SK_ColorGREEN, + SK_ColorBLUE, SK_ColorWHITE + }; + SkColorTable* ctable = new SkColorTable(colors, 4); + bm->setConfig(SkBitmap::kIndex8_Config, 2, 2); + bm->allocPixels(ctable); + ctable->unref(); + + *bm->getAddr8(0, 0) = 0; + *bm->getAddr8(1, 0) = 1; + *bm->getAddr8(0, 1) = 2; + *bm->getAddr8(1, 1) = 3; +} + +static SkScalar draw_bm(SkCanvas* canvas, const SkBitmap& bm, + SkScalar x, SkScalar y, SkPaint* paint) { + canvas->drawBitmap(bm, x, y, paint); + return SkIntToScalar(bm.width()) * 5/4; +} + +static SkScalar draw_set(SkCanvas* c, const SkBitmap& bm, SkScalar x, + SkPaint* p) { + x += draw_bm(c, bm, x, 0, p); + p->setFilterBitmap(true); + x += draw_bm(c, bm, x, 0, p); + p->setDither(true); + return x + draw_bm(c, bm, x, 0, p); +} + +static const char* gConfigNames[] = { + "unknown config", + "A1", + "A8", + "Index8", + "565", + "4444", + "8888" +}; + +static SkScalar draw_row(SkCanvas* canvas, const SkBitmap& bm) { + SkAutoCanvasRestore acr(canvas, true); + + SkPaint paint; + SkScalar x = 0; + const int scale = 32; + + paint.setAntiAlias(true); + const char* name = gConfigNames[bm.config()]; + canvas->drawText(name, strlen(name), x, SkIntToScalar(bm.height())*scale*5/8, + paint); + canvas->translate(SkIntToScalar(48), 0); + + canvas->scale(SkIntToScalar(scale), SkIntToScalar(scale)); + + x += draw_set(canvas, bm, 0, &paint); + paint.reset(); + paint.setAlpha(0x80); + draw_set(canvas, bm, x, &paint); + return x * scale / 3; +} + +class FilterGM : public GM { +public: + SkBitmap fBM8, fBM4444, fBM16, fBM32; + + FilterGM() { + make_bm(&fBM8); + fBM8.copyTo(&fBM4444, SkBitmap::kARGB_4444_Config); + fBM8.copyTo(&fBM16, SkBitmap::kRGB_565_Config); + fBM8.copyTo(&fBM32, SkBitmap::kARGB_8888_Config); + } + +protected: + virtual SkString onShortName() { + return SkString("bitmapfilters"); + } + + virtual SkISize onISize() { + return make_isize(540, 330); + } + + virtual void onDraw(SkCanvas* canvas) { + canvas->drawColor(0xFFDDDDDD); + + SkScalar x = SkIntToScalar(10); + SkScalar y = SkIntToScalar(10); + + canvas->translate(x, y); + y = draw_row(canvas, fBM8); + canvas->translate(0, y); + y = draw_row(canvas, fBM4444); + canvas->translate(0, y); + y = draw_row(canvas, fBM16); + canvas->translate(0, y); + draw_row(canvas, fBM32); + } + +private: + typedef GM INHERITED; +}; + +////////////////////////////////////////////////////////////////////////////// + +static GM* MyFactory(void*) { return new FilterGM; } +static GMRegistry reg(MyFactory); + +} + + + diff --git a/gm/filltypes.cpp b/gm/filltypes.cpp new file mode 100644 index 000000000..e723f1610 --- /dev/null +++ b/gm/filltypes.cpp @@ -0,0 +1,83 @@ +#include "gm.h" + +namespace skiagm { + +class FillTypeGM : public GM { + SkPath fPath; +public: + FillTypeGM() { + const SkScalar radius = SkIntToScalar(45); + fPath.addCircle(SkIntToScalar(50), SkIntToScalar(50), radius); + fPath.addCircle(SkIntToScalar(100), SkIntToScalar(100), radius); + } + +protected: + virtual SkString onShortName() { + return SkString("filltypes"); + } + + virtual SkISize onISize() { + return make_isize(835, 840); + } + + void showPath(SkCanvas* canvas, int x, int y, SkPath::FillType ft, + SkScalar scale, const SkPaint& paint) { + + const SkRect r = { 0, 0, SkIntToScalar(150), SkIntToScalar(150) }; + + canvas->save(); + canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); + canvas->clipRect(r); + canvas->drawColor(SK_ColorWHITE); + fPath.setFillType(ft); + canvas->translate(r.centerX(), r.centerY()); + canvas->scale(scale, scale); + canvas->translate(-r.centerX(), -r.centerY()); + canvas->drawPath(fPath, paint); + canvas->restore(); + } + + void showFour(SkCanvas* canvas, SkScalar scale, const SkPaint& paint) { + showPath(canvas, 0, 0, SkPath::kWinding_FillType, + scale, paint); + showPath(canvas, 200, 0, SkPath::kEvenOdd_FillType, + scale, paint); + showPath(canvas, 00, 200, SkPath::kInverseWinding_FillType, + scale, paint); + showPath(canvas, 200, 200, SkPath::kInverseEvenOdd_FillType, + scale, paint); + } + + virtual void onDraw(SkCanvas* canvas) { + canvas->drawColor(0xFFDDDDDD); + + canvas->translate(SkIntToScalar(20), SkIntToScalar(20)); + + SkPaint paint; + const SkScalar scale = SkIntToScalar(5)/4; + + paint.setAntiAlias(false); + + showFour(canvas, SK_Scalar1, paint); + canvas->translate(SkIntToScalar(450), 0); + showFour(canvas, scale, paint); + + paint.setAntiAlias(true); + + canvas->translate(SkIntToScalar(-450), SkIntToScalar(450)); + showFour(canvas, SK_Scalar1, paint); + canvas->translate(SkIntToScalar(450), 0); + showFour(canvas, scale, paint); + } + +private: + typedef GM INHERITED; +}; + +////////////////////////////////////////////////////////////////////////////// + +static GM* MyFactory(void*) { return new FillTypeGM; } +static GMRegistry reg(MyFactory); + +} + diff --git a/gm/gm_files.mk b/gm/gm_files.mk new file mode 100644 index 000000000..02a416cfb --- /dev/null +++ b/gm/gm_files.mk @@ -0,0 +1,7 @@ +SOURCE := \ + bitmapfilters.cpp \ + filltypes.cpp \ + gradients.cpp \ + tilemodes.cpp \ + xfermodes.cpp \ + gmmain.cpp diff --git a/gm/xfermodes.cpp b/gm/xfermodes.cpp index 8b0ea6527..5a43f4abb 100644 --- a/gm/xfermodes.cpp +++ b/gm/xfermodes.cpp @@ -63,11 +63,13 @@ public: } protected: - SkString onShortName() { + virtual SkString onShortName() { return SkString("xfermodes"); } - SkISize onISize() { return make_isize(790, 480); } + virtual SkISize onISize() { + return make_isize(790, 480); + } void drawBG(SkCanvas* canvas) { canvas->drawColor(SK_ColorWHITE); diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 5865fe85b..a72147939 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -21,9 +21,6 @@ #include "SkMath.h" #include "SkXfermode.h" -// DEPRECATED - remove -#include "SkPorterDuff.h" - class SkAutoGlyphCache; class SkColorFilter; class SkDescriptor; @@ -465,16 +462,6 @@ public: */ SkXfermode* setXfermode(SkXfermode::Mode); - /** DEPRECATED - Helper for setXfermode, passing the corresponding xfermode object - returned from the PorterDuff factory. - @param mode The porter-duff mode used to create an xfermode for the - paint. - @return the resulting xfermode object (or NULL if the mode is - SrcOver) - */ - SkXfermode* setPorterDuffXfermode(SkPorterDuff::Mode mode); - /** Get the paint's patheffect object.

The patheffect reference count is not affected. diff --git a/include/core/SkPorterDuff.h b/include/effects/SkPorterDuff.h similarity index 100% rename from include/core/SkPorterDuff.h rename to include/effects/SkPorterDuff.h diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index 748c4bccc..c80ee432a 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -84,7 +84,7 @@ static void r0(SkLayerRasterizer* rast, SkPaint& p) p.setAlpha(0x11); p.setStyle(SkPaint::kFill_Style); - p.setPorterDuffXfermode(SkPorterDuff::kSrc_Mode); + p.setXfermode(SkXfermode::kSrc_Mode); rast->addLayer(p); } @@ -93,7 +93,7 @@ static void r1(SkLayerRasterizer* rast, SkPaint& p) rast->addLayer(p); p.setAlpha(0x40); - p.setPorterDuffXfermode(SkPorterDuff::kSrc_Mode); + p.setXfermode(SkXfermode::kSrc_Mode); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1*2); rast->addLayer(p); @@ -107,7 +107,7 @@ static void r2(SkLayerRasterizer* rast, SkPaint& p) p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1*3/2); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p); } @@ -119,7 +119,7 @@ static void r3(SkLayerRasterizer* rast, SkPaint& p) p.setAlpha(0x20); p.setStyle(SkPaint::kFill_Style); - p.setPorterDuffXfermode(SkPorterDuff::kSrc_Mode); + p.setXfermode(SkXfermode::kSrc_Mode); rast->addLayer(p); } @@ -129,7 +129,7 @@ static void r4(SkLayerRasterizer* rast, SkPaint& p) rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); p.setAlpha(0xFF); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); p.setXfermode(NULL); @@ -141,7 +141,7 @@ static void r5(SkLayerRasterizer* rast, SkPaint& p) rast->addLayer(p); p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref(); - p.setPorterDuffXfermode(SkPorterDuff::kSrcOut_Mode); + p.setXfermode(SkXfermode::kSrcOut_Mode); rast->addLayer(p); } @@ -153,7 +153,7 @@ static void r6(SkLayerRasterizer* rast, SkPaint& p) SkLayerRasterizer* rast2 = new SkLayerRasterizer; r5(rast2, p); p.setRasterizer(rast2)->unref(); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p); } @@ -208,7 +208,7 @@ static void r8(SkLayerRasterizer* rast, SkPaint& p) lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.postSkew(SK_Scalar1/3, 0, 0, 0); p.setPathEffect(new Dot2DPathEffect(SK_Scalar1*2, lattice))->unref(); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p); p.setPathEffect(NULL); @@ -278,7 +278,7 @@ static void r9(SkLayerRasterizer* rast, SkPaint& p) lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); lattice.postRotate(SkIntToScalar(30), 0, 0); p.setPathEffect(new Line2DPathEffect(SK_Scalar1*2, lattice))->unref(); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p); p.setPathEffect(NULL); @@ -489,7 +489,7 @@ protected: SkEmbossMaskFilter* embossFilter = new SkEmbossMaskFilter(light, radius); - SkXfermode* xfermode = SkPorterDuff::CreateXfermode(SkPorterDuff::kXor_Mode); + SkXfermode* xfermode = SkXfermode::Create(SkXfermode::kXor_Mode); SkColorFilter* lightingFilter = SkColorFilter::CreateLightingFilter( 0xff89bc45, 0xff112233); @@ -684,7 +684,7 @@ SkCornerPathEffect.h:28:class SkCornerPathEffect : public SkPathEffect { SkColor colors2[] = {SK_ColorBLACK, SkColorSetARGB(0x80, 0, 0, 0)}; SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors2, NULL, 2, SkShader::kClamp_TileMode); - SkXfermode* mode = SkPorterDuff::CreateXfermode(SkPorterDuff::kDstIn_Mode); + SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode); SkShader* result = new SkComposeShader(shaderA, shaderB, mode); shaderA->unref(); shaderB->unref(); diff --git a/samplecode/SampleArc.cpp b/samplecode/SampleArc.cpp index 9deec8193..19bf5f853 100644 --- a/samplecode/SampleArc.cpp +++ b/samplecode/SampleArc.cpp @@ -13,7 +13,6 @@ #include "SkRandom.h" #include "SkColorPriv.h" #include "SkColorFilter.h" -#include "SkPorterDuff.h" #include "SkLayerRasterizer.h" #include "SkParsePath.h" diff --git a/samplecode/SampleBitmapRect.cpp b/samplecode/SampleBitmapRect.cpp index ea6c70528..f59ff9441 100644 --- a/samplecode/SampleBitmapRect.cpp +++ b/samplecode/SampleBitmapRect.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRegion.h" #include "SkShader.h" #include "SkUtils.h" diff --git a/samplecode/SampleCamera.cpp b/samplecode/SampleCamera.cpp index 9a8d1efc8..4d50b5a6b 100644 --- a/samplecode/SampleCamera.cpp +++ b/samplecode/SampleCamera.cpp @@ -36,7 +36,6 @@ protected: void drawBG(SkCanvas* canvas) { canvas->drawColor(0xFFDDDDDD); -// canvas->drawColor(0, SkPorterDuff::kClear_Mode); } virtual void onDraw(SkCanvas* canvas) diff --git a/samplecode/SampleEffects.cpp b/samplecode/SampleEffects.cpp index 507f72722..94f041394 100644 --- a/samplecode/SampleEffects.cpp +++ b/samplecode/SampleEffects.cpp @@ -1,7 +1,6 @@ #include "SampleCode.h" #include "SkCanvas.h" #include "SkPaint.h" -#include "SkPorterDuff.h" #include "SkView.h" #include "SkBlurMaskFilter.h" diff --git a/samplecode/SampleEncode.cpp b/samplecode/SampleEncode.cpp index 31ddb8b4b..2730ecef6 100644 --- a/samplecode/SampleEncode.cpp +++ b/samplecode/SampleEncode.cpp @@ -6,7 +6,6 @@ #include "SkImageDecoder.h" #include "SkImageEncoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRegion.h" #include "SkShader.h" #include "SkUtils.h" diff --git a/samplecode/SampleFilter2.cpp b/samplecode/SampleFilter2.cpp index e181870fc..590d3ef01 100644 --- a/samplecode/SampleFilter2.cpp +++ b/samplecode/SampleFilter2.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRegion.h" #include "SkShader.h" #include "SkUtils.h" diff --git a/samplecode/SampleFuzz.cpp b/samplecode/SampleFuzz.cpp index e42887eaa..309affe02 100644 --- a/samplecode/SampleFuzz.cpp +++ b/samplecode/SampleFuzz.cpp @@ -4,7 +4,6 @@ #include "SkBlurMaskFilter.h" #include "SkPaint.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkXfermode.h" #include "SkMatrix.h" #include "SkColor.h" @@ -117,13 +116,13 @@ static void do_fuzz(SkCanvas* canvas) { break; case 2: { - SkPorterDuff::Mode mode; - switch (R(3)) { - case 0: mode = SkPorterDuff::kSrc_Mode; break; - case 1: mode = SkPorterDuff::kXor_Mode; break; - case 2: mode = SkPorterDuff::kSrcOver_Mode; break; - } - paint.setXfermode(SkPorterDuff::CreateXfermode(mode))->safeUnref(); + SkXfermode::Mode mode; + switch (R(3)) { + case 0: mode = SkXfermode::kSrc_Mode; break; + case 1: mode = SkXfermode::kXor_Mode; break; + case 2: mode = SkXfermode::kSrcOver_Mode; break; + } + paint.setXfermode(mode); } break; diff --git a/samplecode/SampleImage.cpp b/samplecode/SampleImage.cpp index 69cbd794d..29442991a 100644 --- a/samplecode/SampleImage.cpp +++ b/samplecode/SampleImage.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRegion.h" #include "SkShader.h" #include "SkUtils.h" diff --git a/samplecode/SampleImageDir.cpp b/samplecode/SampleImageDir.cpp index e221fe187..8ef59ad77 100644 --- a/samplecode/SampleImageDir.cpp +++ b/samplecode/SampleImageDir.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRegion.h" #include "SkShader.h" #include "SkUtils.h" diff --git a/samplecode/SampleLayerMask.cpp b/samplecode/SampleLayerMask.cpp index 8cbe76d34..819eb5c0f 100644 --- a/samplecode/SampleLayerMask.cpp +++ b/samplecode/SampleLayerMask.cpp @@ -1,7 +1,6 @@ #include "SampleCode.h" #include "SkCanvas.h" #include "SkPaint.h" -#include "SkPorterDuff.h" #include "SkView.h" /////////////////////////////////////////////////////////////////////////////// @@ -36,13 +35,13 @@ protected: bounds.offset(-bounds.fLeft, -bounds.fTop); c.drawOval(bounds, paint); - paint.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); + paint.setXfermode(SkXfermode::kDstIn_Mode); canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint); } else { SkPath p; p.addOval(r); p.setFillType(SkPath::kInverseWinding_FillType); - paint.setPorterDuffXfermode(SkPorterDuff::kDstOut_Mode); + paint.setXfermode(SkXfermode::kDstOut_Mode); canvas->drawPath(p, paint); } } diff --git a/samplecode/SampleLayers.cpp b/samplecode/SampleLayers.cpp index e6867bbbb..5a52d0efd 100644 --- a/samplecode/SampleLayers.cpp +++ b/samplecode/SampleLayers.cpp @@ -17,7 +17,6 @@ #include "SkTypeface.h" #include "SkUtils.h" #include "SkKey.h" -#include "SkPorterDuff.h" #include "SkXfermode.h" #include "SkDrawFilter.h" @@ -27,7 +26,7 @@ static void make_paint(SkPaint* paint) { SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode); paint->setShader(s)->unref(); - paint->setXfermode(SkPorterDuff::CreateXfermode(SkPorterDuff::kDstIn_Mode))->unref(); + paint->setXfermode(SkXfermode::kDstIn_Mode); } static void dump_layers(const char label[], SkCanvas* canvas) { @@ -163,7 +162,7 @@ protected: canvas->saveLayer(&r, &p); canvas->drawColor(0xFFFF0000); p.setAlpha(1); // or 0 - p.setPorterDuffXfermode(SkPorterDuff::kSrc_Mode); + p.setXfermode(SkXfermode::kSrc_Mode); canvas->drawOval(r, p); canvas->restore(); return; @@ -240,7 +239,7 @@ protected: canvas->drawOval(r, p); p.setAlpha(0x80); - p.setPorterDuffXfermode(SkPorterDuff::kDstIn_Mode); + p.setXfermode(SkXfermode::kDstIn_Mode); canvas->drawRect(bounds, p); canvas->restore(); diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp index 02b6f9273..466963023 100644 --- a/samplecode/SamplePatch.cpp +++ b/samplecode/SamplePatch.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRandom.h" #include "SkRegion.h" #include "SkShader.h" diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp index 98f1a5b7f..b39e65c6f 100644 --- a/samplecode/SamplePath.cpp +++ b/samplecode/SamplePath.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRegion.h" #include "SkShader.h" #include "SkUtils.h" diff --git a/samplecode/SamplePathClip.cpp b/samplecode/SamplePathClip.cpp index c4be2b896..ece64ae75 100644 --- a/samplecode/SamplePathClip.cpp +++ b/samplecode/SamplePathClip.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRegion.h" #include "SkShader.h" #include "SkUtils.h" diff --git a/samplecode/SamplePathEffects.cpp b/samplecode/SamplePathEffects.cpp index c974850e3..1036db611 100644 --- a/samplecode/SamplePathEffects.cpp +++ b/samplecode/SamplePathEffects.cpp @@ -75,7 +75,6 @@ static SkPathEffect* make_warp_pe() /////////////////////////////////////////////////////////// #include "SkColorFilter.h" -#include "SkPorterDuff.h" #include "SkLayerRasterizer.h" class testrast : public SkLayerRasterizer { @@ -91,7 +90,7 @@ public: this->addLayer(paint); paint.setStrokeWidth(SK_Scalar1*1); - paint.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + paint.setXfermode(SkXfermode::kClear_Mode); this->addLayer(paint); #else paint.setAlpha(0x66); diff --git a/samplecode/SampleShaders.cpp b/samplecode/SampleShaders.cpp index 19f493038..115f9f5bc 100644 --- a/samplecode/SampleShaders.cpp +++ b/samplecode/SampleShaders.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRegion.h" #include "SkShader.h" #include "SkUtils.h" @@ -31,7 +30,7 @@ static SkShader* make_bitmapfade(const SkBitmap& bm) SkShader* shaderB = SkShader::CreateBitmapShader(bm, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode); - SkXfermode* mode = SkPorterDuff::CreateXfermode(SkPorterDuff::kDstIn_Mode); + SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode); SkShader* shader = new SkComposeShader(shaderB, shaderA, mode); shaderA->unref(); @@ -65,7 +64,7 @@ public: colors[1] = SkColorSetARGB(0x80, 0, 0, 0); SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode); - SkXfermode* mode = SkPorterDuff::CreateXfermode(SkPorterDuff::kDstIn_Mode); + SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode); fShader = new SkComposeShader(shaderA, shaderB, mode); shaderA->unref(); diff --git a/samplecode/SampleShapes.cpp b/samplecode/SampleShapes.cpp index bee38840e..8db960cb8 100644 --- a/samplecode/SampleShapes.cpp +++ b/samplecode/SampleShapes.cpp @@ -1,7 +1,6 @@ #include "SampleCode.h" #include "SkCanvas.h" #include "SkPaint.h" -#include "SkPorterDuff.h" #include "SkView.h" #include "SkRectShape.h" diff --git a/samplecode/SampleStrokeText.cpp b/samplecode/SampleStrokeText.cpp index 2743897b8..e144511d5 100644 --- a/samplecode/SampleStrokeText.cpp +++ b/samplecode/SampleStrokeText.cpp @@ -55,7 +55,7 @@ static void lettersToBitmap(SkBitmap* dst, const char chars[], dst->eraseColor(SK_ColorWHITE); { SkCanvas canvas(*dst); - paint.setPorterDuffXfermode(SkPorterDuff::kDstATop_Mode); + paint.setXfermode(SkXfermode::kDstATop_Mode); canvas.drawBitmap(src, 0, 0, &paint); paint.setColor(original.getColor()); paint.setStyle(SkPaint::kStroke_Style); @@ -86,7 +86,7 @@ static void lettersToBitmap2(SkBitmap* dst, const char chars[], SkPaint paint(original); paint.setAntiAlias(true); - paint.setPorterDuffXfermode(SkPorterDuff::kDstATop_Mode); + paint.setXfermode(SkXfermode::kDstATop_Mode); paint.setColor(original.getColor()); paint.setStyle(SkPaint::kStroke_Style); diff --git a/samplecode/SampleTests.cpp b/samplecode/SampleTests.cpp index d0216725c..c05189d0b 100644 --- a/samplecode/SampleTests.cpp +++ b/samplecode/SampleTests.cpp @@ -18,7 +18,6 @@ #include "SkTypeface.h" #include "SkUtils.h" #include "SkKey.h" -#include "SkPorterDuff.h" #include "SkXfermode.h" #include "SkDrawFilter.h" diff --git a/samplecode/SampleTextAlpha.cpp b/samplecode/SampleTextAlpha.cpp index 629056b3f..b23af51b0 100644 --- a/samplecode/SampleTextAlpha.cpp +++ b/samplecode/SampleTextAlpha.cpp @@ -6,7 +6,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRandom.h" #include "SkRegion.h" #include "SkShader.h" diff --git a/samplecode/SampleTextEffects.cpp b/samplecode/SampleTextEffects.cpp index cd18006d9..5f7be1d3b 100644 --- a/samplecode/SampleTextEffects.cpp +++ b/samplecode/SampleTextEffects.cpp @@ -68,7 +68,7 @@ static void r0(SkLayerRasterizer* rast, SkPaint& p) p.setAlpha(0x11); p.setStyle(SkPaint::kFill_Style); - p.setPorterDuffXfermode(SkPorterDuff::kSrc_Mode); + p.setXfermode(SkXfermode::kSrc_Mode); rast->addLayer(p); } @@ -77,7 +77,7 @@ static void r1(SkLayerRasterizer* rast, SkPaint& p) rast->addLayer(p); p.setAlpha(0x40); - p.setPorterDuffXfermode(SkPorterDuff::kSrc_Mode); + p.setXfermode(SkXfermode::kSrc_Mode); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1*2); rast->addLayer(p); @@ -91,7 +91,7 @@ static void r2(SkLayerRasterizer* rast, SkPaint& p) p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1*3/2); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p); } @@ -103,7 +103,7 @@ static void r3(SkLayerRasterizer* rast, SkPaint& p) p.setAlpha(0x20); p.setStyle(SkPaint::kFill_Style); - p.setPorterDuffXfermode(SkPorterDuff::kSrc_Mode); + p.setXfermode(SkXfermode::kSrc_Mode); rast->addLayer(p); } @@ -113,7 +113,7 @@ static void r4(SkLayerRasterizer* rast, SkPaint& p) rast->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); p.setAlpha(0xFF); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); p.setXfermode(NULL); @@ -127,7 +127,7 @@ static void r5(SkLayerRasterizer* rast, SkPaint& p) rast->addLayer(p); p.setPathEffect(new SkDiscretePathEffect(SK_Scalar1*4, SK_Scalar1*3))->unref(); - p.setPorterDuffXfermode(SkPorterDuff::kSrcOut_Mode); + p.setXfermode(SkXfermode::kSrcOut_Mode); rast->addLayer(p); } @@ -139,7 +139,7 @@ static void r6(SkLayerRasterizer* rast, SkPaint& p) SkLayerRasterizer* rast2 = new SkLayerRasterizer; r5(rast2, p); p.setRasterizer(rast2)->unref(); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p); } @@ -196,7 +196,7 @@ static void r8(SkLayerRasterizer* rast, SkPaint& p) lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.postSkew(SK_Scalar1/3, 0, 0, 0); p.setPathEffect(new Dot2DPathEffect(SK_Scalar1*2, lattice))->unref(); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p); p.setPathEffect(NULL); @@ -269,7 +269,7 @@ static void r9(SkLayerRasterizer* rast, SkPaint& p) lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); lattice.postRotate(SkIntToScalar(30), 0, 0); p.setPathEffect(new Line2DPathEffect(SK_Scalar1*2, lattice))->unref(); - p.setPorterDuffXfermode(SkPorterDuff::kClear_Mode); + p.setXfermode(SkXfermode::kClear_Mode); rast->addLayer(p); p.setPathEffect(NULL); diff --git a/samplecode/SampleVertices.cpp b/samplecode/SampleVertices.cpp index 84f1e1254..96c9849e3 100644 --- a/samplecode/SampleVertices.cpp +++ b/samplecode/SampleVertices.cpp @@ -5,7 +5,6 @@ #include "SkGraphics.h" #include "SkImageDecoder.h" #include "SkPath.h" -#include "SkPorterDuff.h" #include "SkRandom.h" #include "SkRegion.h" #include "SkShader.h" diff --git a/src/effects/SkPorterDuff.cpp b/src/effects/SkPorterDuff.cpp index f3f598b92..58447add4 100644 --- a/src/effects/SkPorterDuff.cpp +++ b/src/effects/SkPorterDuff.cpp @@ -74,9 +74,3 @@ SkXfermodeProc16 SkPorterDuff::GetXfermodeProc16(Mode mode, SkColor srcColor) { return SkXfermode::GetProc16(gPairs[mode].fXF, srcColor); } -// DEPRECATED -#include "SkPaint.h" -SkXfermode* SkPaint::setPorterDuffXfermode(SkPorterDuff::Mode mode) { - return this->setXfermode(SkPorterDuff::CreateXfermode(mode)); -} - diff --git a/xcode/sampleapp/SampleApp.xcodeproj/project.pbxproj b/xcode/sampleapp/SampleApp.xcodeproj/project.pbxproj index a8fd22c9a..a7f70e6af 100644 --- a/xcode/sampleapp/SampleApp.xcodeproj/project.pbxproj +++ b/xcode/sampleapp/SampleApp.xcodeproj/project.pbxproj @@ -39,9 +39,6 @@ 0041CE3A0F00A12400695E8C /* SampleDrawLooper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE240F00A12400695E8C /* SampleDrawLooper.cpp */; }; 0041CE3B0F00A12400695E8C /* SampleEmboss.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE250F00A12400695E8C /* SampleEmboss.cpp */; }; 0041CE3C0F00A12400695E8C /* SampleEncode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE260F00A12400695E8C /* SampleEncode.cpp */; }; - 0041CE3D0F00A12400695E8C /* SampleFillType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE270F00A12400695E8C /* SampleFillType.cpp */; }; - 0041CE3E0F00A12400695E8C /* SampleFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE280F00A12400695E8C /* SampleFilter.cpp */; }; - 0041CE3F0F00A12400695E8C /* SampleFilter2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE290F00A12400695E8C /* SampleFilter2.cpp */; }; 0041CE400F00A12400695E8C /* SampleFontCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE2A0F00A12400695E8C /* SampleFontCache.cpp */; }; 0041CE420F00A12400695E8C /* SampleImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE2C0F00A12400695E8C /* SampleImage.cpp */; }; 0041CE430F00A12400695E8C /* SampleLayers.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE2D0F00A12400695E8C /* SampleLayers.cpp */; }; @@ -50,6 +47,9 @@ 0041CE470F00A12400695E8C /* SampleNinePatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE310F00A12400695E8C /* SampleNinePatch.cpp */; }; 0041CE480F00A12400695E8C /* SampleOverflow.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE320F00A12400695E8C /* SampleOverflow.cpp */; }; 0041CE4A0F00A12400695E8C /* SamplePatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE340F00A12400695E8C /* SamplePatch.cpp */; }; + 005E92DC0FF08507008965B9 /* SampleFilter2.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE290F00A12400695E8C /* SampleFilter2.cpp */; }; + 005E92DE0FF0850E008965B9 /* SampleFillType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE270F00A12400695E8C /* SampleFillType.cpp */; }; + 005E92E00FF08512008965B9 /* SampleFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0041CE280F00A12400695E8C /* SampleFilter.cpp */; }; 007A7CB30F01658C00A2D6EE /* SamplePicture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007A7CA40F01658C00A2D6EE /* SamplePicture.cpp */; }; 007A7CB40F01658C00A2D6EE /* SamplePoints.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007A7CA50F01658C00A2D6EE /* SamplePoints.cpp */; }; 007A7CB60F01658C00A2D6EE /* SampleRegion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 007A7CA70F01658C00A2D6EE /* SampleRegion.cpp */; }; @@ -533,9 +533,6 @@ 0041CE390F00A12400695E8C /* SampleDither.cpp in Sources */, 0041CE3A0F00A12400695E8C /* SampleDrawLooper.cpp in Sources */, 0041CE3B0F00A12400695E8C /* SampleEmboss.cpp in Sources */, - 0041CE3D0F00A12400695E8C /* SampleFillType.cpp in Sources */, - 0041CE3E0F00A12400695E8C /* SampleFilter.cpp in Sources */, - 0041CE3F0F00A12400695E8C /* SampleFilter2.cpp in Sources */, 0041CE400F00A12400695E8C /* SampleFontCache.cpp in Sources */, 0041CE420F00A12400695E8C /* SampleImage.cpp in Sources */, 0041CE430F00A12400695E8C /* SampleLayers.cpp in Sources */, @@ -575,6 +572,9 @@ 2794C04F0FE72903009AD112 /* SampleMipMap.cpp in Sources */, 00AF787E0FE94433007F9650 /* SamplePath.cpp in Sources */, 0088C1160FEC311C00CE52F5 /* SampleXfermodes.cpp in Sources */, + 005E92DC0FF08507008965B9 /* SampleFilter2.cpp in Sources */, + 005E92DE0FF0850E008965B9 /* SampleFillType.cpp in Sources */, + 005E92E00FF08512008965B9 /* SampleFilter.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };