8 #ifndef SkPaint_DEFINED
9 #define SkPaint_DEFINED
11 #include "SkBlendMode.h"
13 #include "SkFilterQuality.h"
17 class SkAutoDescriptor;
18 class SkAutoGlyphCache;
34 struct SkScalerContextEffects;
68 uint32_t getHash()
const;
71 void unflatten(SkReadBuffer& buffer);
94 Hinting getHinting()
const {
95 return static_cast<Hinting
>(fBitfields.fHinting);
98 void setHinting(Hinting hintingLevel);
103 kAntiAlias_Flag = 0x01,
105 kFakeBoldText_Flag = 0x20,
106 kLinearText_Flag = 0x40,
107 kSubpixelText_Flag = 0x80,
108 kDevKernText_Flag = 0x100,
109 kLCDRenderText_Flag = 0x200,
110 kEmbeddedBitmapText_Flag = 0x400,
111 kAutoHinting_Flag = 0x800,
112 kVerticalText_Flag = 0x1000,
113 kGenA8FromLCD_Flag = 0x2000,
120 #ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
124 kUnderlineText_ReserveFlag = 0x08,
125 kStrikeThruText_ReserveFlag = 0x10,
132 uint32_t
getFlags()
const {
return fBitfields.fFlags; }
137 void setFlags(uint32_t flags);
143 return SkToBool(this->getFlags() & kAntiAlias_Flag);
149 void setAntiAlias(
bool aa);
155 return SkToBool(this->getFlags() & kDither_Flag);
164 void setDither(
bool dither);
170 return SkToBool(this->getFlags() & kLinearText_Flag);
177 void setLinearText(
bool linearText);
183 return SkToBool(this->getFlags() & kSubpixelText_Flag);
191 void setSubpixelText(
bool subpixelText);
193 bool isLCDRenderText()
const {
194 return SkToBool(this->getFlags() & kLCDRenderText_Flag);
203 void setLCDRenderText(
bool lcdText);
205 bool isEmbeddedBitmapText()
const {
206 return SkToBool(this->getFlags() & kEmbeddedBitmapText_Flag);
213 void setEmbeddedBitmapText(
bool useEmbeddedBitmapText);
215 bool isAutohinted()
const {
216 return SkToBool(this->getFlags() & kAutoHinting_Flag);
224 void setAutohinted(
bool useAutohinter);
226 bool isVerticalText()
const {
227 return SkToBool(this->getFlags() & kVerticalText_Flag);
238 void setVerticalText(
bool verticalText);
244 return SkToBool(this->getFlags() & kFakeBoldText_Flag);
251 void setFakeBoldText(
bool fakeBoldText);
257 return SkToBool(this->getFlags() & kDevKernText_Flag);
264 void setDevKernText(
bool devKernText);
271 return (SkFilterQuality)fBitfields.fFilterQuality;
278 void setFilterQuality(SkFilterQuality quality);
295 kStyleCount = kStrokeAndFill_Style + 1
310 void setStyle(Style style);
336 void setAlpha(
U8CPU a);
362 void setStrokeWidth(SkScalar width);
377 void setStrokeMiter(SkScalar miter);
397 kLast_Cap = kSquare_Cap,
398 kDefault_Cap = kButt_Cap
400 static constexpr
int kCapCount = kLast_Cap + 1;
410 kLast_Join = kBevel_Join,
411 kDefault_Join = kMiter_Join
413 static constexpr
int kJoinCount = kLast_Join + 1;
426 void setStrokeCap(Cap cap);
438 void setStrokeJoin(Join join);
455 SkScalar resScale = 1)
const;
457 bool getFillPath(
const SkPath& src,
SkPath* dst)
const {
458 return this->getFillPath(src, dst, NULL, 1);
506 SkBlendMode getBlendMode()
const {
return (SkBlendMode)fBlendMode; }
507 bool isSrcOver()
const {
return (SkBlendMode)fBlendMode == SkBlendMode::kSrcOver; }
508 void setBlendMode(SkBlendMode mode) { fBlendMode = (unsigned)mode; }
594 SkImageFilter* getImageFilter()
const {
return fImageFilter.get(); }
605 SkDrawLooper* getLooper()
const {
return fDrawLooper.get(); }
636 void setTextAlign(Align align);
646 void setTextSize(SkScalar textSize);
660 void setTextScaleX(SkScalar scaleX);
672 void setTextSkewX(SkScalar skewX);
681 kGlyphID_TextEncoding
684 TextEncoding getTextEncoding()
const {
685 return (TextEncoding)fBitfields.fTextEncoding;
688 void setTextEncoding(TextEncoding encoding);
695 kUnderlineThicknessIsValid_Flag = 1 << 0,
696 kUnderlinePositionIsValid_Flag = 1 << 1,
726 if (
SkToBool(fFlags & kUnderlineThicknessIsValid_Flag)) {
727 *thickness = fUnderlineThickness;
738 if (
SkToBool(fFlags & kUnderlinePositionIsValid_Flag)) {
739 *position = fUnderlinePosition;
758 SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0)
const;
769 int textToGlyphs(
const void* text,
size_t byteLength,
779 bool containsText(
const void* text,
size_t byteLength)
const;
792 int countText(
const void* text,
size_t byteLength)
const {
793 return this->textToGlyphs(text, byteLength, NULL);
806 SkScalar measureText(
const void* text,
size_t length,
SkRect* bounds)
const;
817 return this->measureText(text, length, NULL);
833 size_t breakText(
const void* text,
size_t length, SkScalar maxWidth,
834 SkScalar* measuredWidth = NULL)
const;
848 int getTextWidths(
const void* text,
size_t byteLength, SkScalar widths[],
849 SkRect bounds[] = NULL)
const;
861 void getTextPath(
const void* text,
size_t length, SkScalar x, SkScalar y,
873 void getPosTextPath(
const void* text,
size_t length,
892 int getTextIntercepts(
const void* text,
size_t length, SkScalar x, SkScalar y,
893 const SkScalar bounds[2], SkScalar* intervals)
const;
910 int getPosTextIntercepts(
const void* text,
size_t length,
const SkPoint pos[],
911 const SkScalar bounds[2], SkScalar* intervals)
const;
929 int getPosTextHIntercepts(
const void* text,
size_t length,
const SkScalar xpos[],
930 SkScalar constY,
const SkScalar bounds[2], SkScalar* intervals)
const;
944 int getTextBlobIntercepts(
const SkTextBlob* blob,
const SkScalar bounds[2],
945 SkScalar* intervals)
const;
953 SkRect getFontBounds()
const;
957 bool nothingToDraw()
const;
966 bool canComputeFastBounds()
const;
994 if (kFill_Style == style) {
995 uintptr_t effects =
reinterpret_cast<uintptr_t
>(this->getLooper());
996 effects |=
reinterpret_cast<uintptr_t
>(this->getMaskFilter());
997 effects |=
reinterpret_cast<uintptr_t
>(this->getPathEffect());
998 effects |=
reinterpret_cast<uintptr_t
>(this->getImageFilter());
1004 return this->doComputeFastBounds(orig, storage, style);
1007 const SkRect& computeFastStrokeBounds(
const SkRect& orig,
1009 return this->doComputeFastBounds(orig, storage, kStroke_Style);
1019 SK_TO_STRING_NONVIRT()
1022 typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const
char**);
1034 SkScalar fTextScaleX;
1035 SkScalar fTextSkewX;
1038 SkScalar fMiterLimit;
1039 uint32_t fBlendMode;
1043 unsigned fFlags : 16;
1044 unsigned fTextAlign : 2;
1045 unsigned fCapType : 2;
1046 unsigned fJoinType : 2;
1047 unsigned fStyle : 2;
1048 unsigned fTextEncoding : 2;
1049 unsigned fHinting : 2;
1050 unsigned fFilterQuality : 2;
1053 uint32_t fBitfieldsUInt;
1056 static GlyphCacheProc GetGlyphCacheProc(TextEncoding encoding,
1058 bool needFullMetrics);
1060 SkScalar measure_text(SkGlyphCache*,
const char* text,
size_t length,
1061 int* count,
SkRect* bounds)
const;
1063 enum ScalerContextFlags : uint32_t {
1064 kNone_ScalerContextFlags = 0,
1066 kFakeGamma_ScalerContextFlag = 1 << 0,
1067 kBoostContrast_ScalerContextFlag = 1 << 1,
1069 kFakeGammaAndBoostContrast_ScalerContextFlags =
1070 kFakeGamma_ScalerContextFlag | kBoostContrast_ScalerContextFlag,
1077 void getScalerContextDescriptor(SkScalerContextEffects*, SkAutoDescriptor*,
1079 uint32_t scalerContextFlags,
const SkMatrix*)
const;
1081 SkGlyphCache* detachCache(
const SkSurfaceProps* surfaceProps, uint32_t scalerContextFlags,
1084 void descriptorProc(
const SkSurfaceProps* surfaceProps, uint32_t scalerContextFlags,
1086 void (*proc)(
SkTypeface*,
const SkScalerContextEffects&,
1087 const SkDescriptor*,
void*),
1088 void* context)
const;
1095 SkColor computeLuminanceColor()
const;
1112 kCanonicalTextSizeForPaths = 64,
1120 SkScalar setupForAsPaths();
1122 static SkScalar MaxCacheSize2();
1124 friend class SkAutoGlyphCache;
1125 friend class SkAutoGlyphCacheNoGamma;
1127 friend class SkDraw;
1128 friend class SkPDFDevice;
1129 friend class GrAtlasTextBlob;
1130 friend class GrAtlasTextContext;
1131 friend class GrStencilAndCoverTextContext;
1132 friend class GrPathRendering;
1133 friend class GrTextUtils;
1134 friend class GrGLPathRendering;
1135 friend class SkScalerContext;
1136 friend class SkTextBaseIter;
1137 friend class SkCanonicalizePaint;
SkScalar fTop
The greatest distance above the baseline for any glyph (will be <= 0)
Definition: SkPaint.h:700
bool isDevKernText() const
Helper for getFlags(), returns true if kDevKernText_Flag bit is set.
Definition: SkPaint.h:256
bool hasUnderlineThickness(SkScalar *thickness) const
If the fontmetrics has a valid underline thickness, return true, and set the thickness param to that ...
Definition: SkPaint.h:725
A Canvas encapsulates all of the state about drawing into a device (bitmap).
Definition: SkCanvas.h:59
begin/end contours with a semi-circle extension
Definition: SkPaint.h:394
connect path segments with a round join
Definition: SkPaint.h:407
SkPathEffect * getPathEffect() const
Get the paint's patheffect object.
Definition: SkPaint.h:515
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:25
SkTextBlob combines multiple text runs into an immutable, ref-counted structure.
Definition: SkTextBlob.h:24
SkScalar fDescent
The recommended distance below the baseline (will be >= 0)
Definition: SkPaint.h:702
Shaders specify the source color(s) for what is being drawn.
Definition: SkShader.h:41
SkPathEffect is the base class for objects in the SkPaint that affect the geometry of a drawing primi...
Definition: SkPathEffect.h:27
Style getStyle() const
Return the paint's style, used for controlling how primitives' geometries are interpreted (except for...
Definition: SkPaint.h:303
SkScalar getStrokeMiter() const
Return the paint's stroke miter value.
Definition: SkPaint.h:369
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:32
uint16_t SkGlyphID
16 bit unsigned integer to hold a glyph index
Definition: SkTypes.h:299
bool hasUnderlinePosition(SkScalar *position) const
If the fontmetrics has a valid underline position, return true, and set the position param to that va...
Definition: SkPaint.h:737
bool isFakeBoldText() const
Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set.
Definition: SkPaint.h:243
SkScalar getStrokeWidth() const
Return the width for stroking.
Definition: SkPaint.h:354
the text parameters are UTF8
Definition: SkPaint.h:678
SkScalar fMaxCharWidth
the max character width (>= 0)
Definition: SkPaint.h:706
Describes properties and constraints of a given SkSurface.
Definition: SkSurfaceProps.h:51
Definition: SkPoint.h:156
SkMaskFilter * getMaskFilter() const
Get the paint's maskfilter object.
Definition: SkPaint.h:535
Cap
Cap enum specifies the settings for the paint's strokecap.
Definition: SkPaint.h:392
the text parameters are UTF16
Definition: SkPaint.h:679
TextEncoding
Describes how to interpret the text parameters that are passed to paint methods like measureText() an...
Definition: SkPaint.h:677
connect path segments with a flat bevel join
Definition: SkPaint.h:408
Align getTextAlign() const
Return the paint's Align value for drawing text.
Definition: SkPaint.h:631
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:28
Hinting
Specifies the level of hinting to be performed.
Definition: SkPaint.h:87
SkScalar measureText(const void *text, size_t length) const
Return the width of the text.
Definition: SkPaint.h:816
The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
Definition: SkPaint.h:45
SkScalar fXMin
The minimum bounding box x value for all glyphs.
Definition: SkPaint.h:707
stroke the geometry
Definition: SkPaint.h:291
uint8_t getAlpha() const
Helper to getColor() that just returns the color's alpha value.
Definition: SkPaint.h:330
bool isAntiAlias() const
Helper for getFlags(), returning true if kAntiAlias_Flag bit is set.
Definition: SkPaint.h:142
fill the geometry
Definition: SkPaint.h:290
Definition: SkRasterizer.h:21
Definition: SkPaint.h:690
SkData holds an immutable data buffer.
Definition: SkData.h:22
Join
Join enum specifies the settings for the paint's strokejoin.
Definition: SkPaint.h:405
#define SkToBool(cond)
Returns 0 or 1 based on the condition.
Definition: SkTypes.h:227
Cap getStrokeCap() const
Return the paint's stroke cap type, controlling how the start and end of stroked lines and paths are ...
Definition: SkPaint.h:420
SkScalar getTextScaleX() const
Return the paint's horizontal scale factor for text.
Definition: SkPaint.h:652
The SkTypeface class specifies the typeface and intrinsic style of a font.
Definition: SkTypeface.h:43
Base class for image filters.
Definition: SkImageFilter.h:36
SkScalar fLeading
The recommended distance to add between lines of text (will be >= 0)
Definition: SkPaint.h:704
connect path segments with a sharp join
Definition: SkPaint.h:406
uint32_t getFlags() const
Return the paint's flags.
Definition: SkPaint.h:132
the text parameters are UTF32
Definition: SkPaint.h:680
SkScalar getFontSpacing() const
Return the recommend line spacing.
Definition: SkPaint.h:763
SkMaskFilter is the base class for object that perform transformations on an alpha-channel mask befor...
Definition: SkMaskFilter.h:47
SkDrawLooper * getDrawLooper() const
Return the paint's SkDrawLooper (if any).
Definition: SkPaint.h:602
bool isSubpixelText() const
Helper for getFlags(), returning true if kSubpixelText_Flag bit is set.
Definition: SkPaint.h:182
Style
Styles apply to rect, oval, path, and text.
Definition: SkPaint.h:289
bool isSorted() const
Return true if the rectangle's width and height are >= 0.
Definition: SkRect.h:477
int32_t SkUnichar
32 bit integer to hold a unicode value
Definition: SkTypes.h:295
SkRasterizer * getRasterizer() const
Get the paint's rasterizer (or NULL).
Definition: SkPaint.h:578
SkTypeface * getTypeface() const
Get the paint's typeface object.
Definition: SkPaint.h:558
uint32_t SkColor
32 bit ARGB color value, not premultiplied.
Definition: SkColor.h:28
SkScalar fAvgCharWidth
the average character width (>= 0)
Definition: SkPaint.h:705
SkScalar fXMax
The maximum bounding box x value for all glyphs.
Definition: SkPaint.h:708
SkScalar fUnderlinePosition
Underline Position - position of the top of the Underline stroke relative to the baseline, this can have following values.
Definition: SkPaint.h:719
Subclasses of SkDrawLooper can be attached to a SkPaint.
Definition: SkDrawLooper.h:33
Definition: SkWriteBuffer.h:27
const SkRect & computeFastBounds(const SkRect &orig, SkRect *storage) const
Only call this if canComputeFastBounds() returned true.
Definition: SkPaint.h:989
SkScalar getTextSize() const
Return the paint's text size.
Definition: SkPaint.h:641
Flags
Specifies the bit values that are stored in the paint's flags.
Definition: SkPaint.h:102
#define SkColorGetA(color)
return the alpha byte from a SkColor value
Definition: SkColor.h:62
SkFilterQuality getFilterQuality() const
Return the filter level.
Definition: SkPaint.h:270
fill and stroke the geometry
Definition: SkPaint.h:292
SkScalar fAscent
The recommended distance above the baseline (will be <= 0)
Definition: SkPaint.h:701
begin/end contours with no extension
Definition: SkPaint.h:393
SkShader * getShader() const
Get the paint's shader object.
Definition: SkPaint.h:466
SkScalar getTextSkewX() const
Return the paint's horizontal skew factor for text.
Definition: SkPaint.h:666
SkScalar fCapHeight
The cap height (> 0), or 0 if cannot be determined.
Definition: SkPaint.h:710
uint32_t fFlags
Bit field to identify which values are unknown.
Definition: SkPaint.h:699
bool isLinearText() const
Helper for getFlags(), returning true if kLinearText_Flag bit is set.
Definition: SkPaint.h:169
int countText(const void *text, size_t byteLength) const
Return the number of drawable units in the specified text buffer.
Definition: SkPaint.h:792
unsigned U8CPU
Fast type for unsigned 8 bits.
Definition: SkTypes.h:191
begin/end contours with a half square extension
Definition: SkPaint.h:395
Join getStrokeJoin() const
Return the paint's stroke join type.
Definition: SkPaint.h:432
bool isDither() const
Helper for getFlags(), returning true if kDither_Flag bit is set.
Definition: SkPaint.h:154
SkColorFilter * getColorFilter() const
Get the paint's colorfilter.
Definition: SkPaint.h:495
SkScalar fBottom
The greatest distance below the baseline for any glyph (will be >= 0)
Definition: SkPaint.h:703
FontMetricsFlags
Flags which indicate the confidence level of various metrics.
Definition: SkPaint.h:694
SkScalar fXHeight
The height of an 'x' in px, or 0 if no 'x' in face.
Definition: SkPaint.h:709
SkColor getColor() const
Return the paint's color.
Definition: SkPaint.h:318
Types and macros for colors.
SkScalar fUnderlineThickness
underline thickness, or 0 if cannot be determined
Definition: SkPaint.h:711