#include "SkBitmapProcShader.h"
#include "SkCanvas.h"
-#include "SkComposeShader.h"
#include "SkGradientShader.h"
#include "SkGraphics.h"
#include "SkShader.h"
SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(mode));
- return new SkComposeShader(shaderA, shaderB, xfer);
+ return SkShader::CreateComposeShader(shaderA, shaderB, xfer);
}
class ComposeShaderGM : public skiagm::GM {
SkAutoTUnref<SkXfermode> xfer(SkXfermode::Create(SkXfermode::kDstOver_Mode));
// gradient should appear over color bitmap
- SkAutoTUnref<SkShader> shader0(new SkComposeShader(fLinearGradientShader,
+ SkAutoTUnref<SkShader> shader0(SkShader::CreateComposeShader(fLinearGradientShader,
fColorBitmapShader,
xfer));
// gradient should appear over alpha8 bitmap colorized by the paint color
- SkAutoTUnref<SkShader> shader1(new SkComposeShader(fLinearGradientShader,
+ SkAutoTUnref<SkShader> shader1(SkShader::CreateComposeShader(fLinearGradientShader,
fAlpha8BitmapShader,
xfer));
}
private:
- /** This determines the length and width of the bitmaps used in the SkComposeShaders. Values
+ /** This determines the length and width of the bitmaps used in the ComposeShaders. Values
* above 20 may cause an SkASSERT to fail in SkSmallAllocator. However, larger values will
* work in a release build. You can change this parameter and then compile a release build
* to have this GM draw larger bitmaps for easier visual inspection.
'<(skia_include_path)/core/SkColor.h',
'<(skia_include_path)/core/SkColorFilter.h',
'<(skia_include_path)/core/SkColorPriv.h',
- '<(skia_include_path)/core/SkComposeShader.h',
'<(skia_include_path)/core/SkData.h',
'<(skia_include_path)/core/SkDeque.h',
'<(skia_include_path)/core/SkDevice.h',
+++ /dev/null
-
-/*
- * Copyright 2006 The Android Open Source Project
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-
-#ifndef SkComposeShader_DEFINED
-#define SkComposeShader_DEFINED
-
-#include "SkShader.h"
-
-class SkXfermode;
-
-///////////////////////////////////////////////////////////////////////////////////////////
-
-/** \class SkComposeShader
- This subclass of shader returns the composition of two other shaders, combined by
- a xfermode.
-*/
-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
- "dst", and the result from shader B as its "src".
- mode->xfer32(sA_result, sB_result, ...)
- @param shaderA The colors from this shader are seen as the "dst" by the xfermode
- @param shaderB The colors from this shader are seen as the "src" by the xfermode
- @param mode The xfermode that combines the colors from the two shaders. If mode
- is null, then SRC_OVER is assumed.
- */
- SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL);
- virtual ~SkComposeShader();
-
- size_t contextSize() const override;
-
-#if SK_SUPPORT_GPU
- const GrFragmentProcessor* asFragmentProcessor(GrContext*,
- const SkMatrix& viewM,
- const SkMatrix* localMatrix,
- SkFilterQuality) const override;
-#endif
-
- 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&,
- SkShader::Context* contextA, SkShader::Context* contextB);
-
- SkShader::Context* getShaderContextA() const { return fShaderContextA; }
- SkShader::Context* getShaderContextB() const { return fShaderContextB; }
-
- virtual ~ComposeShaderContext();
-
- void shadeSpan(int x, int y, SkPMColor[], int count) override;
-
- private:
- SkShader::Context* fShaderContextA;
- SkShader::Context* fShaderContextB;
-
- typedef SkShader::Context INHERITED;
- };
-
-#ifdef SK_DEBUG
- SkShader* getShaderA() { return fShaderA; }
- SkShader* getShaderB() { return fShaderB; }
-#endif
-
- bool asACompose(ComposeRec* rec) const override;
-
- SK_TO_STRING_OVERRIDE()
- SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
-
-protected:
- SkComposeShader(SkReadBuffer& );
- void flatten(SkWriteBuffer&) const override;
- Context* onCreateContext(const ContextRec&, void*) const override;
-
-private:
- SkShader* fShaderA;
- SkShader* fShaderB;
- SkXfermode* fMode;
-
- typedef SkShader INHERITED;
-};
-
-#endif
#include "SkGradientShader.h"
#include "SkPatchUtils.h"
#include "SkPerlinNoiseShader2/SkPerlinNoiseShader2.h"
-#include "SkComposeShader.h"
static void draw_control_points(SkCanvas* canvas, const SkPoint cubics[12]) {
//draw control points
SkScalar scaleFreq = 2.0;
fShader1 = SkPerlinNoiseShader2::CreateImprovedNoise(fXFreq/scaleFreq, fYFreq/scaleFreq, 4,
fSeed);
- fShaderCompose = new SkComposeShader(fShader0, fShader1);
+ fShaderCompose = SkShader::CreateComposeShader(fShader0, fShader1, nullptr);
paint.setShader(fShaderCompose);
canvas->drawPatch(fPts, nullptr, texCoords, xfer, paint);
#include "SkPictureRecorder.h"
#include "SkRegion.h"
#include "SkShader.h"
-#include "SkComposeShader.h"
#include "SkCornerPathEffect.h"
#include "SkPathMeasure.h"
#include "SkPicture.h"
SkShader* shaderB = SkGradientShader::CreateLinear(pts, colors2, nullptr,
2, SkShader::kClamp_TileMode);
SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode);
- SkShader* result = new SkComposeShader(shaderA, shaderB, mode);
+ SkShader* result = SkShader::CreateComposeShader(shaderA, shaderB, mode);
shaderA->unref();
shaderB->unref();
mode->unref();
#include "SkRegion.h"
#include "SkShader.h"
#include "SkUtils.h"
-#include "SkComposeShader.h"
#include "Sk1DPathEffect.h"
#include "SkCornerPathEffect.h"
#include "SkPathMeasure.h"
#include "SkShader.h"
#include "SkUtils.h"
#include "SkXfermode.h"
-#include "SkComposeShader.h"
#include "SkColorPriv.h"
#include "SkColorFilter.h"
#include "SkTime.h"
SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode);
- SkShader* shader = new SkComposeShader(shaderB, shaderA, mode);
+ SkShader* shader = SkShader::CreateComposeShader(shaderB, shaderA, mode);
shaderA->unref();
shaderB->unref();
mode->unref();
SkXfermode* mode = SkXfermode::Create(SkXfermode::kDstIn_Mode);
- fShader = new SkComposeShader(shaderA, shaderB, mode);
+ fShader = SkShader::CreateComposeShader(shaderA, shaderB, mode);
shaderA->unref();
shaderB->unref();
mode->unref();
-
/*
* Copyright 2006 The Android Open Source Project
*
* found in the LICENSE file.
*/
-
#include "SkComposeShader.h"
#include "SkColorFilter.h"
#include "SkColorPriv.h"
--- /dev/null
+
+/*
+ * Copyright 2006 The Android Open Source Project
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+
+#ifndef SkComposeShader_DEFINED
+#define SkComposeShader_DEFINED
+
+#include "SkShader.h"
+
+class SkXfermode;
+
+///////////////////////////////////////////////////////////////////////////////////////////
+
+/** \class SkComposeShader
+ This subclass of shader returns the composition of two other shaders, combined by
+ a xfermode.
+*/
+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
+ "dst", and the result from shader B as its "src".
+ mode->xfer32(sA_result, sB_result, ...)
+ @param shaderA The colors from this shader are seen as the "dst" by the xfermode
+ @param shaderB The colors from this shader are seen as the "src" by the xfermode
+ @param mode The xfermode that combines the colors from the two shaders. If mode
+ is null, then SRC_OVER is assumed.
+ */
+ SkComposeShader(SkShader* sA, SkShader* sB, SkXfermode* mode = NULL);
+ virtual ~SkComposeShader();
+
+ size_t contextSize() const override;
+
+#if SK_SUPPORT_GPU
+ const GrFragmentProcessor* asFragmentProcessor(GrContext*,
+ const SkMatrix& viewM,
+ const SkMatrix* localMatrix,
+ SkFilterQuality) const override;
+#endif
+
+ 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&,
+ SkShader::Context* contextA, SkShader::Context* contextB);
+
+ SkShader::Context* getShaderContextA() const { return fShaderContextA; }
+ SkShader::Context* getShaderContextB() const { return fShaderContextB; }
+
+ virtual ~ComposeShaderContext();
+
+ void shadeSpan(int x, int y, SkPMColor[], int count) override;
+
+ private:
+ SkShader::Context* fShaderContextA;
+ SkShader::Context* fShaderContextB;
+
+ typedef SkShader::Context INHERITED;
+ };
+
+#ifdef SK_DEBUG
+ SkShader* getShaderA() { return fShaderA; }
+ SkShader* getShaderB() { return fShaderB; }
+#endif
+
+ bool asACompose(ComposeRec* rec) const override;
+
+ SK_TO_STRING_OVERRIDE()
+ SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkComposeShader)
+
+protected:
+ SkComposeShader(SkReadBuffer& );
+ void flatten(SkWriteBuffer&) const override;
+ Context* onCreateContext(const ContextRec&, void*) const override;
+
+private:
+ SkShader* fShaderA;
+ SkShader* fShaderB;
+ SkXfermode* fMode;
+
+ typedef SkShader INHERITED;
+};
+
+#endif