Revert "SkShaderBase"
authorFlorin Malita <fmalita@chromium.org>
Wed, 24 May 2017 21:15:46 +0000 (21:15 +0000)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Wed, 24 May 2017 21:15:57 +0000 (21:15 +0000)
This reverts commit 58a756435ca3700d9766a4580bb0771a9774f603.

Reason for revert: g3, Android borkage.

Original change's description:
> SkShaderBase
>
> Introduce a private base class (SkShaderBase), to hide
> implementation details from the public interface (SkShader).
>
> Change-Id: If3ec26ca6abc9da20e3f139c11fdc023bdd85176
> Reviewed-on: https://skia-review.googlesource.com/17241
> Commit-Queue: Florin Malita <fmalita@chromium.org>
> Reviewed-by: Mike Reed <reed@google.com>
>

TBR=mtklein@google.com,fmalita@chromium.org,reed@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Change-Id: I32b012ee466dd006c074593f211f43ed602f1078
Reviewed-on: https://skia-review.googlesource.com/17845
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Florin Malita <fmalita@chromium.org>

61 files changed:
bench/SkLinearBitmapPipelineBench.cpp
experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.cpp
experimental/SkPerlinNoiseShader2/SkPerlinNoiseShader2.h
gm/SkLinearBitmapPipelineGM.cpp
gn/core.gni
include/core/SkFlattenable.h
include/core/SkShader.h
src/core/SkBitmapProcShader.cpp
src/core/SkBitmapProcShader.h
src/core/SkBlitter.cpp
src/core/SkBlitter.h
src/core/SkBlitter_A8.cpp
src/core/SkBlitter_ARGB32.cpp
src/core/SkBlitter_PM4f.cpp
src/core/SkBlitter_RGB16.cpp
src/core/SkColorFilterShader.cpp
src/core/SkColorFilterShader.h
src/core/SkColorShader.cpp
src/core/SkColorShader.h
src/core/SkColorSpaceXformer.cpp
src/core/SkComposeShader.cpp
src/core/SkComposeShader.h
src/core/SkCoreBlitters.h
src/core/SkDraw_vertices.cpp
src/core/SkEmptyShader.h
src/core/SkGlobalInitialization_core.cpp
src/core/SkLightingShader.cpp
src/core/SkLocalMatrixShader.cpp
src/core/SkLocalMatrixShader.h
src/core/SkMipMap.h
src/core/SkNormalBevelSource.cpp
src/core/SkNormalBevelSource.h
src/core/SkNormalFlatSource.cpp
src/core/SkNormalFlatSource.h
src/core/SkNormalMapSource.cpp
src/core/SkNormalMapSource.h
src/core/SkNormalSource.h
src/core/SkPaint.cpp
src/core/SkPictureShader.cpp
src/core/SkPictureShader.h
src/core/SkRasterPipelineBlitter.cpp
src/core/SkReadBuffer.h
src/core/SkShader.cpp
src/core/SkShaderBase.h [deleted file]
src/effects/SkGaussianEdgeShader.cpp
src/effects/SkGaussianEdgeShader.h
src/effects/SkPerlinNoiseShader.cpp
src/effects/gradients/Sk4fGradientBase.h
src/effects/gradients/SkGradientShader.cpp
src/effects/gradients/SkGradientShaderPriv.h
src/effects/gradients/SkLinearGradient.cpp
src/effects/gradients/SkRadialGradient.cpp
src/effects/gradients/SkSweepGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient.cpp
src/effects/gradients/SkTwoPointConicalGradient_gpu.cpp
src/gpu/GrTestUtils.h
src/gpu/SkGr.cpp
src/image/SkImageShader.cpp
src/image/SkImageShader.h
tests/SerializationTest.cpp
tests/TessellatingPathRendererTests.cpp

index bbacac7..0a86778 100644 (file)
@@ -15,7 +15,7 @@
 #include "SkImage.h"
 #include "SkLinearBitmapPipeline.h"
 #include "SkPM4f.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 struct CommonBitmapFPBenchmark : public Benchmark {
     CommonBitmapFPBenchmark(
@@ -201,10 +201,10 @@ struct SkBitmapFPOrigShader : public CommonBitmapFPBenchmark {
         SkAutoTMalloc<SkPMColor> buffer4b(width*height);
 
         SkArenaAlloc alloc{0};
-        const SkShaderBase::ContextRec rec(fPaint, fM, nullptr,
-                                           SkShaderBase::ContextRec::kPMColor_DstType,
-                                           nullptr);
-        SkShaderBase::Context* ctx = as_SB(fPaint.getShader())->makeContext(rec, &alloc);
+        const SkShader::ContextRec rec(fPaint, fM, nullptr,
+                                       SkShader::ContextRec::kPMColor_DstType,
+                                       nullptr);
+        SkShader::Context* ctx = fPaint.getShader()->makeContext(rec, &alloc);
 
         int count = 100;
 
index 1ebee2e..88ed0f1 100644 (file)
@@ -564,8 +564,8 @@ SkPMColor SkPerlinNoiseShader2::PerlinNoiseShaderContext::shade(
     return SkPreMultiplyARGB(rgba[3], rgba[0], rgba[1], rgba[2]);
 }
 
-SkShaderBase::Context* SkPerlinNoiseShader2::onMakeContext(const ContextRec& rec,
-                                                           SkArenaAlloc* alloc) const {
+SkShader::Context* SkPerlinNoiseShader2::onMakeContext(const ContextRec& rec,
+                                                       SkArenaAlloc* alloc) const {
     return alloc->make<PerlinNoiseShaderContext>(*this, rec);
 }
 
@@ -719,7 +719,7 @@ sk_sp<GrFragmentProcessor> GrPerlinNoise2Effect::TestCreate(GrProcessorTestData*
                                              stitchTiles ? &tileSize : nullptr));
 
     GrTest::TestAsFPArgs asFPArgs(d);
-    return as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    return shader->asFragmentProcessor(asFPArgs.args());
 }
 #endif
 
@@ -1126,7 +1126,7 @@ sk_sp<GrFragmentProcessor> GrImprovedPerlinNoiseEffect::TestCreate(GrProcessorTe
                                                                    z));
 
     GrTest::TestAsFPArgs asFPArgs(d);
-    return as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    return shader->asFragmentProcessor(asFPArgs.args());
 }
 #endif
 
index 8a46a32..0f40ae4 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SkPerlinNoiseShader2_DEFINED
 #define SkPerlinNoiseShader2_DEFINED
 
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 /** \class SkPerlinNoiseShader2
 
@@ -22,7 +22,7 @@
     The algorithm used is described here :
     http://www.w3.org/TR/SVG/filters.html#feTurbulenceElement
 */
