diff options
author | Mike Reed <reed@google.com> | 2016-10-05 14:03:43 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-05 18:31:17 +0000 |
commit | 2b2fc7db4f8a4a4d4a51d7eb4df6aa62e309928d (patch) | |
tree | cfa3f2de434cb5dcabf98720460105964f78bfc3 /samplecode | |
parent | dbb84c268bd09d2aa47256b5315a87f891583b6b (diff) |
Revert[6] "replace SkXfermode obj with SkBlendMode enum in paints"
- perform version check in CreateProc for XfermodeImageFilter and ArithmeticImageFilter
This reverts commit 3ed485f4249e17abb4b11f5018d03175fd1afb44.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2992
Change-Id: Ib4a154cdd5f5d1dcac921ef50d53b79a2d6a1be8
Reviewed-on: https://skia-review.googlesource.com/2992
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleAARectModes.cpp | 35 | ||||
-rw-r--r-- | samplecode/SampleAll.cpp | 28 | ||||
-rw-r--r-- | samplecode/SampleApp.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleColorFilter.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleFatBits.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleFilterFuzz.cpp | 10 | ||||
-rw-r--r-- | samplecode/SampleFuzz.cpp | 10 | ||||
-rw-r--r-- | samplecode/SampleHairModes.cpp | 34 | ||||
-rw-r--r-- | samplecode/SampleLayerMask.cpp | 4 | ||||
-rw-r--r-- | samplecode/SampleLayers.cpp | 4 | ||||
-rw-r--r-- | samplecode/SamplePathClip.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleQuadStroker.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleRegion.cpp | 2 | ||||
-rw-r--r-- | samplecode/SampleSlides.cpp | 24 | ||||
-rw-r--r-- | samplecode/SampleXfer.cpp | 36 | ||||
-rw-r--r-- | samplecode/SampleXfermodesBlur.cpp | 51 |
16 files changed, 117 insertions, 131 deletions
diff --git a/samplecode/SampleAARectModes.cpp b/samplecode/SampleAARectModes.cpp index 65b1da1405..0a50303935 100644 --- a/samplecode/SampleAARectModes.cpp +++ b/samplecode/SampleAARectModes.cpp @@ -12,21 +12,21 @@ #include "SkShader.h" static const struct { - SkXfermode::Mode fMode; - const char* fLabel; + SkBlendMode fMode; + const char* fLabel; } gModes[] = { - { SkXfermode::kClear_Mode, "Clear" }, - { SkXfermode::kSrc_Mode, "Src" }, - { SkXfermode::kDst_Mode, "Dst" }, - { SkXfermode::kSrcOver_Mode, "SrcOver" }, - { SkXfermode::kDstOver_Mode, "DstOver" }, - { SkXfermode::kSrcIn_Mode, "SrcIn" }, - { SkXfermode::kDstIn_Mode, "DstIn" }, - { SkXfermode::kSrcOut_Mode, "SrcOut" }, - { SkXfermode::kDstOut_Mode, "DstOut" }, - { SkXfermode::kSrcATop_Mode, "SrcATop" }, - { SkXfermode::kDstATop_Mode, "DstATop" }, - { SkXfermode::kXor_Mode, "Xor" }, + { SkBlendMode::kClear, "Clear" }, + { SkBlendMode::kSrc, "Src" }, + { SkBlendMode::kDst, "Dst" }, + { SkBlendMode::kSrcOver, "SrcOver" }, + { SkBlendMode::kDstOver, "DstOver" }, + { SkBlendMode::kSrcIn, "SrcIn" }, + { SkBlendMode::kDstIn, "DstIn" }, + { SkBlendMode::kSrcOut, "SrcOut" }, + { SkBlendMode::kDstOut, "DstOut" }, + { SkBlendMode::kSrcATop, "SrcATop" }, + { SkBlendMode::kDstATop, "DstATop" }, + { SkBlendMode::kXor, "Xor" }, }; const int gWidth = 64; @@ -34,7 +34,7 @@ const int gHeight = 64; const SkScalar W = SkIntToScalar(gWidth); const SkScalar H = SkIntToScalar(gHeight); -static SkScalar drawCell(SkCanvas* canvas, const sk_sp<SkXfermode>& mode, SkAlpha a0, SkAlpha a1) { +static SkScalar drawCell(SkCanvas* canvas, SkBlendMode mode, SkAlpha a0, SkAlpha a1) { SkPaint paint; paint.setAntiAlias(true); @@ -47,7 +47,7 @@ static SkScalar drawCell(SkCanvas* canvas, const sk_sp<SkXfermode>& mode, SkAlph paint.setColor(SK_ColorRED); paint.setAlpha(a1); - paint.setXfermode(mode); + paint.setBlendMode(mode); SkScalar offset = SK_Scalar1 / 3; SkRect rect = SkRect::MakeXYWH(W / 4 + offset, @@ -106,11 +106,10 @@ protected: canvas->translate(W * 5, 0); canvas->save(); } - sk_sp<SkXfermode> mode = SkXfermode::Make(gModes[i].fMode); canvas->drawRect(bounds, fBGPaint); canvas->saveLayer(&bounds, nullptr); - SkScalar dy = drawCell(canvas, mode, gAlphaValue[alpha & 1], + SkScalar dy = drawCell(canvas, gModes[i].fMode, gAlphaValue[alpha & 1], gAlphaValue[alpha & 2]); canvas->restore(); diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp index 29b5c66c74..8c1ace564a 100644 --- a/samplecode/SampleAll.cpp +++ b/samplecode/SampleAll.cpp @@ -89,7 +89,7 @@ static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { p.setAlpha(0x11); p.setStyle(SkPaint::kFill_Style); - p.setXfermodeMode(SkXfermode::kSrc_Mode); + p.setBlendMode(SkBlendMode::kSrc); rastBuilder->addLayer(p); } @@ -97,7 +97,7 @@ static void r1(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { rastBuilder->addLayer(p); p.setAlpha(0x40); - p.setXfermodeMode(SkXfermode::kSrc_Mode); + p.setBlendMode(SkBlendMode::kSrc); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1*2); rastBuilder->addLayer(p); @@ -110,7 +110,7 @@ static void r2(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1*3/2); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p); } @@ -121,7 +121,7 @@ static void r3(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { p.setAlpha(0x20); p.setStyle(SkPaint::kFill_Style); - p.setXfermodeMode(SkXfermode::kSrc_Mode); + p.setBlendMode(SkBlendMode::kSrc); rastBuilder->addLayer(p); } @@ -130,10 +130,10 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); p.setAlpha(0xFF); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); - p.setXfermode(nullptr); + p.setBlendMode(SkBlendMode::kSrcOver); rastBuilder->addLayer(p); } @@ -141,7 +141,7 @@ static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { rastBuilder->addLayer(p); p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3)); - p.setXfermodeMode(SkXfermode::kSrcOut_Mode); + p.setBlendMode(SkBlendMode::kSrcOut); rastBuilder->addLayer(p); } @@ -152,7 +152,7 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { SkLayerRasterizer::Builder rastBuilder2; r5(&rastBuilder2, p); p.setRasterizer(rastBuilder2.detach()); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p); } @@ -194,11 +194,11 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.postSkew(SK_Scalar1/3, 0, 0, 0); p.setPathEffect(sk_make_sp<Dot2DPathEffect>(SK_Scalar1*2, lattice)); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p); p.setPathEffect(nullptr); - p.setXfermode(nullptr); + p.setBlendMode(SkBlendMode::kSrcOver); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1); rastBuilder->addLayer(p); @@ -211,11 +211,11 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) { lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); lattice.postRotate(SkIntToScalar(30), 0, 0); p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice)); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p); p.setPathEffect(nullptr); - p.setXfermode(nullptr); + p.setBlendMode(SkBlendMode::kSrcOver); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1); rastBuilder->addLayer(p); @@ -401,10 +401,10 @@ protected: paint.setColor(SK_ColorGREEN); paint.setStrokeWidth(SkIntToScalar(10)); paint.setStyle(SkPaint::kStroke_Style); - paint.setXfermode(SkXfermode::Make(SkXfermode::kXor_Mode)); + paint.setBlendMode(SkBlendMode::kXor); paint.setColorFilter(lightingFilter); canvas->drawLine(start.fX, start.fY, stop.fX, stop.fY, paint); // should not be green - paint.setXfermode(nullptr); + paint.setBlendMode(SkBlendMode::kSrcOver); paint.setColorFilter(nullptr); // rectangle diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index a37a6ffc9f..52e063d367 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -352,7 +352,7 @@ public: bool doGamma = (fActualColorBits == 30) && SkImageInfoIsGammaCorrect(win->info()); SkPaint gammaPaint; - gammaPaint.setXfermodeMode(SkXfermode::kSrc_Mode); + gammaPaint.setBlendMode(SkBlendMode::kSrc); if (doGamma) { gammaPaint.setColorFilter(SkGammaColorFilter::Make(1.0f / 2.2f)); } diff --git a/samplecode/SampleColorFilter.cpp b/samplecode/SampleColorFilter.cpp index 3da77a441f..67c7b2e13d 100644 --- a/samplecode/SampleColorFilter.cpp +++ b/samplecode/SampleColorFilter.cpp @@ -100,7 +100,7 @@ static SkBitmap createBitmap(int n) { canvas.drawOval(r, paint); r.inset(SK_Scalar1*n/4, SK_Scalar1*n/4); - paint.setXfermodeMode(SkXfermode::kSrc_Mode); + paint.setBlendMode(SkBlendMode::kSrc); paint.setColor(0x800000FF); canvas.drawOval(r, paint); diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp index 8da6058f9d..82eb25fd70 100644 --- a/samplecode/SampleFatBits.cpp +++ b/samplecode/SampleFatBits.cpp @@ -163,7 +163,7 @@ private: canvas->restore(); SkPaint paint; - paint.setXfermodeMode(SkXfermode::kClear_Mode); + paint.setBlendMode(SkBlendMode::kClear); for (int iy = 1; iy < fH; ++iy) { SkScalar y = SkIntToScalar(iy * fZoom); canvas->drawLine(0, y - SK_ScalarHalf, 999, y - SK_ScalarHalf, paint); diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp index 755e8fb458..28aa5f4caf 100644 --- a/samplecode/SampleFilterFuzz.cpp +++ b/samplecode/SampleFilterFuzz.cpp @@ -157,8 +157,8 @@ static SkMatrix make_matrix() { return m; } -static SkXfermode::Mode make_xfermode() { - return static_cast<SkXfermode::Mode>(R(SkXfermode::kLastMode+1)); +static SkBlendMode make_xfermode() { + return static_cast<SkBlendMode>(R(SkXfermode::kLastMode+1)); } static SkPaint::Align make_paint_align() { @@ -508,7 +508,7 @@ static SkPaint make_paint() { paint.setStrokeCap(make_paint_cap()); paint.setStrokeJoin(make_paint_join()); paint.setColorFilter(make_color_filter()); - paint.setXfermodeMode(make_xfermode()); + paint.setBlendMode(make_xfermode()); paint.setPathEffect(make_path_effect()); paint.setMaskFilter(make_mask_filter()); @@ -558,7 +558,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { case MERGE: filter = SkMergeImageFilter::Make(make_image_filter(), make_image_filter(), - make_xfermode()); + (SkXfermode::Mode)make_xfermode()); break; case COLOR: { sk_sp<SkColorFilter> cf(make_color_filter()); @@ -585,7 +585,7 @@ static sk_sp<SkImageFilter> make_image_filter(bool canBeNull) { make_image_filter()); break; case XFERMODE: - filter = SkXfermodeImageFilter::Make(SkXfermode::Make(make_xfermode()), + filter = SkXfermodeImageFilter::Make(make_xfermode(), make_image_filter(), make_image_filter(), nullptr); diff --git a/samplecode/SampleFuzz.cpp b/samplecode/SampleFuzz.cpp index 76420f026a..c7d05782e3 100644 --- a/samplecode/SampleFuzz.cpp +++ b/samplecode/SampleFuzz.cpp @@ -153,15 +153,15 @@ static void do_fuzz(SkCanvas* canvas) { break; case 2: { - SkXfermode::Mode mode; + SkBlendMode mode; switch (R(3)) { - case 0: mode = SkXfermode::kSrc_Mode; break; - case 1: mode = SkXfermode::kXor_Mode; break; + case 0: mode = SkBlendMode::kSrc; break; + case 1: mode = SkBlendMode::kXor; break; case 2: default: // silence warning - mode = SkXfermode::kSrcOver_Mode; break; + mode = SkBlendMode::kSrcOver; break; } - paint.setXfermodeMode(mode); + paint.setBlendMode(mode); } break; diff --git a/samplecode/SampleHairModes.cpp b/samplecode/SampleHairModes.cpp index 26037d7dc9..5eeb6cbbba 100644 --- a/samplecode/SampleHairModes.cpp +++ b/samplecode/SampleHairModes.cpp @@ -12,21 +12,21 @@ #include "SkShader.h" static const struct { - SkXfermode::Mode fMode; - const char* fLabel; + SkBlendMode fMode; + const char* fLabel; } gModes[] = { - { SkXfermode::kClear_Mode, "Clear" }, - { SkXfermode::kSrc_Mode, "Src" }, - { SkXfermode::kDst_Mode, "Dst" }, - { SkXfermode::kSrcOver_Mode, "SrcOver" }, - { SkXfermode::kDstOver_Mode, "DstOver" }, - { SkXfermode::kSrcIn_Mode, "SrcIn" }, - { SkXfermode::kDstIn_Mode, "DstIn" }, - { SkXfermode::kSrcOut_Mode, "SrcOut" }, - { SkXfermode::kDstOut_Mode, "DstOut" }, - { SkXfermode::kSrcATop_Mode, "SrcATop" }, - { SkXfermode::kDstATop_Mode, "DstATop" }, - { SkXfermode::kXor_Mode, "Xor" }, + { SkBlendMode::kClear, "Clear" }, + { SkBlendMode::kSrc, "Src" }, + { SkBlendMode::kDst, "Dst" }, + { SkBlendMode::kSrcOver, "SrcOver" }, + { SkBlendMode::kDstOver, "DstOver" }, + { SkBlendMode::kSrcIn, "SrcIn" }, + { SkBlendMode::kDstIn, "DstIn" }, + { SkBlendMode::kSrcOut, "SrcOut" }, + { SkBlendMode::kDstOut, "DstOut" }, + { SkBlendMode::kSrcATop, "SrcATop" }, + { SkBlendMode::kDstATop, "DstATop" }, + { SkBlendMode::kXor, "Xor" }, }; const int gWidth = 64; @@ -34,7 +34,7 @@ const int gHeight = 64; const SkScalar W = SkIntToScalar(gWidth); const SkScalar H = SkIntToScalar(gHeight); -static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, SkAlpha a1) { +static SkScalar drawCell(SkCanvas* canvas, SkBlendMode mode, SkAlpha a0, SkAlpha a1) { SkPaint paint; paint.setAntiAlias(true); @@ -47,7 +47,7 @@ static SkScalar drawCell(SkCanvas* canvas, sk_sp<SkXfermode> mode, SkAlpha a0, S paint.setColor(SK_ColorRED); paint.setAlpha(a1); - paint.setXfermode(mode); + paint.setBlendMode(mode); for (int angle = 0; angle < 24; ++angle) { SkScalar x = SkScalarCos(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gWidth; SkScalar y = SkScalarSin(SkIntToScalar(angle) * (SK_ScalarPI * 2) / 24) * gHeight; @@ -105,7 +105,7 @@ protected: } canvas->drawRect(bounds, fBGPaint); canvas->saveLayer(&bounds, nullptr); - SkScalar dy = drawCell(canvas, SkXfermode::Make(gModes[i].fMode), + SkScalar dy = drawCell(canvas, gModes[i].fMode, gAlphaValue[alpha & 1], gAlphaValue[alpha & 2]); canvas->restore(); diff --git a/samplecode/SampleLayerMask.cpp b/samplecode/SampleLayerMask.cpp index 5fce85c4b7..f0c6a40dc2 100644 --- a/samplecode/SampleLayerMask.cpp +++ b/samplecode/SampleLayerMask.cpp @@ -44,13 +44,13 @@ protected: bounds.offset(-bounds.fLeft, -bounds.fTop); c.drawOval(bounds, paint); - paint.setXfermodeMode(SkXfermode::kDstIn_Mode); + paint.setBlendMode(SkBlendMode::kDstIn); canvas->drawBitmap(mask, r.fLeft, r.fTop, &paint); } else { SkPath p; p.addOval(r); p.setFillType(SkPath::kInverseWinding_FillType); - paint.setXfermodeMode(SkXfermode::kDstOut_Mode); + paint.setBlendMode(SkBlendMode::kDstOut); canvas->drawPath(p, paint); } } diff --git a/samplecode/SampleLayers.cpp b/samplecode/SampleLayers.cpp index 52e6593a85..71b2e8ba66 100644 --- a/samplecode/SampleLayers.cpp +++ b/samplecode/SampleLayers.cpp @@ -31,7 +31,7 @@ static void make_paint(SkPaint* paint, const SkMatrix& localMatrix) { SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } }; paint->setShader(SkGradientShader::MakeLinear(pts, colors, nullptr, 2, SkShader::kClamp_TileMode, 0, &localMatrix)); - paint->setXfermodeMode(SkXfermode::kDstIn_Mode); + paint->setBlendMode(SkBlendMode::kDstIn); } // test drawing with strips of fading gradient above and below @@ -141,7 +141,7 @@ protected: canvas->saveLayer(&r, &p); canvas->drawColor(0xFFFF0000); p.setAlpha(0); // or 0 - p.setXfermodeMode(SkXfermode::kSrc_Mode); + p.setBlendMode(SkBlendMode::kSrc); canvas->drawOval(r, p); canvas->restore(); return; diff --git a/samplecode/SamplePathClip.cpp b/samplecode/SamplePathClip.cpp index a53fe7186b..af9608f0eb 100644 --- a/samplecode/SamplePathClip.cpp +++ b/samplecode/SamplePathClip.cpp @@ -225,7 +225,7 @@ protected: // We use a layer, so we can PLUS the different edge-colors, showing where two edges // canceled each other out. canvas->saveLayer(nullptr, nullptr); - p.setXfermodeMode(SkXfermode::kPlus_Mode); + p.setBlendMode(SkBlendMode::kPlus); for (int i = 0; i < N; ++i) { const int j = (i + 1) % N; p.setColor(fEdgeColor[i]); diff --git a/samplecode/SampleQuadStroker.cpp b/samplecode/SampleQuadStroker.cpp index ab65ff6d87..30b8603bcf 100644 --- a/samplecode/SampleQuadStroker.cpp +++ b/samplecode/SampleQuadStroker.cpp @@ -248,7 +248,7 @@ protected: canvas->restore(); SkPaint paint; - paint.setXfermodeMode(SkXfermode::kClear_Mode); + paint.setBlendMode(SkBlendMode::kClear); for (int iy = 1; iy < fH; ++iy) { SkScalar y = SkIntToScalar(iy * fZoom); canvas->drawLine(0, y - SK_ScalarHalf, 999, y - SK_ScalarHalf, paint); diff --git a/samplecode/SampleRegion.cpp b/samplecode/SampleRegion.cpp index 1934dc74cb..082ff22286 100644 --- a/samplecode/SampleRegion.cpp +++ b/samplecode/SampleRegion.cpp @@ -80,7 +80,7 @@ static void drawFadingText(SkCanvas* canvas, SkPaint p; p.setShader(SkGradientShader::MakeLinear(pts, colors, pos, 3, SkShader::kClamp_TileMode)); - p.setXfermodeMode(SkXfermode::kDstIn_Mode); + p.setBlendMode(SkBlendMode::kDstIn); canvas->drawRect(bounds, p); canvas->restore(); diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp index 5858d2674e..521e9f6ead 100644 --- a/samplecode/SampleSlides.cpp +++ b/samplecode/SampleSlides.cpp @@ -472,7 +472,7 @@ static void r0(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) p.setAlpha(0x11); p.setStyle(SkPaint::kFill_Style); - p.setXfermodeMode(SkXfermode::kSrc_Mode); + p.setBlendMode(SkBlendMode::kSrc); rastBuilder->addLayer(p); } @@ -481,7 +481,7 @@ static void r1(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) rastBuilder->addLayer(p); p.setAlpha(0x40); - p.setXfermodeMode(SkXfermode::kSrc_Mode); + p.setBlendMode(SkBlendMode::kSrc); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1*2); rastBuilder->addLayer(p); @@ -495,7 +495,7 @@ static void r2(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1*3/2); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p); } @@ -507,7 +507,7 @@ static void r3(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) p.setAlpha(0x20); p.setStyle(SkPaint::kFill_Style); - p.setXfermodeMode(SkXfermode::kSrc_Mode); + p.setBlendMode(SkBlendMode::kSrc); rastBuilder->addLayer(p); } @@ -517,10 +517,10 @@ static void r4(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) rastBuilder->addLayer(p, SkIntToScalar(3), SkIntToScalar(3)); p.setAlpha(0xFF); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p, SK_Scalar1*3/2, SK_Scalar1*3/2); - p.setXfermode(nullptr); + p.setBlendMode(SkBlendMode::kSrcOver); rastBuilder->addLayer(p); } @@ -531,7 +531,7 @@ static void r5(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) rastBuilder->addLayer(p); p.setPathEffect(SkDiscretePathEffect::Make(SK_Scalar1*4, SK_Scalar1*3)); - p.setXfermodeMode(SkXfermode::kSrcOut_Mode); + p.setBlendMode(SkBlendMode::kSrcOut); rastBuilder->addLayer(p); } @@ -543,7 +543,7 @@ static void r6(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) SkLayerRasterizer::Builder rastBuilder2; r5(&rastBuilder2, p); p.setRasterizer(rastBuilder2.detach()); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p); } @@ -572,11 +572,11 @@ static void r8(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) lattice.setScale(SK_Scalar1*6, SK_Scalar1*6, 0, 0); lattice.postSkew(SK_Scalar1/3, 0, 0, 0); p.setPathEffect(MakeDotEffect(SK_Scalar1*2, lattice)); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p); p.setPathEffect(nullptr); - p.setXfermode(nullptr); + p.setBlendMode(SkBlendMode::kSrcOver); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1); rastBuilder->addLayer(p); @@ -590,11 +590,11 @@ static void r9(SkLayerRasterizer::Builder* rastBuilder, SkPaint& p) lattice.setScale(SK_Scalar1, SK_Scalar1*6, 0, 0); lattice.postRotate(SkIntToScalar(30), 0, 0); p.setPathEffect(SkLine2DPathEffect::Make(SK_Scalar1*2, lattice)); - p.setXfermodeMode(SkXfermode::kClear_Mode); + p.setBlendMode(SkBlendMode::kClear); rastBuilder->addLayer(p); p.setPathEffect(nullptr); - p.setXfermode(nullptr); + p.setBlendMode(SkBlendMode::kSrcOver); p.setStyle(SkPaint::kStroke_Style); p.setStrokeWidth(SK_Scalar1); rastBuilder->addLayer(p); diff --git a/samplecode/SampleXfer.cpp b/samplecode/SampleXfer.cpp index 6aaffe59c9..c0ad000501 100644 --- a/samplecode/SampleXfer.cpp +++ b/samplecode/SampleXfer.cpp @@ -18,18 +18,18 @@ #include "SkGradientShader.h" const struct { - SkXfermode::Mode fMode; - const char* fName; + SkBlendMode fMode; + const char* fName; } gModes[] = { - { SkXfermode::kSrcOver_Mode, "src-over" }, - { SkXfermode::kSrc_Mode, "src" }, - { SkXfermode::kSrcIn_Mode, "src-in" }, - { SkXfermode::kSrcOut_Mode, "src-out" }, - { SkXfermode::kSrcATop_Mode, "src-atop" }, - { SkXfermode::kDstOver_Mode, "dst-over" }, - { SkXfermode::kDstIn_Mode, "dst-in" }, - { SkXfermode::kDstOut_Mode, "dst-out" }, - { SkXfermode::kDstATop_Mode, "dst-atop" }, + { SkBlendMode::kSrcOver, "src-over" }, + { SkBlendMode::kSrc, "src" }, + { SkBlendMode::kSrcIn, "src-in" }, + { SkBlendMode::kSrcOut, "src-out" }, + { SkBlendMode::kSrcATop, "src-atop" }, + { SkBlendMode::kDstOver, "dst-over" }, + { SkBlendMode::kDstIn, "dst-in" }, + { SkBlendMode::kDstOut, "dst-out" }, + { SkBlendMode::kDstATop, "dst-atop" }, }; const int N_Modes = SK_ARRAY_COUNT(gModes); @@ -109,10 +109,10 @@ private: class ModeDrawable : public SkDrawable { public: - ModeDrawable() : fMode(SkXfermode::kSrcOver_Mode), fLoc(SkPoint::Make(0, 0)) {} + ModeDrawable() : fMode(SkBlendMode::kSrcOver), fLoc(SkPoint::Make(0, 0)) {} - SkXfermode::Mode fMode; - SkPoint fLoc; + SkBlendMode fMode; + SkPoint fLoc; bool hitTest(SkScalar x, SkScalar y) { SkRect target = SkRect::MakeXYWH(x - fLoc.x() - 1, y - fLoc.y() - 1, 3, 3); @@ -139,7 +139,7 @@ protected: } void onDraw(SkCanvas* canvas) override { - fPaint.setXfermodeMode(fMode); + fPaint.setBlendMode(fMode); canvas->save(); canvas->translate(fLoc.x(), fLoc.y()); canvas->drawOval(fBounds, fPaint); @@ -160,7 +160,7 @@ class XferDemo : public SampleView { SkScalar x = 10; SkScalar y = 10; for (int i = 0; i < N_Modes; ++i) { - SkAutoTUnref<SkView> v(new PushButtonWig(gModes[i].fName, gModes[i].fMode)); + SkAutoTUnref<SkView> v(new PushButtonWig(gModes[i].fName, (int)gModes[i].fMode)); v->setSize(70, 25); v->setLoc(x, y); v->setVisibleP(true); @@ -178,7 +178,7 @@ public: for (int i = 0; i < N; ++i) { fDrs[i].reset(new CircDrawable(200, colors[i])); fDrs[i]->fLoc.set(100.f + i * 100, 100.f + i * 100); - fDrs[i]->fMode = SkXfermode::kSrcOver_Mode; + fDrs[i]->fMode = SkBlendMode::kSrcOver; } fSelected = nullptr; @@ -189,7 +189,7 @@ protected: bool onEvent(const SkEvent& evt) override { if (evt.isType("push-button")) { if (fSelected) { - fSelected->fMode = (SkXfermode::Mode)evt.getFast32(); + fSelected->fMode = (SkBlendMode)evt.getFast32(); this->inval(nullptr); } return true; diff --git a/samplecode/SampleXfermodesBlur.cpp b/samplecode/SampleXfermodesBlur.cpp index ef25114cf0..fe07c9b567 100644 --- a/samplecode/SampleXfermodesBlur.cpp +++ b/samplecode/SampleXfermodesBlur.cpp @@ -37,8 +37,7 @@ class XfermodesBlurView : public SampleView { SkBitmap fBG; SkBitmap fSrcB, fDstB; - void draw_mode(SkCanvas* canvas, sk_sp<SkXfermode> mode, int alpha, - SkScalar x, SkScalar y) { + void draw_mode(SkCanvas* canvas, SkBlendMode mode, int alpha, SkScalar x, SkScalar y) { SkPaint p; p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, SkBlurMask::ConvertRadiusToSigma(5), @@ -55,7 +54,7 @@ class XfermodesBlurView : public SampleView { r.offset(x, y); canvas->drawOval(r, p); - p.setXfermode(std::move(mode)); + p.setBlendMode(mode); // draw a square overlapping the circle // in the lower right of the canvas @@ -110,34 +109,23 @@ protected: } const struct { - SkXfermode::Mode fMode; - const char* fLabel; + SkBlendMode fMode; + const char* fLabel; } gModes[] = { - { SkXfermode::kClear_Mode, "Clear" }, - { SkXfermode::kSrc_Mode, "Src" }, - { SkXfermode::kDst_Mode, "Dst" }, - { SkXfermode::kSrcOver_Mode, "SrcOver" }, - { SkXfermode::kDstOver_Mode, "DstOver" }, - { SkXfermode::kSrcIn_Mode, "SrcIn" }, - { SkXfermode::kDstIn_Mode, "DstIn" }, - { SkXfermode::kSrcOut_Mode, "SrcOut" }, - { SkXfermode::kDstOut_Mode, "DstOut" }, - { SkXfermode::kSrcATop_Mode, "SrcATop" }, - { SkXfermode::kDstATop_Mode, "DstATop" }, - { SkXfermode::kXor_Mode, "Xor" }, - - { SkXfermode::kPlus_Mode, "Plus" }, - /*{ SkXfermode::kModulate_Mode, "Modulate" }, - { SkXfermode::kScreen_Mode, "Screen" }, - { SkXfermode::kOverlay_Mode, "Overlay" }, - { SkXfermode::kDarken_Mode, "Darken" }, - { SkXfermode::kLighten_Mode, "Lighten" }, - { SkXfermode::kColorDodge_Mode, "ColorDodge" }, - { SkXfermode::kColorBurn_Mode, "ColorBurn" }, - { SkXfermode::kHardLight_Mode, "HardLight" }, - { SkXfermode::kSoftLight_Mode, "SoftLight" }, - { SkXfermode::kDifference_Mode, "Difference" }, - { SkXfermode::kExclusion_Mode, "Exclusion" },*/ + { SkBlendMode::kClear, "Clear" }, + { SkBlendMode::kSrc, "Src" }, + { SkBlendMode::kDst, "Dst" }, + { SkBlendMode::kSrcOver, "SrcOver" }, + { SkBlendMode::kDstOver, "DstOver" }, + { SkBlendMode::kSrcIn, "SrcIn" }, + { SkBlendMode::kDstIn, "DstIn" }, + { SkBlendMode::kSrcOut, "SrcOut" }, + { SkBlendMode::kDstOut, "DstOut" }, + { SkBlendMode::kSrcATop, "SrcATop" }, + { SkBlendMode::kDstATop, "DstATop" }, + { SkBlendMode::kXor, "Xor" }, + + { SkBlendMode::kPlus, "Plus" }, }; const SkScalar w = SkIntToScalar(W); @@ -168,8 +156,7 @@ protected: canvas->drawRect(r, p); canvas->saveLayer(&r, nullptr); - draw_mode(canvas, SkXfermode::Make(gModes[i].fMode), - twice ? 0x88 : 0xFF, r.fLeft, r.fTop); + draw_mode(canvas, gModes[i].fMode, twice ? 0x88 : 0xFF, r.fLeft, r.fTop); canvas->restore(); r.inset(-SK_ScalarHalf, -SK_ScalarHalf); |