2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPaint_DEFINED
|
|
|
|
#define SkPaint_DEFINED
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/core/SkBlendMode.h"
|
|
|
|
#include "include/core/SkColor.h"
|
|
|
|
#include "include/core/SkFilterQuality.h"
|
|
|
|
#include "include/core/SkRefCnt.h"
|
2021-06-29 20:21:34 +00:00
|
|
|
#include "include/private/SkTOptional.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/private/SkTo.h"
|
2009-06-22 17:38:10 +00:00
|
|
|
|
2021-06-17 15:07:55 +00:00
|
|
|
class SkBlender;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkColorFilter;
|
2018-09-05 14:16:27 +00:00
|
|
|
class SkColorSpace;
|
2008-12-17 15:59:43 +00:00
|
|
|
struct SkRect;
|
2011-11-03 19:29:08 +00:00
|
|
|
class SkImageFilter;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkMaskFilter;
|
|
|
|
class SkPath;
|
|
|
|
class SkPathEffect;
|
|
|
|
class SkShader;
|
2019-02-01 19:00:34 +00:00
|
|
|
|
2021-02-13 15:12:53 +00:00
|
|
|
// Move to clients when they are ready -- aid in deprecating the enum
|
2020-12-19 20:14:06 +00:00
|
|
|
#define SK_SUPPORT_LEGACY_SETFILTERQUALITY
|
2021-07-07 20:05:25 +00:00
|
|
|
#define SK_SUPPORT_LEGACY_GETBLENDMODE
|
2020-12-19 20:14:06 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** \class SkPaint
|
2019-01-28 15:57:28 +00:00
|
|
|
SkPaint controls options applied when drawing. SkPaint collects all
|
2017-07-26 14:15:23 +00:00
|
|
|
options outside of the SkCanvas clip and SkCanvas matrix.
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2019-01-28 15:57:28 +00:00
|
|
|
Various options apply to strokes and fills, and images.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-07-27 20:30:51 +00:00
|
|
|
SkPaint collects effects and filters that describe single-pass and multiple-pass
|
2017-07-26 14:15:23 +00:00
|
|
|
algorithms that alter the drawing geometry, color, and transparency. For instance,
|
|
|
|
SkPaint does not directly implement dashing or blur, but contains the objects that do so.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2011-03-15 21:27:08 +00:00
|
|
|
class SK_API SkPaint {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
/** Constructs SkPaint with default values.
|
|
|
|
|
|
|
|
@return default initialized SkPaint
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_empty_constructor
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
SkPaint();
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2019-05-02 15:31:28 +00:00
|
|
|
/** Constructs SkPaint with default values and the given color.
|
|
|
|
|
|
|
|
Sets alpha and RGB used when stroking and filling. The color is four floating
|
|
|
|
point values, unpremultiplied. The color values are interpreted as being in
|
|
|
|
the colorSpace. If colorSpace is nullptr, then color is assumed to be in the
|
|
|
|
sRGB color space.
|
|
|
|
|
|
|
|
@param color unpremultiplied RGBA
|
|
|
|
@param colorSpace SkColorSpace describing the encoding of color
|
|
|
|
@return SkPaint with the given color
|
|
|
|
*/
|
|
|
|
explicit SkPaint(const SkColor4f& color, SkColorSpace* colorSpace = nullptr);
|
|
|
|
|
2019-01-28 15:57:28 +00:00
|
|
|
/** Makes a shallow copy of SkPaint. SkPathEffect, SkShader,
|
2019-07-29 21:52:48 +00:00
|
|
|
SkMaskFilter, SkColorFilter, and SkImageFilter are shared
|
2017-09-01 17:49:54 +00:00
|
|
|
between the original paint and the copy. Objects containing SkRefCnt increment
|
|
|
|
their references by one.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2018-01-20 00:09:32 +00:00
|
|
|
The referenced objects SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
2019-07-29 21:52:48 +00:00
|
|
|
and SkImageFilter cannot be modified after they are created.
|
2017-07-26 14:15:23 +00:00
|
|
|
This prevents objects with SkRefCnt from being modified once SkPaint refers to them.
|
|
|
|
|
|
|
|
@param paint original to copy
|
|
|
|
@return shallow copy of paint
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_copy_const_SkPaint
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
SkPaint(const SkPaint& paint);
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Implements a move constructor to avoid increasing the reference counts
|
2017-07-26 14:15:23 +00:00
|
|
|
of objects referenced by the paint.
|
|
|
|
|
|
|
|
After the call, paint is undefined, and can be safely destructed.
|
|
|
|
|
|
|
|
@param paint original to move
|
|
|
|
@return content of paint
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_move_SkPaint
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2016-02-07 22:37:23 +00:00
|
|
|
SkPaint(SkPaint&& paint);
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2019-01-28 15:57:28 +00:00
|
|
|
/** Decreases SkPaint SkRefCnt of owned objects: SkPathEffect, SkShader,
|
2019-07-29 21:52:48 +00:00
|
|
|
SkMaskFilter, SkColorFilter, and SkImageFilter. If the
|
2017-09-01 17:49:54 +00:00
|
|
|
objects containing SkRefCnt go to zero, they are deleted.
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
~SkPaint();
|
|
|
|
|
2019-01-28 15:57:28 +00:00
|
|
|
/** Makes a shallow copy of SkPaint. SkPathEffect, SkShader,
|
2019-07-29 21:52:48 +00:00
|
|
|
SkMaskFilter, SkColorFilter, and SkImageFilter are shared
|
2017-09-01 17:49:54 +00:00
|
|
|
between the original paint and the copy. Objects containing SkRefCnt in the
|
2017-07-26 14:15:23 +00:00
|
|
|
prior destination are decreased by one, and the referenced objects are deleted if the
|
2017-09-01 17:49:54 +00:00
|
|
|
resulting count is zero. Objects containing SkRefCnt in the parameter paint
|
|
|
|
are increased by one. paint is unmodified.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param paint original to copy
|
|
|
|
@return content of paint
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_copy_operator
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
SkPaint& operator=(const SkPaint& paint);
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Moves the paint to avoid increasing the reference counts
|
2017-09-01 17:49:54 +00:00
|
|
|
of objects referenced by the paint parameter. Objects containing SkRefCnt in the
|
|
|
|
prior destination are decreased by one; those objects are deleted if the resulting count
|
|
|
|
is zero.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
After the call, paint is undefined, and can be safely destructed.
|
|
|
|
|
|
|
|
@param paint original to move
|
|
|
|
@return content of paint
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_move_operator
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
SkPaint& operator=(SkPaint&& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Compares a and b, and returns true if a and b are equivalent. May return false
|
2019-01-28 15:57:28 +00:00
|
|
|
if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
2019-07-29 21:52:48 +00:00
|
|
|
or SkImageFilter have identical contents but different pointers.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param a SkPaint to compare
|
|
|
|
@param b SkPaint to compare
|
|
|
|
@return true if SkPaint pair are equivalent
|
2014-08-25 17:10:47 +00:00
|
|
|
*/
|
2013-08-07 22:36:29 +00:00
|
|
|
SK_API friend bool operator==(const SkPaint& a, const SkPaint& b);
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
/** Compares a and b, and returns true if a and b are not equivalent. May return true
|
2019-01-28 15:57:28 +00:00
|
|
|
if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
|
2019-07-29 21:52:48 +00:00
|
|
|
or SkImageFilter have identical contents but different pointers.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param a SkPaint to compare
|
|
|
|
@param b SkPaint to compare
|
|
|
|
@return true if SkPaint pair are not equivalent
|
|
|
|
*/
|
2013-08-07 22:36:29 +00:00
|
|
|
friend bool operator!=(const SkPaint& a, const SkPaint& b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
2017-10-30 15:48:35 +00:00
|
|
|
/** Sets all SkPaint contents to their initial values. This is equivalent to replacing
|
|
|
|
SkPaint with the result of SkPaint().
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_reset
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void reset();
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns true if pixels on the active edges of SkPath may be drawn with partial transparency.
|
2019-01-28 15:57:28 +00:00
|
|
|
@return antialiasing state
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isAntiAlias() const {
|
2019-01-28 15:57:28 +00:00
|
|
|
return SkToBool(fBitfields.fAntiAlias);
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2018-11-19 01:09:42 +00:00
|
|
|
/** Requests, but does not require, that edge pixels draw opaque or with
|
2017-07-26 14:15:23 +00:00
|
|
|
partial transparency.
|
2019-01-28 15:57:28 +00:00
|
|
|
@param aa setting for antialiasing
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2019-01-28 15:57:28 +00:00
|
|
|
void setAntiAlias(bool aa) { fBitfields.fAntiAlias = static_cast<unsigned>(aa); }
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns true if color error may be distributed to smooth color transition.
|
2019-01-28 15:57:28 +00:00
|
|
|
@return dithering state
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isDither() const {
|
2019-01-28 15:57:28 +00:00
|
|
|
return SkToBool(fBitfields.fDither);
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Requests, but does not require, to distribute color error.
|
2019-01-28 15:57:28 +00:00
|
|
|
@param dither setting for ditering
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2019-01-28 15:57:28 +00:00
|
|
|
void setDither(bool dither) { fBitfields.fDither = static_cast<unsigned>(dither); }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2021-03-21 01:39:16 +00:00
|
|
|
#ifdef SK_SUPPORT_LEGACY_SETFILTERQUALITY
|
2021-03-20 22:14:29 +00:00
|
|
|
// DEPRECATED -- this field is unused.
|
2015-01-23 13:58:07 +00:00
|
|
|
SkFilterQuality getFilterQuality() const {
|
|
|
|
return (SkFilterQuality)fBitfields.fFilterQuality;
|
|
|
|
}
|
2015-09-09 14:35:42 +00:00
|
|
|
|
2021-03-20 22:14:29 +00:00
|
|
|
// DEPRECATED -- this field is unused.
|
2021-03-21 01:39:16 +00:00
|
|
|
void setFilterQuality(SkFilterQuality fq) {
|
|
|
|
fBitfields.fFilterQuality = fq;
|
|
|
|
}
|
2020-12-19 20:14:06 +00:00
|
|
|
#endif
|
2013-07-18 13:47:01 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** \enum SkPaint::Style
|
2017-07-27 20:30:51 +00:00
|
|
|
Set Style to fill, stroke, or both fill and stroke geometry.
|
2017-07-26 14:15:23 +00:00
|
|
|
The stroke and fill
|
|
|
|
share all paint attributes; for instance, they are drawn with the same color.
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
Use kStrokeAndFill_Style to avoid hitting the same pixels twice with a stroke draw and
|
|
|
|
a fill draw.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2018-11-05 21:48:46 +00:00
|
|
|
enum Style : uint8_t {
|
2018-05-30 13:20:29 +00:00
|
|
|
kFill_Style, //!< set to fill geometry
|
|
|
|
kStroke_Style, //!< set to stroke geometry
|
|
|
|
kStrokeAndFill_Style, //!< sets to stroke and fill geometry
|
2013-02-04 05:17:10 +00:00
|
|
|
};
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** May be used to verify that SkPaint::Style is a legal value.
|
2018-04-26 12:32:37 +00:00
|
|
|
*/
|
|
|
|
static constexpr int kStyleCount = kStrokeAndFill_Style + 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns whether the geometry is filled, stroked, or filled and stroked.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-07-14 21:39:15 +00:00
|
|
|
Style getStyle() const { return (Style)fBitfields.fStyle; }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Sets whether the geometry is filled, stroked, or filled and stroked.
|
|
|
|
Has no effect if style is not a legal SkPaint::Style value.
|
|
|
|
|
2019-03-15 19:47:01 +00:00
|
|
|
example: https://fiddle.skia.org/c/@Paint_setStyle
|
|
|
|
example: https://fiddle.skia.org/c/@Stroke_Width
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setStyle(Style style);
|
|
|
|
|
2020-05-19 01:25:44 +00:00
|
|
|
/**
|
|
|
|
* Set paint's style to kStroke if true, or kFill if false.
|
|
|
|
*/
|
|
|
|
void setStroke(bool);
|
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
|
|
|
|
Use helpers SkColorGetA(), SkColorGetR(), SkColorGetG(), and SkColorGetB() to extract
|
|
|
|
a color component.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@return unpremultiplied ARGB
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2018-09-05 14:16:27 +00:00
|
|
|
SkColor getColor() const { return fColor4f.toSkColor(); }
|
|
|
|
|
2018-10-31 14:54:50 +00:00
|
|
|
/** Retrieves alpha and RGB, unpremultiplied, as four floating point values. RGB are
|
2020-09-30 19:39:48 +00:00
|
|
|
extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).
|
2018-09-05 14:16:27 +00:00
|
|
|
|
|
|
|
@return unpremultiplied RGBA
|
|
|
|
*/
|
|
|
|
SkColor4f getColor4f() const { return fColor4f; }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Sets alpha and RGB used when stroking and filling. The color is a 32-bit value,
|
2017-09-01 17:49:54 +00:00
|
|
|
unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param color unpremultiplied ARGB
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setColor
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setColor(SkColor color);
|
|
|
|
|
2018-09-05 14:16:27 +00:00
|
|
|
/** Sets alpha and RGB used when stroking and filling. The color is four floating
|
|
|
|
point values, unpremultiplied. The color values are interpreted as being in
|
|
|
|
the colorSpace. If colorSpace is nullptr, then color is assumed to be in the
|
|
|
|
sRGB color space.
|
|
|
|
|
|
|
|
@param color unpremultiplied RGBA
|
|
|
|
@param colorSpace SkColorSpace describing the encoding of color
|
|
|
|
*/
|
2019-05-20 15:47:49 +00:00
|
|
|
void setColor(const SkColor4f& color, SkColorSpace* colorSpace = nullptr);
|
|
|
|
|
|
|
|
void setColor4f(const SkColor4f& color, SkColorSpace* colorSpace = nullptr) {
|
|
|
|
this->setColor(color, colorSpace);
|
|
|
|
}
|
2018-09-05 14:16:27 +00:00
|
|
|
|
2017-07-31 11:52:43 +00:00
|
|
|
/** Retrieves alpha from the color used when stroking and filling.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@return alpha ranging from zero, fully transparent, to 255, fully opaque
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2019-02-15 21:13:57 +00:00
|
|
|
float getAlphaf() const { return fColor4f.fA; }
|
|
|
|
|
|
|
|
// Helper that scales the alpha by 255.
|
|
|
|
uint8_t getAlpha() const { return sk_float_round2int(this->getAlphaf() * 255); }
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Replaces alpha, leaving RGB
|
|
|
|
unchanged. An out of range value triggers an assert in the debug
|
2019-02-15 21:13:57 +00:00
|
|
|
build. a is a value from 0.0 to 1.0.
|
|
|
|
a set to zero makes color fully transparent; a set to 1.0 makes color
|
2017-07-26 14:15:23 +00:00
|
|
|
fully opaque.
|
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
@param a alpha component of color
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2019-02-15 21:13:57 +00:00
|
|
|
void setAlphaf(float a);
|
|
|
|
|
|
|
|
// Helper that accepts an int between 0 and 255, and divides it by 255.0
|
|
|
|
void setAlpha(U8CPU a) {
|
|
|
|
this->setAlphaf(a * (1.0f / 255));
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-07-31 11:52:43 +00:00
|
|
|
/** Sets color used when drawing solid fills. The color components range from 0 to 255.
|
2017-09-01 17:49:54 +00:00
|
|
|
The color is unpremultiplied; alpha sets the transparency independent of RGB.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
@param a amount of alpha, from fully transparent (0) to fully opaque (255)
|
|
|
|
@param r amount of red, from no red (0) to full red (255)
|
|
|
|
@param g amount of green, from no green (0) to full green (255)
|
|
|
|
@param b amount of blue, from no blue (0) to full blue (255)
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setARGB
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
|
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Returns the thickness of the pen used by SkPaint to
|
|
|
|
outline the shape.
|
|
|
|
|
2017-07-31 11:52:43 +00:00
|
|
|
@return zero for hairline, greater than zero for pen thickness
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
SkScalar getStrokeWidth() const { return fWidth; }
|
|
|
|
|
2020-05-18 20:11:49 +00:00
|
|
|
/** Sets the thickness of the pen used by the paint to outline the shape.
|
|
|
|
A stroke-width of zero is treated as "hairline" width. Hairlines are always exactly one
|
|
|
|
pixel wide in device space (their thickness does not change as the canvas is scaled).
|
|
|
|
Negative stroke-widths are invalid; setting a negative width will have no effect.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-07-31 11:52:43 +00:00
|
|
|
@param width zero thickness for hairline; greater than zero for pen thickness
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Miter_Limit
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setStrokeWidth
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setStrokeWidth(SkScalar width);
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns the limit at which a sharp corner is drawn beveled.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@return zero and greater miter limit
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
SkScalar getStrokeMiter() const { return fMiterLimit; }
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Sets the limit at which a sharp corner is drawn beveled.
|
2017-07-26 14:15:23 +00:00
|
|
|
Valid values are zero and greater.
|
|
|
|
Has no effect if miter is less than zero.
|
|
|
|
|
|
|
|
@param miter zero and greater miter limit
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setStrokeMiter
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setStrokeMiter(SkScalar miter);
|
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** \enum SkPaint::Cap
|
|
|
|
Cap draws at the beginning and end of an open path contour.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
enum Cap {
|
2018-05-30 13:20:29 +00:00
|
|
|
kButt_Cap, //!< no stroke extension
|
|
|
|
kRound_Cap, //!< adds circle
|
|
|
|
kSquare_Cap, //!< adds square
|
|
|
|
kLast_Cap = kSquare_Cap, //!< largest Cap value
|
|
|
|
kDefault_Cap = kButt_Cap, //!< equivalent to kButt_Cap
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** May be used to verify that SkPaint::Cap is a legal value.
|
|
|
|
*/
|
2016-07-06 18:54:59 +00:00
|
|
|
static constexpr int kCapCount = kLast_Cap + 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** \enum SkPaint::Join
|
2017-07-31 11:52:43 +00:00
|
|
|
Join specifies how corners are drawn when a shape is stroked. Join
|
2017-07-26 14:15:23 +00:00
|
|
|
affects the four corners of a stroked rectangle, and the connected segments in a
|
|
|
|
stroked path.
|
|
|
|
|
|
|
|
Choose miter join to draw sharp corners. Choose round join to draw a circle with a
|
|
|
|
radius equal to the stroke width on top of the corner. Choose bevel join to minimally
|
|
|
|
connect the thick strokes.
|
|
|
|
|
|
|
|
The fill path constructed to describe the stroked path respects the join setting but may
|
|
|
|
not contain the actual join. For instance, a fill path constructed with round joins does
|
|
|
|
not necessarily include circles at each connected segment.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2018-11-05 21:48:46 +00:00
|
|
|
enum Join : uint8_t {
|
2018-05-30 13:20:29 +00:00
|
|
|
kMiter_Join, //!< extends to miter limit
|
|
|
|
kRound_Join, //!< adds circle
|
|
|
|
kBevel_Join, //!< connects outside edges
|
|
|
|
kLast_Join = kBevel_Join, //!< equivalent to the largest value for Join
|
|
|
|
kDefault_Join = kMiter_Join, //!< equivalent to kMiter_Join
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** May be used to verify that SkPaint::Join is a legal value.
|
|
|
|
*/
|
2016-07-06 18:54:59 +00:00
|
|
|
static constexpr int kJoinCount = kLast_Join + 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns the geometry drawn at the beginning and end of strokes.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-07-14 21:39:15 +00:00
|
|
|
Cap getStrokeCap() const { return (Cap)fBitfields.fCapType; }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Sets the geometry drawn at the beginning and end of strokes.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2019-03-15 19:47:01 +00:00
|
|
|
example: https://fiddle.skia.org/c/@Paint_setStrokeCap_a
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setStrokeCap_b
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setStrokeCap(Cap cap);
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns the geometry drawn at the corners of strokes.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2014-07-14 21:39:15 +00:00
|
|
|
Join getStrokeJoin() const { return (Join)fBitfields.fJoinType; }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Sets the geometry drawn at the corners of strokes.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2019-03-15 19:47:01 +00:00
|
|
|
example: https://fiddle.skia.org/c/@Paint_setStrokeJoin
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
void setStrokeJoin(Join join);
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns the filled equivalent of the stroked path.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param src SkPath read to create a filled version
|
|
|
|
@param dst resulting SkPath; may be the same as src, but may not be nullptr
|
|
|
|
@param cullRect optional limit passed to SkPathEffect
|
2018-10-31 14:54:50 +00:00
|
|
|
@param resScale if > 1, increase precision, else if (0 < resScale < 1) reduce precision
|
2017-07-26 14:15:23 +00:00
|
|
|
to favor speed and size
|
2017-07-31 11:52:43 +00:00
|
|
|
@return true if the path represents style fill, or false if it represents hairline
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2015-02-12 21:35:52 +00:00
|
|
|
bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
|
|
|
|
SkScalar resScale = 1) const;
|
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns the filled equivalent of the stroked path.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-07-27 20:30:51 +00:00
|
|
|
Replaces dst with the src path modified by SkPathEffect and style stroke.
|
|
|
|
SkPathEffect, if any, is not culled. stroke width is created with default precision.
|
|
|
|
|
|
|
|
@param src SkPath read to create a filled version
|
|
|
|
@param dst resulting SkPath dst may be the same as src, but may not be nullptr
|
2017-07-31 11:52:43 +00:00
|
|
|
@return true if the path represents style fill, or false if it represents hairline
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2015-02-12 21:35:52 +00:00
|
|
|
bool getFillPath(const SkPath& src, SkPath* dst) const {
|
2017-08-28 14:34:05 +00:00
|
|
|
return this->getFillPath(src, dst, nullptr, 1);
|
2015-02-12 21:35:52 +00:00
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns optional colors used when filling a path, such as a gradient.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
Does not alter SkShader SkRefCnt.
|
|
|
|
|
|
|
|
@return SkShader if previously set, nullptr otherwise
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkShader* getShader() const { return fShader.get(); }
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Returns optional colors used when filling a path, such as a gradient.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
Increases SkShader SkRefCnt by one.
|
|
|
|
|
|
|
|
@return SkShader if previously set, nullptr otherwise
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_refShader
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkShader> refShader() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2018-07-13 12:21:59 +00:00
|
|
|
/** Sets optional colors used when filling a path, such as a gradient.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
Sets SkShader to shader, decreasing SkRefCnt of the previous SkShader.
|
|
|
|
Increments shader SkRefCnt by one.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-07-31 11:52:43 +00:00
|
|
|
@param shader how geometry is filled with color; if nullptr, color is used instead
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Color_Filter_Methods
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setShader
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setShader(sk_sp<SkShader> shader);
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Returns SkColorFilter if set, or nullptr.
|
|
|
|
Does not alter SkColorFilter SkRefCnt.
|
|
|
|
|
|
|
|
@return SkColorFilter if previously set, nullptr otherwise
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkColorFilter* getColorFilter() const { return fColorFilter.get(); }
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
/** Returns SkColorFilter if set, or nullptr.
|
|
|
|
Increases SkColorFilter SkRefCnt by one.
|
|
|
|
|
|
|
|
@return SkColorFilter if set, or nullptr
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_refColorFilter
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkColorFilter> refColorFilter() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Sets SkColorFilter to filter, decreasing SkRefCnt of the previous
|
|
|
|
SkColorFilter. Pass nullptr to clear SkColorFilter.
|
|
|
|
|
|
|
|
Increments filter SkRefCnt by one.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param colorFilter SkColorFilter to apply to subsequent draw
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Blend_Mode_Methods
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setColorFilter
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setColorFilter(sk_sp<SkColorFilter> colorFilter);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2021-07-07 18:28:30 +00:00
|
|
|
/** If the current blender can be represented as a SkBlendMode enum, this returns that
|
|
|
|
* enum in the optional's value(). If it cannot, then the returned optional does not
|
|
|
|
* contain a value.
|
|
|
|
*/
|
|
|
|
skstd::optional<SkBlendMode> asBlendMode() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Queries the blender, and if it can be represented as a SkBendMode, return that mode,
|
|
|
|
* else return the defaultMode provided.
|
|
|
|
*/
|
|
|
|
SkBlendMode getBlendMode_or(SkBlendMode defaultMode) const;
|
|
|
|
|
2021-07-07 20:05:25 +00:00
|
|
|
#ifndef SK_SUPPORT_LEGACY_GETBLENDMODE
|
|
|
|
private:
|
|
|
|
#endif
|
2021-06-29 20:21:34 +00:00
|
|
|
/** DEPRECATED
|
2021-07-07 18:28:30 +00:00
|
|
|
* Use asBlendMode() or getBlendMode_or() instead.
|
2021-06-29 20:21:34 +00:00
|
|
|
*
|
|
|
|
* This attempts to inspect the current blender, and if it claims to be equivalent to
|
|
|
|
* one of the predefiend SkBlendMode enums, returns that mode. If the blender does not,
|
|
|
|
* this returns kSrcOver.
|
|
|
|
*/
|
2021-07-07 18:28:30 +00:00
|
|
|
SkBlendMode getBlendMode() const { return this->getBlendMode_or(SkBlendMode::kSrcOver); }
|
2021-07-07 20:05:25 +00:00
|
|
|
public:
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2021-06-29 20:21:34 +00:00
|
|
|
/** Returns true iff the current blender claims to be equivalent to SkBlendMode::kSrcOver.
|
2021-07-06 15:29:45 +00:00
|
|
|
*
|
|
|
|
* Also returns true of the current blender is nullptr.
|
|
|
|
*/
|
2021-06-29 20:21:34 +00:00
|
|
|
bool isSrcOver() const;
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2021-06-29 20:21:34 +00:00
|
|
|
/** Helper method for calling setBlender().
|
|
|
|
*
|
|
|
|
* This sets a blender that implements the specified blendmode enum.
|
|
|
|
*/
|
|
|
|
void setBlendMode(SkBlendMode mode);
|
2009-06-22 17:38:10 +00:00
|
|
|
|
2021-06-17 15:07:55 +00:00
|
|
|
/** Returns the user-supplied blend function, if one has been set.
|
2021-07-06 15:29:45 +00:00
|
|
|
* Does not alter SkBlender's SkRefCnt.
|
|
|
|
*
|
|
|
|
* A nullptr blender signifies the default SrcOver behavior.
|
|
|
|
*
|
|
|
|
* @return the SkBlender assigned to this paint, otherwise nullptr
|
|
|
|
*/
|
2021-06-17 15:07:55 +00:00
|
|
|
SkBlender* getBlender() const { return fBlender.get(); }
|
|
|
|
|
|
|
|
/** Returns the user-supplied blend function, if one has been set.
|
2021-07-06 15:29:45 +00:00
|
|
|
* Increments the SkBlender's SkRefCnt by one.
|
|
|
|
*
|
|
|
|
* A nullptr blender signifies the default SrcOver behavior.
|
|
|
|
*
|
|
|
|
* @return the SkBlender assigned to this paint, otherwise nullptr
|
|
|
|
*/
|
2021-06-17 15:07:55 +00:00
|
|
|
sk_sp<SkBlender> refBlender() const;
|
|
|
|
|
2021-06-29 20:21:34 +00:00
|
|
|
/** Sets the current blender, increasing its refcnt, and if a blender is already
|
|
|
|
* present, decreasing that object's refcnt.
|
2021-07-06 15:29:45 +00:00
|
|
|
*
|
|
|
|
* A nullptr blender signifies the default SrcOver behavior.
|
|
|
|
*
|
|
|
|
* For convenience, you can call setBlendMode() if the blend effect can be expressed
|
|
|
|
* as one of those values.
|
2021-06-29 20:21:34 +00:00
|
|
|
*/
|
2021-07-06 15:29:45 +00:00
|
|
|
void setBlender(sk_sp<SkBlender> blender);
|
2021-06-17 15:07:55 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Returns SkPathEffect if set, or nullptr.
|
|
|
|
Does not alter SkPathEffect SkRefCnt.
|
|
|
|
|
|
|
|
@return SkPathEffect if previously set, nullptr otherwise
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkPathEffect* getPathEffect() const { return fPathEffect.get(); }
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
/** Returns SkPathEffect if set, or nullptr.
|
|
|
|
Increases SkPathEffect SkRefCnt by one.
|
|
|
|
|
|
|
|
@return SkPathEffect if previously set, nullptr otherwise
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_refPathEffect
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkPathEffect> refPathEffect() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Sets SkPathEffect to pathEffect, decreasing SkRefCnt of the previous
|
|
|
|
SkPathEffect. Pass nullptr to leave the path geometry unaltered.
|
|
|
|
|
|
|
|
Increments pathEffect SkRefCnt by one.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param pathEffect replace SkPath with a modification when drawn
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Mask_Filter_Methods
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setPathEffect
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setPathEffect(sk_sp<SkPathEffect> pathEffect);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Returns SkMaskFilter if set, or nullptr.
|
|
|
|
Does not alter SkMaskFilter SkRefCnt.
|
|
|
|
|
|
|
|
@return SkMaskFilter if previously set, nullptr otherwise
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); }
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
/** Returns SkMaskFilter if set, or nullptr.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
Increases SkMaskFilter SkRefCnt by one.
|
|
|
|
|
|
|
|
@return SkMaskFilter if previously set, nullptr otherwise
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_refMaskFilter
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkMaskFilter> refMaskFilter() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Sets SkMaskFilter to maskFilter, decreasing SkRefCnt of the previous
|
|
|
|
SkMaskFilter. Pass nullptr to clear SkMaskFilter and leave SkMaskFilter effect on
|
|
|
|
mask alpha unaltered.
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
Increments maskFilter SkRefCnt by one.
|
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
@param maskFilter modifies clipping mask generated from drawn geometry
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setMaskFilter
|
|
|
|
example: https://fiddle.skia.org/c/@Typeface_Methods
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setMaskFilter(sk_sp<SkMaskFilter> maskFilter);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
/** Returns SkImageFilter if set, or nullptr.
|
|
|
|
Does not alter SkImageFilter SkRefCnt.
|
|
|
|
|
|
|
|
@return SkImageFilter if previously set, nullptr otherwise
|
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkImageFilter* getImageFilter() const { return fImageFilter.get(); }
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
/** Returns SkImageFilter if set, or nullptr.
|
|
|
|
Increases SkImageFilter SkRefCnt by one.
|
|
|
|
|
|
|
|
@return SkImageFilter if previously set, nullptr otherwise
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_refImageFilter
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkImageFilter> refImageFilter() const;
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2017-09-21 16:28:43 +00:00
|
|
|
/** Sets SkImageFilter to imageFilter, decreasing SkRefCnt of the previous
|
|
|
|
SkImageFilter. Pass nullptr to clear SkImageFilter, and remove SkImageFilter effect
|
2017-07-26 14:15:23 +00:00
|
|
|
on drawing.
|
2017-09-21 16:28:43 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
Increments imageFilter SkRefCnt by one.
|
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
@param imageFilter how SkImage is sampled when transformed
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_setImageFilter
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setImageFilter(sk_sp<SkImageFilter> imageFilter);
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2017-07-31 15:48:27 +00:00
|
|
|
/** Returns true if SkPaint prevents all drawing;
|
|
|
|
otherwise, the SkPaint may or may not allow drawing.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
Returns true if, for example, SkBlendMode combined with alpha computes a
|
2017-09-01 17:49:54 +00:00
|
|
|
new alpha of zero.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@return true if SkPaint prevents all drawing
|
2019-03-15 19:47:01 +00:00
|
|
|
|
|
|
|
example: https://fiddle.skia.org/c/@Paint_nothingToDraw
|
2017-07-26 14:15:23 +00:00
|
|
|
*/
|
2011-10-06 12:37:00 +00:00
|
|
|
bool nothingToDraw() const;
|
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** (to be made private)
|
2017-07-26 14:15:23 +00:00
|
|
|
Returns true if SkPaint does not include elements requiring extensive computation
|
|
|
|
to compute SkBaseDevice bounds of drawn geometry. For instance, SkPaint with SkPathEffect
|
|
|
|
always returns false.
|
2012-05-16 14:15:02 +00:00
|
|
|
|
2017-07-26 14:15:23 +00:00
|
|
|
@return true if SkPaint allows for fast computation of bounds
|
|
|
|
*/
|
2015-08-20 18:10:41 +00:00
|
|
|
bool canComputeFastBounds() const;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** (to be made private)
|
2017-07-31 15:48:27 +00:00
|
|
|
Only call this if canComputeFastBounds() returned true. This takes a
|
2017-07-26 14:15:23 +00:00
|
|
|
raw rectangle (the raw bounds of a shape), and adjusts it for stylistic
|
|
|
|
effects in the paint (e.g. stroking). If needed, it uses the storage
|
2017-09-01 17:49:54 +00:00
|
|
|
parameter. It returns the adjusted bounds that can then be used
|
2017-07-26 14:15:23 +00:00
|
|
|
for SkCanvas::quickReject tests.
|
|
|
|
|
2017-09-01 17:49:54 +00:00
|
|
|
The returned SkRect will either be orig or storage, thus the caller
|
2017-07-26 14:15:23 +00:00
|
|
|
should not rely on storage being set to the result, but should always
|
2017-09-01 17:49:54 +00:00
|
|
|
use the returned value. It is legal for orig and storage to be the same
|
|
|
|
SkRect.
|
2018-05-30 13:20:29 +00:00
|
|
|
For example:
|
|
|
|
if (!path.isInverseFillType() && paint.canComputeFastBounds()) {
|
|
|
|
SkRect storage;
|
|
|
|
if (canvas->quickReject(paint.computeFastBounds(path.getBounds(), &storage))) {
|
|
|
|
return; // do not draw the path
|
|
|
|
}
|
2018-01-03 15:00:34 +00:00
|
|
|
}
|
2018-05-30 13:20:29 +00:00
|
|
|
// draw the path
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param orig geometry modified by SkPaint when drawn
|
|
|
|
@param storage computed bounds of geometry; may not be nullptr
|
|
|
|
@return fast computed bounds
|
|
|
|
*/
|
2012-05-16 14:06:02 +00:00
|
|
|
const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const {
|
2017-05-12 15:21:36 +00:00
|
|
|
// Things like stroking, etc... will do math on the bounds rect, assuming that it's sorted.
|
|
|
|
SkASSERT(orig.isSorted());
|
2012-05-16 14:06:02 +00:00
|
|
|
SkPaint::Style style = this->getStyle();
|
|
|
|
// ultra fast-case: filling with no effects that affect geometry
|
|
|
|
if (kFill_Style == style) {
|
2019-07-22 18:51:10 +00:00
|
|
|
uintptr_t effects = 0;
|
2012-05-16 14:06:02 +00:00
|
|
|
effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
|
|
|
|
effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
|
2014-01-27 21:03:17 +00:00
|
|
|
effects |= reinterpret_cast<uintptr_t>(this->getImageFilter());
|
2012-05-16 14:06:02 +00:00
|
|
|
if (!effects) {
|
|
|
|
return orig;
|
|
|
|
}
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
return this->doComputeFastBounds(orig, storage, style);
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** (to be made private)
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param orig geometry modified by SkPaint when drawn
|
|
|
|
@param storage computed bounds of geometry
|
|
|
|
@return fast computed bounds
|
|
|
|
*/
|
2012-05-16 14:06:02 +00:00
|
|
|
const SkRect& computeFastStrokeBounds(const SkRect& orig,
|
|
|
|
SkRect* storage) const {
|
2012-05-16 19:21:12 +00:00
|
|
|
return this->doComputeFastBounds(orig, storage, kStroke_Style);
|
2012-05-16 14:06:02 +00:00
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-01-03 15:00:34 +00:00
|
|
|
/** (to be made private)
|
2017-09-01 17:49:54 +00:00
|
|
|
Computes the bounds, overriding the SkPaint SkPaint::Style. This can be used to
|
|
|
|
account for additional width required by stroking orig, without
|
|
|
|
altering SkPaint::Style set to fill.
|
2017-07-26 14:15:23 +00:00
|
|
|
|
|
|
|
@param orig geometry modified by SkPaint when drawn
|
|
|
|
@param storage computed bounds of geometry
|
|
|
|
@param style overrides SkPaint::Style
|
|
|
|
@return fast computed bounds
|
|
|
|
*/
|
2012-05-16 14:06:02 +00:00
|
|
|
const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
|
2017-05-10 13:07:42 +00:00
|
|
|
Style style) const;
|
|
|
|
|
2012-05-16 14:15:02 +00:00
|
|
|
private:
|
2016-03-07 02:10:48 +00:00
|
|
|
sk_sp<SkPathEffect> fPathEffect;
|
|
|
|
sk_sp<SkShader> fShader;
|
|
|
|
sk_sp<SkMaskFilter> fMaskFilter;
|
|
|
|
sk_sp<SkColorFilter> fColorFilter;
|
|
|
|
sk_sp<SkImageFilter> fImageFilter;
|
2021-06-17 15:07:55 +00:00
|
|
|
sk_sp<SkBlender> fBlender;
|
2012-05-16 14:15:02 +00:00
|
|
|
|
2018-09-05 14:16:27 +00:00
|
|
|
SkColor4f fColor4f;
|
2012-05-16 14:15:02 +00:00
|
|
|
SkScalar fWidth;
|
|
|
|
SkScalar fMiterLimit;
|
2014-02-21 18:18:05 +00:00
|
|
|
union {
|
|
|
|
struct {
|
2019-01-28 15:57:28 +00:00
|
|
|
unsigned fAntiAlias : 1;
|
|
|
|
unsigned fDither : 1;
|
|
|
|
unsigned fCapType : 2;
|
|
|
|
unsigned fJoinType : 2;
|
|
|
|
unsigned fStyle : 2;
|
|
|
|
unsigned fFilterQuality : 2;
|
2021-06-29 20:21:34 +00:00
|
|
|
unsigned fPadding : 22; // 22 == 32 -1-1-2-2-2-2
|
2014-07-14 21:39:15 +00:00
|
|
|
} fBitfields;
|
|
|
|
uint32_t fBitfieldsUInt;
|
2014-02-21 18:18:05 +00:00
|
|
|
};
|
2020-12-19 20:14:06 +00:00
|
|
|
|
|
|
|
friend class SkPaintPriv;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|