diff options
author | Mike Reed <reed@google.com> | 2016-10-03 18:02:50 +0000 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-10-03 18:03:29 +0000 |
commit | ce02e7175872abde3721df9e5d3ec0ab8384cd8e (patch) | |
tree | 620eec63e1082137df3111d09cd2bf1eb7ebd180 /include | |
parent | 6fb592e6afb0061c9c0af15ddf599e2903f508f1 (diff) |
Revert "replace SkXfermode obj with SkBlendMode enum in paints"
This reverts commit I4fb489ba6b3f77b458f7e4a99f79c7ad10859135.
Reason for revert: <INSERT REASONING HERE>
Original change's description:
> replace SkXfermode obj with SkBlendMode enum in paints
>
> BUG=skia:5814
>
> GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2714
>
> Change-Id: I4fb489ba6b3f77b458f7e4a99f79c7ad10859135
> Reviewed-on: https://skia-review.googlesource.com/2714
> Reviewed-by: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Mike Reed <reed@google.com>
>
TBR=bsalomon@google.com,fmalita@chromium.org,fmalita@google.com,reed@google.com,reviews@skia.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Change-Id: I3e43f79ef5c1709929663fe63cc1f67cd78270b7
Reviewed-on: https://skia-review.googlesource.com/2871
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/core/SkBlendMode.h | 51 | ||||
-rw-r--r-- | include/core/SkCanvas.h | 18 | ||||
-rw-r--r-- | include/core/SkColorFilter.h | 3 | ||||
-rw-r--r-- | include/core/SkPaint.h | 13 | ||||
-rw-r--r-- | include/core/SkPicture.h | 3 | ||||
-rw-r--r-- | include/core/SkXfermode.h | 32 | ||||
-rw-r--r-- | include/effects/SkXfermodeImageFilter.h | 17 | ||||
-rw-r--r-- | include/gpu/GrPaint.h | 6 | ||||
-rw-r--r-- | include/gpu/effects/GrPorterDuffXferProcessor.h | 3 |
9 files changed, 12 insertions, 134 deletions
diff --git a/include/core/SkBlendMode.h b/include/core/SkBlendMode.h deleted file mode 100644 index eb3469f256..0000000000 --- a/include/core/SkBlendMode.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2016 Google Inc. - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#ifndef SkBlendMode_DEFINED -#define SkBlendMode_DEFINED - -enum class SkBlendMode { - kClear, //!< [0, 0] - kSrc, //!< [Sa, Sc] - kDst, //!< [Da, Dc] - kSrcOver, //!< [Sa + Da * (1 - Sa), Sc + Dc * (1 - Sa)] - kDstOver, //!< [Da + Sa * (1 - Da), Dc + Sc * (1 - Da)] - kSrcIn, //!< [Sa * Da, Sc * Da] - kDstIn, //!< [Da * Sa, Dc * Sa] - kSrcOut, //!< [Sa * (1 - Da), Sc * (1 - Da)] - kDstOut, //!< [Da * (1 - Sa), Dc * (1 - Sa)] - kSrcATop, //!< [Da, Sc * Da + Dc * (1 - Sa)] - kDstATop, //!< [Sa, Dc * Sa + Sc * (1 - Da)] - kXor, //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + Dc * (1 - Sa)] - kPlus, //!< [Sa + Da, Sc + Dc] - kModulate, // multiplies all components (= alpha and color) - - // Following blend modes are defined in the CSS Compositing standard: - // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending - kScreen, - kLastCoeffMode = kScreen, - - kOverlay, - kDarken, - kLighten, - kColorDodge, - kColorBurn, - kHardLight, - kSoftLight, - kDifference, - kExclusion, - kMultiply, - kLastSeparableMode = kMultiply, - - kHue, - kSaturation, - kColor, - kLuminosity, - kLastMode = kLuminosity -}; - -#endif diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h index 5078f4255c..8d98e5024f 100644 --- a/include/core/SkCanvas.h +++ b/include/core/SkCanvas.h @@ -9,7 +9,6 @@ #define SkCanvas_DEFINED #include "SkTypes.h" -#include "SkBlendMode.h" #include "SkBitmap.h" #include "SkClipOp.h" #include "SkDeque.h" @@ -596,31 +595,22 @@ public: @param b the blue component (0..255) of the color to fill the canvas @param mode the mode to apply the color in (defaults to SrcOver) */ - void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, SkBlendMode mode = SkBlendMode::kSrcOver); -#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT - void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, SkXfermode::Mode mode) { - this->drawARGB(a, r, g, b, (SkBlendMode)mode); - } -#endif + void drawARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b, + SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode); /** Fill the entire canvas' bitmap (restricted to the current clip) with the specified color and mode. @param color the color to draw with @param mode the mode to apply the color in (defaults to SrcOver) */ - void drawColor(SkColor color, SkBlendMode mode = SkBlendMode::kSrcOver); -#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT - void drawColor(SkColor color, SkXfermode::Mode mode) { - this->drawColor(color, (SkBlendMode)mode); - } -#endif + void drawColor(SkColor color, SkXfermode::Mode mode = SkXfermode::kSrcOver_Mode); /** * Helper method for drawing a color in SRC mode, completely replacing all the pixels * in the current clip with this color. */ void clear(SkColor color) { - this->drawColor(color, SkBlendMode::kSrc); + this->drawColor(color, SkXfermode::kSrc_Mode); } /** diff --git a/include/core/SkColorFilter.h b/include/core/SkColorFilter.h index 5a23a343a2..609550f676 100644 --- a/include/core/SkColorFilter.h +++ b/include/core/SkColorFilter.h @@ -115,9 +115,6 @@ public: or NULL if the mode will have no effect. */ static sk_sp<SkColorFilter> MakeModeFilter(SkColor c, SkXfermode::Mode mode); - static sk_sp<SkColorFilter> MakeModeFilter(SkColor c, SkBlendMode mode) { - return MakeModeFilter(c, (SkXfermode::Mode)mode); - } /** Construct a colorfilter whose effect is to first apply the inner filter and then apply * the outer filter to the result of the inner's. diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index ddc90ae19c..e28d2fc92d 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -8,14 +8,11 @@ #ifndef SkPaint_DEFINED #define SkPaint_DEFINED -#include "SkBlendMode.h" #include "SkColor.h" #include "SkFilterQuality.h" #include "SkMatrix.h" #include "SkXfermode.h" -//#define SK_SUPPORT_LEGACY_XFERMODE_OBJECT - class SkAutoDescriptor; class SkAutoGlyphCache; class SkColorFilter; @@ -528,13 +525,12 @@ public: #endif void setColorFilter(sk_sp<SkColorFilter>); -#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT /** Get the paint's xfermode object. <p /> The xfermode's reference count is not affected. @return the paint's xfermode (or NULL) */ - SkXfermode* getXfermode() const; + SkXfermode* getXfermode() const { return fXfermode.get(); } /** Set or clear the xfermode object. <p /> @@ -556,11 +552,6 @@ public: the paint's xfermode is set to null. */ SkXfermode* setXfermodeMode(SkXfermode::Mode); -#endif - - SkBlendMode getBlendMode() const { return (SkBlendMode)fBlendMode; } - bool isSrcOver() const { return (SkBlendMode)fBlendMode == SkBlendMode::kSrcOver; } - void setBlendMode(SkBlendMode mode) { fBlendMode = (unsigned)mode; } /** Get the paint's patheffect object. <p /> @@ -1099,6 +1090,7 @@ private: sk_sp<SkTypeface> fTypeface; sk_sp<SkPathEffect> fPathEffect; sk_sp<SkShader> fShader; + sk_sp<SkXfermode> fXfermode; sk_sp<SkMaskFilter> fMaskFilter; sk_sp<SkColorFilter> fColorFilter; sk_sp<SkRasterizer> fRasterizer; @@ -1111,7 +1103,6 @@ private: SkColor fColor; SkScalar fWidth; SkScalar fMiterLimit; - uint32_t fBlendMode; // just need 5-6 bits for SkXfermode::Mode union { struct { // all of these bitfields should add up to 32 diff --git a/include/core/SkPicture.h b/include/core/SkPicture.h index c2d05f9c41..c398d3a4ec 100644 --- a/include/core/SkPicture.h +++ b/include/core/SkPicture.h @@ -224,11 +224,10 @@ private: // V47: Add occluder rect to SkBlurMaskFilter // V48: Read and write extended SkTextBlobs. // V49: Gradients serialized as SkColor4f + SkColorSpace - // V50: SkXfermode -> SkBlendMode // Only SKPs within the min/current picture version range (inclusive) can be read. static const uint32_t MIN_PICTURE_VERSION = 35; // Produced by Chrome M39. - static const uint32_t CURRENT_PICTURE_VERSION = 50; + static const uint32_t CURRENT_PICTURE_VERSION = 49; static_assert(MIN_PICTURE_VERSION <= 41, "Remove kFontFileName and related code from SkFontDescriptor.cpp."); diff --git a/include/core/SkXfermode.h b/include/core/SkXfermode.h index 8319ad6882..2d12b3c931 100644 --- a/include/core/SkXfermode.h +++ b/include/core/SkXfermode.h @@ -8,9 +8,8 @@ #ifndef SkXfermode_DEFINED #define SkXfermode_DEFINED -#include "SkBlendMode.h" -#include "SkColor.h" #include "SkFlattenable.h" +#include "SkColor.h" class GrFragmentProcessor; class GrTexture; @@ -113,9 +112,6 @@ public: * Gets the name of the Mode as a string. */ static const char* ModeName(Mode); - static const char* ModeName(SkBlendMode mode) { - return ModeName(Mode(mode)); - } /** * If the xfermode is one of the modes in the Mode enum, then asMode() @@ -161,31 +157,6 @@ public: } #endif - /** - * Skia maintains global xfermode objects corresponding to each BlendMode. This returns a - * ptr to that global xfermode (or null if the mode is srcover). Thus the caller may use - * the returned ptr, but it should leave its refcnt untouched. - */ - static SkXfermode* Peek(SkBlendMode mode) { - sk_sp<SkXfermode> xfer = Make(mode); - if (!xfer) { - SkASSERT(SkBlendMode::kSrcOver == mode); - return nullptr; - } - SkASSERT(!xfer->unique()); - return xfer.get(); - } - - static sk_sp<SkXfermode> Make(SkBlendMode bm) { - return Make((Mode)bm); - } - - SkBlendMode blend() const { - Mode mode; - SkAssertResult(this->asMode(&mode)); - return (SkBlendMode)mode; - } - /** Return a function pointer to a routine that applies the specified porter-duff transfer mode. */ @@ -244,7 +215,6 @@ public: static bool IsOpaque(const sk_sp<SkXfermode>& xfer, SrcColorOpacity opacityType) { return IsOpaque(xfer.get(), opacityType); } - static bool IsOpaque(SkBlendMode, SrcColorOpacity); #if SK_SUPPORT_GPU /** Used by the SkXfermodeImageFilter to blend two colors via a GrFragmentProcessor. diff --git a/include/effects/SkXfermodeImageFilter.h b/include/effects/SkXfermodeImageFilter.h index fa9c857a7e..6066b8d2e0 100644 --- a/include/effects/SkXfermodeImageFilter.h +++ b/include/effects/SkXfermodeImageFilter.h @@ -8,7 +8,6 @@ #ifndef SkXfermodeImageFilter_DEFINED #define SkXfermodeImageFilter_DEFINED -#include "SkBlendMode.h" #include "SkImageFilter.h" class SkXfermode; @@ -20,11 +19,11 @@ class SkXfermode; */ class SK_API SkXfermodeImageFilter { public: - static sk_sp<SkImageFilter> Make(SkBlendMode, sk_sp<SkImageFilter> background, + static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background, sk_sp<SkImageFilter> foreground, const SkImageFilter::CropRect* cropRect); - static sk_sp<SkImageFilter> Make(SkBlendMode mode, sk_sp<SkImageFilter> background) { - return Make(mode, std::move(background), nullptr, nullptr); + static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background) { + return Make(std::move(mode), std::move(background), nullptr, nullptr); } static sk_sp<SkImageFilter> MakeArithmetic(float k1, float k2, float k3, float k4, @@ -39,16 +38,6 @@ public: nullptr, nullptr); } -#ifdef SK_SUPPORT_LEGACY_XFERMODE_OBJECT - static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background, - sk_sp<SkImageFilter> foreground, - const SkImageFilter::CropRect* cropRect); - static sk_sp<SkImageFilter> Make(sk_sp<SkXfermode> mode, sk_sp<SkImageFilter> background) { - return Make(std::move(mode), std::move(background), nullptr, nullptr); - } - -#endif - #ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR static SkImageFilter* Create(SkXfermode* mode, SkImageFilter* background, SkImageFilter* foreground = NULL, diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h index a8af3c2f17..6120348792 100644 --- a/include/gpu/GrPaint.h +++ b/include/gpu/GrPaint.h @@ -16,9 +16,9 @@ #include "effects/GrPorterDuffXferProcessor.h" #include "GrFragmentProcessor.h" -#include "SkBlendMode.h" #include "SkRefCnt.h" #include "SkRegion.h" +#include "SkXfermode.h" /** * The paint describes how color and coverage are computed at each pixel by GrContext draw @@ -95,10 +95,6 @@ public: fXPFactory = std::move(xpFactory); } - void setPorterDuffXPFactory(SkBlendMode mode) { - fXPFactory = GrPorterDuffXPFactory::Make((SkXfermode::Mode)mode); - } - void setPorterDuffXPFactory(SkXfermode::Mode mode) { fXPFactory = GrPorterDuffXPFactory::Make(mode); } diff --git a/include/gpu/effects/GrPorterDuffXferProcessor.h b/include/gpu/effects/GrPorterDuffXferProcessor.h index 6777d76046..8399d5805e 100644 --- a/include/gpu/effects/GrPorterDuffXferProcessor.h +++ b/include/gpu/effects/GrPorterDuffXferProcessor.h @@ -17,9 +17,6 @@ class GrProcOptInfo; class GrPorterDuffXPFactory : public GrXPFactory { public: static sk_sp<GrXPFactory> Make(SkXfermode::Mode mode); - static sk_sp<GrXPFactory> Make(SkBlendMode mode) { - return Make((SkXfermode::Mode)mode); - } void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, GrXPFactory::InvariantBlendedColor*) const override; |