8 #ifndef SkShader_DEFINED
9 #define SkShader_DEFINED
12 #include "SkFlattenable.h"
13 #include "SkImageInfo.h"
17 #include "../gpu/GrColor.h"
72 kTileModeCount = kMirror_TileMode + 1
79 kOpaqueAlpha_Flag = 1 << 0,
86 kConstInY32_Flag = 1 << 1,
90 kPrefers4f_Flag = 1 << 2,
99 virtual bool isOpaque()
const {
return false; }
114 , fLocalMatrix(localM)
115 , fPreferredDstType(dstType) {}
120 const DstType fPreferredDstType;
143 virtual void shadeSpan(
int x,
int y,
SkPMColor[],
int count) = 0;
145 virtual void shadeSpan4f(
int x,
int y, SkPM4f[],
int count);
148 typedef void (*BlitBW)(BlitState*,
149 int x,
int y,
const SkPixmap&,
int count);
150 typedef void (*BlitAA)(BlitState*,
167 state->fBlitBW =
nullptr;
168 state->fBlitAA =
nullptr;
169 if (this->onChooseBlitProcs(info, state)) {
170 SkASSERT(state->fBlitBW || state->fBlitAA);
180 typedef void (*ShadeProc)(
const void* ctx,
int x,
int y,
SkPMColor[],
int count);
181 virtual ShadeProc asAShadeProc(
void** ctx);
188 virtual void shadeSpanAlpha(
int x,
int y, uint8_t alpha[],
int count);
191 virtual void set3DMask(
const SkMask*) {}
199 kFixedStepInX_MatrixClass,
201 kPerspective_MatrixClass
203 static MatrixClass ComputeMatrixClass(
const SkMatrix&);
205 uint8_t getPaintAlpha()
const {
return fPaintAlpha; }
206 const SkMatrix& getTotalInverse()
const {
return fTotalInverse; }
207 MatrixClass getInverseClass()
const {
return (MatrixClass)fTotalInverseClass; }
208 const SkMatrix& getCTM()
const {
return fCTM; }
210 virtual bool onChooseBlitProcs(
const SkImageInfo&, BlitState*) {
return false; }
216 uint8_t fTotalInverseClass;
218 typedef SkNoncopyable INHERITED;
225 Context* createContext(
const ContextRec&,
void* storage)
const;
230 size_t contextSize(
const ContextRec&)
const;
238 return this->onIsABitmap(outTexture, outMatrix, xy);
241 bool isABitmap()
const {
242 return this->isABitmap(
nullptr,
nullptr,
nullptr);
250 return this->onIsAImage(localMatrix, xy);
253 bool isAImage()
const {
254 return this->isAImage(
nullptr,
nullptr) !=
nullptr;
289 kLinear_GradientType,
290 kRadial_GradientType,
292 kConical_GradientType,
293 kLast_GradientType = kConical_GradientType
324 virtual bool asACompose(
ComposeRec*)
const {
return false; }
331 SkFilterQuality filterQuality,
333 SkSourceGammaTreatment gammaTreatment)
335 , fViewMatrix(viewMatrix)
336 , fLocalMatrix(localMatrix)
337 , fFilterQuality(filterQuality)
338 , fDstColorSpace(dstColorSpace)
339 , fGammaTreatment(gammaTreatment) {}
344 SkFilterQuality fFilterQuality;
346 SkSourceGammaTreatment fGammaTreatment;
373 bool asLuminanceColor(
SkColor*)
const;
375 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
380 virtual bool asACustomShader(
void** )
const {
return false; }
423 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
424 static SkShader* CreateEmptyShader() {
return MakeEmptyShader().release(); }
425 static SkShader* CreateColorShader(
SkColor c) {
return MakeColorShader(c).release(); }
426 static SkShader* CreateBitmapShader(
const SkBitmap& src, TileMode tmx, TileMode tmy,
427 const SkMatrix* localMatrix =
nullptr) {
428 return MakeBitmapShader(src, tmx, tmy, localMatrix).release();
432 static SkShader* CreatePictureShader(
const SkPicture* src, TileMode tmx, TileMode tmy,
436 return this->makeWithLocalMatrix(matrix).release();
450 #ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR
470 const SkMatrix* localMatrix =
nullptr);
501 SK_DEFINE_FLATTENABLE_TYPE(
SkShader)
502 SK_DECLARE_FLATTENABLE_REGISTRAR_GROUP()
507 bool computeTotalInverse(const ContextRec&,
SkMatrix* totalInverse) const;
513 virtual Context* onCreateContext(const ContextRec&,
void* storage) const;
519 virtual
size_t onContextSize(const ContextRec&) const;
521 virtual
bool onAsLuminanceColor(
SkColor*)
const {
539 friend class SkLocalMatrixShader;
540 friend class SkBitmapProcLegacyShader;
Flags
Definition: SkShader.h:77
If the shader subclass is composed of two shaders, return true, and if rec is not NULL...
Definition: SkShader.h:318
TileMode fTileMode
The tile mode used.
Definition: SkShader.h:305
Provides custom fragment shader code.
Definition: GrFragmentProcessor.h:24
Definition: SkColorSpace.h:16
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:27
Describe an image's dimensions and pixel type.
Definition: SkImageInfo.h:181
SkImage * isAImage(SkMatrix *localMatrix, TileMode xy[2]) const
Iff this shader is backed by a single SkImage, return its ptr (the caller must ref this if they want ...
Definition: SkShader.h:249
Mode
List of predefined xfermodes.
Definition: SkXfermode.h:71
Definition: SkShader.h:327
Shaders specify the source color(s) for what is being drawn.
Definition: SkShader.h:38
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:29
Pairs SkImageInfo with actual pixels and rowbytes.
Definition: SkPixmap.h:23
Definition: SkPoint.h:156
SkColor * fColors
The colors in the gradient.
Definition: SkShader.h:301
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
const SkMatrix & getLocalMatrix() const
Returns the local matrix.
Definition: SkShader.h:49
virtual bool isOpaque() const
Returns true if the shader is guaranteed to produce only opaque colors, subject to the SkPaint using ...
Definition: SkShader.h:99
uint8_t SkAlpha
8-bit type for an alpha value.
Definition: SkColor.h:22
uint32_t fGradientFlags
see SkGradientShader::Flags
Definition: SkShader.h:306
The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
Definition: SkPaint.h:46
Definition: SkColor.h:169
An SkPicture records drawing commands made to a canvas to be played back at a later time...
Definition: SkPicture.h:38
SkMask is used to describe alpha bitmaps, either 1bit, 8bit, or the 3-channel 3D format.
Definition: SkMask.h:19
SkXfermode is the base class for objects that are called to implement custom "transfer-modes" in the ...
Definition: SkXfermode.h:34
SkFlattenable is the base class for objects that need to be flattened into a data stream for either t...
Definition: SkFlattenable.h:70
The SkBitmap class specifies a raster bitmap.
Definition: SkBitmap.h:41
Shared pointer class to wrap classes that support a ref()/unref() interface.
Definition: SkRefCnt.h:258
Definition: GrContext.h:48
virtual uint32_t getFlags() const
Called sometimes before drawing with this shader.
Definition: SkShader.h:136
uint32_t SkPMColor
32 bit ARGB color value, premultiplied.
Definition: SkColor.h:147
SkScalar * fColorOffsets
The unit offset for color transitions.
Definition: SkShader.h:302
uint32_t SkColor
32 bit ARGB color value, not premultiplied.
Definition: SkColor.h:28
Definition: SkShader.h:123
int fColorCount
In-out parameter, specifies passed size.
Definition: SkShader.h:297
GradientType
If the shader subclass can be represented as a gradient, asAGradient returns the matching GradientTyp...
Definition: SkShader.h:286
Definition: SkWriteBuffer.h:26
TileMode
Definition: SkShader.h:51
replicate the edge color if the shader draws outside of its original bounds
Definition: SkShader.h:55
ContextRec acts as a parameter bundle for creating Contexts.
Definition: SkShader.h:104
Definition: SkShader.h:296
Definition: SkShader.h:153
repeat the shader's image horizontally and vertically
Definition: SkShader.h:58
SkImage is an abstraction for drawing a rectagle of pixels, though the particular type of image could...
Definition: SkImage.h:45
repeat the shader's image horizontally and vertically, alternating mirror images so that adjacent ima...
Definition: SkShader.h:63
bool isABitmap(SkBitmap *outTexture, SkMatrix *outMatrix, TileMode xy[2]) const
Returns true if this shader is just a bitmap, and if not null, returns the bitmap, localMatrix, and tilemodes.
Definition: SkShader.h:237