Skia
2D Graphics Library
SkShader.h
Go to the documentation of this file.
1 /*
2  * Copyright 2006 The Android Open Source Project
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #ifndef SkShader_DEFINED
9 #define SkShader_DEFINED
10 
12 #include "include/core/SkColor.h"
16 #include "include/core/SkMatrix.h"
18 
19 class SkArenaAlloc;
20 class SkBitmap;
21 class SkColorFilter;
22 class SkColorSpace;
23 class SkImage;
24 class SkPath;
25 class SkPicture;
26 class SkRasterPipeline;
27 class GrFragmentProcessor;
28 
39 class SK_API SkShader : public SkFlattenable {
40 public:
47  virtual bool isOpaque() const { return false; }
48 
53  SkImage* isAImage(SkMatrix* localMatrix, SkTileMode xy[2]) const;
54 
55  bool isAImage() const {
56  return this->isAImage(nullptr, (SkTileMode*)nullptr) != nullptr;
57  }
58 
88  enum GradientType {
95  kLast_GradientType = kConical_GradientType,
96  };
97 
98  struct GradientInfo {
100  // of fColors/fColorOffsets on input, and
101  // actual number of colors/offsets on
102  // output.
105  SkPoint fPoint[2];
106  SkScalar fRadius[2];
108  uint32_t fGradientFlags;
109  };
110 
111  // DEPRECATED. skbug.com/8941
112  virtual GradientType asAGradient(GradientInfo* info) const;
113 
115  // Methods to create combinations or variants of shaders
116 
122 
128 
129 private:
130  SkShader() = default;
131  friend class SkShaderBase;
132 
133  using INHERITED = SkFlattenable;
134 };
135 
137 public:
143 
144 private:
145  SkShaders() = delete;
146 };
147 
148 #endif
SkShader::GradientInfo::fColors
SkColor * fColors
The colors in the gradient.
Definition: SkShader.h:103
SkShader::GradientInfo::fTileMode
SkTileMode fTileMode
Definition: SkShader.h:107
SkFlattenable.h
SkColorFilter
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:25
SkImage
Definition: SkImage.h:61
SkShader::kLinear_GradientType
@ kLinear_GradientType
Definition: SkShader.h:91
SkPath
Definition: SkPath.h:44
SkRefCnt
Definition: SkRefCnt.h:118
SkShaders::Blend
static sk_sp< SkShader > Blend(SkBlendMode mode, sk_sp< SkShader > dst, sk_sp< SkShader > src)
SkColor4f
SkShader::GradientInfo::fColorOffsets
SkScalar * fColorOffsets
The unit offset for color transitions.
Definition: SkShader.h:104
SkShader::makeWithColorFilter
sk_sp< SkShader > makeWithColorFilter(sk_sp< SkColorFilter >) const
Create a new shader that produces the same colors as invoking this shader and then applying the color...
SkBlendMode
SkBlendMode
Blends are operators that take in two colors (source, destination) and return a new color.
Definition: SkBlendMode.h:38
SkShader
Definition: SkShader.h:39
SkShader::kSweep_GradientType
@ kSweep_GradientType
Definition: SkShader.h:93
SkShader::GradientInfo::fGradientFlags
uint32_t fGradientFlags
see SkGradientShader::Flags
Definition: SkShader.h:108
SkShaders::Color
static sk_sp< SkShader > Color(const SkColor4f &, sk_sp< SkColorSpace >)
SkTileMode
SkTileMode
Definition: SkTileMode.h:13
sk_sp< SkShader >
SkPoint
Definition: SkPoint.h:160
SkFlattenable::SkFlattenable
SkFlattenable()
Definition: SkFlattenable.h:45
SkShader::GradientType
GradientType
If the shader subclass can be represented as a gradient, asAGradient returns the matching GradientTyp...
Definition: SkShader.h:88
SK_API
#define SK_API
Definition: SkTypes.h:181
SkShader::kNone_GradientType
@ kNone_GradientType
Definition: SkShader.h:89
SkShader::isOpaque
virtual bool isOpaque() const
Returns true if the shader is guaranteed to produce only opaque colors, subject to the SkPaint using ...
Definition: SkShader.h:47
SkPicture
Definition: SkPicture.h:39
SkShader::GradientInfo
Definition: SkShader.h:98
SkBlendMode.h
SkFilterQuality.h
SkScalar
float SkScalar
Definition: SkScalar.h:16
SkShader::isAImage
SkImage * isAImage(SkMatrix *localMatrix, SkTileMode xy[2]) const
Iff this shader is backed by a single SkImage, return its ptr (the caller must ref this if they want ...
SkShaders
Definition: SkShader.h:136
SkShader::kRadial_GradientType
@ kRadial_GradientType
Definition: SkShader.h:92
SkMatrix
Definition: SkMatrix.h:48
SkTileMode.h
SkMatrix.h
SkShader::GradientInfo::fColorCount
int fColorCount
In-out parameter, specifies passed size.
Definition: SkShader.h:99
SkShader::kColor_GradientType
@ kColor_GradientType
Definition: SkShader.h:90
SkShaders::Empty
static sk_sp< SkShader > Empty()
SkShader::makeWithLocalMatrix
sk_sp< SkShader > makeWithLocalMatrix(const SkMatrix &) const
Return a shader that will apply the specified localMatrix to this shader.
SkColor
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:35
SkShader::asAGradient
virtual GradientType asAGradient(GradientInfo *info) const
SkShaders::Color
static sk_sp< SkShader > Color(SkColor)
SkColor.h
SkShader::kConical_GradientType
@ kConical_GradientType
Definition: SkShader.h:94
SkFlattenable
Definition: SkFlattenable.h:26
SkImageInfo.h
SkBitmap
Definition: SkBitmap.h:50
SkShader::isAImage
bool isAImage() const
Definition: SkShader.h:55
SkShaders::Lerp
static sk_sp< SkShader > Lerp(float t, sk_sp< SkShader > dst, sk_sp< SkShader > src)
SkColorSpace
Definition: SkColorSpace.h:104