Skia
2DGraphicsLibrary
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SkPaint.h
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 SkPaint_DEFINED
9 #define SkPaint_DEFINED
10 
11 #include "SkColor.h"
12 #include "SkFilterQuality.h"
13 #include "SkMatrix.h"
14 #include "SkXfermode.h"
15 
16 class SkAutoDescriptor;
17 class SkAutoGlyphCache;
18 class SkColorFilter;
19 class SkData;
20 class SkDescriptor;
21 class SkDrawLooper;
22 class SkReadBuffer;
23 class SkWriteBuffer;
24 class SkGlyph;
25 struct SkRect;
26 class SkGlyphCache;
27 class SkImageFilter;
28 class SkMaskFilter;
29 class SkPath;
30 class SkPathEffect;
31 struct SkPoint;
32 class SkRasterizer;
33 struct SkScalerContextEffects;
34 class SkShader;
35 class SkSurfaceProps;
36 class SkTextBlob;
37 class SkTypeface;
38 
39 #define kBicubicFilterBitmap_Flag kHighQualityFilterBitmap_Flag
40 
46 class SK_API SkPaint {
47 public:
48  SkPaint();
49  SkPaint(const SkPaint& paint);
50  SkPaint(SkPaint&& paint);
51  ~SkPaint();
52 
53  SkPaint& operator=(const SkPaint&);
54  SkPaint& operator=(SkPaint&&);
55 
60  SK_API friend bool operator==(const SkPaint& a, const SkPaint& b);
61  friend bool operator!=(const SkPaint& a, const SkPaint& b) {
62  return !(a == b);
63  }
64 
68  uint32_t getHash() const;
69 
70  void flatten(SkWriteBuffer&) const;
71  void unflatten(SkReadBuffer&);
72 
75  void reset();
76 
87  enum Hinting {
88  kNo_Hinting = 0,
89  kSlight_Hinting = 1,
90  kNormal_Hinting = 2,
91  kFull_Hinting = 3
92  };
93 
94  Hinting getHinting() const {
95  return static_cast<Hinting>(fBitfields.fHinting);
96  }
97 
98  void setHinting(Hinting hintingLevel);
99 
102  enum Flags {
103  kAntiAlias_Flag = 0x01,
104  kDither_Flag = 0x04,
105  kUnderlineText_Flag = 0x08,
106  kStrikeThruText_Flag = 0x10,
107  kFakeBoldText_Flag = 0x20,
108  kLinearText_Flag = 0x40,
109  kSubpixelText_Flag = 0x80,
110  kDevKernText_Flag = 0x100,
111  kLCDRenderText_Flag = 0x200,
112  kEmbeddedBitmapText_Flag = 0x400,
113  kAutoHinting_Flag = 0x800,
114  kVerticalText_Flag = 0x1000,
115  kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it
116  // when adding extra flags, note that the fFlags member is specified
117  // with a bit-width and you'll have to expand it.
118 
119  kAllFlags = 0xFFFF
120  };
121 
125  uint32_t getFlags() const { return fBitfields.fFlags; }
126 
130  void setFlags(uint32_t flags);
131 
135  bool isAntiAlias() const {
136  return SkToBool(this->getFlags() & kAntiAlias_Flag);
137  }
138 
142  void setAntiAlias(bool aa);
143 
147  bool isDither() const {
148  return SkToBool(this->getFlags() & kDither_Flag);
149  }
150 
154  void setDither(bool dither);
155 
159  bool isLinearText() const {
160  return SkToBool(this->getFlags() & kLinearText_Flag);
161  }
162 
167  void setLinearText(bool linearText);
168 
172  bool isSubpixelText() const {
173  return SkToBool(this->getFlags() & kSubpixelText_Flag);
174  }
175 
181  void setSubpixelText(bool subpixelText);
182 
183  bool isLCDRenderText() const {
184  return SkToBool(this->getFlags() & kLCDRenderText_Flag);
185  }
186 
193  void setLCDRenderText(bool lcdText);
194 
195  bool isEmbeddedBitmapText() const {
196  return SkToBool(this->getFlags() & kEmbeddedBitmapText_Flag);
197  }
198 
203  void setEmbeddedBitmapText(bool useEmbeddedBitmapText);
204 
205  bool isAutohinted() const {
206  return SkToBool(this->getFlags() & kAutoHinting_Flag);
207  }
208 
214  void setAutohinted(bool useAutohinter);
215 
216  bool isVerticalText() const {
217  return SkToBool(this->getFlags() & kVerticalText_Flag);
218  }
219 
228  void setVerticalText(bool);
229 
233  bool isUnderlineText() const {
234  return SkToBool(this->getFlags() & kUnderlineText_Flag);
235  }
236 
241  void setUnderlineText(bool underlineText);
242 
246  bool isStrikeThruText() const {
247  return SkToBool(this->getFlags() & kStrikeThruText_Flag);
248  }
249 
254  void setStrikeThruText(bool strikeThruText);
255 
259  bool isFakeBoldText() const {
260  return SkToBool(this->getFlags() & kFakeBoldText_Flag);
261  }
262 
267  void setFakeBoldText(bool fakeBoldText);
268 
272  bool isDevKernText() const {
273  return SkToBool(this->getFlags() & kDevKernText_Flag);
274  }
275 
280  void setDevKernText(bool devKernText);
281 
286  SkFilterQuality getFilterQuality() const {
287  return (SkFilterQuality)fBitfields.fFilterQuality;
288  }
289 
294  void setFilterQuality(SkFilterQuality quality);
295 
305  enum Style {
309  };
310  enum {
311  kStyleCount = kStrokeAndFill_Style + 1
312  };
313 
319  Style getStyle() const { return (Style)fBitfields.fStyle; }
320 
326  void setStyle(Style style);
327 
334  SkColor getColor() const { return fColor; }
335 
341  void setColor(SkColor color);
342 
346  uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); }
347 
352  void setAlpha(U8CPU a);
353 
361  void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
362 
370  SkScalar getStrokeWidth() const { return fWidth; }
371 
378  void setStrokeWidth(SkScalar width);
379 
385  SkScalar getStrokeMiter() const { return fMiterLimit; }
386 
393  void setStrokeMiter(SkScalar miter);
394 
408  enum Cap {
412 
413  kLast_Cap = kSquare_Cap,
414  kDefault_Cap = kButt_Cap
415  };
416  static constexpr int kCapCount = kLast_Cap + 1;
417 
421  enum Join {
425 
426  kLast_Join = kBevel_Join,
427  kDefault_Join = kMiter_Join
428  };
429  static constexpr int kJoinCount = kLast_Join + 1;
430 
436  Cap getStrokeCap() const { return (Cap)fBitfields.fCapType; }
437 
442  void setStrokeCap(Cap cap);
443 
448  Join getStrokeJoin() const { return (Join)fBitfields.fJoinType; }
449 
454  void setStrokeJoin(Join join);
455 
470  bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
471  SkScalar resScale = 1) const;
472 
473  bool getFillPath(const SkPath& src, SkPath* dst) const {
474  return this->getFillPath(src, dst, NULL, 1);
475  }
476 
482  SkShader* getShader() const { return fShader.get(); }
483 
505  void setShader(sk_sp<SkShader>);
506 #ifdef SK_SUPPORT_LEGACY_CREATESHADER_PTR
507  SkShader* setShader(SkShader* shader);
508 #endif
509 
514  SkColorFilter* getColorFilter() const { return fColorFilter.get(); }
515 
523 #ifdef SK_SUPPORT_LEGACY_COLORFILTER_PTR
524  SkColorFilter* setColorFilter(SkColorFilter* filter);
525 #endif
526  void setColorFilter(sk_sp<SkColorFilter>);
527 
533  SkXfermode* getXfermode() const { return fXfermode.get(); }
534 
545  void setXfermode(sk_sp<SkXfermode>);
546 #ifdef SK_SUPPORT_LEGACY_XFERMODE_PTR
547  SkXfermode* setXfermode(SkXfermode* xfermode);
548 #endif
549 
554  SkXfermode* setXfermodeMode(SkXfermode::Mode);
555 
561  SkPathEffect* getPathEffect() const { return fPathEffect.get(); }
562 
573  void setPathEffect(sk_sp<SkPathEffect>);
574 #ifdef SK_SUPPORT_LEGACY_PATHEFFECT_PTR
575  SkPathEffect* setPathEffect(SkPathEffect* effect);
576 #endif
577 
583  SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); }
584 
595 #ifdef SK_SUPPORT_LEGACY_MASKFILTER_PTR
596  SkMaskFilter* setMaskFilter(SkMaskFilter* maskfilter);
597 #endif
598  void setMaskFilter(sk_sp<SkMaskFilter>);
599 
600  // These attributes are for text/fonts
601 
608  SkTypeface* getTypeface() const { return fTypeface.get(); }
609 
620  void setTypeface(sk_sp<SkTypeface>);
621 #ifdef SK_SUPPORT_LEGACY_TYPEFACE_PTR
622  SkTypeface* setTypeface(SkTypeface* typeface);
623 #endif
624 
630  SkRasterizer* getRasterizer() const { return fRasterizer.get(); }
631 
643 #ifdef SK_SUPPORT_LEGACY_MINOR_EFFECT_PTR
644  SkRasterizer* setRasterizer(SkRasterizer* rasterizer);
645 #endif
646  void setRasterizer(sk_sp<SkRasterizer>);
647 
648  SkImageFilter* getImageFilter() const { return fImageFilter.get(); }
649  SkImageFilter* setImageFilter(SkImageFilter*);
650  void setImageFilter(sk_sp<SkImageFilter>);
651 
656  SkDrawLooper* getLooper() const { return fLooper.get(); }
657 
669 #ifdef SK_SUPPORT_LEGACY_MINOR_EFFECT_PTR
670  SkDrawLooper* setLooper(SkDrawLooper* looper);
671 #endif
672  void setLooper(sk_sp<SkDrawLooper>);
673 
674  enum Align {
675  kLeft_Align,
676  kCenter_Align,
677  kRight_Align,
678  };
679  enum {
680  kAlignCount = 3
681  };
682 
686  Align getTextAlign() const { return (Align)fBitfields.fTextAlign; }
687 
691  void setTextAlign(Align align);
692 
696  SkScalar getTextSize() const { return fTextSize; }
697 
701  void setTextSize(SkScalar textSize);
702 
707  SkScalar getTextScaleX() const { return fTextScaleX; }
708 
715  void setTextScaleX(SkScalar scaleX);
716 
721  SkScalar getTextSkewX() const { return fTextSkewX; }
722 
727  void setTextSkewX(SkScalar skewX);
728 
736  kGlyphID_TextEncoding
737  };
738 
739  TextEncoding getTextEncoding() const {
740  return (TextEncoding)fBitfields.fTextEncoding;
741  }
742 
743  void setTextEncoding(TextEncoding encoding);
744 
745  struct FontMetrics {
750  kUnderlineThinknessIsValid_Flag = 1 << 0,
751  kUnderlinePositionIsValid_Flag = 1 << 1,
752  };
753 
754  uint32_t fFlags;
755  SkScalar fTop;
756  SkScalar fAscent;
757  SkScalar fDescent;
758  SkScalar fBottom;
759  SkScalar fLeading;
760  SkScalar fAvgCharWidth;
761  SkScalar fMaxCharWidth;
762  SkScalar fXMin;
763  SkScalar fXMax;
764  SkScalar fXHeight;
765  SkScalar fCapHeight;
767 
775 
780  bool hasUnderlineThickness(SkScalar* thickness) const {
781  if (SkToBool(fFlags & kUnderlineThinknessIsValid_Flag)) {
782  *thickness = fUnderlineThickness;
783  return true;
784  }
785  return false;
786  }
787 
792  bool hasUnderlinePosition(SkScalar* position) const {
793  if (SkToBool(fFlags & kUnderlinePositionIsValid_Flag)) {
794  *position = fUnderlinePosition;
795  return true;
796  }
797  return false;
798  }
799 
800  };
801 
813  SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0) const;
814 
818  SkScalar getFontSpacing() const { return this->getFontMetrics(NULL, 0); }
819 
824  int textToGlyphs(const void* text, size_t byteLength,
825  SkGlyphID glyphs[]) const;
826 
834  bool containsText(const void* text, size_t byteLength) const;
835 
840  void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const;
841 
847  int countText(const void* text, size_t byteLength) const {
848  return this->textToGlyphs(text, byteLength, NULL);
849  }
850 
861  SkScalar measureText(const void* text, size_t length, SkRect* bounds) const;
862 
871  SkScalar measureText(const void* text, size_t length) const {
872  return this->measureText(text, length, NULL);
873  }
874 
888  size_t breakText(const void* text, size_t length, SkScalar maxWidth,
889  SkScalar* measuredWidth = NULL) const;
890 
903  int getTextWidths(const void* text, size_t byteLength, SkScalar widths[],
904  SkRect bounds[] = NULL) const;
905 
916  void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y,
917  SkPath* path) const;
918 
928  void getPosTextPath(const void* text, size_t length,
929  const SkPoint pos[], SkPath* path) const;
930 
947  int getTextIntercepts(const void* text, size_t length, SkScalar x, SkScalar y,
948  const SkScalar bounds[2], SkScalar* intervals) const;
949 
965  int getPosTextIntercepts(const void* text, size_t length, const SkPoint pos[],
966  const SkScalar bounds[2], SkScalar* intervals) const;
967 
984  int getPosTextHIntercepts(const void* text, size_t length, const SkScalar xpos[],
985  SkScalar constY, const SkScalar bounds[2], SkScalar* intervals) const;
986 
999  int getTextBlobIntercepts(const SkTextBlob* blob, const SkScalar bounds[2],
1000  SkScalar* intervals) const;
1001 
1008  SkRect getFontBounds() const;
1009 
1010  // returns true if the paint's settings (e.g. xfermode + alpha) resolve to
1011  // mean that we need not draw at all (e.g. SrcOver + 0-alpha)
1012  bool nothingToDraw() const;
1013 
1015  // would prefer to make these private...
1016 
1021  bool canComputeFastBounds() const;
1022 
1044  const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const {
1045  SkPaint::Style style = this->getStyle();
1046  // ultra fast-case: filling with no effects that affect geometry
1047  if (kFill_Style == style) {
1048  uintptr_t effects = reinterpret_cast<uintptr_t>(this->getLooper());
1049  effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
1050  effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
1051  effects |= reinterpret_cast<uintptr_t>(this->getImageFilter());
1052  if (!effects) {
1053  return orig;
1054  }
1055  }
1056 
1057  return this->doComputeFastBounds(orig, storage, style);
1058  }
1059 
1060  const SkRect& computeFastStrokeBounds(const SkRect& orig,
1061  SkRect* storage) const {
1062  return this->doComputeFastBounds(orig, storage, kStroke_Style);
1063  }
1064 
1065  // Take the style explicitly, so the caller can force us to be stroked
1066  // without having to make a copy of the paint just to change that field.
1067  const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
1068  Style) const;
1069 
1073  static SkMatrix* SetTextMatrix(SkMatrix* matrix, SkScalar size,
1074  SkScalar scaleX, SkScalar skewX) {
1075  matrix->setScale(size * scaleX, size);
1076  if (skewX) {
1077  matrix->postSkew(skewX, 0);
1078  }
1079  return matrix;
1080  }
1081 
1082  SkMatrix* setTextMatrix(SkMatrix* matrix) const {
1083  return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX);
1084  }
1085 
1086  typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**);
1087 
1088  SK_TO_STRING_NONVIRT()
1089 
1090 private:
1091  sk_sp<SkTypeface> fTypeface;
1092  sk_sp<SkPathEffect> fPathEffect;
1093  sk_sp<SkShader> fShader;
1094  sk_sp<SkXfermode> fXfermode;
1095  sk_sp<SkMaskFilter> fMaskFilter;
1096  sk_sp<SkColorFilter> fColorFilter;
1097  sk_sp<SkRasterizer> fRasterizer;
1098  sk_sp<SkDrawLooper> fLooper;
1099  sk_sp<SkImageFilter> fImageFilter;
1100 
1101  SkScalar fTextSize;
1102  SkScalar fTextScaleX;
1103  SkScalar fTextSkewX;
1104  SkColor fColor;
1105  SkScalar fWidth;
1106  SkScalar fMiterLimit;
1107  union {
1108  struct {
1109  // all of these bitfields should add up to 32
1110  unsigned fFlags : 16;
1111  unsigned fTextAlign : 2;
1112  unsigned fCapType : 2;
1113  unsigned fJoinType : 2;
1114  unsigned fStyle : 2;
1115  unsigned fTextEncoding : 2; // 3 values
1116  unsigned fHinting : 2;
1117  unsigned fFilterQuality : 2;
1118  //unsigned fFreeBits : 2;
1119  } fBitfields;
1120  uint32_t fBitfieldsUInt;
1121  };
1122 
1123  static GlyphCacheProc GetGlyphCacheProc(TextEncoding encoding,
1124  bool isDevKern,
1125  bool needFullMetrics);
1126 
1127  SkScalar measure_text(SkGlyphCache*, const char* text, size_t length,
1128  int* count, SkRect* bounds) const;
1129 
1130  enum ScalerContextFlags : uint32_t {
1131  kNone_ScalerContextFlags = 0,
1132 
1133  kFakeGamma_ScalerContextFlag = 1 << 0,
1134  kBoostContrast_ScalerContextFlag = 1 << 1,
1135 
1136  kFakeGammaAndBoostContrast_ScalerContextFlags =
1137  kFakeGamma_ScalerContextFlag | kBoostContrast_ScalerContextFlag,
1138  };
1139 
1140  /*
1141  * Allocs an SkDescriptor on the heap and return it to the caller as a refcnted
1142  * SkData. Caller is responsible for managing the lifetime of this object.
1143  */
1144  void getScalerContextDescriptor(SkScalerContextEffects*, SkAutoDescriptor*,
1145  const SkSurfaceProps& surfaceProps,
1146  uint32_t scalerContextFlags, const SkMatrix*) const;
1147 
1148  SkGlyphCache* detachCache(const SkSurfaceProps* surfaceProps, uint32_t scalerContextFlags,
1149  const SkMatrix*) const;
1150 
1151  void descriptorProc(const SkSurfaceProps* surfaceProps, uint32_t scalerContextFlags,
1152  const SkMatrix* deviceMatrix,
1153  void (*proc)(SkTypeface*, const SkScalerContextEffects&,
1154  const SkDescriptor*, void*),
1155  void* context) const;
1156 
1157  /*
1158  * The luminance color is used to determine which Gamma Canonical color to map to. This is
1159  * really only used by backends which want to cache glyph masks, and need some way to know if
1160  * they need to generate new masks based off a given color.
1161  */
1162  SkColor computeLuminanceColor() const;
1163 
1164  enum {
1165  /* This is the size we use when we ask for a glyph's path. We then
1166  * post-transform it as we draw to match the request.
1167  * This is done to try to re-use cache entries for the path.
1168  *
1169  * This value is somewhat arbitrary. In theory, it could be 1, since
1170  * we store paths as floats. However, we get the path from the font
1171  * scaler, and it may represent its paths as fixed-point (or 26.6),
1172  * so we shouldn't ask for something too big (might overflow 16.16)
1173  * or too small (underflow 26.6).
1174  *
1175  * This value could track kMaxSizeForGlyphCache, assuming the above
1176  * constraints, but since we ask for unhinted paths, the two values
1177  * need not match per-se.
1178  */
1179  kCanonicalTextSizeForPaths = 64,
1180 
1181  /*
1182  * Above this size (taking into account CTM and textSize), we never use
1183  * the cache for bits or metrics (we might overflow), so we just ask
1184  * for a caononical size and post-transform that.
1185  */
1186  kMaxSizeForGlyphCache = 256,
1187  };
1188 
1189  static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM);
1190 
1191  // Set flags/hinting/textSize up to use for drawing text as paths.
1192  // Returns scale factor to restore the original textSize, since will will
1193  // have change it to kCanonicalTextSizeForPaths.
1194  SkScalar setupForAsPaths();
1195 
1196  static SkScalar MaxCacheSize2() {
1197  static const SkScalar kMaxSize = SkIntToScalar(kMaxSizeForGlyphCache);
1198  static const SkScalar kMag2Max = kMaxSize * kMaxSize;
1199  return kMag2Max;
1200  }
1201 
1202  friend class SkAutoGlyphCache;
1203  friend class SkAutoGlyphCacheNoGamma;
1204  friend class SkCanvas;
1205  friend class SkDraw;
1206  friend class SkPDFDevice;
1207  friend class GrAtlasTextBlob;
1208  friend class GrAtlasTextContext;
1209  friend class GrStencilAndCoverTextContext;
1210  friend class GrPathRendering;
1211  friend class GrTextUtils;
1212  friend class GrGLPathRendering;
1213  friend class SkScalerContext;
1214  friend class SkTextBaseIter;
1215  friend class SkCanonicalizePaint;
1216 };
1217 
1218 #endif
SkScalar fTop
The greatest distance above the baseline for any glyph (will be <= 0)
Definition: SkPaint.h:755
bool isDevKernText() const
Helper for getFlags(), returns true if kDevKernText_Flag bit is set.
Definition: SkPaint.h:272
bool hasUnderlineThickness(SkScalar *thickness) const
If the fontmetrics has a valid underlinethickness, return true, and set the thickness param to that v...
Definition: SkPaint.h:780
A Canvas encapsulates all of the state about drawing into a device (bitmap).
Definition: SkCanvas.h:58
begin/end contours with a semi-circle extension
Definition: SkPaint.h:410
connect path segments with a round join
Definition: SkPaint.h:423
SkPathEffect * getPathEffect() const
Get the paint's patheffect object.
Definition: SkPaint.h:561
The SkPath class encapsulates compound (multiple contour) geometric paths consisting of straight line...
Definition: SkPath.h:27
SkTextBlob combines multiple text runs into an immutable, ref-counted structure.
Definition: SkTextBlob.h:22
SkScalar fDescent
The recommended distance below the baseline (will be >= 0)
Definition: SkPaint.h:757
Mode
List of predefined xfermodes.
Definition: SkXfermode.h:71
Shaders specify the source color(s) for what is being drawn.
Definition: SkShader.h:38
SkPathEffect is the base class for objects in the SkPaint that affect the geometry of a drawing primi...
Definition: SkPathEffect.h:29
Style getStyle() const
Return the paint's style, used for controlling how primitives' geometries are interpreted (except for...
Definition: SkPaint.h:319
SkScalar getStrokeMiter() const
Return the paint's stroke miter value.
Definition: SkPaint.h:385
ColorFilters are optional objects in the drawing pipeline.
Definition: SkColorFilter.h:29
uint16_t SkGlyphID
16 bit unsigned integer to hold a glyph index
Definition: SkTypes.h:359
bool hasUnderlinePosition(SkScalar *position) const
If the fontmetrics has a valid underlineposition, return true, and set the thickness param to that va...
Definition: SkPaint.h:792
void setScale(SkScalar sx, SkScalar sy, SkScalar px, SkScalar py)
Set the matrix to scale by sx and sy, with a pivot point at (px, py).
bool isFakeBoldText() const
Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set.
Definition: SkPaint.h:259
SkScalar getStrokeWidth() const
Return the width for stroking.
Definition: SkPaint.h:370
the text parameters are UTF8
Definition: SkPaint.h:733
SkScalar fMaxCharWidth
the max character width (>= 0)
Definition: SkPaint.h:761
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:583
Cap
Cap enum specifies the settings for the paint's strokecap.
Definition: SkPaint.h:408
the text parameters are UTF16
Definition: SkPaint.h:734
TextEncoding
Describes how to interpret the text parameters that are passed to paint methods like measureText() an...
Definition: SkPaint.h:732
connect path segments with a flat bevel join
Definition: SkPaint.h:424
Align getTextAlign() const
Return the paint's Align value for drawing text.
Definition: SkPaint.h:686
The SkMatrix class holds a 3x3 matrix for transforming coordinates.
Definition: SkMatrix.h:26
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:871
The SkPaint class holds the style and color information about how to draw geometries, text and bitmaps.
Definition: SkPaint.h:46
SkScalar fXMin
The minimum bounding box x value for all glyphs.
Definition: SkPaint.h:762
stroke the geometry
Definition: SkPaint.h:307
SkDrawLooper * getLooper() const
Return the paint's SkDrawLooper (if any).
Definition: SkPaint.h:656
uint8_t getAlpha() const
Helper to getColor() that just returns the color's alpha value.
Definition: SkPaint.h:346
bool isAntiAlias() const
Helper for getFlags(), returning true if kAntiAlias_Flag bit is set.
Definition: SkPaint.h:135
fill the geometry
Definition: SkPaint.h:306
Definition: SkRasterizer.h:21
SkXfermode is the base class for objects that are called to implement custom "transfer-modes" in the ...
Definition: SkXfermode.h:34
Definition: SkPaint.h:745
SkData holds an immutable data buffer.
Definition: SkData.h:22
Join
Join enum specifies the settings for the paint's strokejoin.
Definition: SkPaint.h:421
#define SkToBool(cond)
Returns 0 or 1 based on the condition.
Definition: SkTypes.h:287
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:436
SkScalar getTextScaleX() const
Return the paint's horizontal scale factor for text.
Definition: SkPaint.h:707
The SkTypeface class specifies the typeface and intrinsic style of a font.
Definition: SkTypeface.h:42
Base class for image filters.
Definition: SkImageFilter.h:35
SkScalar fLeading
The recommended distance to add between lines of text (will be >= 0)
Definition: SkPaint.h:759
connect path segments with a sharp join
Definition: SkPaint.h:422
uint32_t getFlags() const
Return the paint's flags.
Definition: SkPaint.h:125
the text parameters are UTF32
Definition: SkPaint.h:735
SkScalar getFontSpacing() const
Return the recommend line spacing.
Definition: SkPaint.h:818
SkMaskFilter is the base class for object that perform transformations on an alpha-channel mask befor...
Definition: SkMaskFilter.h:44
void postSkew(SkScalar kx, SkScalar ky, SkScalar px, SkScalar py)
Postconcats the matrix with the specified skew.
bool isSubpixelText() const
Helper for getFlags(), returning true if kSubpixelText_Flag bit is set.
Definition: SkPaint.h:172
Style
Styles apply to rect, oval, path, and text.
Definition: SkPaint.h:305
int32_t SkUnichar
32 bit integer to hold a unicode value
Definition: SkTypes.h:355
SkRasterizer * getRasterizer() const
Get the paint's rasterizer (or NULL).
Definition: SkPaint.h:630
SkTypeface * getTypeface() const
Get the paint's typeface object.
Definition: SkPaint.h:608
uint32_t SkColor
32 bit ARGB color value, not premultiplied.
Definition: SkColor.h:28
SkScalar fAvgCharWidth
the average character width (>= 0)
Definition: SkPaint.h:760
static SkMatrix * SetTextMatrix(SkMatrix *matrix, SkScalar size, SkScalar scaleX, SkScalar skewX)
Return a matrix that applies the paint's text values: size, scale, skew.
Definition: SkPaint.h:1073
Definition: SkDraw.h:30
SkScalar fXMax
The maximum bounding box x value for all glyphs.
Definition: SkPaint.h:763
SkScalar fUnderlinePosition
Underline Position - position of the top of the Underline stroke relative to the baseline, this can have following values.
Definition: SkPaint.h:774
Subclasses of SkDrawLooper can be attached to a SkPaint.
Definition: SkDrawLooper.h:31
Definition: SkWriteBuffer.h:26
const SkRect & computeFastBounds(const SkRect &orig, SkRect *storage) const
Only call this if canComputeFastBounds() returned true.
Definition: SkPaint.h:1044
Definition: SkRect.h:390
SkScalar getTextSize() const
Return the paint's text size.
Definition: SkPaint.h:696
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:286
fill and stroke the geometry
Definition: SkPaint.h:308
SkXfermode * getXfermode() const
Get the paint's xfermode object.
Definition: SkPaint.h:533
SkScalar fAscent
The recommended distance above the baseline (will be <= 0)
Definition: SkPaint.h:756
begin/end contours with no extension
Definition: SkPaint.h:409
SkShader * getShader() const
Get the paint's shader object.
Definition: SkPaint.h:482
bool isUnderlineText() const
Helper for getFlags(), returning true if kUnderlineText_Flag bit is set.
Definition: SkPaint.h:233
SkScalar getTextSkewX() const
Return the paint's horizontal skew factor for text.
Definition: SkPaint.h:721
SkScalar fCapHeight
The cap height (> 0), or 0 if cannot be determined.
Definition: SkPaint.h:765
uint32_t fFlags
Bit field to identify which values are unknown.
Definition: SkPaint.h:754
bool isLinearText() const
Helper for getFlags(), returning true if kLinearText_Flag bit is set.
Definition: SkPaint.h:159
int countText(const void *text, size_t byteLength) const
Return the number of drawable units in the specified text buffer.
Definition: SkPaint.h:847
unsigned U8CPU
Fast type for unsigned 8 bits.
Definition: SkTypes.h:251
begin/end contours with a half square extension
Definition: SkPaint.h:411
Join getStrokeJoin() const
Return the paint's stroke join type.
Definition: SkPaint.h:448
bool isDither() const
Helper for getFlags(), returning true if kDither_Flag bit is set.
Definition: SkPaint.h:147
SkColorFilter * getColorFilter() const
Get the paint's colorfilter.
Definition: SkPaint.h:514
SkScalar fBottom
The greatest distance below the baseline for any glyph (will be >= 0)
Definition: SkPaint.h:758
FontMetricsFlags
Flags which indicate the confidence level of various metrics.
Definition: SkPaint.h:749
SkScalar fXHeight
The height of an 'x' in px, or 0 if no 'x' in face.
Definition: SkPaint.h:764
SkColor getColor() const
Return the paint's color.
Definition: SkPaint.h:334
Types and macros for colors.
SkScalar fUnderlineThickness
underline thickness, or 0 if cannot be determined
Definition: SkPaint.h:766
bool isStrikeThruText() const
Helper for getFlags(), returns true if kStrikeThruText_Flag bit is set.
Definition: SkPaint.h:246