8 #ifndef SkPaint_DEFINED
9 #define SkPaint_DEFINED
15 #include "include/private/base/SkCPUTypes.h"
16 #include "include/private/base/SkFloatingPoint.h"
17 #include "include/private/base/SkTo.h"
18 #include "include/private/base/SkTypeTraits.h"
22 #include <type_traits>
163 return SkToBool(fBitfields.fAntiAlias);
170 void setAntiAlias(
bool aa) { fBitfields.fAntiAlias =
static_cast<unsigned>(aa); }
176 return SkToBool(fBitfields.fDither);
182 void setDither(
bool dither) { fBitfields.fDither =
static_cast<unsigned>(dither); }
200 static constexpr
int kStyleCount = kStrokeAndFill_Style + 1;
254 this->setColor(color, colorSpace);
265 return static_cast<uint8_t
>(sk_float_round2int(this->getAlphaf() * 255));
280 this->setAlphaf(a * (1.0f / 255));
293 void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
337 kLast_Cap = kSquare_Cap,
338 kDefault_Cap = kButt_Cap,
343 static constexpr
int kCapCount = kLast_Cap + 1;
362 kLast_Join = kBevel_Join,
363 kDefault_Join = kMiter_Join,
368 static constexpr
int kJoinCount = kLast_Join + 1;
642 return this->doComputeFastBounds(orig, storage, kStroke_Style);
683 static_assert(::sk_is_trivially_relocatable<decltype(fPathEffect)>::value);
684 static_assert(::sk_is_trivially_relocatable<decltype(fShader)>::value);
685 static_assert(::sk_is_trivially_relocatable<decltype(fMaskFilter)>::value);
686 static_assert(::sk_is_trivially_relocatable<decltype(fColorFilter)>::value);
687 static_assert(::sk_is_trivially_relocatable<decltype(fImageFilter)>::value);
688 static_assert(::sk_is_trivially_relocatable<decltype(fBlender)>::value);
689 static_assert(::sk_is_trivially_relocatable<decltype(fColor4f)>::value);
690 static_assert(::sk_is_trivially_relocatable<decltype(fBitfields)>::value);
692 friend class SkPaintPriv;
SkBlendMode
Blends are operators that take in two colors (source, destination) and return a new color.
Definition: SkBlendMode.h:38
Types, consts, functions, and macros for colors.
uint32_t SkColor
32-bit ARGB color value, unpremultiplied.
Definition: SkColor.h:37
float SkScalar
Definition: SkScalar.h:14
SkBlender represents a custom blend function in the Skia pipeline.
Definition: SkBlender.h:19
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:35
Definition: SkColorSpace.h:107
Base class for image filters.
Definition: SkImageFilter.h:35
SkMaskFilter is the base class for object that perform transformations on the mask before drawing it.
Definition: SkMaskFilter.h:27
SkPaint controls options applied when drawing.
Definition: SkPaint.h:44
SkPaint & operator=(const SkPaint &paint)
Makes a shallow copy of SkPaint.
SkScalar getStrokeMiter() const
Returns the limit at which a sharp corner is drawn beveled.
Definition: SkPaint.h:318
SK_API friend bool operator==(const SkPaint &a, const SkPaint &b)
Compares a and b, and returns true if a and b are equivalent.
Cap
Definition: SkPaint.h:333
@ kRound_Cap
adds circle
Definition: SkPaint.h:335
@ kButt_Cap
no stroke extension
Definition: SkPaint.h:334
@ kSquare_Cap
adds square
Definition: SkPaint.h:336
SkPaint(const SkColor4f &color, SkColorSpace *colorSpace=nullptr)
Constructs SkPaint with default values and the given color.
void setStyle(Style style)
Sets whether the geometry is filled, stroked, or filled and stroked.
Style getStyle() const
Returns whether the geometry is filled, stroked, or filled and stroked.
Definition: SkPaint.h:204
friend bool operator!=(const SkPaint &a, const SkPaint &b)
Compares a and b, and returns true if a and b are not equivalent.
Definition: SkPaint.h:148
void setColor(SkColor color)
Sets alpha and RGB used when stroking and filling.
sk_sp< SkShader > refShader() const
Returns optional colors used when filling a path, such as a gradient.
void setStrokeMiter(SkScalar miter)
Sets the limit at which a sharp corner is drawn beveled.
void setAntiAlias(bool aa)
Requests, but does not require, that edge pixels draw opaque or with partial transparency.
Definition: SkPaint.h:170
std::true_type sk_is_trivially_relocatable
Definition: SkPaint.h:658
bool isSrcOver() const
Returns true iff the current blender claims to be equivalent to SkBlendMode::kSrcOver.
unsigned fPadding
Definition: SkPaint.h:678
void setDither(bool dither)
Requests, but does not require, to distribute color error.
Definition: SkPaint.h:182
void setImageFilter(sk_sp< SkImageFilter > imageFilter)
Sets SkImageFilter to imageFilter, decreasing SkRefCnt of the previous SkImageFilter.
sk_sp< SkPathEffect > refPathEffect() const
Returns SkPathEffect if set, or nullptr.
unsigned fDither
Definition: SkPaint.h:674
void setStrokeCap(Cap cap)
Sets the geometry drawn at the beginning and end of strokes.
SkShader * getShader() const
Returns optional colors used when filling a path, such as a gradient.
Definition: SkPaint.h:397
SkBlendMode getBlendMode_or(SkBlendMode defaultMode) const
Queries the blender, and if it can be represented as a SkBlendMode, return that mode,...
sk_sp< SkMaskFilter > refMaskFilter() const
Returns SkMaskFilter if set, or nullptr.
void reset()
Sets all SkPaint contents to their initial values.
SkColor getColor() const
Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
Definition: SkPaint.h:225
Style
Definition: SkPaint.h:192
@ kStroke_Style
set to stroke geometry
Definition: SkPaint.h:194
@ kFill_Style
set to fill geometry
Definition: SkPaint.h:193
@ kStrokeAndFill_Style
sets to stroke and fill geometry
Definition: SkPaint.h:195
void setStrokeJoin(Join join)
Sets the geometry drawn at the corners of strokes.
bool isDither() const
Returns true if color error may be distributed to smooth color transition.
Definition: SkPaint.h:175
std::optional< SkBlendMode > asBlendMode() const
If the current blender can be represented as a SkBlendMode enum, this returns that enum in the option...
const SkRect & computeFastStrokeBounds(const SkRect &orig, SkRect *storage) const
(to be made private)
Definition: SkPaint.h:640
void setAlpha(U8CPU a)
Definition: SkPaint.h:279
void setColor(const SkColor4f &color, SkColorSpace *colorSpace=nullptr)
Sets alpha and RGB used when stroking and filling.
sk_sp< SkColorFilter > refColorFilter() const
Returns SkColorFilter if set, or nullptr.
SkPaint(const SkPaint &paint)
Makes a shallow copy of SkPaint.
void setColor4f(const SkColor4f &color, SkColorSpace *colorSpace=nullptr)
Definition: SkPaint.h:253
SkMaskFilter * getMaskFilter() const
Returns SkMaskFilter if set, or nullptr.
Definition: SkPaint.h:534
void setMaskFilter(sk_sp< SkMaskFilter > maskFilter)
Sets SkMaskFilter to maskFilter, decreasing SkRefCnt of the previous SkMaskFilter.
bool nothingToDraw() const
Returns true if SkPaint prevents all drawing; otherwise, the SkPaint may or may not allow drawing.
SkColor4f getColor4f() const
Retrieves alpha and RGB, unpremultiplied, as four floating point values.
Definition: SkPaint.h:232
unsigned fCapType
Definition: SkPaint.h:675
void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b)
Sets color used when drawing solid fills.
bool isAntiAlias() const
Returns true if pixels on the active edges of SkPath may be drawn with partial transparency.
Definition: SkPaint.h:162
void setShader(sk_sp< SkShader > shader)
Sets optional colors used when filling a path, such as a gradient.
void setPathEffect(sk_sp< SkPathEffect > pathEffect)
Sets SkPathEffect to pathEffect, decreasing SkRefCnt of the previous SkPathEffect.
float getAlphaf() const
Retrieves alpha from the color used when stroking and filling.
Definition: SkPaint.h:261
unsigned fJoinType
Definition: SkPaint.h:676
SkPaint & operator=(SkPaint &&paint)
Moves the paint to avoid increasing the reference counts of objects referenced by the paint parameter...
unsigned fAntiAlias
Definition: SkPaint.h:673
SkScalar getStrokeWidth() const
Returns the thickness of the pen used by SkPaint to outline the shape.
Definition: SkPaint.h:300
SkImageFilter * getImageFilter() const
Returns SkImageFilter if set, or nullptr.
Definition: SkPaint.h:564
uint32_t fBitfieldsUInt
Definition: SkPaint.h:680
Join
Definition: SkPaint.h:358
@ kRound_Join
adds circle
Definition: SkPaint.h:360
@ kMiter_Join
extends to miter limit
Definition: SkPaint.h:359
@ kBevel_Join
connects outside edges
Definition: SkPaint.h:361
const SkRect & computeFastBounds(const SkRect &orig, SkRect *storage) const
(to be made private) Only call this if canComputeFastBounds() returned true.
void setBlendMode(SkBlendMode mode)
Helper method for calling setBlender().
const SkRect & doComputeFastBounds(const SkRect &orig, SkRect *storage, Style style) const
(to be made private) Computes the bounds, overriding the SkPaint SkPaint::Style.
SkPathEffect * getPathEffect() const
Returns SkPathEffect if set, or nullptr.
Definition: SkPaint.h:506
SkBlender * getBlender() const
Returns the user-supplied blend function, if one has been set.
Definition: SkPaint.h:480
SkPaint()
Constructs SkPaint with default values.
uint8_t getAlpha() const
Definition: SkPaint.h:264
Cap getStrokeCap() const
Returns the geometry drawn at the beginning and end of strokes.
Definition: SkPaint.h:372
void setColorFilter(sk_sp< SkColorFilter > colorFilter)
Sets SkColorFilter to filter, decreasing SkRefCnt of the previous SkColorFilter.
~SkPaint()
Decreases SkPaint SkRefCnt of owned objects: SkPathEffect, SkShader, SkMaskFilter,...
sk_sp< SkImageFilter > refImageFilter() const
Returns SkImageFilter if set, or nullptr.
SkColorFilter * getColorFilter() const
Returns SkColorFilter if set, or nullptr.
Definition: SkPaint.h:426
void setBlender(sk_sp< SkBlender > blender)
Sets the current blender, increasing its refcnt, and if a blender is already present,...
Join getStrokeJoin() const
Returns the geometry drawn at the corners of strokes.
Definition: SkPaint.h:383
unsigned fStyle
Definition: SkPaint.h:677
void setStroke(bool)
Set paint's style to kStroke if true, or kFill if false.
bool canComputeFastBounds() const
(to be made private) Returns true if SkPaint does not include elements requiring extensive computatio...
void setStrokeWidth(SkScalar width)
Sets the thickness of the pen used by the paint to outline the shape.
sk_sp< SkBlender > refBlender() const
Returns the user-supplied blend function, if one has been set.
void setAlphaf(float a)
Replaces alpha, leaving RGB unchanged.
SkPaint(SkPaint &&paint)
Implements a move constructor to avoid increasing the reference counts of objects referenced by the p...
SkPathEffect is the base class for objects in the SkPaint that affect the geometry of a drawing primi...
Definition: SkPathEffect.h:28
Shaders specify the source color(s) for what is being drawn.
Definition: SkShader.h:35
RGBA color value, holding four floating point components.
SkRect holds four float coordinates describing the upper and lower bounds of a rectangle.
Definition: SkRect.h:582