-class SK_API SkPerlinNoiseShader2 : public SkShaderBase {
+class SK_API SkPerlinNoiseShader2 : public SkShader {
 public:
     struct StitchData;
     struct PaintingData;
@@ -83,7 +83,7 @@ public:
         return MakeTurbulence(baseFrequencyX, baseFrequencyY, numOctaves, seed, tileSize);
     }
 
-    class PerlinNoiseShaderContext : public Context {
+    class PerlinNoiseShaderContext : public SkShader::Context {
     public:
         PerlinNoiseShaderContext(const SkPerlinNoiseShader2& shader, const ContextRec&);
         ~PerlinNoiseShaderContext() override;
@@ -102,7 +102,7 @@ public:
         SkMatrix fMatrix;
         PaintingData* fPaintingData;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
 #if SK_SUPPORT_GPU
@@ -130,7 +130,7 @@ private:
     const SkISize                   fTileSize;
     const bool                      fStitchTiles;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index 87566ad..f07d2f7 100644 (file)
@@ -16,7 +16,7 @@
 #include "SkLinearBitmapPipeline.h"
 #include "SkXfermodePriv.h"
 #include "SkPM4fPriv.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 static void fill_in_bits(SkBitmap& bm, SkIRect ir, SkColor c, bool premul) {
     bm.allocN32Pixels(ir.width(), ir.height());
@@ -72,11 +72,11 @@ static void draw_rect_orig(SkCanvas* canvas, const SkRect& r, SkColor c, const S
         paint.setFilterQuality(SkFilterQuality::kNone_SkFilterQuality);
     }
     paint.setShader(std::move(shader));
-    const SkShaderBase::ContextRec rec(paint, *mat, nullptr,
-                                       SkBlitter::PreferredShaderDest(pmsrc.info()),
-                                       canvas->imageInfo().colorSpace());
+    const SkShader::ContextRec rec(paint, *mat, nullptr,
+                                   SkBlitter::PreferredShaderDest(pmsrc.info()),
+                                   canvas->imageInfo().colorSpace());
 
-    SkShaderBase::Context* ctx = as_SB(paint.getShader())->makeContext(rec, &alloc);
+    SkShader::Context* ctx = paint.getShader()->makeContext(rec, &alloc);
 
     for (int y = 0; y < ir.height(); y++) {
         ctx->shadeSpan(0, y, pmdst.writable_addr32(0, y), ir.width());
index 9dfc478..5566dde 100644 (file)
@@ -302,7 +302,6 @@ skia_core_sources = [
   "$_src/core/SkScan_Path.cpp",
   "$_src/core/SkSemaphore.cpp",
   "$_src/core/SkShader.cpp",
-  "$_src/core/SkShaderBase.h",
   "$_src/core/SkSharedMutex.cpp",
   "$_src/core/SkSharedMutex.h",
   "$_src/core/SkSinglyLinkedList.h",
index 49c491e..88aeb7e 100644 (file)
@@ -78,7 +78,7 @@ public:
         kSkPathEffect_Type,
         kSkPixelRef_Type,
         kSkRasterizer_Type,
-        kSkShaderBase_Type,
+        kSkShader_Type,
         kSkUnused_Type,     // used to be SkUnitMapper
         kSkXfermode_Type,
         kSkNormalSource_Type,
index 2089857..260306c 100644 (file)
@@ -40,6 +40,17 @@ class GrFragmentProcessor;
  */
 class SK_API SkShader : public SkFlattenable {
 public:
+    SkShader(const SkMatrix* localMatrix = NULL);
+    ~SkShader() override;
+
+    /**
+     *  Returns the local matrix.
+     *
+     *  FIXME: This can be incorrect for a Shader with its own local matrix
+     *  that is also wrapped via CreateLocalMatrixShader.
+     */
+    const SkMatrix& getLocalMatrix() const { return fLocalMatrix; }
+
     enum TileMode {
         /** replicate the edge color if the shader draws outside of its
          *  original bounds
@@ -64,13 +75,23 @@ public:
         kTileModeCount = kMirror_TileMode + 1
     };
 
-    /**
-     *  Returns the local matrix.
-     *
-     *  FIXME: This can be incorrect for a Shader with its own local matrix
-     *  that is also wrapped via CreateLocalMatrixShader.
-     */
-    const SkMatrix& getLocalMatrix() const;
+    // override these in your subclass
+
+    enum Flags {
+        //!< set if all of the colors will be opaque
+        kOpaqueAlpha_Flag = 1 << 0,
+
+        /** set if the spans only vary in X (const in Y).
+            e.g. an Nx1 bitmap that is being tiled in Y, or a linear-gradient
+            that varies from left-to-right. This flag specifies this for
+            shadeSpan().
+         */
+        kConstInY32_Flag = 1 << 1,
+
+        /** hint for the blitter that 4f is the preferred shading mode.
+         */
+        kPrefers4f_Flag  = 1 << 2,
+    };
 
     /**
      *  Returns true if the shader is guaranteed to produce only opaque
@@ -80,13 +101,150 @@ public:
      */
     virtual bool isOpaque() const { return false; }
 
+    /**
+     *  Returns true if the shader is guaranteed to produce only a single color.
+     *  Subclasses can override this to allow loop-hoisting optimization.
+     */
+    virtual bool isConstant() const { return false; }
+
+    /**
+     *  ContextRec acts as a parameter bundle for creating Contexts.
+     */
+    struct ContextRec {
+        enum DstType {
+            kPMColor_DstType, // clients prefer shading into PMColor dest
+            kPM4f_DstType,    // clients prefer shading into PM4f dest
+        };
+
+        ContextRec(const SkPaint& paint, const SkMatrix& matrix, const SkMatrix* localM,
+                   DstType dstType, SkColorSpace* dstColorSpace)
+            : fPaint(&paint)
+            , fMatrix(&matrix)
+            , fLocalMatrix(localM)
+            , fPreferredDstType(dstType)
+            , fDstColorSpace(dstColorSpace) {}
+
+        const SkPaint*  fPaint;            // the current paint associated with the draw
+        const SkMatrix* fMatrix;           // the current matrix in the canvas
+        const SkMatrix* fLocalMatrix;      // optional local matrix
+        const DstType   fPreferredDstType; // the "natural" client dest type
+        SkColorSpace*   fDstColorSpace;    // the color space of the dest surface (if any)
+    };
+
+    class Context : public ::SkNoncopyable {
+    public:
+        Context(const SkShader& shader, const ContextRec&);
+
+        virtual ~Context();
+
+        /**
+         *  Called sometimes before drawing with this shader. Return the type of
+         *  alpha your shader will return. The default implementation returns 0.
+         *  Your subclass should override if it can (even sometimes) report a
+         *  non-zero value, since that will enable various blitters to perform
+         *  faster.
+         */
+        virtual uint32_t getFlags() const { return 0; }
+
+        /**
+         *  Called for each span of the object being drawn. Your subclass should
+         *  set the appropriate colors (with premultiplied alpha) that correspond
+         *  to the specified device coordinates.
+         */
+        virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0;
+
+        virtual void shadeSpan4f(int x, int y, SkPM4f[], int count);
+
+        struct BlitState;
+        typedef void (*BlitBW)(BlitState*,
+                               int x, int y, const SkPixmap&, int count);
+        typedef void (*BlitAA)(BlitState*,
+                               int x, int y, const SkPixmap&, int count, const SkAlpha[]);
+
+        struct BlitState {
+            // inputs
+            Context*    fCtx;
+            SkBlendMode fMode;
+
+            // outputs
+            enum { N = 2 };
+            void*       fStorage[N];
+            BlitBW      fBlitBW;
+            BlitAA      fBlitAA;
+        };
+
+        // Returns true if one or more of the blitprocs are set in the BlitState
+        bool chooseBlitProcs(const SkImageInfo& info, BlitState* state) {
+            state->fBlitBW = nullptr;
+            state->fBlitAA = nullptr;
+            if (this->onChooseBlitProcs(info, state)) {
+                SkASSERT(state->fBlitBW || state->fBlitAA);
+                return true;
+            }
+            return false;
+        }
+
+        /**
+         * The const void* ctx is only const because all the implementations are const.
+         * This can be changed to non-const if a new shade proc needs to change the ctx.
+         */
+        typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], int count);
+        virtual ShadeProc asAShadeProc(void** ctx);
+
+        /**
+         *  Similar to shadeSpan, but only returns the alpha-channel for a span.
+         *  The default implementation calls shadeSpan() and then extracts the alpha
+         *  values from the returned colors.
+         */
+        virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
+
+        // Notification from blitter::blitMask in case we need to see the non-alpha channels
+        virtual void set3DMask(const SkMask*) {}
+
+    protected:
+        // Reference to shader, so we don't have to dupe information.
+        const SkShader& fShader;
+
+        enum MatrixClass {
+            kLinear_MatrixClass,            // no perspective
+            kFixedStepInX_MatrixClass,      // fast perspective, need to call fixedStepInX() each
+                                            // scanline
+            kPerspective_MatrixClass        // slow perspective, need to mappoints each pixel
+        };
+        static MatrixClass ComputeMatrixClass(const SkMatrix&);
+
+        uint8_t         getPaintAlpha() const { return fPaintAlpha; }
+        const SkMatrix& getTotalInverse() const { return fTotalInverse; }
+        MatrixClass     getInverseClass() const { return (MatrixClass)fTotalInverseClass; }
+        const SkMatrix& getCTM() const { return fCTM; }
+
+        virtual bool onChooseBlitProcs(const SkImageInfo&, BlitState*) { return false; }
+
+    private:
+        SkMatrix    fCTM;
+        SkMatrix    fTotalInverse;
+        uint8_t     fPaintAlpha;
+        uint8_t     fTotalInverseClass;
+
+        typedef SkNoncopyable INHERITED;
+    };
+
+    /**
+     * Make a context using the memory provided by the arena.
+     *
+     * @return pointer to context or nullptr if can't be created
+     */
+    Context* makeContext(const ContextRec&, SkArenaAlloc*) const;
+
 #ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
     /**
      *  Returns true if this shader is just a bitmap, and if not null, returns the bitmap,
      *  localMatrix, and tilemodes. If this is not a bitmap, returns false and ignores the
      *  out-parameters.
      */
-    bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) const;
+    bool isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) const {
+        return this->onIsABitmap(outTexture, outMatrix, xy);
+    }
 
     bool isABitmap() const {
         return this->isABitmap(nullptr, nullptr, nullptr);
@@ -97,7 +255,9 @@ public:
      *  Iff this shader is backed by a single SkImage, return its ptr (the caller must ref this
      *  if they want to keep it longer than the lifetime of the shader). If not, return nullptr.
      */
-    SkImage* isAImage(SkMatrix* localMatrix, TileMode xy[2]) const;
+    SkImage* isAImage(SkMatrix* localMatrix, TileMode xy[2]) const {
+        return this->onIsAImage(localMatrix, xy);
+    }
 
     bool isAImage() const {
         return this->isAImage(nullptr, nullptr) != nullptr;
@@ -157,6 +317,68 @@ public:
 
     virtual GradientType asAGradient(GradientInfo* info) const;
 
+    /**
+     *  If the shader subclass is composed of two shaders, return true, and if rec is not NULL,
+     *  fill it out with info about the shader.
+     *
+     *  These are bare pointers; the ownership and reference count are unchanged.
+     */
+
+    struct ComposeRec {
+        const SkShader*     fShaderA;
+        const SkShader*     fShaderB;
+        SkBlendMode         fBlendMode;
+    };
+
+    virtual bool asACompose(ComposeRec*) const { return false; }
+
+#if SK_SUPPORT_GPU
+    struct AsFPArgs {
+        AsFPArgs() {}
+        AsFPArgs(GrContext* context,
+                 const SkMatrix* viewMatrix,
+                 const SkMatrix* localMatrix,
+                 SkFilterQuality filterQuality,
+                 SkColorSpace* dstColorSpace)
+            : fContext(context)
+            , fViewMatrix(viewMatrix)
+            , fLocalMatrix(localMatrix)
+            , fFilterQuality(filterQuality)
+            , fDstColorSpace(dstColorSpace) {}
+
+        GrContext*                    fContext;
+        const SkMatrix*               fViewMatrix;
+        const SkMatrix*               fLocalMatrix;
+        SkFilterQuality               fFilterQuality;
+        SkColorSpace*                 fDstColorSpace;
+    };
+
+    /**
+     *  Returns a GrFragmentProcessor that implements the shader for the GPU backend. NULL is
+     *  returned if there is no GPU implementation.
+     *
+     *  The GPU device does not call SkShader::createContext(), instead we pass the view matrix,
+     *  local matrix, and filter quality directly.
+     *
+     *  The GrContext may be used by the to create textures that are required by the returned
+     *  processor.
+     *
+     *  The returned GrFragmentProcessor should expect an unpremultiplied input color and
+     *  produce a premultiplied output.
+     */
+    virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const;
+#endif
+
+    /**
+     *  If the shader can represent its "average" luminance in a single color, return true and
+     *  if color is not NULL, return that color. If it cannot, return false and ignore the color
+     *  parameter.
+     *
+     *  Note: if this returns true, the returned color will always be opaque, as only the RGB
+     *  components are used to compute luminance.
+     */
+    bool asLuminanceColor(SkColor*) const;
+
     //////////////////////////////////////////////////////////////////////////
     //  Methods to create combinations or variants of shaders
 
@@ -232,10 +454,73 @@ public:
     static sk_sp<SkShader> MakePictureShader(sk_sp<SkPicture> src, TileMode tmx, TileMode tmy,
                                              const SkMatrix* localMatrix, const SkRect* tile);
 
+    /**
+     *  If this shader can be represented by another shader + a localMatrix, return that shader and
+     *  the localMatrix. If not, return nullptr and ignore the localMatrix parameter.
+     */
+    virtual sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const;
+
+    SK_TO_STRING_VIRT()
+    SK_DEFINE_FLATTENABLE_TYPE(SkShader)
+    SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
+
+    bool appendStages(SkRasterPipeline*, SkColorSpace* dstCS, SkArenaAlloc*,
+                      const SkMatrix& ctm, const SkPaint&, const SkMatrix* localM=nullptr) const;
+
 protected:
-    SkShader() = default;
+    void flatten(SkWriteBuffer&) const override;
+
+    bool computeTotalInverse(const SkMatrix& ctm,
+                             const SkMatrix* outerLocalMatrix,
+                             SkMatrix* totalInverse) const;
+
+    /**
+     * Specialize creating a SkShader context using the supplied allocator.
+     * @return pointer to context owned by the arena allocator.
+     */
+    virtual Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const {
+        return nullptr;
+    }
+
+    virtual bool onAsLuminanceColor(SkColor*) const {
+        return false;
+    }
+
+#ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
+    virtual bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode[2]) const {
+        return false;
+    }
+#endif
+
+    virtual SkImage* onIsAImage(SkMatrix*, TileMode[2]) const {
+        return nullptr;
+    }
+
+    /**
+     *  Returns a shader transformed into a new color space via the |xformer|.
+     */
+    sk_sp<SkShader> makeColorSpace(SkColorSpaceXformer* xformer) const {
+        return this->onMakeColorSpace(xformer);
+    }
+    virtual sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer*) const {
+        return sk_ref_sp(const_cast<SkShader*>(this));
+    }
+
+    virtual bool isRasterPipelineOnly() const { return false; }
 
 private:
+    virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace* dstCS, SkArenaAlloc*,
+                                const SkMatrix&, const SkPaint&, const SkMatrix* localM) const;
+
+    // This is essentially const, but not officially so it can be modified in constructors.
+    SkMatrix fLocalMatrix;
+
+    friend class SkLocalMatrixShader;         // sets fLocalMatrix in SkReadBuffer constructor
+    friend class SkBitmapProcLegacyShader;    // calls computeTotalInverse()
+    friend class SkColorSpaceXformer;         // calls makeColorSpace()
+    friend class SkBlitter;                   // calls isRasterPipelineOnly()
+    friend class SkComposeShader;             // calls isRasterPipelineOnly()
+
     typedef SkFlattenable INHERITED;
 };
 
index e529823..b7bd39c 100644 (file)
@@ -17,21 +17,21 @@ static bool only_scale_and_translate(const SkMatrix& matrix) {
     return (matrix.getType() & ~mask) == 0;
 }
 
-class BitmapProcInfoContext : public SkShaderBase::Context {
+class BitmapProcInfoContext : public SkShader::Context {
 public:
     // The info has been allocated elsewhere, but we are responsible for calling its destructor.
-    BitmapProcInfoContext(const SkShaderBase& shader, const SkShaderBase::ContextRec& rec,
+    BitmapProcInfoContext(const SkShader& shader, const SkShader::ContextRec& rec,
                             SkBitmapProcInfo* info)
         : INHERITED(shader, rec)
         , fInfo(info)
     {
         fFlags = 0;
         if (fInfo->fPixmap.isOpaque() && (255 == this->getPaintAlpha())) {
-            fFlags |= SkShaderBase::kOpaqueAlpha_Flag;
+            fFlags |= SkShader::kOpaqueAlpha_Flag;
         }
 
         if (1 == fInfo->fPixmap.height() && only_scale_and_translate(this->getTotalInverse())) {
-            fFlags |= SkShaderBase::kConstInY32_Flag;
+            fFlags |= SkShader::kConstInY32_Flag;
         }
     }
 
@@ -41,14 +41,14 @@ private:
     SkBitmapProcInfo*   fInfo;
     uint32_t            fFlags;
 
-    typedef SkShaderBase::Context INHERITED;
+    typedef SkShader::Context INHERITED;
 };
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
 class BitmapProcShaderContext : public BitmapProcInfoContext {
 public:
-    BitmapProcShaderContext(const SkShaderBase& shader, const SkShaderBase::ContextRec& rec,
+    BitmapProcShaderContext(const SkShader& shader, const SkShader::ContextRec& rec,
                             SkBitmapProcState* state)
         : INHERITED(shader, rec, state)
         , fState(state)
@@ -104,7 +104,7 @@ private:
 
 class LinearPipelineContext : public BitmapProcInfoContext {
 public:
-    LinearPipelineContext(const SkShaderBase& shader, const SkShaderBase::ContextRec& rec,
+    LinearPipelineContext(const SkShader& shader, const SkShader::ContextRec& rec,
                           SkBitmapProcInfo* info, SkArenaAlloc* alloc)
         : INHERITED(shader, rec, info), fAllocator{alloc}
     {
@@ -183,12 +183,12 @@ private:
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-static bool choose_linear_pipeline(const SkShaderBase::ContextRec& rec, const SkImageInfo& srcInfo) {
+static bool choose_linear_pipeline(const SkShader::ContextRec& rec, const SkImageInfo& srcInfo) {
     // If we get here, we can reasonably use either context, respect the caller's preference
     //
     bool needsPremul = srcInfo.alphaType() == kUnpremul_SkAlphaType;
     bool needsSwizzle = srcInfo.bytesPerPixel() == 4 && srcInfo.colorType() != kN32_SkColorType;
-    return SkShaderBase::ContextRec::kPM4f_DstType == rec.fPreferredDstType
+    return SkShader::ContextRec::kPM4f_DstType == rec.fPreferredDstType
            || needsPremul || needsSwizzle;
 }
 
@@ -199,8 +199,8 @@ size_t SkBitmapProcLegacyShader::ContextSize(const ContextRec& rec, const SkImag
     return s;
 }
 
-SkShaderBase::Context* SkBitmapProcLegacyShader::MakeContext(
-    const SkShaderBase& shader, TileMode tmx, TileMode tmy,
+SkShader::Context* SkBitmapProcLegacyShader::MakeContext(
+    const SkShader& shader, TileMode tmx, TileMode tmy,
     const SkBitmapProvider& provider, const ContextRec& rec, SkArenaAlloc* alloc)
 {
     SkMatrix totalInverse;
index 2a2599c..204b27d 100644 (file)
@@ -8,19 +8,19 @@
 #define SkBitmapProcShader_DEFINED
 
 #include "SkImagePriv.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 class SkBitmapProvider;
 
-class SkBitmapProcLegacyShader : public SkShaderBase {
+class SkBitmapProcLegacyShader : public SkShader {
 private:
     friend class SkImageShader;
 
     static size_t ContextSize(const ContextRec&, const SkImageInfo& srcInfo);
-    static Context* MakeContext(const SkShaderBase&, TileMode tmx, TileMode tmy,
+    static Context* MakeContext(const SkShader&, TileMode tmx, TileMode tmy,
                                 const SkBitmapProvider&, const ContextRec&, SkArenaAlloc* alloc);
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index ba79abd..30f845a 100644 (file)
@@ -14,7 +14,6 @@
 #include "SkWriteBuffer.h"
 #include "SkMask.h"
 #include "SkMaskFilter.h"
-#include "SkShaderBase.h"
 #include "SkString.h"
 #include "SkTLazy.h"
 #include "SkUtils.h"
@@ -583,14 +582,14 @@ SkBlitter* SkBlitterClipper::apply(SkBlitter* blitter, const SkRegion* clip,
 #include "SkColorShader.h"
 #include "SkColorPriv.h"
 
-class Sk3DShader : public SkShaderBase {
+class Sk3DShader : public SkShader {
 public:
     Sk3DShader(sk_sp<SkShader> proxy) : fProxy(std::move(proxy)) {}
 
     Context* onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc) const override {
-        SkShaderBase::Context* proxyContext = nullptr;
+        SkShader::Context* proxyContext = nullptr;
         if (fProxy) {
-            proxyContext = as_SB(fProxy)->makeContext(rec, alloc);
+            proxyContext = fProxy->makeContext(rec, alloc);
             if (!proxyContext) {
                 return nullptr;
             }
@@ -598,11 +597,11 @@ public:
         return alloc->make<Sk3DShaderContext>(*this, rec, proxyContext);
     }
 
-    class Sk3DShaderContext : public Context {
+    class Sk3DShaderContext : public SkShader::Context {
     public:
         // Calls proxyContext's destructor but will NOT free its memory.
         Sk3DShaderContext(const Sk3DShader& shader, const ContextRec& rec,
-                          Context* proxyContext)
+                          SkShader::Context* proxyContext)
             : INHERITED(shader, rec)
             , fMask(nullptr)
             , fProxyContext(proxyContext)
@@ -686,12 +685,12 @@ public:
 
     private:
         // Unowned.
-        const SkMask* fMask;
+        const SkMask*       fMask;
         // Memory is unowned, but we need to call the destructor.
-        Context*      fProxyContext;
-        SkPMColor     fPMColor;
+        SkShader::Context*  fProxyContext;
+        SkPMColor           fPMColor;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
 #ifndef SK_IGNORE_TO_STRING
@@ -700,7 +699,7 @@ public:
 
         if (fProxy) {
             str->append("Proxy: ");
-            as_SB(fProxy)->toString(str);
+            fProxy->toString(str);
         }
 
         this->INHERITED::toString(str);
@@ -719,7 +718,7 @@ protected:
 private:
     sk_sp<SkShader> fProxy;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 sk_sp<SkFlattenable> Sk3DShader::CreateProc(SkReadBuffer& buffer) {
@@ -728,7 +727,7 @@ sk_sp<SkFlattenable> Sk3DShader::CreateProc(SkReadBuffer& buffer) {
 
 class Sk3DBlitter : public SkBlitter {
 public:
-    Sk3DBlitter(SkBlitter* proxy, SkShaderBase::Context* shaderContext)
+    Sk3DBlitter(SkBlitter* proxy, SkShader::Context* shaderContext)
         : fProxy(proxy)
         , fShaderContext(shaderContext)
     {}
@@ -765,21 +764,21 @@ public:
 
 private:
     // Both pointers are unowned. They will be deleted by SkSmallAllocator.
-    SkBlitter*              fProxy;
-    SkShaderBase::Context*  fShaderContext;
+    SkBlitter*          fProxy;
+    SkShader::Context*  fShaderContext;
 };
 
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "SkCoreBlitters.h"
 
-SkShaderBase::ContextRec::DstType SkBlitter::PreferredShaderDest(const SkImageInfo& dstInfo) {
+SkShader::ContextRec::DstType SkBlitter::PreferredShaderDest(const SkImageInfo& dstInfo) {
 #ifdef SK_FORCE_PM4f_FOR_L32_BLITS
     return SkShader::ContextRec::kPM4f_DstType;
 #else
     return (dstInfo.gammaCloseToSRGB() || dstInfo.colorType() == kRGBA_F16_SkColorType)
-            ? SkShaderBase::ContextRec::kPM4f_DstType
-            : SkShaderBase::ContextRec::kPMColor_DstType;
+            ? SkShader::ContextRec::kPM4f_DstType
+            : SkShader::ContextRec::kPMColor_DstType;
 #endif
 }
 
@@ -793,7 +792,7 @@ bool SkBlitter::UseRasterPipelineBlitter(const SkPixmap& device, const SkPaint&
     }
 
     // ... unless the shader is raster pipeline-only.
-    if (paint.getShader() && as_SB(paint.getShader())->isRasterPipelineOnly()) {
+    if (paint.getShader() && paint.getShader()->isRasterPipelineOnly()) {
         return true;
     }
 
@@ -815,7 +814,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
         return alloc->make<SkNullBlitter>();
     }
 
-    auto* shader = as_SB(origPaint.getShader());
+    SkShader* shader = origPaint.getShader();
     SkColorFilter* cf = origPaint.getColorFilter();
     SkBlendMode mode = origPaint.getBlendMode();
     sk_sp<Sk3DShader> shader3D;
@@ -827,7 +826,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
         shader3D = sk_make_sp<Sk3DShader>(sk_ref_sp(shader));
         // we know we haven't initialized lazyPaint yet, so just do it
         paint.writable()->setShader(shader3D);
-        shader = as_SB(shader3D.get());
+        shader = shader3D.get();
     }
 
     if (mode != SkBlendMode::kSrcOver) {
@@ -877,7 +876,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
             // xfermodes (and filters) require shaders for our current blitters
             paint.writable()->setShader(SkShader::MakeColorShader(paint->getColor()));
             paint.writable()->setAlpha(0xFF);
-            shader = as_SB(paint->getShader());
+            shader = paint->getShader();
         } else if (cf) {
             // if no shader && no xfermode, we just apply the colorfilter to
             // our color and move on.
@@ -891,7 +890,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
     if (cf) {
         SkASSERT(shader);
         paint.writable()->setShader(shader->makeWithColorFilter(sk_ref_sp(cf)));
-        shader = as_SB(paint->getShader());
+        shader = paint->getShader();
         // blitters should ignore the presence/absence of a filter, since
         // if there is one, the shader will take care of it.
     }
@@ -899,9 +898,9 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
     /*
      *  We create a SkShader::Context object, and store it on the blitter.
      */
-    SkShaderBase::Context* shaderContext = nullptr;
+    SkShader::Context* shaderContext = nullptr;
     if (shader) {
-        const SkShaderBase::ContextRec rec(*paint, matrix, nullptr,
+        const SkShader::ContextRec rec(*paint, matrix, nullptr,
                                        PreferredShaderDest(device.info()),
                                        device.colorSpace());
         // Try to create the ShaderContext
@@ -975,7 +974,7 @@ SkBlitter* SkBlitter::Choose(const SkPixmap& device,
 ///////////////////////////////////////////////////////////////////////////////
 
 SkShaderBlitter::SkShaderBlitter(const SkPixmap& device, const SkPaint& paint,
-                                 SkShaderBase::Context* shaderContext)
+                                 SkShader::Context* shaderContext)
         : INHERITED(device)
         , fShader(paint.getShader())
         , fShaderContext(shaderContext) {
@@ -984,7 +983,7 @@ SkShaderBlitter::SkShaderBlitter(const SkPixmap& device, const SkPaint& paint,
 
     fShader->ref();
     fShaderFlags = fShaderContext->getFlags();
-    fConstInY = SkToBool(fShaderFlags & SkShaderBase::kConstInY32_Flag);
+    fConstInY = SkToBool(fShaderFlags & SkShader::kConstInY32_Flag);
 }
 
 SkShaderBlitter::~SkShaderBlitter() {
index 6558045..27552b9 100644 (file)
@@ -13,7 +13,7 @@
 #include "SkColor.h"
 #include "SkRect.h"
 #include "SkRegion.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 class SkArenaAlloc;
 class SkMatrix;
@@ -148,7 +148,7 @@ public:
                                    SkArenaAlloc*);
     ///@}
 
-    static SkShaderBase::ContextRec::DstType PreferredShaderDest(const SkImageInfo&);
+    static SkShader::ContextRec::DstType PreferredShaderDest(const SkImageInfo&);
 
     static bool UseRasterPipelineBlitter(const SkPixmap&, const SkPaint&);
 
index 6f0df2e..1fd4d5f 100644 (file)
@@ -227,7 +227,7 @@ void SkA8_Blitter::blitRect(int x, int y, int width, int height) {
 ///////////////////////////////////////////////////////////////////////
 
 SkA8_Shader_Blitter::SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
-                                         SkShaderBase::Context* shaderContext)
+                                         SkShader::Context* shaderContext)
     : INHERITED(device, paint, shaderContext)
 {
     fXfermode = SkXfermode::Peek(paint.getBlendMode());
@@ -247,9 +247,9 @@ void SkA8_Shader_Blitter::blitH(int x, int y, int width) {
              (unsigned)(x + width) <= (unsigned)fDevice.width());
 
     uint8_t* device = fDevice.writable_addr8(x, y);
-    auto* shaderContext = fShaderContext;
+    SkShader::Context* shaderContext = fShaderContext;
 
-    if ((shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag) && !fXfermode) {
+    if ((shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) && !fXfermode) {
         memset(device, 0xFF, width);
     } else {
         SkPMColor*  span = fBuffer;
@@ -280,12 +280,12 @@ static inline uint8_t aa_blend8(SkPMColor src, U8CPU da, int aa) {
 
 void SkA8_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
                                     const int16_t runs[]) {
-    auto* shaderContext = fShaderContext;
+    SkShader::Context* shaderContext = fShaderContext;
     SkXfermode*        mode = fXfermode;
     uint8_t*           aaExpand = fAAExpand;
     SkPMColor*         span = fBuffer;
     uint8_t*           device = fDevice.writable_addr8(x, y);
-    int                opaque = shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag;
+    int                opaque = shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag;
 
     for (;;) {
         int count = *runs;
@@ -327,7 +327,7 @@ void SkA8_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) {
     int height = clip.height();
     uint8_t* device = fDevice.writable_addr8(x, y);
     const uint8_t* alpha = mask.getAddr8(x, y);
-    auto* shaderContext = fShaderContext;
+    SkShader::Context* shaderContext = fShaderContext;
 
     SkPMColor*  span = fBuffer;
 
index aef1044..4478b2b 100644 (file)
@@ -330,7 +330,7 @@ static void blend_srcmode(SkPMColor* SK_RESTRICT device,
 }
 
 SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device,
-        const SkPaint& paint, SkShaderBase::Context* shaderContext)
+        const SkPaint& paint, SkShader::Context* shaderContext)
     : INHERITED(device, paint, shaderContext)
 {
     fBuffer = (SkPMColor*)sk_malloc_throw(device.width() * (sizeof(SkPMColor)));
@@ -338,7 +338,7 @@ SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device,
     fXfermode = SkXfermode::Peek(paint.getBlendMode());
 
     int flags = 0;
-    if (!(shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag)) {
+    if (!(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) {
         flags |= SkBlitRow::kSrcPixelAlpha_Flag32;
     }
     // we call this on the output from the shader
@@ -348,7 +348,7 @@ SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device,
 
     fShadeDirectlyIntoDevice = false;
     if (fXfermode == nullptr) {
-        if (shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag) {
+        if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) {
             fShadeDirectlyIntoDevice = true;
         }
     } else {
@@ -361,7 +361,7 @@ SkARGB32_Shader_Blitter::SkARGB32_Shader_Blitter(const SkPixmap& device,
         }
     }
 
-    fConstInY = SkToBool(shaderContext->getFlags() & SkShaderBase::kConstInY32_Flag);
+    fConstInY = SkToBool(shaderContext->getFlags() & SkShader::kConstInY32_Flag);
 }
 
 SkARGB32_Shader_Blitter::~SkARGB32_Shader_Blitter() {
@@ -390,10 +390,10 @@ void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) {
     SkASSERT(x >= 0 && y >= 0 &&
              x + width <= fDevice.width() && y + height <= fDevice.height());
 
-    uint32_t*  device = fDevice.writable_addr32(x, y);
-    size_t     deviceRB = fDevice.rowBytes();
-    auto*      shaderContext = fShaderContext;
-    SkPMColor* span = fBuffer;
+    uint32_t*          device = fDevice.writable_addr32(x, y);
+    size_t             deviceRB = fDevice.rowBytes();
+    SkShader::Context* shaderContext = fShaderContext;
+    SkPMColor*         span = fBuffer;
 
     if (fConstInY) {
         if (fShadeDirectlyIntoDevice) {
@@ -427,7 +427,7 @@ void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) {
 
     if (fShadeDirectlyIntoDevice) {
         void* ctx;
-        auto shadeProc = shaderContext->asAShadeProc(&ctx);
+        SkShader::Context::ShadeProc shadeProc = shaderContext->asAShadeProc(&ctx);
         if (shadeProc) {
             do {
                 shadeProc(ctx, x, y, device, width);
@@ -464,9 +464,9 @@ void SkARGB32_Shader_Blitter::blitRect(int x, int y, int width, int height) {
 
 void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
                                         const int16_t runs[]) {
-    SkPMColor* span = fBuffer;
-    uint32_t*  device = fDevice.writable_addr32(x, y);
-    auto*      shaderContext = fShaderContext;
+    SkPMColor*         span = fBuffer;
+    uint32_t*          device = fDevice.writable_addr32(x, y);
+    SkShader::Context* shaderContext = fShaderContext;
 
     if (fXfermode && !fShadeDirectlyIntoDevice) {
         for (;;) {
@@ -493,7 +493,7 @@ void SkARGB32_Shader_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[],
             x += count;
         }
     } else if (fShadeDirectlyIntoDevice ||
-               (shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag)) {
+               (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)) {
         for (;;) {
             int count = *runs;
             if (count <= 0) {
@@ -546,11 +546,11 @@ void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
 
     SkASSERT(mask.fBounds.contains(clip));
 
-    auto* shaderContext = fShaderContext;
+    SkShader::Context*  shaderContext = fShaderContext;
     SkBlitMask::RowProc proc = nullptr;
     if (!fXfermode) {
         unsigned flags = 0;
-        if (shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag) {
+        if (shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag) {
             flags |= SkBlitMask::kSrcIsOpaque_RowFlag;
         }
         proc = SkBlitMask::RowFactory(kN32_SkColorType, mask.fFormat,
@@ -597,9 +597,9 @@ void SkARGB32_Shader_Blitter::blitMask(const SkMask& mask, const SkIRect& clip)
 void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
     SkASSERT(x >= 0 && y >= 0 && y + height <= fDevice.height());
 
-    uint32_t* device = fDevice.writable_addr32(x, y);
-    size_t    deviceRB = fDevice.rowBytes();
-    auto*     shaderContext = fShaderContext;
+    uint32_t*          device = fDevice.writable_addr32(x, y);
+    size_t             deviceRB = fDevice.rowBytes();
+    SkShader::Context* shaderContext = fShaderContext;
 
     if (fConstInY) {
         SkPMColor c;
@@ -637,7 +637,7 @@ void SkARGB32_Shader_Blitter::blitV(int x, int y, int height, SkAlpha alpha) {
 
     if (fShadeDirectlyIntoDevice) {
         void* ctx;
-        auto shadeProc = shaderContext->asAShadeProc(&ctx);
+        SkShader::Context::ShadeProc shadeProc = shaderContext->asAShadeProc(&ctx);
         if (255 == alpha) {
             if (shadeProc) {
                 do {
index f83e0c2..61105ce 100644 (file)
@@ -139,7 +139,7 @@ public:
 template <typename State> class SkState_Shader_Blitter : public SkShaderBlitter {
 public:
     SkState_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
-                           const SkShaderBase::Context::BlitState& bstate)
+                           const SkShader::Context::BlitState& bstate)
         : INHERITED(device, paint, bstate.fCtx)
         , fState(device.info(), paint, bstate.fCtx)
         , fBState(bstate)
@@ -309,10 +309,10 @@ public:
     }
 
 protected:
-    State                            fState;
-    SkShaderBase::Context::BlitState fBState;
-    SkShaderBase::Context::BlitBW    fBlitBW;
-    SkShaderBase::Context::BlitAA    fBlitAA;
+    State                        fState;
+    SkShader::Context::BlitState fBState;
+    SkShader::Context::BlitBW    fBlitBW;
+    SkShader::Context::BlitAA    fBlitAA;
 
     typedef SkShaderBlitter INHERITED;
 };
@@ -320,14 +320,13 @@ protected:
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-static bool is_opaque(const SkPaint& paint, const SkShaderBase::Context* shaderContext) {
-    return shaderContext ? SkToBool(shaderContext->getFlags() & SkShaderBase::kOpaqueAlpha_Flag)
+static bool is_opaque(const SkPaint& paint, const SkShader::Context* shaderContext) {
+    return shaderContext ? SkToBool(shaderContext->getFlags() & SkShader::kOpaqueAlpha_Flag)
     : 0xFF == paint.getAlpha();
 }
 
 struct State4f {
-    State4f(const SkImageInfo& info, const SkPaint& paint,
-            const SkShaderBase::Context* shaderContext) {
+    State4f(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext) {
         fMode = paint.getBlendMode();
         if (shaderContext) {
             fBuffer.reset(info.width());
@@ -337,11 +336,12 @@ struct State4f {
         fFlags = 0;
     }
 
-    SkPM4f                           fPM4f;
-    SkAutoTMalloc<SkPM4f>            fBuffer;
-    uint32_t                         fFlags;
-    SkBlendMode                      fMode;
-    SkShaderBase::Context::BlitState fBState;
+    SkPM4f                  fPM4f;
+    SkAutoTMalloc<SkPM4f>   fBuffer;
+    uint32_t                fFlags;
+    SkBlendMode             fMode;
+
+    SkShader::Context::BlitState fBState;
 };
 
 struct State32 : State4f {
@@ -350,8 +350,7 @@ struct State32 : State4f {
     SkXfermode::D32Proc fProc1;
     SkXfermode::D32Proc fProcN;
 
-    State32(const SkImageInfo& info, const SkPaint& paint,
-            const SkShaderBase::Context* shaderContext)
+    State32(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext)
         : State4f(info, paint, shaderContext)
     {
         if (is_opaque(paint, shaderContext)) {
@@ -383,8 +382,7 @@ struct StateF16 : State4f {
     SkXfermode::F16Proc fProc1;
     SkXfermode::F16Proc fProcN;
 
-    StateF16(const SkImageInfo& info, const SkPaint& paint,
-             const SkShaderBase::Context* shaderContext)
+    StateF16(const SkImageInfo& info, const SkPaint& paint, const SkShader::Context* shaderContext)
         : State4f(info, paint, shaderContext)
     {
         if (is_opaque(paint, shaderContext)) {
@@ -406,12 +404,12 @@ struct StateF16 : State4f {
 };
 
 template <typename State> SkBlitter* create(const SkPixmap& device, const SkPaint& paint,
-                                            SkShaderBase::Context* shaderContext,
+                                            SkShader::Context* shaderContext,
                                             SkArenaAlloc* alloc) {
     SkASSERT(alloc != nullptr);
 
     if (shaderContext) {
-        SkShaderBase::Context::BlitState bstate;
+        SkShader::Context::BlitState bstate;
         sk_bzero(&bstate, sizeof(bstate));
         bstate.fCtx = shaderContext;
         bstate.fMode = paint.getBlendMode();
@@ -428,13 +426,13 @@ template <typename State> SkBlitter* create(const SkPixmap& device, const SkPain
 }
 
 SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint& paint,
-                                   SkShaderBase::Context* shaderContext,
+                                   SkShader::Context* shaderContext,
                                    SkArenaAlloc* alloc) {
     return create<State32>(device, paint, shaderContext, alloc);
 }
 
 SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint& paint,
-                                SkShaderBase::Context* shaderContext,
+                                SkShader::Context* shaderContext,
                                 SkArenaAlloc* alloc) {
     return create<StateF16>(device, paint, shaderContext, alloc);
 }
index 2c7fbf7..6330a39 100644 (file)
@@ -110,7 +110,7 @@ private:
 class SkRGB16_Shader_Blitter : public SkShaderBlitter {
 public:
     SkRGB16_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
-                           SkShaderBase::Context* shaderContext);
+                           SkShader::Context* shaderContext);
     ~SkRGB16_Shader_Blitter() override;
     void blitH(int x, int y, int width) override;
     virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
@@ -132,7 +132,7 @@ private:
 class SkRGB16_Shader_Xfermode_Blitter : public SkShaderBlitter {
 public:
     SkRGB16_Shader_Xfermode_Blitter(const SkPixmap& device, const SkPaint& paint,
-                                    SkShaderBase::Context* shaderContext);
+                                    SkShader::Context* shaderContext);
     ~SkRGB16_Shader_Xfermode_Blitter() override;
     void blitH(int x, int y, int width) override;
     virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
@@ -671,7 +671,7 @@ void SkRGB16_Blitter::blitRect(int x, int y, int width, int height) {
 
 SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device,
                                                const SkPaint& paint,
-                                               SkShaderBase::Context* shaderContext)
+                                               SkShader::Context* shaderContext)
     : INHERITED(device, paint, shaderContext)
 {
     SkASSERT(paint.isSrcOver());
@@ -683,7 +683,7 @@ SkRGB16_Shader_Blitter::SkRGB16_Shader_Blitter(const SkPixmap& device,
 
     uint32_t shaderFlags = fShaderFlags;
     // shaders take care of global alpha, so we never set it in SkBlitRow
-    if (!(shaderFlags & SkShaderBase::kOpaqueAlpha_Flag)) {
+    if (!(shaderFlags & SkShader::kOpaqueAlpha_Flag)) {
         flags |= SkBlitRow::kSrcPixelAlpha_Flag;
     }
     if (paint.isDither()) {
@@ -708,13 +708,13 @@ void SkRGB16_Shader_Blitter::blitH(int x, int y, int width) {
 }
 
 void SkRGB16_Shader_Blitter::blitRect(int x, int y, int width, int height) {
-    auto* shaderContext = fShaderContext;
+    SkShader::Context* shaderContext = fShaderContext;
     SkBlitRow::Proc16  proc = fOpaqueProc;
     SkPMColor*         buffer = fBuffer;
     uint16_t*          dst = fDevice.writable_addr16(x, y);
     size_t             dstRB = fDevice.rowBytes();
 
-    if (fShaderFlags & SkShaderBase::kConstInY32_Flag) {
+    if (fShaderFlags & SkShader::kConstInY32_Flag) {
         shaderContext->shadeSpan(x, y, buffer, width);
         do {
             proc(dst, buffer, width, 0xFF, x, y);
@@ -748,7 +748,7 @@ static inline int count_nonzero_span(const int16_t runs[], const SkAlpha aa[]) {
 void SkRGB16_Shader_Blitter::blitAntiH(int x, int y,
                                        const SkAlpha* SK_RESTRICT antialias,
                                        const int16_t* SK_RESTRICT runs) {
-    auto*     shaderContext = fShaderContext;
+    SkShader::Context*     shaderContext = fShaderContext;
     SkPMColor* SK_RESTRICT span = fBuffer;
     uint16_t* SK_RESTRICT  device = fDevice.writable_addr16(x, y);
 
@@ -797,7 +797,7 @@ void SkRGB16_Shader_Blitter::blitAntiH(int x, int y,
 
 SkRGB16_Shader_Xfermode_Blitter::SkRGB16_Shader_Xfermode_Blitter(
                                 const SkPixmap& device, const SkPaint& paint,
-                                SkShaderBase::Context* shaderContext)
+                                SkShader::Context* shaderContext)
     : INHERITED(device, paint, shaderContext)
 {
     fXfermode = SkXfermode::Peek(paint.getBlendMode());
@@ -825,7 +825,7 @@ void SkRGB16_Shader_Xfermode_Blitter::blitH(int x, int y, int width) {
 void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y,
                                 const SkAlpha* SK_RESTRICT antialias,
                                 const int16_t* SK_RESTRICT runs) {
-    auto*     shaderContext = fShaderContext;
+    SkShader::Context*     shaderContext = fShaderContext;
     SkXfermode*            mode = fXfermode;
     SkPMColor* SK_RESTRICT span = fBuffer;
     uint8_t* SK_RESTRICT   aaExpand = fAAExpand;
@@ -880,7 +880,7 @@ void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y,
 ///////////////////////////////////////////////////////////////////////////////
 
 SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint,
-        SkShaderBase::Context* shaderContext,
+        SkShader::Context* shaderContext,
         SkArenaAlloc* alloc) {
     SkASSERT(alloc != nullptr);
 
index 4798422..6569e13 100644 (file)
@@ -49,14 +49,14 @@ uint32_t SkColorFilterShader::FilterShaderContext::getFlags() const {
     // in the shader flags.
     //
     if (!(filterF & SkColorFilter::kAlphaUnchanged_Flag)) {
-        shaderF &= ~kOpaqueAlpha_Flag;
+        shaderF &= ~SkShader::kOpaqueAlpha_Flag;
     }
     return shaderF;
 }
 
-SkShaderBase::Context* SkColorFilterShader::onMakeContext(const ContextRec& rec,
-                                                          SkArenaAlloc* alloc) const {
-    auto* shaderContext = as_SB(fShader)->makeContext(rec, alloc);
+SkShader::Context* SkColorFilterShader::onMakeContext(const ContextRec& rec,
+                                                      SkArenaAlloc* alloc) const {
+    SkShader::Context* shaderContext = fShader->makeContext(rec, alloc);
     if (nullptr == shaderContext) {
         return nullptr;
     }
@@ -69,7 +69,7 @@ sk_sp<SkShader> SkColorFilterShader::onMakeColorSpace(SkColorSpaceXformer* xform
 
 SkColorFilterShader::FilterShaderContext::FilterShaderContext(
                                                          const SkColorFilterShader& filterShader,
-                                                         SkShaderBase::Context* shaderContext,
+                                                         SkShader::Context* shaderContext,
                                                          const ContextRec& rec)
     : INHERITED(filterShader, rec)
     , fShaderContext(shaderContext)
@@ -96,7 +96,7 @@ void SkColorFilterShader::FilterShaderContext::shadeSpan4f(int x, int y, SkPM4f
 
 sk_sp<GrFragmentProcessor> SkColorFilterShader::asFragmentProcessor(const AsFPArgs& args) const {
 
-    sk_sp<GrFragmentProcessor> fp1(as_SB(fShader)->asFragmentProcessor(args));
+    sk_sp<GrFragmentProcessor> fp1(fShader->asFragmentProcessor(args));
     if (!fp1) {
         return nullptr;
     }
@@ -117,7 +117,7 @@ void SkColorFilterShader::toString(SkString* str) const {
     str->append("SkColorFilterShader: (");
 
     str->append("Shader: ");
-    as_SB(fShader)->toString(str);
+    fShader->toString(str);
     str->append(" Filter: ");
     // TODO: add "fFilter->toString(str);" once SkColorFilter::toString is added
 
index 7f42021..18f65ba 100644 (file)
@@ -9,11 +9,11 @@
 #define SkColorFilterShader_DEFINED
 
 #include "SkColorFilter.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 class SkArenaAlloc;
 
-class SkColorFilterShader : public SkShaderBase {
+class SkColorFilterShader : public SkShader {
 public:
     SkColorFilterShader(sk_sp<SkShader> shader, sk_sp<SkColorFilter> filter);
 
@@ -21,10 +21,10 @@ public:
     sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
-    class FilterShaderContext : public Context {
+    class FilterShaderContext : public SkShader::Context {
     public:
         // Takes ownership of shaderContext and calls its destructor.
-        FilterShaderContext(const SkColorFilterShader&, SkShaderBase::Context*, const ContextRec&);
+        FilterShaderContext(const SkColorFilterShader&, SkShader::Context*, const ContextRec&);
 
         uint32_t getFlags() const override;
 
@@ -37,9 +37,9 @@ public:
         }
 
     private:
-        SkShaderBase::Context* fShaderContext;
+        SkShader::Context* fShaderContext;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
     SK_TO_STRING_OVERRIDE()
@@ -54,7 +54,7 @@ private:
     sk_sp<SkShader>      fShader;
     sk_sp<SkColorFilter> fFilter;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index 32b2c54..94d1abc 100644 (file)
@@ -31,8 +31,7 @@ uint32_t SkColorShader::ColorShaderContext::getFlags() const {
     return fFlags;
 }
 
-SkShaderBase::Context* SkColorShader::onMakeContext(const ContextRec& rec,
-                                                    SkArenaAlloc* alloc) const {
+SkShader::Context* SkColorShader::onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc) const {
     return alloc->make<ColorShaderContext>(*this, rec);
 }
 
@@ -150,8 +149,7 @@ uint32_t SkColor4Shader::Color4Context::getFlags() const {
     return fFlags;
 }
 
-SkShaderBase::Context* SkColor4Shader::onMakeContext(const ContextRec& rec,
-                                                     SkArenaAlloc* alloc) const {
+SkShader::Context* SkColor4Shader::onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc) const {
     return alloc->make<Color4Context>(*this, rec);
 }
 
@@ -252,28 +250,28 @@ sk_sp<SkShader> SkShader::MakeColorShader(const SkColor4f& color, sk_sp<SkColorS
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 
-static void D32_BlitBW(SkShaderBase::Context::BlitState* state, int x, int y, const SkPixmap& dst,
+static void D32_BlitBW(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
                        int count) {
     SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0];
     const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
     proc(state->fMode, dst.writable_addr32(x, y), src, count, nullptr);
 }
 
-static void D32_BlitAA(SkShaderBase::Context::BlitState* state, int x, int y, const SkPixmap& dst,
+static void D32_BlitAA(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
                        int count, const SkAlpha aa[]) {
     SkXfermode::D32Proc proc = (SkXfermode::D32Proc)state->fStorage[0];
     const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
     proc(state->fMode, dst.writable_addr32(x, y), src, count, aa);
 }
 
-static void F16_BlitBW(SkShaderBase::Context::BlitState* state, int x, int y, const SkPixmap& dst,
+static void F16_BlitBW(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
                        int count) {
     SkXfermode::F16Proc proc = (SkXfermode::F16Proc)state->fStorage[0];
     const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
     proc(state->fMode, dst.writable_addr64(x, y), src, count, nullptr);
 }
 
-static void F16_BlitAA(SkShaderBase::Context::BlitState* state, int x, int y, const SkPixmap& dst,
+static void F16_BlitAA(SkShader::Context::BlitState* state, int x, int y, const SkPixmap& dst,
                        int count, const SkAlpha aa[]) {
     SkXfermode::F16Proc proc = (SkXfermode::F16Proc)state->fStorage[0];
     const SkPM4f* src = (const SkPM4f*)state->fStorage[1];
@@ -281,7 +279,7 @@ static void F16_BlitAA(SkShaderBase::Context::BlitState* state, int x, int y, co
 }
 
 static bool choose_blitprocs(const SkPM4f* pm4, const SkImageInfo& info,
-                             SkShaderBase::Context::BlitState* state) {
+                             SkShader::Context::BlitState* state) {
     uint32_t flags = SkXfermode::kSrcIsSingle_D32Flag;
     if (pm4->a() == 1) {
         flags |= SkXfermode::kSrcIsOpaque_D32Flag;
index 9af83c1..0a6a935 100644 (file)
@@ -9,7 +9,7 @@
 #define SkColorShader_DEFINED
 
 #include "SkColorSpaceXformer.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkPM4f.h"
 
 /** \class SkColorShader
@@ -17,7 +17,7 @@
     accomplished by just using the color field on the paint, but if an
     actual shader object is needed, this provides that feature.
 */
-class SK_API SkColorShader : public SkShaderBase {
+class SK_API SkColorShader : public SkShader {
 public:
     /** Create a ColorShader that ignores the color in the paint, and uses the
         specified color. Note: like all shaders, at draw time the paint's alpha
@@ -28,7 +28,7 @@ public:
     bool isOpaque() const override;
     bool isConstant() const override { return true; }
 
-    class ColorShaderContext : public Context {
+    class ColorShaderContext : public SkShader::Context {
     public:
         ColorShaderContext(const SkColorShader& shader, const ContextRec&);
 
@@ -45,7 +45,7 @@ public:
         SkPMColor   fPMColor;
         uint32_t    fFlags;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
     GradientType asAGradient(GradientInfo* info) const override;
@@ -77,10 +77,10 @@ protected:
 private:
     SkColor fColor;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
-class SkColor4Shader : public SkShaderBase {
+class SkColor4Shader : public SkShader {
 public:
     SkColor4Shader(const SkColor4f&, sk_sp<SkColorSpace>);
 
@@ -89,7 +89,7 @@ public:
     }
     bool isConstant() const override { return true; }
 
-    class Color4Context : public Context {
+    class Color4Context : public SkShader::Context {
     public:
         Color4Context(const SkColor4Shader& shader, const ContextRec&);
 
@@ -106,7 +106,7 @@ public:
         SkPMColor   fPMColor;
         uint32_t    fFlags;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
     GradientType asAGradient(GradientInfo* info) const override;
@@ -136,7 +136,7 @@ private:
     const SkColor4f     fColor4;
     const SkColor       fCachedByteColor;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index 74daf66..f5f22a1 100644 (file)
@@ -14,7 +14,6 @@
 #include "SkImageFilter.h"
 #include "SkImagePriv.h"
 #include "SkMakeUnique.h"
-#include "SkShaderBase.h"
 
 std::unique_ptr<SkColorSpaceXformer> SkColorSpaceXformer::Make(sk_sp<SkColorSpace> dst) {
     std::unique_ptr<SkColorSpaceXform> fromSRGB = SkColorSpaceXform_Base::New(
@@ -54,7 +53,7 @@ sk_sp<SkImageFilter> SkColorSpaceXformer::apply(const SkImageFilter* imageFilter
 }
 
 sk_sp<SkShader> SkColorSpaceXformer::apply(const SkShader* shader) {
-    return as_SB(shader)->makeColorSpace(this);
+    return shader->makeColorSpace(this);
 }
 
 void SkColorSpaceXformer::apply(SkColor* xformed, const SkColor* srgb, int n) {
index 7735494..942c293 100644 (file)
@@ -72,7 +72,7 @@ void SkComposeShader::flatten(SkWriteBuffer& buffer) const {
     buffer.write32((int)fMode);
 }
 
-SkShaderBase::Context* SkComposeShader::onMakeContext(
+SkShader::Context* SkComposeShader::onMakeContext(
     const ContextRec& rec, SkArenaAlloc* alloc) const
 {
     // we preconcat our localMatrix (if any) with the device matrix
@@ -90,8 +90,8 @@ SkShaderBase::Context* SkComposeShader::onMakeContext(
     newRec.fMatrix = &tmpM;
     newRec.fPaint = &opaquePaint;
 
-    SkShaderBase::Context* contextA = as_SB(fShaderA)->makeContext(newRec, alloc);
-    SkShaderBase::Context* contextB = as_SB(fShaderB)->makeContext(newRec, alloc);
+    SkShader::Context* contextA = fShaderA->makeContext(newRec, alloc);
+    SkShader::Context* contextB = fShaderB->makeContext(newRec, alloc);
     if (!contextA || !contextB) {
         return nullptr;
     }
@@ -106,7 +106,7 @@ sk_sp<SkShader> SkComposeShader::onMakeColorSpace(SkColorSpaceXformer* xformer)
 
 SkComposeShader::ComposeShaderContext::ComposeShaderContext(
         const SkComposeShader& shader, const ContextRec& rec,
-        SkShaderBase::Context* contextA, SkShaderBase::Context* contextB)
+        SkShader::Context* contextA, SkShader::Context* contextB)
     : INHERITED(shader, rec)
     , fShaderContextA(contextA)
     , fShaderContextB(contextB) {}
@@ -121,7 +121,7 @@ bool SkComposeShader::asACompose(ComposeRec* rec) const {
 }
 
 bool SkComposeShader::isRasterPipelineOnly() const {
-    return as_SB(fShaderA)->isRasterPipelineOnly() || as_SB(fShaderB)->isRasterPipelineOnly();
+    return fShaderA->isRasterPipelineOnly() || fShaderB->isRasterPipelineOnly();
 }
 
 bool SkComposeShader::onAppendStages(SkRasterPipeline* pipeline, SkColorSpace* dstCS,
@@ -138,7 +138,7 @@ bool SkComposeShader::onAppendStages(SkRasterPipeline* pipeline, SkColorSpace* d
     // will be smashed, and I'll need them again for fShaderB. store_rgba saves off 4 registers
     // even though we only need to save r,g.
     pipeline->append(SkRasterPipeline::store_rgba, storage->fXY);
-    if (!as_SB(fShaderB)->appendStages(pipeline, dstCS, alloc, ctm, paint, localM)) { // SRC
+    if (!fShaderB->appendStages(pipeline, dstCS, alloc, ctm, paint, localM)) { // SRC
         return false;
     }
     // This outputs r,g,b,a, which we'll need later when we apply the mode, but we save it off now
@@ -146,7 +146,7 @@ bool SkComposeShader::onAppendStages(SkRasterPipeline* pipeline, SkColorSpace* d
     pipeline->append(SkRasterPipeline::store_rgba, storage->fRGBA);
     // Now we restore the device x,y for the next shader
     pipeline->append(SkRasterPipeline::load_rgba, storage->fXY);
-    if (!as_SB(fShaderA)->appendStages(pipeline, dstCS, alloc, ctm, paint, localM)) {  // DST
+    if (!fShaderA->appendStages(pipeline, dstCS, alloc, ctm, paint, localM)) {  // DST
         return false;
     }
     // We now have our logical 'dst' in r,g,b,a, but we need it in dr,dg,db,da for the mode
@@ -169,8 +169,8 @@ bool SkComposeShader::onAppendStages(SkRasterPipeline* pipeline, SkColorSpace* d
 #define TMP_COLOR_COUNT     64
 
 void SkComposeShader::ComposeShaderContext::shadeSpan(int x, int y, SkPMColor result[], int count) {
-    auto* shaderContextA = fShaderContextA;
-    auto* shaderContextB = fShaderContextB;
+    SkShader::Context* shaderContextA = fShaderContextA;
+    SkShader::Context* shaderContextB = fShaderContextB;
     SkBlendMode        mode = static_cast<const SkComposeShader&>(fShader).fMode;
     unsigned           scale = SkAlpha255To256(this->getPaintAlpha());
 
@@ -229,8 +229,8 @@ void SkComposeShader::ComposeShaderContext::shadeSpan(int x, int y, SkPMColor re
 }
 
 void SkComposeShader::ComposeShaderContext::shadeSpan4f(int x, int y, SkPM4f result[], int count) {
-    auto* shaderContextA = fShaderContextA;
-    auto* shaderContextB = fShaderContextB;
+    SkShader::Context* shaderContextA = fShaderContextA;
+    SkShader::Context* shaderContextB = fShaderContextB;
     SkBlendMode        mode = static_cast<const SkComposeShader&>(fShader).fMode;
     unsigned           alpha = this->getPaintAlpha();
     Sk4f               scale(alpha * (1.0f / 255));
@@ -272,17 +272,17 @@ sk_sp<GrFragmentProcessor> SkComposeShader::asFragmentProcessor(const AsFPArgs&
                                                GrConstColorProcessor::kIgnore_InputMode);
             break;
         case SkBlendMode::kSrc:
-            return as_SB(fShaderB)->asFragmentProcessor(args);
+            return fShaderB->asFragmentProcessor(args);
             break;
         case SkBlendMode::kDst:
-            return as_SB(fShaderA)->asFragmentProcessor(args);
+            return fShaderA->asFragmentProcessor(args);
             break;
         default:
-            sk_sp<GrFragmentProcessor> fpA(as_SB(fShaderA)->asFragmentProcessor(args));
+            sk_sp<GrFragmentProcessor> fpA(fShaderA->asFragmentProcessor(args));
             if (!fpA) {
                 return nullptr;
             }
-            sk_sp<GrFragmentProcessor> fpB(as_SB(fShaderB)->asFragmentProcessor(args));
+            sk_sp<GrFragmentProcessor> fpB(fShaderB->asFragmentProcessor(args));
             if (!fpB) {
                 return nullptr;
             }
@@ -297,9 +297,9 @@ void SkComposeShader::toString(SkString* str) const {
     str->append("SkComposeShader: (");
 
     str->append("ShaderA: ");
-    as_SB(fShaderA)->toString(str);
+    fShaderA->toString(str);
     str->append(" ShaderB: ");
-    as_SB(fShaderB)->toString(str);
+    fShaderB->toString(str);
     if (SkBlendMode::kSrcOver != fMode) {
         str->appendf(" Xfermode: %s", SkXfermode::ModeName(fMode));
     }
index 8592f3a..d3f8c9d 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SkComposeShader_DEFINED
 #define SkComposeShader_DEFINED
 
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkBlendMode.h"
 
 class SkColorSpacXformer;
@@ -19,7 +19,7 @@ class SkColorSpacXformer;
     This subclass of shader returns the composition of two other shaders, combined by
     a xfermode.
 */
-class SK_API SkComposeShader : public SkShaderBase {
+class SK_API SkComposeShader : public SkShader {
 public:
     /** Create a new compose shader, given shaders A, B, and a combining xfermode mode.
         When the xfermode is called, it will be given the result from shader A as its
@@ -40,21 +40,21 @@ public:
     sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
-    class ComposeShaderContext : public Context {
+    class ComposeShaderContext : public SkShader::Context {
     public:
         // When this object gets destroyed, it will call contextA and contextB's destructor
         // but it will NOT free the memory.
         ComposeShaderContext(const SkComposeShader&, const ContextRec&,
-                             SkShaderBase::Context* contextA, SkShaderBase::Context* contextB);
+                             SkShader::Context* contextA, SkShader::Context* contextB);
 
         void shadeSpan(int x, int y, SkPMColor[], int count) override;
         void shadeSpan4f(int x, int y, SkPM4f[], int count) override;
 
     private:
-        SkShaderBase::Context* fShaderContextA;
-        SkShaderBase::Context* fShaderContextB;
+        SkShader::Context* fShaderContextA;
+        SkShader::Context* fShaderContextB;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
 #ifdef SK_DEBUG
@@ -82,7 +82,7 @@ private:
     sk_sp<SkShader>     fShaderB;
     SkBlendMode         fMode;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index 7f3de32..8dfeb74 100644 (file)
@@ -11,7 +11,7 @@
 #include "SkBitmapProcShader.h"
 #include "SkBlitter.h"
 #include "SkBlitRow.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkXfermodePriv.h"
 
 class SkRasterBlitter : public SkBlitter {
@@ -33,14 +33,14 @@ public:
       *  exchange that object.
       */
     SkShaderBlitter(const SkPixmap& device, const SkPaint& paint,
-                    SkShaderBase::Context* shaderContext);
+                    SkShader::Context* shaderContext);
     virtual ~SkShaderBlitter();
 
 protected:
-    uint32_t                fShaderFlags;
-    const SkShader*         fShader;
-    SkShaderBase::Context*  fShaderContext;
-    bool                    fConstInY;
+    uint32_t            fShaderFlags;
+    const SkShader*     fShader;
+    SkShader::Context*  fShaderContext;
+    bool                fConstInY;
 
 private:
     // illegal
@@ -84,7 +84,7 @@ private:
 class SkA8_Shader_Blitter : public SkShaderBlitter {
 public:
     SkA8_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
-                        SkShaderBase::Context* shaderContext);
+                        SkShader::Context* shaderContext);
     ~SkA8_Shader_Blitter() override;
     void blitH(int x, int y, int width) override;
     void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
@@ -155,7 +155,7 @@ private:
 class SkARGB32_Shader_Blitter : public SkShaderBlitter {
 public:
     SkARGB32_Shader_Blitter(const SkPixmap& device, const SkPaint& paint,
-                            SkShaderBase::Context* shaderContext);
+                            SkShader::Context* shaderContext);
     ~SkARGB32_Shader_Blitter() override;
     void blitH(int x, int y, int width) override;
     void blitV(int x, int y, int height, SkAlpha alpha) override;
@@ -176,10 +176,10 @@ private:
     typedef SkShaderBlitter INHERITED;
 };
 
-SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint&, SkShaderBase::Context*,
+SkBlitter* SkBlitter_ARGB32_Create(const SkPixmap& device, const SkPaint&, SkShader::Context*,
                                    SkArenaAlloc*);
 
-SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint&, SkShaderBase::Context*,
+SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint&, SkShader::Context*,
                                 SkArenaAlloc*);
 
 ///////////////////////////////////////////////////////////////////////////////
@@ -198,7 +198,7 @@ SkBlitter* SkBlitter_F16_Create(const SkPixmap& device, const SkPaint&, SkShader
  */
 
 SkBlitter* SkBlitter_ChooseD565(const SkPixmap& device, const SkPaint& paint,
-                                SkShaderBase::Context* shaderContext,
+                                SkShader::Context* shaderContext,
                                 SkArenaAlloc* allocator);
 
 
index 7720acc..125ab7a 100644 (file)
@@ -13,7 +13,7 @@
 #include "SkPM4fPriv.h"
 #include "SkRasterClip.h"
 #include "SkScan.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkString.h"
 #include "SkVertState.h"
 
@@ -69,7 +69,7 @@ static bool texture_to_matrix(const VertState& state, const SkPoint verts[],
     return matrix->setPolyToPoly(src, dst, 3);
 }
 
-class SkTriColorShader : public SkShaderBase {
+class SkTriColorShader : public SkShader {
 public:
     SkTriColorShader(bool isOpaque) : fIsOpaque(isOpaque) {}
 
@@ -102,7 +102,7 @@ private:
     Matrix43 fM43;
     const bool fIsOpaque;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #ifndef SK_IGNORE_TO_STRING
index c1bcfe0..b2c9b76 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SkEmptyShader_DEFINED
 #define SkEmptyShader_DEFINED
 
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 // TODO: move this to private, as there is a public factory on SkShader
 
@@ -16,7 +16,7 @@
  *  \class SkEmptyShader
  *  A Shader that always draws nothing. Its createContext always returns nullptr.
  */
-class SK_API SkEmptyShader : public SkShaderBase {
+class SK_API SkEmptyShader : public SkShader {
 public:
     SkEmptyShader() {}
 
@@ -24,7 +24,7 @@ public:
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkEmptyShader)
 
 protected:
-    Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override {
+    SkShader::Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override {
         return nullptr;
     }
 
@@ -35,7 +35,7 @@ protected:
     }
 
 private:
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index 9fa128f..298357e 100644 (file)
@@ -19,7 +19,6 @@
 #include "SkPathEffect.h"
 #include "SkPictureShader.h"
 #include "SkRecordedDrawable.h"
-#include "SkShaderBase.h"
 
 /*
  *  Registers all of the required effects subclasses for picture deserialization.
@@ -43,7 +42,7 @@ void SkFlattenable::PrivateInitializer::InitCore() {
 
     SkColorFilter::InitializeFlattenables();
     SkPathEffect::InitializeFlattenables();
-    SkShaderBase::InitializeFlattenables();
+    SkShader::InitializeFlattenables();
     SkXfermode::InitializeFlattenables();
 
     // Drawable
index cdfa528..ca370b0 100644 (file)
@@ -16,7 +16,6 @@
 #include "SkNormalSource.h"
 #include "SkPoint3.h"
 #include "SkReadBuffer.h"
-#include "SkShaderBase.h"
 #include "SkWriteBuffer.h"
 
 ////////////////////////////////////////////////////////////////////////////
@@ -37,7 +36,7 @@
 /** \class SkLightingShaderImpl
     This subclass of shader applies lighting.
 */
-class SkLightingShaderImpl : public SkShaderBase {
+class SkLightingShaderImpl : public SkShader {
 public:
     /** Create a new lighting shader that uses the provided normal map and
         lights to light the diffuse bitmap.
@@ -58,12 +57,12 @@ public:
     sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
 #endif
 
-    class LightingShaderContext : public Context {
+    class LightingShaderContext : public SkShader::Context {
     public:
         // The context takes ownership of the context and provider. It will call their destructors
         // and then indirectly free their memory by calling free() on heapAllocated
         LightingShaderContext(const SkLightingShaderImpl&, const ContextRec&,
-                              SkShaderBase::Context* diffuseContext, SkNormalSource::Provider*,
+                              SkShader::Context* diffuseContext, SkNormalSource::Provider*,
                               void* heapAllocated);
 
         void shadeSpan(int x, int y, SkPMColor[], int count) override;
@@ -71,12 +70,12 @@ public:
         uint32_t getFlags() const override { return fFlags; }
 
     private:
-        SkShaderBase::Context*    fDiffuseContext;
+        SkShader::Context*        fDiffuseContext;
         SkNormalSource::Provider* fNormalProvider;
         SkColor                   fPaintColor;
         uint32_t                  fFlags;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
     SK_TO_STRING_OVERRIDE()
@@ -94,7 +93,7 @@ private:
 
     friend class SkLightingShader;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 ////////////////////////////////////////////////////////////////////////////
@@ -271,7 +270,7 @@ sk_sp<GrFragmentProcessor> SkLightingShaderImpl::asFragmentProcessor(const AsFPA
 
     if (fDiffuseShader) {
         sk_sp<GrFragmentProcessor> fpPipeline[] = {
-            as_SB(fDiffuseShader)->asFragmentProcessor(args),
+            fDiffuseShader->asFragmentProcessor(args),
             sk_make_sp<LightingFP>(std::move(normalFP), fLights)
         };
         if(!fpPipeline[0]) {
@@ -299,7 +298,7 @@ bool SkLightingShaderImpl::isOpaque() const {
 
 SkLightingShaderImpl::LightingShaderContext::LightingShaderContext(
         const SkLightingShaderImpl& shader, const ContextRec& rec,
-        SkShaderBase::Context* diffuseContext, SkNormalSource::Provider* normalProvider,
+        SkShader::Context* diffuseContext, SkNormalSource::Provider* normalProvider,
         void* heapAllocated)
     : INHERITED(shader, rec)
     , fDiffuseContext(diffuseContext)
@@ -420,7 +419,7 @@ sk_sp<SkFlattenable> SkLightingShaderImpl::CreateProc(SkReadBuffer& buf) {
     bool hasDiffuse = buf.readBool();
     sk_sp<SkShader> diffuseShader = nullptr;
     if (hasDiffuse) {
-        diffuseShader = buf.readFlattenable<SkShaderBase>();
+        diffuseShader = buf.readFlattenable<SkShader>();
     }
 
     return sk_make_sp<SkLightingShaderImpl>(std::move(diffuseShader), std::move(normalSource),
@@ -439,12 +438,12 @@ void SkLightingShaderImpl::flatten(SkWriteBuffer& buf) const {
     }
 }
 
-SkShaderBase::Context* SkLightingShaderImpl::onMakeContext(
+SkShader::Context* SkLightingShaderImpl::onMakeContext(
     const ContextRec& rec, SkArenaAlloc* alloc) const
 {
-    SkShaderBase::Context *diffuseContext = nullptr;
+    SkShader::Context *diffuseContext = nullptr;
     if (fDiffuseShader) {
-        diffuseContext = as_SB(fDiffuseShader)->makeContext(rec, alloc);
+        diffuseContext = fDiffuseShader->makeContext(rec, alloc);
         if (!diffuseContext) {
             return nullptr;
         }
index e21e4a8..8a9a165 100644 (file)
@@ -17,7 +17,7 @@ sk_sp<GrFragmentProcessor> SkLocalMatrixShader::asFragmentProcessor(const AsFPAr
     if (args.fLocalMatrix) {
         tmp.preConcat(*args.fLocalMatrix);
     }
-    return as_SB(fProxyShader)->asFragmentProcessor(AsFPArgs(
+    return fProxyShader->asFragmentProcessor(AsFPArgs(
         args.fContext, args.fViewMatrix, &tmp, args.fFilterQuality, args.fDstColorSpace));
 }
 #endif
@@ -37,7 +37,7 @@ void SkLocalMatrixShader::flatten(SkWriteBuffer& buffer) const {
     buffer.writeFlattenable(fProxyShader.get());
 }
 
-SkShaderBase::Context* SkLocalMatrixShader::onMakeContext(
+SkShader::Context* SkLocalMatrixShader::onMakeContext(
     const ContextRec& rec, SkArenaAlloc* alloc) const
 {
     ContextRec newRec(rec);
@@ -48,7 +48,7 @@ SkShaderBase::Context* SkLocalMatrixShader::onMakeContext(
     } else {
         newRec.fLocalMatrix = &this->getLocalMatrix();
     }
-    return as_SB(fProxyShader)->makeContext(newRec, alloc);
+    return fProxyShader->makeContext(newRec, alloc);
 }
 
 SkImage* SkLocalMatrixShader::onIsAImage(SkMatrix* outMatrix, enum TileMode* mode) const {
@@ -72,15 +72,15 @@ bool SkLocalMatrixShader::onAppendStages(SkRasterPipeline* p,
     if (localM) {
         tmp.setConcat(*localM, this->getLocalMatrix());
     }
-    return as_SB(fProxyShader)->appendStages(p, dst, scratch, ctm, paint,
-                                             localM ? &tmp : &this->getLocalMatrix());
+    return fProxyShader->appendStages(p, dst, scratch, ctm, paint,
+                                      localM ? &tmp : &this->getLocalMatrix());
 }
 
 #ifndef SK_IGNORE_TO_STRING
 void SkLocalMatrixShader::toString(SkString* str) const {
     str->append("SkLocalMatrixShader: (");
 
-    as_SB(fProxyShader)->toString(str);
+    fProxyShader->toString(str);
 
     this->INHERITED::toString(str);
 
@@ -97,7 +97,7 @@ sk_sp<SkShader> SkShader::makeWithLocalMatrix(const SkMatrix& localMatrix) const
 
     sk_sp<SkShader> baseShader;
     SkMatrix otherLocalMatrix;
-    sk_sp<SkShader> proxy(as_SB(this)->makeAsALocalMatrixShader(&otherLocalMatrix));
+    sk_sp<SkShader> proxy(this->makeAsALocalMatrixShader(&otherLocalMatrix));
     if (proxy) {
         otherLocalMatrix.preConcat(localMatrix);
         lm = &otherLocalMatrix;
index 4572e9f..b00ee89 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SkLocalMatrixShader_DEFINED
 #define SkLocalMatrixShader_DEFINED
 
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkReadBuffer.h"
 #include "SkWriteBuffer.h"
 
@@ -16,7 +16,7 @@ class GrFragmentProcessor;
 class SkArenaAlloc;
 class SkColorSpaceXformer;
 
-class SkLocalMatrixShader : public SkShaderBase {
+class SkLocalMatrixShader : public SkShader {
 public:
     SkLocalMatrixShader(sk_sp<SkShader> proxy, const SkMatrix& localMatrix)
     : INHERITED(&localMatrix)
@@ -52,8 +52,7 @@ protected:
                         const SkMatrix&, const SkPaint&, const SkMatrix*) const override;
 
     sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override {
-        return as_SB(fProxyShader)->makeColorSpace(xformer)->makeWithLocalMatrix(
-            this->getLocalMatrix());
+        return fProxyShader->makeColorSpace(xformer)->makeWithLocalMatrix(this->getLocalMatrix());
     }
 
 #ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
@@ -63,13 +62,13 @@ protected:
 #endif
 
     bool isRasterPipelineOnly() const final {
-        return as_SB(fProxyShader)->isRasterPipelineOnly();
+        return fProxyShader->isRasterPipelineOnly();
     }
 
 private:
     sk_sp<SkShader> fProxyShader;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index 4ca9cbd..f3425cb 100644 (file)
@@ -12,7 +12,7 @@
 #include "SkPixmap.h"
 #include "SkScalar.h"
 #include "SkSize.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 class SkBitmap;
 class SkDiscardableMemory;
@@ -33,8 +33,8 @@ public:
     static SkMipMap* Build(const SkBitmap& src, SkDestinationSurfaceColorMode,
                            SkDiscardableFactoryProc);
 
-    static SkDestinationSurfaceColorMode DeduceColorMode(const SkShaderBase::ContextRec& rec) {
-        return (SkShaderBase::ContextRec::kPMColor_DstType == rec.fPreferredDstType)
+    static SkDestinationSurfaceColorMode DeduceColorMode(const SkShader::ContextRec& rec) {
+        return (SkShader::ContextRec::kPMColor_DstType == rec.fPreferredDstType)
             ? SkDestinationSurfaceColorMode::kLegacy
             : SkDestinationSurfaceColorMode::kGammaAndColorSpaceAware;
     }
index 0f1305c..05bb5f6 100644 (file)
@@ -241,7 +241,7 @@ private:
 };
 
 sk_sp<GrFragmentProcessor> SkNormalBevelSourceImpl::asFragmentProcessor(
-        const SkShaderBase::AsFPArgs& args) const {
+        const SkShader::AsFPArgs& args) const {
 
     // This assumes a uniform scale. Anisotropic scaling might not be handled gracefully.
     SkScalar maxScale = args.fViewMatrix->getMaxScale();
@@ -258,7 +258,7 @@ SkNormalBevelSourceImpl::Provider::Provider() {}
 
 SkNormalBevelSourceImpl::Provider::~Provider() {}
 
-SkNormalSource::Provider* SkNormalBevelSourceImpl::asProvider(const SkShaderBase::ContextRec &rec,
+SkNormalSource::Provider* SkNormalBevelSourceImpl::asProvider(const SkShader::ContextRec &rec,
                                                               SkArenaAlloc* alloc) const {
     return alloc->make<Provider>();
 }
index 1e06303..2fefacd 100644 (file)
@@ -18,10 +18,10 @@ public:
         , fHeight(height) {}
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShaderBase::AsFPArgs&) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const override;
 #endif
 
-    SkNormalSource::Provider* asProvider(const SkShaderBase::ContextRec& rec,
+    SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec,
                                          SkArenaAlloc*) const override;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalBevelSourceImpl)
index 922ad15..2547f4b 100644 (file)
@@ -60,7 +60,7 @@ private:
 };
 
 sk_sp<GrFragmentProcessor> SkNormalFlatSourceImpl::asFragmentProcessor(
-        const SkShaderBase::AsFPArgs&) const {
+        const SkShader::AsFPArgs&) const {
 
     return sk_make_sp<NormalFlatFP>();
 }
@@ -73,7 +73,7 @@ SkNormalFlatSourceImpl::Provider::Provider() {}
 
 SkNormalFlatSourceImpl::Provider::~Provider() {}
 
-SkNormalSource::Provider* SkNormalFlatSourceImpl::asProvider(const SkShaderBase::ContextRec &rec,
+SkNormalSource::Provider* SkNormalFlatSourceImpl::asProvider(const SkShader::ContextRec &rec,
                                                              SkArenaAlloc *alloc) const {
     return alloc->make<Provider>();
 }
index 938e28f..82b56f1 100644 (file)
@@ -15,10 +15,10 @@ public:
     SkNormalFlatSourceImpl(){}
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShaderBase::AsFPArgs&) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const override;
 #endif
 
-    SkNormalSource::Provider* asProvider(const SkShaderBase::ContextRec& rec,
+    SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec,
                                          SkArenaAlloc* alloc) const override;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalFlatSourceImpl)
index f655b68..fb133da 100644 (file)
@@ -118,8 +118,8 @@ private:
 };
 
 sk_sp<GrFragmentProcessor> SkNormalMapSourceImpl::asFragmentProcessor(
-        const SkShaderBase::AsFPArgs& args) const {
-    sk_sp<GrFragmentProcessor> mapFP = as_SB(fMapShader)->asFragmentProcessor(args);
+        const SkShader::AsFPArgs& args) const {
+    sk_sp<GrFragmentProcessor> mapFP = fMapShader->asFragmentProcessor(args);
     if (!mapFP) {
         return nullptr;
     }
@@ -132,11 +132,11 @@ sk_sp<GrFragmentProcessor> SkNormalMapSourceImpl::asFragmentProcessor(
 ////////////////////////////////////////////////////////////////////////////
 
 SkNormalMapSourceImpl::Provider::Provider(const SkNormalMapSourceImpl& source,
-                                          SkShaderBase::Context* mapContext)
+                                          SkShader::Context* mapContext)
     : fSource(source)
     , fMapContext(mapContext) {}
 
-SkNormalSource::Provider* SkNormalMapSourceImpl::asProvider(const SkShaderBase::ContextRec &rec,
+SkNormalSource::Provider* SkNormalMapSourceImpl::asProvider(const SkShader::ContextRec &rec,
                                                             SkArenaAlloc* alloc) const {
     SkMatrix normTotalInv;
     if (!this->computeNormTotalInverse(rec, &normTotalInv)) {
@@ -146,10 +146,10 @@ SkNormalSource::Provider* SkNormalMapSourceImpl::asProvider(const SkShaderBase::
     // Overriding paint's alpha because we need the normal map's RGB channels to be unpremul'd
     SkPaint overridePaint {*(rec.fPaint)};
     overridePaint.setAlpha(0xFF);
-    SkShaderBase::ContextRec overrideRec(overridePaint, *(rec.fMatrix), rec.fLocalMatrix,
-                                         rec.fPreferredDstType, rec.fDstColorSpace);
+    SkShader::ContextRec overrideRec(overridePaint, *(rec.fMatrix), rec.fLocalMatrix,
+                                     rec.fPreferredDstType, rec.fDstColorSpace);
 
-    auto* context = as_SB(fMapShader)->makeContext(overrideRec, alloc);
+    SkShader::Context* context = fMapShader->makeContext(overrideRec, alloc);
     if (!context) {
         return nullptr;
     }
@@ -157,7 +157,7 @@ SkNormalSource::Provider* SkNormalMapSourceImpl::asProvider(const SkShaderBase::
     return alloc->make<Provider>(*this, context);
 }
 
-bool SkNormalMapSourceImpl::computeNormTotalInverse(const SkShaderBase::ContextRec& rec,
+bool SkNormalMapSourceImpl::computeNormTotalInverse(const SkShader::ContextRec& rec,
                                                     SkMatrix* normTotalInverse) const {
     SkMatrix total = SkMatrix::Concat(*rec.fMatrix, fMapShader->getLocalMatrix());
     if (rec.fLocalMatrix) {
@@ -221,7 +221,7 @@ void SkNormalMapSourceImpl::Provider::fillScanLine(int x, int y, SkPoint3 output
 
 sk_sp<SkFlattenable> SkNormalMapSourceImpl::CreateProc(SkReadBuffer& buf) {
 
-    sk_sp<SkShader> mapShader = buf.readFlattenable<SkShaderBase>();
+    sk_sp<SkShader> mapShader = buf.readFlattenable<SkShader>();
 
     SkMatrix invCTM;
     buf.readMatrix(&invCTM);
index a02e6ab..f2b07f2 100644 (file)
@@ -17,10 +17,10 @@ public:
             , fInvCTM(invCTM) {}
 
 #if SK_SUPPORT_GPU
-    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShaderBase::AsFPArgs&) const override;
+    sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const override;
 #endif
 
-    SkNormalSource::Provider* asProvider(const SkShaderBase::ContextRec& rec,
+    SkNormalSource::Provider* asProvider(const SkShader::ContextRec& rec,
                                          SkArenaAlloc* alloc) const override;
 
     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkNormalMapSourceImpl)
@@ -28,19 +28,18 @@ public:
 protected:
     void flatten(SkWriteBuffer& buf) const override;
 
-    bool computeNormTotalInverse(const SkShaderBase::ContextRec& rec,
-                                 SkMatrix* normTotalInverse) const;
+    bool computeNormTotalInverse(const SkShader::ContextRec& rec, SkMatrix* normTotalInverse) const;
 
 private:
     class Provider : public SkNormalSource::Provider {
     public:
-        Provider(const SkNormalMapSourceImpl& source, SkShaderBase::Context* mapContext);
+        Provider(const SkNormalMapSourceImpl& source, SkShader::Context* mapContext);
 
         void fillScanLine(int x, int y, SkPoint3 output[], int count) const override;
 
     private:
         const SkNormalMapSourceImpl& fSource;
-        SkShaderBase::Context*       fMapContext;
+        SkShader::Context* fMapContext;
 
         typedef SkNormalSource::Provider INHERITED;
     };
index 54d44d4..221c09d 100644 (file)
@@ -9,7 +9,7 @@
 #define SkNormalSource_DEFINED
 
 #include "SkFlattenable.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 class SkMatrix;
 struct SkPoint3;
@@ -28,7 +28,7 @@ public:
     /** Returns a fragment processor that takes no input and outputs a normal (already rotated)
         as its output color. To be used as a child fragment processor.
     */
-    virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShaderBase::AsFPArgs&) const = 0;
+    virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(const SkShader::AsFPArgs&) const = 0;
 #endif
 
     class Provider {
@@ -44,7 +44,7 @@ public:
     /** Returns an instance of 'Provider' that provides normals for the CPU pipeline. The
         necessary data will be initialized in place at 'storage'.
     */
-    virtual Provider* asProvider(const SkShaderBase::ContextRec&, SkArenaAlloc*) const = 0;
+    virtual Provider* asProvider(const SkShader::ContextRec&, SkArenaAlloc*) const = 0;
 
     /** Returns a normal source that provides normals sourced from the the normal map argument.
 
index 2d3eb18..568ba6a 100644 (file)
@@ -26,7 +26,6 @@
 #include "SkScalar.h"
 #include "SkScalerContext.h"
 #include "SkShader.h"
-#include "SkShaderBase.h"
 #include "SkStringUtils.h"
 #include "SkStroke.h"
 #include "SkStrokeRec.h"
@@ -1251,7 +1250,7 @@ static SkPaint::Hinting computeHinting(const SkPaint& paint) {
 static bool justAColor(const SkPaint& paint, SkColor* color) {
     SkColor c = paint.getColor();
 
-    const auto* shader = as_SB(paint.getShader());
+    SkShader* shader = paint.getShader();
     if (shader && !shader->asLuminanceColor(&c)) {
         return false;
     }
@@ -2072,7 +2071,8 @@ void SkPaint::toString(SkString* str) const {
         str->append("</dd>");
     }
 
-    if (const auto* shader = as_SB(this->getShader())) {
+    SkShader* shader = this->getShader();
+    if (shader) {
         str->append("<dt>Shader:</dt><dd>");
         shader->toString(str);
         str->append("</dd>");
index d6ee941..a92cf04 100644 (file)
@@ -277,11 +277,11 @@ bool SkPictureShader::onAppendStages(SkRasterPipeline* p, SkColorSpace* cs, SkAr
     // Keep bitmapShader alive by using alloc instead of stack memory
     auto& bitmapShader = *alloc->make<sk_sp<SkShader>>();
     bitmapShader = this->refBitmapShader(ctm, localMatrix, cs);
-    return bitmapShader && as_SB(bitmapShader)->appendStages(p, cs, alloc, ctm, paint);
+    return bitmapShader && bitmapShader->appendStages(p, cs, alloc, ctm, paint);
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////
-SkShaderBase::Context* SkPictureShader::onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc)
+SkShader::Context* SkPictureShader::onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc)
 const {
     sk_sp<SkShader> bitmapShader(this->refBitmapShader(*rec.fMatrix, rec.fLocalMatrix,
                                                        rec.fDstColorSpace));
@@ -310,7 +310,7 @@ SkPictureShader::PictureShaderContext::PictureShaderContext(
     : INHERITED(shader, rec)
     , fBitmapShader(std::move(bitmapShader))
 {
-    fBitmapShaderContext = as_SB(fBitmapShader)->makeContext(rec, alloc);
+    fBitmapShaderContext = fBitmapShader->makeContext(rec, alloc);
     //if fBitmapShaderContext is null, we are invalid
 }
 
@@ -319,7 +319,7 @@ uint32_t SkPictureShader::PictureShaderContext::getFlags() const {
     return fBitmapShaderContext->getFlags();
 }
 
-SkShaderBase::Context::ShadeProc SkPictureShader::PictureShaderContext::asAShadeProc(void** ctx) {
+SkShader::Context::ShadeProc SkPictureShader::PictureShaderContext::asAShadeProc(void** ctx) {
     SkASSERT(fBitmapShaderContext);
     return fBitmapShaderContext->asAShadeProc(ctx);
 }
@@ -358,7 +358,7 @@ sk_sp<GrFragmentProcessor> SkPictureShader::asFragmentProcessor(const AsFPArgs&
     if (!bitmapShader) {
         return nullptr;
     }
-    return as_SB(bitmapShader)->asFragmentProcessor(SkShaderBase::AsFPArgs(
+    return bitmapShader->asFragmentProcessor(SkShader::AsFPArgs(
         args.fContext, args.fViewMatrix, nullptr, args.fFilterQuality, args.fDstColorSpace));
 }
 #endif
index f7a509f..10b1f93 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SkPictureShader_DEFINED
 #define SkPictureShader_DEFINED
 
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 class SkArenaAlloc;
 class SkBitmap;
@@ -20,7 +20,7 @@ class SkPicture;
  * The SkPicture is first rendered into a tile, which is then used to shade the area according
  * to specified tiling rules.
  */
-class SkPictureShader : public SkShaderBase {
+class SkPictureShader : public SkShader {
 public:
     static sk_sp<SkShader> Make(sk_sp<SkPicture>, TileMode, TileMode, const SkMatrix*,
                                 const SkRect*);
@@ -52,7 +52,7 @@ private:
     SkRect              fTile;
     TileMode            fTmx, fTmy;
 
-    class PictureShaderContext : public Context {
+    class PictureShaderContext : public SkShader::Context {
     public:
         PictureShaderContext(
             const SkPictureShader&, const ContextRec&, sk_sp<SkShader> bitmapShader, SkArenaAlloc*);
@@ -62,18 +62,18 @@ private:
         ShadeProc asAShadeProc(void** ctx) override;
         void shadeSpan(int x, int y, SkPMColor dstC[], int count) override;
 
-        sk_sp<SkShader>         fBitmapShader;
-        SkShaderBase::Context*  fBitmapShaderContext;
-        void*                   fBitmapShaderContextStorage;
+        sk_sp<SkShader>     fBitmapShader;
+        SkShader::Context*  fBitmapShaderContext;
+        void*               fBitmapShaderContextStorage;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
     // Should never be set by a public constructor.  This is only used when onMakeColorSpace()
     // forces a deferred color space xform.
     sk_sp<SkColorSpace>   fColorSpace;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif // SkPictureShader_DEFINED
index cc48df0..023ff1e 100644 (file)
@@ -16,7 +16,6 @@
 #include "SkPM4fPriv.h"
 #include "SkRasterPipeline.h"
 #include "SkShader.h"
-#include "SkShaderBase.h"
 #include "SkUtils.h"
 #include "../jumper/SkJumper.h"
 
@@ -24,14 +23,13 @@ class SkRasterPipelineBlitter final : public SkBlitter {
 public:
     // This is our common entrypoint for creating the blitter once we've sorted out shaders.
     static SkBlitter* Create(const SkPixmap&, const SkPaint&, SkArenaAlloc*,
-                             const SkRasterPipeline& shaderPipeline,
-                             SkShaderBase::Context* shaderCtx,
+                             const SkRasterPipeline& shaderPipeline, SkShader::Context* shaderCtx,
                              bool is_opaque, bool is_constant, bool wants_dither);
 
     SkRasterPipelineBlitter(SkPixmap dst,
                             SkBlendMode blend,
                             SkArenaAlloc* alloc,
-                            SkShaderBase::Context* shaderCtx)
+                            SkShader::Context* shaderCtx)
         : fDst(dst)
         , fBlend(blend)
         , fAlloc(alloc)
@@ -56,11 +54,11 @@ private:
     // If we have an SkShader::Context, use it to fill our shader buffer.
     void maybe_shade(int x, int y, int w);
 
-    SkPixmap               fDst;
-    SkBlendMode            fBlend;
-    SkArenaAlloc*          fAlloc;
-    SkShaderBase::Context* fShaderCtx;
-    SkRasterPipeline       fColorPipeline;
+    SkPixmap           fDst;
+    SkBlendMode        fBlend;
+    SkArenaAlloc*      fAlloc;
+    SkShader::Context* fShaderCtx;
+    SkRasterPipeline   fColorPipeline;
 
     // We may be able to specialize blitH() into a memset.
     bool     fCanMemsetInBlitH = false;
@@ -92,7 +90,7 @@ SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap& dst,
                                          SkArenaAlloc* alloc) {
     SkColorSpace* dstCS = dst.colorSpace();
     auto paintColor = alloc->make<SkPM4f>(SkPM4f_from_SkColor(paint.getColor(), dstCS));
-    auto shader = as_SB(paint.getShader());
+    auto shader = paint.getShader();
 
     SkRasterPipeline_<256> shaderPipeline;
     if (!shader) {
@@ -126,12 +124,11 @@ SkBlitter* SkCreateRasterPipelineBlitter(const SkPixmap& dst,
     if (dstCS) {
         // We need to transform the shader into the dst color space, and extend its lifetime.
         sk_sp<SkShader> in_dstCS = SkColorSpaceXformer::Make(sk_ref_sp(dstCS))->apply(shader);
-        shader = as_SB(in_dstCS.get());
+        shader = in_dstCS.get();
         alloc->make<sk_sp<SkShader>>(std::move(in_dstCS));
     }
-    SkShaderBase::ContextRec rec(paint, ctm, nullptr, SkShaderBase::ContextRec::kPM4f_DstType,
-                                 dstCS);
-    SkShaderBase::Context* shaderCtx = shader->makeContext(rec, alloc);
+    SkShader::ContextRec rec(paint, ctm, nullptr, SkShader::ContextRec::kPM4f_DstType, dstCS);
+    SkShader::Context* shaderCtx = shader->makeContext(rec, alloc);
     if (!shaderCtx) {
         // When a shader fails to create a context, it has vetoed drawing entirely.
         return alloc->make<SkNullBlitter>();
@@ -157,7 +154,7 @@ SkBlitter* SkRasterPipelineBlitter::Create(const SkPixmap& dst,
                                            const SkPaint& paint,
                                            SkArenaAlloc* alloc,
                                            const SkRasterPipeline& shaderPipeline,
-                                           SkShaderBase::Context* shaderCtx,
+                                           SkShader::Context* shaderCtx,
                                            bool is_opaque,
                                            bool is_constant,
                                            bool wants_dither) {
index 453d22f..adc529e 100644 (file)
@@ -20,7 +20,7 @@
 #include "SkReadBuffer.h"
 #include "SkReader32.h"
 #include "SkRefCnt.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkTHash.h"
 #include "SkWriteBuffer.h"
 #include "SkXfermodePriv.h"
@@ -150,7 +150,7 @@ public:
     sk_sp<SkMaskFilter> readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); }
     sk_sp<SkPathEffect> readPathEffect() { return this->readFlattenable<SkPathEffect>(); }
     sk_sp<SkRasterizer> readRasterizer() { return this->readFlattenable<SkRasterizer>(); }
-    sk_sp<SkShader> readShader() { return this->readFlattenable<SkShaderBase>(); }
+    sk_sp<SkShader> readShader() { return this->readFlattenable<SkShader>(); }
     sk_sp<SkXfermode> readXfermode() { return this->readFlattenable<SkXfermode>(); }
 
     // binary data and arrays
index 4f39f70..ff5b400 100644 (file)
@@ -18,7 +18,7 @@
 #include "SkRasterPipeline.h"
 #include "SkReadBuffer.h"
 #include "SkScalar.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkTLazy.h"
 #include "SkWriteBuffer.h"
 #include "../jumper/SkJumper.h"
@@ -46,18 +46,22 @@ static inline void dec_shader_counter() {
 #endif
 }
 
-SkShaderBase::SkShaderBase(const SkMatrix* localMatrix)
-    : fLocalMatrix(localMatrix ? *localMatrix : SkMatrix::I()) {
+SkShader::SkShader(const SkMatrix* localMatrix) {
     inc_shader_counter();
+    if (localMatrix) {
+        fLocalMatrix = *localMatrix;
+    } else {
+        fLocalMatrix.reset();
+    }
     // Pre-cache so future calls to fLocalMatrix.getType() are threadsafe.
     (void)fLocalMatrix.getType();
 }
 
-SkShaderBase::~SkShaderBase() {
+SkShader::~SkShader() {
     dec_shader_counter();
 }
 
-void SkShaderBase::flatten(SkWriteBuffer& buffer) const {
+void SkShader::flatten(SkWriteBuffer& buffer) const {
     this->INHERITED::flatten(buffer);
     bool hasLocalM = !fLocalMatrix.isIdentity();
     buffer.writeBool(hasLocalM);
@@ -66,9 +70,9 @@ void SkShaderBase::flatten(SkWriteBuffer& buffer) const {
     }
 }
 
-bool SkShaderBase::computeTotalInverse(const SkMatrix& ctm,
-                                       const SkMatrix* outerLocalMatrix,
-                                       SkMatrix* totalInverse) const {
+bool SkShader::computeTotalInverse(const SkMatrix& ctm,
+                                   const SkMatrix* outerLocalMatrix,
+                                   SkMatrix* totalInverse) const {
     SkMatrix total = SkMatrix::Concat(ctm, fLocalMatrix);
     if (outerLocalMatrix) {
         total.preConcat(*outerLocalMatrix);
@@ -77,7 +81,7 @@ bool SkShaderBase::computeTotalInverse(const SkMatrix& ctm,
     return total.invert(totalInverse);
 }
 
-bool SkShaderBase::asLuminanceColor(SkColor* colorPtr) const {
+bool SkShader::asLuminanceColor(SkColor* colorPtr) const {
     SkColor storage;
     if (nullptr == colorPtr) {
         colorPtr = &storage;
@@ -89,14 +93,14 @@ bool SkShaderBase::asLuminanceColor(SkColor* colorPtr) const {
     return false;
 }
 
-SkShaderBase::Context* SkShaderBase::makeContext(const ContextRec& rec, SkArenaAlloc* alloc) const {
+SkShader::Context* SkShader::makeContext(const ContextRec& rec, SkArenaAlloc* alloc) const {
     if (!this->computeTotalInverse(*rec.fMatrix, rec.fLocalMatrix, nullptr)) {
         return nullptr;
     }
     return this->onMakeContext(rec, alloc);
 }
 
-SkShaderBase::Context::Context(const SkShaderBase& shader, const ContextRec& rec)
+SkShader::Context::Context(const SkShader& shader, const ContextRec& rec)
     : fShader(shader), fCTM(*rec.fMatrix)
 {
     // We should never use a context for RP-only shaders.
@@ -110,13 +114,13 @@ SkShaderBase::Context::Context(const SkShaderBase& shader, const ContextRec& rec
     fPaintAlpha = rec.fPaint->getAlpha();
 }
 
-SkShaderBase::Context::~Context() {}
+SkShader::Context::~Context() {}
 
-SkShaderBase::Context::ShadeProc SkShaderBase::Context::asAShadeProc(void** ctx) {
+SkShader::Context::ShadeProc SkShader::Context::asAShadeProc(void** ctx) {
     return nullptr;
 }
 
-void SkShaderBase::Context::shadeSpan4f(int x, int y, SkPM4f dst[], int count) {
+void SkShader::Context::shadeSpan4f(int x, int y, SkPM4f dst[], int count) {
     const int N = 128;
     SkPMColor tmp[N];
     while (count > 0) {
@@ -142,7 +146,7 @@ void SkShaderBase::Context::shadeSpan4f(int x, int y, SkPM4f dst[], int count) {
     #define SkU32BitShiftToByteOffset(shift)    ((shift) >> 3)
 #endif
 
-void SkShaderBase::Context::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {
+void SkShader::Context::shadeSpanAlpha(int x, int y, uint8_t alpha[], int count) {
     SkASSERT(count > 0);
 
     SkPMColor   colors[kTempColorCount];
@@ -196,7 +200,7 @@ void SkShaderBase::Context::shadeSpanAlpha(int x, int y, uint8_t alpha[], int co
 #endif
 }
 
-SkShaderBase::Context::MatrixClass SkShaderBase::Context::ComputeMatrixClass(const SkMatrix& mat) {
+SkShader::Context::MatrixClass SkShader::Context::ComputeMatrixClass(const SkMatrix& mat) {
     MatrixClass mc = kLinear_MatrixClass;
 
     if (mat.hasPerspective()) {
@@ -211,31 +215,17 @@ SkShaderBase::Context::MatrixClass SkShaderBase::Context::ComputeMatrixClass(con
 
 //////////////////////////////////////////////////////////////////////////////
 
-const SkMatrix& SkShader::getLocalMatrix() const {
-    return as_SB(this)->getLocalMatrix();
-}
-
-#ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
-bool SkShader::isABitmap(SkBitmap* outTexture, SkMatrix* outMatrix, TileMode xy[2]) const {
-    return  as_SB(this)->onIsABitmap(outTexture, outMatrix, xy);
-}
-#endif
-
-SkImage* SkShader::isAImage(SkMatrix* localMatrix, TileMode xy[2]) const {
-    return as_SB(this)->onIsAImage(localMatrix, xy);
-}
-
 SkShader::GradientType SkShader::asAGradient(GradientInfo* info) const {
     return kNone_GradientType;
 }
 
 #if SK_SUPPORT_GPU
-sk_sp<GrFragmentProcessor> SkShaderBase::asFragmentProcessor(const AsFPArgs&) const {
+sk_sp<GrFragmentProcessor> SkShader::asFragmentProcessor(const AsFPArgs&) const {
     return nullptr;
 }
 #endif
 
-sk_sp<SkShader> SkShaderBase::makeAsALocalMatrixShader(SkMatrix*) const {
+sk_sp<SkShader> SkShader::makeAsALocalMatrixShader(SkMatrix*) const {
     return nullptr;
 }
 
@@ -260,7 +250,7 @@ sk_sp<SkShader> SkShader::MakePictureShader(sk_sp<SkPicture> src, TileMode tmx,
 }
 
 #ifndef SK_IGNORE_TO_STRING
-void SkShaderBase::toString(SkString* str) const {
+void SkShader::toString(SkString* str) const {
     if (!fLocalMatrix.isIdentity()) {
         str->append(" ");
         fLocalMatrix.toString(str);
@@ -268,21 +258,21 @@ void SkShaderBase::toString(SkString* str) const {
 }
 #endif
 
-bool SkShaderBase::appendStages(SkRasterPipeline* p,
-                                SkColorSpace* dstCS,
-                                SkArenaAlloc* alloc,
-                                const SkMatrix& ctm,
-                                const SkPaint& paint,
-                                const SkMatrix* localM) const {
+bool SkShader::appendStages(SkRasterPipeline* p,
+                            SkColorSpace* dstCS,
+                            SkArenaAlloc* alloc,
+                            const SkMatrix& ctm,
+                            const SkPaint& paint,
+                            const SkMatrix* localM) const {
     return this->onAppendStages(p, dstCS, alloc, ctm, paint, localM);
 }
 
-bool SkShaderBase::onAppendStages(SkRasterPipeline* p,
-                                  SkColorSpace* dstCS,
-                                  SkArenaAlloc* alloc,
-                                  const SkMatrix& ctm,
-                                  const SkPaint& paint,
-                                  const SkMatrix* localM) const {
+bool SkShader::onAppendStages(SkRasterPipeline* p,
+                              SkColorSpace* dstCS,
+                              SkArenaAlloc* alloc,
+                              const SkMatrix& ctm,
+                              const SkPaint& paint,
+                              const SkMatrix* localM) const {
     return false;
 }
 
diff --git a/src/core/SkShaderBase.h b/src/core/SkShaderBase.h
deleted file mode 100644 (file)
index e03fb76..0000000
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright 2017 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef SkShaderBase_DEFINED
-#define SkShaderBase_DEFINED
-
-#include "SkFilterQuality.h"
-#include "SkMatrix.h"
-#include "SkShader.h"
-
-class GrContext;
-class GrFragmentProcessor;
-class SkArenaAlloc;
-class SkColorSpace;
-class SkColorSpaceXformer;
-class SkImage;
-struct SkImageInfo;
-class SkPaint;
-class SkRasterPipeline;
-
-class SkShaderBase : public SkShader {
-public:
-    SkShaderBase(const SkMatrix* localMatrix = nullptr);
-
-    ~SkShaderBase() override;
-
-    /**
-     *  Returns true if the shader is guaranteed to produce only a single color.
-     *  Subclasses can override this to allow loop-hoisting optimization.
-     */
-    virtual bool isConstant() const { return false; }
-
-    const SkMatrix& getLocalMatrix() const { return fLocalMatrix; }
-
-    enum Flags {
-        //!< set if all of the colors will be opaque
-        kOpaqueAlpha_Flag = 1 << 0,
-
-        /** set if the spans only vary in X (const in Y).
-            e.g. an Nx1 bitmap that is being tiled in Y, or a linear-gradient
-            that varies from left-to-right. This flag specifies this for
-            shadeSpan().
-         */
-        kConstInY32_Flag = 1 << 1,
-
-        /** hint for the blitter that 4f is the preferred shading mode.
-         */
-        kPrefers4f_Flag  = 1 << 2,
-    };
-
-    /**
-     *  ContextRec acts as a parameter bundle for creating Contexts.
-     */
-    struct ContextRec {
-        enum DstType {
-            kPMColor_DstType, // clients prefer shading into PMColor dest
-            kPM4f_DstType,    // clients prefer shading into PM4f dest
-        };
-
-        ContextRec(const SkPaint& paint, const SkMatrix& matrix, const SkMatrix* localM,
-                   DstType dstType, SkColorSpace* dstColorSpace)
-            : fPaint(&paint)
-            , fMatrix(&matrix)
-            , fLocalMatrix(localM)
-            , fPreferredDstType(dstType)
-            , fDstColorSpace(dstColorSpace) {}
-
-        const SkPaint*  fPaint;            // the current paint associated with the draw
-        const SkMatrix* fMatrix;           // the current matrix in the canvas
-        const SkMatrix* fLocalMatrix;      // optional local matrix
-        const DstType   fPreferredDstType; // the "natural" client dest type
-        SkColorSpace*   fDstColorSpace;    // the color space of the dest surface (if any)
-    };
-
-    class Context : public ::SkNoncopyable {
-    public:
-        Context(const SkShaderBase& shader, const ContextRec&);
-
-        virtual ~Context();
-
-        /**
-         *  Called sometimes before drawing with this shader. Return the type of
-         *  alpha your shader will return. The default implementation returns 0.
-         *  Your subclass should override if it can (even sometimes) report a
-         *  non-zero value, since that will enable various blitters to perform
-         *  faster.
-         */
-        virtual uint32_t getFlags() const { return 0; }
-
-        /**
-         *  Called for each span of the object being drawn. Your subclass should
-         *  set the appropriate colors (with premultiplied alpha) that correspond
-         *  to the specified device coordinates.
-         */
-        virtual void shadeSpan(int x, int y, SkPMColor[], int count) = 0;
-
-        virtual void shadeSpan4f(int x, int y, SkPM4f[], int count);
-
-        struct BlitState;
-        typedef void (*BlitBW)(BlitState*,
-                               int x, int y, const SkPixmap&, int count);
-        typedef void (*BlitAA)(BlitState*,
-                               int x, int y, const SkPixmap&, int count, const SkAlpha[]);
-
-        struct BlitState {
-            // inputs
-            Context*    fCtx;
-            SkBlendMode fMode;
-
-            // outputs
-            enum { N = 2 };
-            void*       fStorage[N];
-            BlitBW      fBlitBW;
-            BlitAA      fBlitAA;
-        };
-
-        // Returns true if one or more of the blitprocs are set in the BlitState
-        bool chooseBlitProcs(const SkImageInfo& info, BlitState* state) {
-            state->fBlitBW = nullptr;
-            state->fBlitAA = nullptr;
-            if (this->onChooseBlitProcs(info, state)) {
-                SkASSERT(state->fBlitBW || state->fBlitAA);
-                return true;
-            }
-            return false;
-        }
-
-        /**
-         * The const void* ctx is only const because all the implementations are const.
-         * This can be changed to non-const if a new shade proc needs to change the ctx.
-         */
-        typedef void (*ShadeProc)(const void* ctx, int x, int y, SkPMColor[], int count);
-        virtual ShadeProc asAShadeProc(void** ctx);
-
-        /**
-         *  Similar to shadeSpan, but only returns the alpha-channel for a span.
-         *  The default implementation calls shadeSpan() and then extracts the alpha
-         *  values from the returned colors.
-         */
-        virtual void shadeSpanAlpha(int x, int y, uint8_t alpha[], int count);
-
-        // Notification from blitter::blitMask in case we need to see the non-alpha channels
-        virtual void set3DMask(const SkMask*) {}
-
-    protected:
-        // Reference to shader, so we don't have to dupe information.
-        const SkShaderBase& fShader;
-
-        enum MatrixClass {
-            kLinear_MatrixClass,            // no perspective
-            kFixedStepInX_MatrixClass,      // fast perspective, need to call fixedStepInX() each
-                                            // scanline
-            kPerspective_MatrixClass        // slow perspective, need to mappoints each pixel
-        };
-        static MatrixClass ComputeMatrixClass(const SkMatrix&);
-
-        uint8_t         getPaintAlpha() const { return fPaintAlpha; }
-        const SkMatrix& getTotalInverse() const { return fTotalInverse; }
-        MatrixClass     getInverseClass() const { return (MatrixClass)fTotalInverseClass; }
-        const SkMatrix& getCTM() const { return fCTM; }
-
-        virtual bool onChooseBlitProcs(const SkImageInfo&, BlitState*) { return false; }
-
-    private:
-        SkMatrix    fCTM;
-        SkMatrix    fTotalInverse;
-        uint8_t     fPaintAlpha;
-        uint8_t     fTotalInverseClass;
-
-        typedef SkNoncopyable INHERITED;
-    };
-
-    /**
-     * Make a context using the memory provided by the arena.
-     *
-     * @return pointer to context or nullptr if can't be created
-     */
-    Context* makeContext(const ContextRec&, SkArenaAlloc*) const;
-
-    /**
-     *  If the shader subclass is composed of two shaders, return true, and if rec is not NULL,
-     *  fill it out with info about the shader.
-     *
-     *  These are bare pointers; the ownership and reference count are unchanged.
-     */
-
-    struct ComposeRec {
-        const SkShader*     fShaderA;
-        const SkShader*     fShaderB;
-        SkBlendMode         fBlendMode;
-    };
-
-    virtual bool asACompose(ComposeRec*) const { return false; }
-
-#if SK_SUPPORT_GPU
-    struct AsFPArgs {
-        AsFPArgs() {}
-        AsFPArgs(GrContext* context,
-                 const SkMatrix* viewMatrix,
-                 const SkMatrix* localMatrix,
-                 SkFilterQuality filterQuality,
-                 SkColorSpace* dstColorSpace)
-            : fContext(context)
-            , fViewMatrix(viewMatrix)
-            , fLocalMatrix(localMatrix)
-            , fFilterQuality(filterQuality)
-            , fDstColorSpace(dstColorSpace) {}
-
-        GrContext*                    fContext;
-        const SkMatrix*               fViewMatrix;
-        const SkMatrix*               fLocalMatrix;
-        SkFilterQuality               fFilterQuality;
-        SkColorSpace*                 fDstColorSpace;
-    };
-
-    /**
-     *  Returns a GrFragmentProcessor that implements the shader for the GPU backend. NULL is
-     *  returned if there is no GPU implementation.
-     *
-     *  The GPU device does not call SkShader::createContext(), instead we pass the view matrix,
-     *  local matrix, and filter quality directly.
-     *
-     *  The GrContext may be used by the to create textures that are required by the returned
-     *  processor.
-     *
-     *  The returned GrFragmentProcessor should expect an unpremultiplied input color and
-     *  produce a premultiplied output.
-     */
-    virtual sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const;
-#endif
-
-    /**
-     *  If the shader can represent its "average" luminance in a single color, return true and
-     *  if color is not NULL, return that color. If it cannot, return false and ignore the color
-     *  parameter.
-     *
-     *  Note: if this returns true, the returned color will always be opaque, as only the RGB
-     *  components are used to compute luminance.
-     */
-    bool asLuminanceColor(SkColor*) const;
-
-    /**
-     *  Returns a shader transformed into a new color space via the |xformer|.
-     */
-    sk_sp<SkShader> makeColorSpace(SkColorSpaceXformer* xformer) const {
-        return this->onMakeColorSpace(xformer);
-    }
-
-    /**
-     *  If this shader can be represented by another shader + a localMatrix, return that shader and
-     *  the localMatrix. If not, return nullptr and ignore the localMatrix parameter.
-     */
-    virtual sk_sp<SkShader> makeAsALocalMatrixShader(SkMatrix* localMatrix) const;
-
-    virtual bool isRasterPipelineOnly() const { return false; }
-
-    bool appendStages(SkRasterPipeline*, SkColorSpace* dstCS, SkArenaAlloc*,
-                      const SkMatrix& ctm, const SkPaint&, const SkMatrix* localM=nullptr) const;
-
-    bool computeTotalInverse(const SkMatrix& ctm,
-                             const SkMatrix* outerLocalMatrix,
-                             SkMatrix* totalInverse) const;
-
-#ifdef SK_SUPPORT_LEGACY_SHADER_ISABITMAP
-    virtual bool onIsABitmap(SkBitmap*, SkMatrix*, TileMode[2]) const {
-        return false;
-    }
-#endif
-
-    virtual SkImage* onIsAImage(SkMatrix*, TileMode[2]) const {
-        return nullptr;
-    }
-
-    SK_TO_STRING_VIRT()
-
-    SK_DEFINE_FLATTENABLE_TYPE(SkShaderBase)
-    SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
-
-protected:
-    void flatten(SkWriteBuffer&) const override;
-
-    /**
-     * Specialize creating a SkShader context using the supplied allocator.
-     * @return pointer to context owned by the arena allocator.
-     */
-    virtual Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const {
-        return nullptr;
-    }
-
-    virtual bool onAsLuminanceColor(SkColor*) const {
-        return false;
-    }
-
-    virtual sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer*) const {
-        return sk_ref_sp(const_cast<SkShaderBase*>(this));
-    }
-
-    virtual bool onAppendStages(SkRasterPipeline*, SkColorSpace* dstCS, SkArenaAlloc*,
-                                const SkMatrix&, const SkPaint&, const SkMatrix* localM) const;
-
-private:
-    // This is essentially const, but not officially so it can be modified in constructors.
-    SkMatrix fLocalMatrix;
-
-    typedef SkShader INHERITED;
-};
-
-inline SkShaderBase* as_SB(SkShader* shader) {
-    return static_cast<SkShaderBase*>(shader);
-}
-
-inline const SkShaderBase* as_SB(const SkShader* shader) {
-    return static_cast<const SkShaderBase*>(shader);
-}
-
-inline const SkShaderBase* as_SB(const sk_sp<SkShader>& shader) {
-    return static_cast<SkShaderBase*>(shader.get());
-}
-
-#endif // SkShaderBase_DEFINED
index c710b94..7bbbb79 100644 (file)
@@ -21,7 +21,7 @@ class SkArenaAlloc;
  When not using implicit distance, then b in the input color represents the input to the
  blur function.
  */
-class SkGaussianEdgeShaderImpl : public SkShaderBase {
+class SkGaussianEdgeShaderImpl : public SkShader {
 public:
     SkGaussianEdgeShaderImpl() {}
 
@@ -42,7 +42,7 @@ protected:
 private:
     friend class SkGaussianEdgeShader;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 ////////////////////////////////////////////////////////////////////////////
index f0554dd..ef54ece 100644 (file)
@@ -8,7 +8,7 @@
 #ifndef SkGaussianEdgeShader_DEFINED
 #define SkGaussianEdgeShader_DEFINED
 
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
 class SK_API SkGaussianEdgeShader {
 public:
index 87f8967..f2877cf 100644 (file)
@@ -10,7 +10,7 @@
 #include "SkArenaAlloc.h"
 #include "SkColorFilter.h"
 #include "SkReadBuffer.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkString.h"
 #include "SkUnPreMultiply.h"
 #include "SkWriteBuffer.h"
@@ -50,7 +50,7 @@ inline SkScalar smoothCurve(SkScalar t) {
     return t * t * (3 - 2 * t);
 }
 
-class SkPerlinNoiseShaderImpl final : public SkShaderBase {
+class SkPerlinNoiseShaderImpl final : public SkShader {
 public:
     /**
      *  About the noise types : the difference between the 2 is just minor tweaks to the algorithm,
@@ -87,7 +87,7 @@ protected:
     Context* onMakeContext(const ContextRec&, SkArenaAlloc* storage) const override;
 
 private:
-    class PerlinNoiseShaderContext final : public Context {
+    class PerlinNoiseShaderContext final : public SkShader::Context {
     public:
         PerlinNoiseShaderContext(const SkPerlinNoiseShaderImpl& shader, const ContextRec&);
         ~PerlinNoiseShaderContext() override;
@@ -105,7 +105,7 @@ private:
         SkMatrix fMatrix;
         PaintingData* fPaintingData;
 
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
     const Type     fType;
@@ -118,7 +118,7 @@ private:
 
     friend class ::SkPerlinNoiseShader;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 } // end namespace
@@ -503,7 +503,7 @@ SkPMColor SkPerlinNoiseShaderImpl::PerlinNoiseShaderContext::shade(
     return SkPreMultiplyARGB(rgba[3], rgba[0], rgba[1], rgba[2]);
 }
 
-SkShaderBase::Context* SkPerlinNoiseShaderImpl::onMakeContext(
+SkShader::Context* SkPerlinNoiseShaderImpl::onMakeContext(
     const ContextRec& rec, SkArenaAlloc* alloc) const {
     return alloc->make<PerlinNoiseShaderContext>(*this, rec);
 }
@@ -658,7 +658,7 @@ sk_sp<GrFragmentProcessor> GrPerlinNoiseEffect::TestCreate(GrProcessorTestData*
                                             stitchTiles ? &tileSize : nullptr));
 
     GrTest::TestAsFPArgs asFPArgs(d);
-    return as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    return shader->asFragmentProcessor(asFPArgs.args());
 }
 #endif
 
index a660d6b..9209a90 100644 (file)
@@ -14,7 +14,7 @@
 #include "SkMatrix.h"
 #include "SkNx.h"
 #include "SkPM4f.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkTArray.h"
 
 struct Sk4fGradientInterval {
@@ -53,7 +53,7 @@ private:
 };
 
 class SkGradientShaderBase::
-GradientShaderBase4fContext : public Context {
+GradientShaderBase4fContext : public SkShader::Context {
 public:
     GradientShaderBase4fContext(const SkGradientShaderBase&,
                                 const ContextRec&);
@@ -77,7 +77,7 @@ protected:
     bool                       fColorsArePremul;
 
 private:
-    using INHERITED = Context;
+    using INHERITED = SkShader::Context;
 
     void addMirrorIntervals(const SkGradientShaderBase&,
                             const Sk4f& componentScale, bool reverse);
index 137da84..5a4a31c 100644 (file)
@@ -582,7 +582,7 @@ SkGradientShaderBase::GradientShaderBaseContext::GradientShaderBaseContext(
     fDstToIndex.setConcat(shader.fPtsToUnit, inverse);
 
     fDstToIndexProc = fDstToIndex.getMapXYProc();
-    fDstToIndexClass = (uint8_t)SkShaderBase::Context::ComputeMatrixClass(fDstToIndex);
+    fDstToIndexClass = (uint8_t)SkShader::Context::ComputeMatrixClass(fDstToIndex);
 
     // now convert our colors in to PMColors
     unsigned paintAlpha = this->getPaintAlpha();
index 7a66eda..8c188de 100644 (file)
@@ -20,7 +20,7 @@
 #include "SkPM4fPriv.h"
 #include "SkRasterPipeline.h"
 #include "SkReadBuffer.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkUtils.h"
 #include "SkWriteBuffer.h"
 
@@ -79,7 +79,7 @@ static const TileProc gTileProcs[] = {
 
 ///////////////////////////////////////////////////////////////////////////////
 
-class SkGradientShaderBase : public SkShaderBase {
+class SkGradientShaderBase : public SkShader {
 public:
     struct Descriptor {
         Descriptor() {
@@ -156,7 +156,7 @@ public:
                                     U8CPU alpha, uint32_t gradFlags, bool dither);
     };
 
-    class GradientShaderBaseContext : public Context {
+    class GradientShaderBaseContext : public SkShader::Context {
     public:
         GradientShaderBaseContext(const SkGradientShaderBase& shader, const ContextRec&);
 
@@ -174,7 +174,7 @@ public:
         sk_sp<GradientShaderCache> fCache;
 
     private:
-        typedef Context INHERITED;
+        typedef SkShader::Context INHERITED;
     };
 
     bool isOpaque() const override;
@@ -283,7 +283,7 @@ private:
 
     void initCommon();
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 
index 17c4fd3..bd46452 100644 (file)
@@ -39,11 +39,11 @@ static SkMatrix pts_to_unit_matrix(const SkPoint pts[2]) {
     return matrix;
 }
 
-static bool use_4f_context(const SkShaderBase::ContextRec& rec, uint32_t flags) {
+static bool use_4f_context(const SkShader::ContextRec& rec, uint32_t flags) {
 #ifdef FORCE_4F_CONTEXT
     return true;
 #else
-    return rec.fPreferredDstType == SkShaderBase::ContextRec::kPM4f_DstType
+    return rec.fPreferredDstType == SkShader::ContextRec::kPM4f_DstType
         || SkToBool(flags & SkLinearGradient::kForce4fContext_PrivateFlag);
 #endif
 }
@@ -75,7 +75,7 @@ void SkLinearGradient::flatten(SkWriteBuffer& buffer) const {
     buffer.writePoint(fEnd);
 }
 
-SkShaderBase::Context* SkLinearGradient::onMakeContext(
+SkShader::Context* SkLinearGradient::onMakeContext(
     const ContextRec& rec, SkArenaAlloc* alloc) const
 {
     return use_4f_context(rec, fGradFlags)
@@ -436,7 +436,7 @@ sk_sp<GrFragmentProcessor> GrLinearGradient::TestCreate(GrProcessorTestData* d)
         SkGradientShader::MakeLinear(points, params.fColors, params.fStops,
                                      params.fColorCount, params.fTileMode);
     GrTest::TestAsFPArgs asFPArgs(d);
-    sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args());
     GrAlwaysAssert(fp);
     return fp;
 }
index d49b3dd..339c5ff 100644 (file)
@@ -40,7 +40,7 @@ SkRadialGradient::SkRadialGradient(const SkPoint& center, SkScalar radius, const
     , fRadius(radius) {
 }
 
-SkShaderBase::Context* SkRadialGradient::onMakeContext(
+SkShader::Context* SkRadialGradient::onMakeContext(
     const ContextRec& rec, SkArenaAlloc* alloc) const
 {
     return CheckedMakeContext<RadialGradientContext>(alloc, *this, rec);
@@ -318,7 +318,7 @@ sk_sp<GrFragmentProcessor> GrRadialGradient::TestCreate(GrProcessorTestData* d)
                                                         params.fTileMode);
     } while (!shader);
     GrTest::TestAsFPArgs asFPArgs(d);
-    sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args());
     GrAlwaysAssert(fp);
     return fp;
 }
index 1e583c2..66913c6 100644 (file)
@@ -52,7 +52,7 @@ void SkSweepGradient::flatten(SkWriteBuffer& buffer) const {
     buffer.writePoint(fCenter);
 }
 
-SkShaderBase::Context* SkSweepGradient::onMakeContext(
+SkShader::Context* SkSweepGradient::onMakeContext(
     const ContextRec& rec, SkArenaAlloc* alloc) const
 {
     return CheckedMakeContext<SweepGradientContext>(alloc, *this, rec);
@@ -210,7 +210,7 @@ sk_sp<GrFragmentProcessor> GrSweepGradient::TestCreate(GrProcessorTestData* d) {
         SkGradientShader::MakeSweep(center.fX, center.fY,  params.fColors,
                                     params.fStops, params.fColorCount);
     GrTest::TestAsFPArgs asFPArgs(d);
-    sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args());
     GrAlwaysAssert(fp);
     return fp;
 }
index 4549527..ced299e 100644 (file)
@@ -210,7 +210,7 @@ bool SkTwoPointConicalGradient::isOpaque() const {
     return false;
 }
 
-SkShaderBase::Context* SkTwoPointConicalGradient::onMakeContext(
+SkShader::Context* SkTwoPointConicalGradient::onMakeContext(
     const ContextRec& rec, SkArenaAlloc* alloc) const {
     return CheckedMakeContext<TwoPointConicalGradientContext>(alloc, *this, rec);
 }
index 8402199..fedb445 100644 (file)
@@ -207,7 +207,7 @@ sk_sp<GrFragmentProcessor> Edge2PtConicalEffect::TestCreate(GrProcessorTestData*
                                               params.fColors, params.fStops,
                                               params.fColorCount, params.fTileMode);
     GrTest::TestAsFPArgs asFPArgs(d);
-    sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args());
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -486,7 +486,7 @@ sk_sp<GrFragmentProcessor> FocalOutside2PtConicalEffect::TestCreate(GrProcessorT
                                               params.fColors, params.fStops,
                                               params.fColorCount, params.fTileMode);
     GrTest::TestAsFPArgs asFPArgs(d);
-    sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args());
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -690,7 +690,7 @@ sk_sp<GrFragmentProcessor> FocalInside2PtConicalEffect::TestCreate(GrProcessorTe
                                               params.fColors, params.fStops,
                                               params.fColorCount, params.fTileMode);
     GrTest::TestAsFPArgs asFPArgs(d);
-    sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args());
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -936,7 +936,7 @@ sk_sp<GrFragmentProcessor> CircleInside2PtConicalEffect::TestCreate(GrProcessorT
                                               params.fColors, params.fStops,
                                               params.fColorCount, params.fTileMode);
     GrTest::TestAsFPArgs asFPArgs(d);
-    sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args());
     GrAlwaysAssert(fp);
     return fp;
 }
@@ -1170,7 +1170,7 @@ sk_sp<GrFragmentProcessor> CircleOutside2PtConicalEffect::TestCreate(GrProcessor
                                               params.fColors, params.fStops,
                                               params.fColorCount, params.fTileMode);
     GrTest::TestAsFPArgs asFPArgs(d);
-    sk_sp<GrFragmentProcessor> fp = as_SB(shader)->asFragmentProcessor(asFPArgs.args());
+    sk_sp<GrFragmentProcessor> fp = shader->asFragmentProcessor(asFPArgs.args());
     GrAlwaysAssert(fp);
     return fp;
 }
index fd9398d..5bb1cc1 100644 (file)
@@ -16,7 +16,7 @@
 #include "GrColorSpaceXform.h"
 #include "SkPathEffect.h"
 #include "SkRandom.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 #include "SkStrokeRec.h"
 #include "../private/SkTemplates.h"
 
@@ -50,10 +50,10 @@ sk_sp<GrColorSpaceXform> TestColorXform(SkRandom*);
 class TestAsFPArgs {
 public:
     TestAsFPArgs(GrProcessorTestData*);
-    const SkShaderBase::AsFPArgs& args() const { return fArgs; }
+    const SkShader::AsFPArgs& args() const { return fArgs; }
 
 private:
-    SkShaderBase::AsFPArgs fArgs;
+    SkShader::AsFPArgs fArgs;
     SkMatrix fViewMatrixStorage;
     sk_sp<SkColorSpace> fColorSpaceStorage;
 };
index fd9be57..81fde35 100644 (file)
@@ -30,7 +30,6 @@
 #include "SkPM4fPriv.h"
 #include "SkPixelRef.h"
 #include "SkResourceCache.h"
-#include "SkShaderBase.h"
 #include "SkTemplates.h"
 #include "effects/GrBicubicEffect.h"
 #include "effects/GrConstColorProcessor.h"
@@ -425,10 +424,10 @@ static inline bool skpaint_to_grpaint_impl(GrContext* context,
     if (!primColorMode || blend_requires_shader(*primColorMode)) {
         if (shaderProcessor) {
             shaderFP = *shaderProcessor;
-        } else if (const auto* shader = as_SB(skPaint.getShader())) {
-            shaderFP = shader->asFragmentProcessor(
-                SkShaderBase::AsFPArgs(context, &viewM, nullptr, skPaint.getFilterQuality(),
-                                       rtc->getColorSpace()));
+        } else if (const SkShader* shader = skPaint.getShader()) {
+            shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context, &viewM, nullptr,
+                                                                      skPaint.getFilterQuality(),
+                                                                      rtc->getColorSpace()));
             if (!shaderFP) {
                 return false;
             }
@@ -600,10 +599,12 @@ bool SkPaintToGrPaintWithTexture(GrContext* context,
                                  GrPaint* grPaint) {
     sk_sp<GrFragmentProcessor> shaderFP;
     if (textureIsAlphaOnly) {
-        if (const auto* shader = as_SB(paint.getShader())) {
-            shaderFP = shader->asFragmentProcessor(
-                SkShaderBase::AsFPArgs(context, &viewM, nullptr, paint.getFilterQuality(),
-                                       rtc->getColorSpace()));
+        if (const SkShader* shader = paint.getShader()) {
+            shaderFP = shader->asFragmentProcessor(SkShader::AsFPArgs(context,
+                                                                      &viewM,
+                                                                      nullptr,
+                                                                      paint.getFilterQuality(),
+                                                                      rtc->getColorSpace()));
             if (!shaderFP) {
                 return false;
             }
index 751300e..0dbf944 100644 (file)
@@ -48,8 +48,7 @@ bool SkImageShader::isOpaque() const {
     return fImage->isOpaque();
 }
 
-SkShaderBase::Context* SkImageShader::onMakeContext(const ContextRec& rec,
-                                                    SkArenaAlloc* alloc) const {
+SkShader::Context* SkImageShader::onMakeContext(const ContextRec& rec, SkArenaAlloc* alloc) const {
     return SkBitmapProcLegacyShader::MakeContext(*this, fTileModeX, fTileModeY,
                                                  SkBitmapProvider(fImage.get(), rec.fDstColorSpace),
                                                  rec, alloc);
@@ -205,9 +204,9 @@ static sk_sp<SkFlattenable> SkBitmapProcShader_CreateProc(SkReadBuffer& buffer)
     return image ? image->makeShader(mx, my, &lm) : nullptr;
 }
 
-SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkShaderBase)
+SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_START(SkShader)
 SK_DEFINE_FLATTENABLE_REGISTRAR_ENTRY(SkImageShader)
-SkFlattenable::Register("SkBitmapProcShader", SkBitmapProcShader_CreateProc, kSkShaderBase_Type);
+SkFlattenable::Register("SkBitmapProcShader", SkBitmapProcShader_CreateProc, kSkShader_Type);
 SK_DEFINE_FLATTENABLE_REGISTRAR_GROUP_END
 
 
index 7be982c..5274826 100644 (file)
@@ -11,9 +11,9 @@
 #include "SkBitmapProcShader.h"
 #include "SkColorSpaceXformer.h"
 #include "SkImage.h"
-#include "SkShaderBase.h"
+#include "SkShader.h"
 
-class SkImageShader : public SkShaderBase {
+class SkImageShader : public SkShader {
 public:
     static sk_sp<SkShader> Make(sk_sp<SkImage>, TileMode tx, TileMode ty,
                                 const SkMatrix* localMatrix);
@@ -50,9 +50,9 @@ protected:
     const TileMode  fTileModeY;
 
 private:
-    friend class SkShaderBase;
+    friend class SkShader;
 
-    typedef SkShaderBase INHERITED;
+    typedef SkShader INHERITED;
 };
 
 #endif
index 1212833..bb49df0 100644 (file)
@@ -18,7 +18,6 @@
 #include "SkNormalSource.h"
 #include "SkOSFile.h"
 #include "SkPictureRecorder.h"
-#include "SkShaderBase.h"
 #include "SkTableColorFilter.h"
 #include "SkTemplates.h"
 #include "SkTypeface.h"
@@ -611,22 +610,22 @@ DEF_TEST(Serialization, reporter) {
         sk_sp<SkShader> lightingShader = SkLightingShader::Make(diffuseShader,
                                                                 normalSource,
                                                                 fLights);
-        sk_sp<SkShader>(TestFlattenableSerialization(as_SB(lightingShader.get()), true, reporter));
+        sk_sp<SkShader>(TestFlattenableSerialization(lightingShader.get(), true, reporter));
 
         lightingShader = SkLightingShader::Make(std::move(diffuseShader),
                                                 nullptr,
                                                 fLights);
-        sk_sp<SkShader>(TestFlattenableSerialization(as_SB(lightingShader.get()), true, reporter));
+        sk_sp<SkShader>(TestFlattenableSerialization(lightingShader.get(), true, reporter));
 
         lightingShader = SkLightingShader::Make(nullptr,
                                                 std::move(normalSource),
                                                 fLights);
-        sk_sp<SkShader>(TestFlattenableSerialization(as_SB(lightingShader.get()), true, reporter));
+        sk_sp<SkShader>(TestFlattenableSerialization(lightingShader.get(), true, reporter));
 
         lightingShader = SkLightingShader::Make(nullptr,
                                                 nullptr,
                                                 fLights);
-        sk_sp<SkShader>(TestFlattenableSerialization(as_SB(lightingShader.get()), true, reporter));
+        sk_sp<SkShader>(TestFlattenableSerialization(lightingShader.get(), true, reporter));
     }
 
     // Test NormalBevelSource serialization
index f799bd7..79385af 100644 (file)
@@ -13,7 +13,6 @@
 #include "GrClip.h"
 #include "GrContext.h"
 #include "SkGradientShader.h"
-#include "SkShaderBase.h"
 #include "ops/GrTessellatingPathRenderer.h"
 
 /*
@@ -280,9 +279,9 @@ static sk_sp<GrFragmentProcessor> create_linear_gradient_processor(GrContext* ct
     SkColor colors[2] = { SK_ColorGREEN, SK_ColorBLUE };
     sk_sp<SkShader> shader = SkGradientShader::MakeLinear(
         pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkShader::kClamp_TileMode);
-    SkShaderBase::AsFPArgs args(
+    SkShader::AsFPArgs args(
         ctx, &SkMatrix::I(), &SkMatrix::I(), SkFilterQuality::kLow_SkFilterQuality, nullptr);
-    return as_SB(shader)->asFragmentProcessor(args);
+    return shader->asFragmentProcessor(args);
 }
 
 static void test_path(GrContext* ctx,