Update rive-cpp to 2.0 version
[platform/core/uifw/rive-tizen.git] / submodule / skia / include / core / 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 "include/core/SkBlendMode.h"
12 #include "include/core/SkColor.h"
13 #include "include/core/SkRefCnt.h"
14 #include "include/private/SkTo.h"
15
16 #include <optional>
17
18 class SkBlender;
19 class SkColorFilter;
20 class SkColorSpace;
21 struct SkRect;
22 class SkImageFilter;
23 class SkMaskFilter;
24 class SkMatrix;
25 class SkPath;
26 class SkPathEffect;
27 class SkShader;
28
29 /** \class SkPaint
30     SkPaint controls options applied when drawing. SkPaint collects all
31     options outside of the SkCanvas clip and SkCanvas matrix.
32
33     Various options apply to strokes and fills, and images.
34
35     SkPaint collects effects and filters that describe single-pass and multiple-pass
36     algorithms that alter the drawing geometry, color, and transparency. For instance,
37     SkPaint does not directly implement dashing or blur, but contains the objects that do so.
38 */
39 class SK_API SkPaint {
40 public:
41
42     /** Constructs SkPaint with default values.
43
44         @return  default initialized SkPaint
45
46         example: https://fiddle.skia.org/c/@Paint_empty_constructor
47     */
48     SkPaint();
49
50     /** Constructs SkPaint with default values and the given color.
51
52         Sets alpha and RGB used when stroking and filling. The color is four floating
53         point values, unpremultiplied. The color values are interpreted as being in
54         the colorSpace. If colorSpace is nullptr, then color is assumed to be in the
55         sRGB color space.
56
57         @param color       unpremultiplied RGBA
58         @param colorSpace  SkColorSpace describing the encoding of color
59         @return            SkPaint with the given color
60     */
61     explicit SkPaint(const SkColor4f& color, SkColorSpace* colorSpace = nullptr);
62
63     /** Makes a shallow copy of SkPaint. SkPathEffect, SkShader,
64         SkMaskFilter, SkColorFilter, and SkImageFilter are shared
65         between the original paint and the copy. Objects containing SkRefCnt increment
66         their references by one.
67
68         The referenced objects SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
69         and SkImageFilter cannot be modified after they are created.
70         This prevents objects with SkRefCnt from being modified once SkPaint refers to them.
71
72         @param paint  original to copy
73         @return       shallow copy of paint
74
75         example: https://fiddle.skia.org/c/@Paint_copy_const_SkPaint
76     */
77     SkPaint(const SkPaint& paint);
78
79     /** Implements a move constructor to avoid increasing the reference counts
80         of objects referenced by the paint.
81
82         After the call, paint is undefined, and can be safely destructed.
83
84         @param paint  original to move
85         @return       content of paint
86
87         example: https://fiddle.skia.org/c/@Paint_move_SkPaint
88     */
89     SkPaint(SkPaint&& paint);
90
91     /** Decreases SkPaint SkRefCnt of owned objects: SkPathEffect, SkShader,
92         SkMaskFilter, SkColorFilter, and SkImageFilter. If the
93         objects containing SkRefCnt go to zero, they are deleted.
94     */
95     ~SkPaint();
96
97     /** Makes a shallow copy of SkPaint. SkPathEffect, SkShader,
98         SkMaskFilter, SkColorFilter, and SkImageFilter are shared
99         between the original paint and the copy. Objects containing SkRefCnt in the
100         prior destination are decreased by one, and the referenced objects are deleted if the
101         resulting count is zero. Objects containing SkRefCnt in the parameter paint
102         are increased by one. paint is unmodified.
103
104         @param paint  original to copy
105         @return       content of paint
106
107         example: https://fiddle.skia.org/c/@Paint_copy_operator
108     */
109     SkPaint& operator=(const SkPaint& paint);
110
111     /** Moves the paint to avoid increasing the reference counts
112         of objects referenced by the paint parameter. Objects containing SkRefCnt in the
113         prior destination are decreased by one; those objects are deleted if the resulting count
114         is zero.
115
116         After the call, paint is undefined, and can be safely destructed.
117
118         @param paint  original to move
119         @return       content of paint
120
121         example: https://fiddle.skia.org/c/@Paint_move_operator
122     */
123     SkPaint& operator=(SkPaint&& paint);
124
125     /** Compares a and b, and returns true if a and b are equivalent. May return false
126         if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
127         or SkImageFilter have identical contents but different pointers.
128
129         @param a  SkPaint to compare
130         @param b  SkPaint to compare
131         @return   true if SkPaint pair are equivalent
132     */
133     SK_API friend bool operator==(const SkPaint& a, const SkPaint& b);
134
135     /** Compares a and b, and returns true if a and b are not equivalent. May return true
136         if SkPathEffect, SkShader, SkMaskFilter, SkColorFilter,
137         or SkImageFilter have identical contents but different pointers.
138
139         @param a  SkPaint to compare
140         @param b  SkPaint to compare
141         @return   true if SkPaint pair are not equivalent
142     */
143     friend bool operator!=(const SkPaint& a, const SkPaint& b) {
144         return !(a == b);
145     }
146
147     /** Sets all SkPaint contents to their initial values. This is equivalent to replacing
148         SkPaint with the result of SkPaint().
149
150         example: https://fiddle.skia.org/c/@Paint_reset
151     */
152     void reset();
153
154     /** Returns true if pixels on the active edges of SkPath may be drawn with partial transparency.
155         @return  antialiasing state
156     */
157     bool isAntiAlias() const {
158         return SkToBool(fBitfields.fAntiAlias);
159     }
160
161     /** Requests, but does not require, that edge pixels draw opaque or with
162         partial transparency.
163         @param aa  setting for antialiasing
164     */
165     void setAntiAlias(bool aa) { fBitfields.fAntiAlias = static_cast<unsigned>(aa); }
166
167     /** Returns true if color error may be distributed to smooth color transition.
168         @return  dithering state
169     */
170     bool isDither() const {
171         return SkToBool(fBitfields.fDither);
172     }
173
174     /** Requests, but does not require, to distribute color error.
175         @param dither  setting for ditering
176     */
177     void setDither(bool dither) { fBitfields.fDither = static_cast<unsigned>(dither); }
178
179     /** \enum SkPaint::Style
180         Set Style to fill, stroke, or both fill and stroke geometry.
181         The stroke and fill
182         share all paint attributes; for instance, they are drawn with the same color.
183
184         Use kStrokeAndFill_Style to avoid hitting the same pixels twice with a stroke draw and
185         a fill draw.
186     */
187     enum Style : uint8_t {
188         kFill_Style,          //!< set to fill geometry
189         kStroke_Style,        //!< set to stroke geometry
190         kStrokeAndFill_Style, //!< sets to stroke and fill geometry
191     };
192
193     /** May be used to verify that SkPaint::Style is a legal value.
194     */
195     static constexpr int kStyleCount = kStrokeAndFill_Style + 1;
196
197     /** Returns whether the geometry is filled, stroked, or filled and stroked.
198     */
199     Style getStyle() const { return (Style)fBitfields.fStyle; }
200
201     /** Sets whether the geometry is filled, stroked, or filled and stroked.
202         Has no effect if style is not a legal SkPaint::Style value.
203
204         example: https://fiddle.skia.org/c/@Paint_setStyle
205         example: https://fiddle.skia.org/c/@Stroke_Width
206     */
207     void setStyle(Style style);
208
209     /**
210      *  Set paint's style to kStroke if true, or kFill if false.
211      */
212     void setStroke(bool);
213
214     /** Retrieves alpha and RGB, unpremultiplied, packed into 32 bits.
215         Use helpers SkColorGetA(), SkColorGetR(), SkColorGetG(), and SkColorGetB() to extract
216         a color component.
217
218         @return  unpremultiplied ARGB
219     */
220     SkColor getColor() const { return fColor4f.toSkColor(); }
221
222     /** Retrieves alpha and RGB, unpremultiplied, as four floating point values. RGB are
223         extended sRGB values (sRGB gamut, and encoded with the sRGB transfer function).
224
225         @return  unpremultiplied RGBA
226     */
227     SkColor4f getColor4f() const { return fColor4f; }
228
229     /** Sets alpha and RGB used when stroking and filling. The color is a 32-bit value,
230         unpremultiplied, packing 8-bit components for alpha, red, blue, and green.
231
232         @param color  unpremultiplied ARGB
233
234         example: https://fiddle.skia.org/c/@Paint_setColor
235     */
236     void setColor(SkColor color);
237
238     /** Sets alpha and RGB used when stroking and filling. The color is four floating
239         point values, unpremultiplied. The color values are interpreted as being in
240         the colorSpace. If colorSpace is nullptr, then color is assumed to be in the
241         sRGB color space.
242
243         @param color       unpremultiplied RGBA
244         @param colorSpace  SkColorSpace describing the encoding of color
245     */
246     void setColor(const SkColor4f& color, SkColorSpace* colorSpace = nullptr);
247
248     void setColor4f(const SkColor4f& color, SkColorSpace* colorSpace = nullptr) {
249         this->setColor(color, colorSpace);
250     }
251
252     /** Retrieves alpha from the color used when stroking and filling.
253
254         @return  alpha ranging from zero, fully transparent, to 255, fully opaque
255     */
256     float getAlphaf() const { return fColor4f.fA; }
257
258     // Helper that scales the alpha by 255.
259     uint8_t getAlpha() const { return sk_float_round2int(this->getAlphaf() * 255); }
260
261     /** Replaces alpha, leaving RGB
262         unchanged. An out of range value triggers an assert in the debug
263         build. a is a value from 0.0 to 1.0.
264         a set to zero makes color fully transparent; a set to 1.0 makes color
265         fully opaque.
266
267         @param a  alpha component of color
268     */
269     void setAlphaf(float a);
270
271     // Helper that accepts an int between 0 and 255, and divides it by 255.0
272     void setAlpha(U8CPU a) {
273         this->setAlphaf(a * (1.0f / 255));
274     }
275
276     /** Sets color used when drawing solid fills. The color components range from 0 to 255.
277         The color is unpremultiplied; alpha sets the transparency independent of RGB.
278
279         @param a  amount of alpha, from fully transparent (0) to fully opaque (255)
280         @param r  amount of red, from no red (0) to full red (255)
281         @param g  amount of green, from no green (0) to full green (255)
282         @param b  amount of blue, from no blue (0) to full blue (255)
283
284         example: https://fiddle.skia.org/c/@Paint_setARGB
285     */
286     void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
287
288     /** Returns the thickness of the pen used by SkPaint to
289         outline the shape.
290
291         @return  zero for hairline, greater than zero for pen thickness
292     */
293     SkScalar getStrokeWidth() const { return fWidth; }
294
295     /** Sets the thickness of the pen used by the paint to outline the shape.
296         A stroke-width of zero is treated as "hairline" width. Hairlines are always exactly one
297         pixel wide in device space (their thickness does not change as the canvas is scaled).
298         Negative stroke-widths are invalid; setting a negative width will have no effect.
299
300         @param width  zero thickness for hairline; greater than zero for pen thickness
301
302         example: https://fiddle.skia.org/c/@Miter_Limit
303         example: https://fiddle.skia.org/c/@Paint_setStrokeWidth
304     */
305     void setStrokeWidth(SkScalar width);
306
307     /** Returns the limit at which a sharp corner is drawn beveled.
308
309         @return  zero and greater miter limit
310     */
311     SkScalar getStrokeMiter() const { return fMiterLimit; }
312
313     /** Sets the limit at which a sharp corner is drawn beveled.
314         Valid values are zero and greater.
315         Has no effect if miter is less than zero.
316
317         @param miter  zero and greater miter limit
318
319         example: https://fiddle.skia.org/c/@Paint_setStrokeMiter
320     */
321     void setStrokeMiter(SkScalar miter);
322
323     /** \enum SkPaint::Cap
324         Cap draws at the beginning and end of an open path contour.
325     */
326     enum Cap {
327         kButt_Cap,                  //!< no stroke extension
328         kRound_Cap,                 //!< adds circle
329         kSquare_Cap,                //!< adds square
330         kLast_Cap    = kSquare_Cap, //!< largest Cap value
331         kDefault_Cap = kButt_Cap,   //!< equivalent to kButt_Cap
332     };
333
334     /** May be used to verify that SkPaint::Cap is a legal value.
335     */
336     static constexpr int kCapCount = kLast_Cap + 1;
337
338     /** \enum SkPaint::Join
339         Join specifies how corners are drawn when a shape is stroked. Join
340         affects the four corners of a stroked rectangle, and the connected segments in a
341         stroked path.
342
343         Choose miter join to draw sharp corners. Choose round join to draw a circle with a
344         radius equal to the stroke width on top of the corner. Choose bevel join to minimally
345         connect the thick strokes.
346
347         The fill path constructed to describe the stroked path respects the join setting but may
348         not contain the actual join. For instance, a fill path constructed with round joins does
349         not necessarily include circles at each connected segment.
350     */
351     enum Join : uint8_t {
352         kMiter_Join,                 //!< extends to miter limit
353         kRound_Join,                 //!< adds circle
354         kBevel_Join,                 //!< connects outside edges
355         kLast_Join    = kBevel_Join, //!< equivalent to the largest value for Join
356         kDefault_Join = kMiter_Join, //!< equivalent to kMiter_Join
357     };
358
359     /** May be used to verify that SkPaint::Join is a legal value.
360     */
361     static constexpr int kJoinCount = kLast_Join + 1;
362
363     /** Returns the geometry drawn at the beginning and end of strokes.
364     */
365     Cap getStrokeCap() const { return (Cap)fBitfields.fCapType; }
366
367     /** Sets the geometry drawn at the beginning and end of strokes.
368
369         example: https://fiddle.skia.org/c/@Paint_setStrokeCap_a
370         example: https://fiddle.skia.org/c/@Paint_setStrokeCap_b
371     */
372     void setStrokeCap(Cap cap);
373
374     /** Returns the geometry drawn at the corners of strokes.
375     */
376     Join getStrokeJoin() const { return (Join)fBitfields.fJoinType; }
377
378     /** Sets the geometry drawn at the corners of strokes.
379
380         example: https://fiddle.skia.org/c/@Paint_setStrokeJoin
381     */
382     void setStrokeJoin(Join join);
383
384     /** Returns the filled equivalent of the stroked path.
385
386         @param src       SkPath read to create a filled version
387         @param dst       resulting SkPath; may be the same as src, but may not be nullptr
388         @param cullRect  optional limit passed to SkPathEffect
389         @param resScale  if > 1, increase precision, else if (0 < resScale < 1) reduce precision
390                          to favor speed and size
391         @return          true if the path represents style fill, or false if it represents hairline
392     */
393     bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
394                      SkScalar resScale = 1) const;
395
396     bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
397                      const SkMatrix& ctm) const;
398
399     /** Returns the filled equivalent of the stroked path.
400
401         Replaces dst with the src path modified by SkPathEffect and style stroke.
402         SkPathEffect, if any, is not culled. stroke width is created with default precision.
403
404         @param src  SkPath read to create a filled version
405         @param dst  resulting SkPath dst may be the same as src, but may not be nullptr
406         @return     true if the path represents style fill, or false if it represents hairline
407     */
408     bool getFillPath(const SkPath& src, SkPath* dst) const {
409         return this->getFillPath(src, dst, nullptr, 1);
410     }
411
412     /** Returns optional colors used when filling a path, such as a gradient.
413
414         Does not alter SkShader SkRefCnt.
415
416         @return  SkShader if previously set, nullptr otherwise
417     */
418     SkShader* getShader() const { return fShader.get(); }
419
420     /** Returns optional colors used when filling a path, such as a gradient.
421
422         Increases SkShader SkRefCnt by one.
423
424         @return  SkShader if previously set, nullptr otherwise
425
426         example: https://fiddle.skia.org/c/@Paint_refShader
427     */
428     sk_sp<SkShader> refShader() const;
429
430     /** Sets optional colors used when filling a path, such as a gradient.
431
432         Sets SkShader to shader, decreasing SkRefCnt of the previous SkShader.
433         Increments shader SkRefCnt by one.
434
435         @param shader  how geometry is filled with color; if nullptr, color is used instead
436
437         example: https://fiddle.skia.org/c/@Color_Filter_Methods
438         example: https://fiddle.skia.org/c/@Paint_setShader
439     */
440     void setShader(sk_sp<SkShader> shader);
441
442     /** Returns SkColorFilter if set, or nullptr.
443         Does not alter SkColorFilter SkRefCnt.
444
445         @return  SkColorFilter if previously set, nullptr otherwise
446     */
447     SkColorFilter* getColorFilter() const { return fColorFilter.get(); }
448
449     /** Returns SkColorFilter if set, or nullptr.
450         Increases SkColorFilter SkRefCnt by one.
451
452         @return  SkColorFilter if set, or nullptr
453
454         example: https://fiddle.skia.org/c/@Paint_refColorFilter
455     */
456     sk_sp<SkColorFilter> refColorFilter() const;
457
458     /** Sets SkColorFilter to filter, decreasing SkRefCnt of the previous
459         SkColorFilter. Pass nullptr to clear SkColorFilter.
460
461         Increments filter SkRefCnt by one.
462
463         @param colorFilter  SkColorFilter to apply to subsequent draw
464
465         example: https://fiddle.skia.org/c/@Blend_Mode_Methods
466         example: https://fiddle.skia.org/c/@Paint_setColorFilter
467     */
468     void setColorFilter(sk_sp<SkColorFilter> colorFilter);
469
470     /** If the current blender can be represented as a SkBlendMode enum, this returns that
471      *  enum in the optional's value(). If it cannot, then the returned optional does not
472      *  contain a value.
473      */
474     std::optional<SkBlendMode> asBlendMode() const;
475
476     /**
477      *  Queries the blender, and if it can be represented as a SkBlendMode, return that mode,
478      *  else return the defaultMode provided.
479      */
480     SkBlendMode getBlendMode_or(SkBlendMode defaultMode) const;
481
482     /** Returns true iff the current blender claims to be equivalent to SkBlendMode::kSrcOver.
483      *
484      *  Also returns true of the current blender is nullptr.
485      */
486     bool isSrcOver() const;
487
488     /** Helper method for calling setBlender().
489      *
490      *  This sets a blender that implements the specified blendmode enum.
491      */
492     void setBlendMode(SkBlendMode mode);
493
494     /** Returns the user-supplied blend function, if one has been set.
495      *  Does not alter SkBlender's SkRefCnt.
496      *
497      *  A nullptr blender signifies the default SrcOver behavior.
498      *
499      *  @return  the SkBlender assigned to this paint, otherwise nullptr
500      */
501     SkBlender* getBlender() const { return fBlender.get(); }
502
503     /** Returns the user-supplied blend function, if one has been set.
504      *  Increments the SkBlender's SkRefCnt by one.
505      *
506      *  A nullptr blender signifies the default SrcOver behavior.
507      *
508      *  @return  the SkBlender assigned to this paint, otherwise nullptr
509      */
510     sk_sp<SkBlender> refBlender() const;
511
512     /** Sets the current blender, increasing its refcnt, and if a blender is already
513      *  present, decreasing that object's refcnt.
514      *
515      *  A nullptr blender signifies the default SrcOver behavior.
516      *
517      *  For convenience, you can call setBlendMode() if the blend effect can be expressed
518      *  as one of those values.
519      */
520     void setBlender(sk_sp<SkBlender> blender);
521
522     /** Returns SkPathEffect if set, or nullptr.
523         Does not alter SkPathEffect SkRefCnt.
524
525         @return  SkPathEffect if previously set, nullptr otherwise
526     */
527     SkPathEffect* getPathEffect() const { return fPathEffect.get(); }
528
529     /** Returns SkPathEffect if set, or nullptr.
530         Increases SkPathEffect SkRefCnt by one.
531
532         @return  SkPathEffect if previously set, nullptr otherwise
533
534         example: https://fiddle.skia.org/c/@Paint_refPathEffect
535     */
536     sk_sp<SkPathEffect> refPathEffect() const;
537
538     /** Sets SkPathEffect to pathEffect, decreasing SkRefCnt of the previous
539         SkPathEffect. Pass nullptr to leave the path geometry unaltered.
540
541         Increments pathEffect SkRefCnt by one.
542
543         @param pathEffect  replace SkPath with a modification when drawn
544
545         example: https://fiddle.skia.org/c/@Mask_Filter_Methods
546         example: https://fiddle.skia.org/c/@Paint_setPathEffect
547     */
548     void setPathEffect(sk_sp<SkPathEffect> pathEffect);
549
550     /** Returns SkMaskFilter if set, or nullptr.
551         Does not alter SkMaskFilter SkRefCnt.
552
553         @return  SkMaskFilter if previously set, nullptr otherwise
554     */
555     SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); }
556
557     /** Returns SkMaskFilter if set, or nullptr.
558
559         Increases SkMaskFilter SkRefCnt by one.
560
561         @return  SkMaskFilter if previously set, nullptr otherwise
562
563         example: https://fiddle.skia.org/c/@Paint_refMaskFilter
564     */
565     sk_sp<SkMaskFilter> refMaskFilter() const;
566
567     /** Sets SkMaskFilter to maskFilter, decreasing SkRefCnt of the previous
568         SkMaskFilter. Pass nullptr to clear SkMaskFilter and leave SkMaskFilter effect on
569         mask alpha unaltered.
570
571         Increments maskFilter SkRefCnt by one.
572
573         @param maskFilter  modifies clipping mask generated from drawn geometry
574
575         example: https://fiddle.skia.org/c/@Paint_setMaskFilter
576         example: https://fiddle.skia.org/c/@Typeface_Methods
577     */
578     void setMaskFilter(sk_sp<SkMaskFilter> maskFilter);
579
580     /** Returns SkImageFilter if set, or nullptr.
581         Does not alter SkImageFilter SkRefCnt.
582
583         @return  SkImageFilter if previously set, nullptr otherwise
584     */
585     SkImageFilter* getImageFilter() const { return fImageFilter.get(); }
586
587     /** Returns SkImageFilter if set, or nullptr.
588         Increases SkImageFilter SkRefCnt by one.
589
590         @return  SkImageFilter if previously set, nullptr otherwise
591
592         example: https://fiddle.skia.org/c/@Paint_refImageFilter
593     */
594     sk_sp<SkImageFilter> refImageFilter() const;
595
596     /** Sets SkImageFilter to imageFilter, decreasing SkRefCnt of the previous
597         SkImageFilter. Pass nullptr to clear SkImageFilter, and remove SkImageFilter effect
598         on drawing.
599
600         Increments imageFilter SkRefCnt by one.
601
602         @param imageFilter  how SkImage is sampled when transformed
603
604         example: https://fiddle.skia.org/c/@Paint_setImageFilter
605     */
606     void setImageFilter(sk_sp<SkImageFilter> imageFilter);
607
608     /** Returns true if SkPaint prevents all drawing;
609         otherwise, the SkPaint may or may not allow drawing.
610
611         Returns true if, for example, SkBlendMode combined with alpha computes a
612         new alpha of zero.
613
614         @return  true if SkPaint prevents all drawing
615
616         example: https://fiddle.skia.org/c/@Paint_nothingToDraw
617     */
618     bool nothingToDraw() const;
619
620     /**     (to be made private)
621         Returns true if SkPaint does not include elements requiring extensive computation
622         to compute SkBaseDevice bounds of drawn geometry. For instance, SkPaint with SkPathEffect
623         always returns false.
624
625         @return  true if SkPaint allows for fast computation of bounds
626     */
627     bool canComputeFastBounds() const;
628
629     /**     (to be made private)
630         Only call this if canComputeFastBounds() returned true. This takes a
631         raw rectangle (the raw bounds of a shape), and adjusts it for stylistic
632         effects in the paint (e.g. stroking). If needed, it uses the storage
633         parameter. It returns the adjusted bounds that can then be used
634         for SkCanvas::quickReject tests.
635
636         The returned SkRect will either be orig or storage, thus the caller
637         should not rely on storage being set to the result, but should always
638         use the returned value. It is legal for orig and storage to be the same
639         SkRect.
640             For example:
641             if (!path.isInverseFillType() && paint.canComputeFastBounds()) {
642                 SkRect storage;
643                 if (canvas->quickReject(paint.computeFastBounds(path.getBounds(), &storage))) {
644                     return; // do not draw the path
645                 }
646             }
647             // draw the path
648
649         @param orig     geometry modified by SkPaint when drawn
650         @param storage  computed bounds of geometry; may not be nullptr
651         @return         fast computed bounds
652     */
653     const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const;
654
655     /**     (to be made private)
656
657         @param orig     geometry modified by SkPaint when drawn
658         @param storage  computed bounds of geometry
659         @return         fast computed bounds
660     */
661     const SkRect& computeFastStrokeBounds(const SkRect& orig,
662                                           SkRect* storage) const {
663         return this->doComputeFastBounds(orig, storage, kStroke_Style);
664     }
665
666     /**     (to be made private)
667         Computes the bounds, overriding the SkPaint SkPaint::Style. This can be used to
668         account for additional width required by stroking orig, without
669         altering SkPaint::Style set to fill.
670
671         @param orig     geometry modified by SkPaint when drawn
672         @param storage  computed bounds of geometry
673         @param style    overrides SkPaint::Style
674         @return         fast computed bounds
675     */
676     const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
677                                       Style style) const;
678
679 private:
680     sk_sp<SkPathEffect>   fPathEffect;
681     sk_sp<SkShader>       fShader;
682     sk_sp<SkMaskFilter>   fMaskFilter;
683     sk_sp<SkColorFilter>  fColorFilter;
684     sk_sp<SkImageFilter>  fImageFilter;
685     sk_sp<SkBlender>      fBlender;
686
687     SkColor4f       fColor4f;
688     SkScalar        fWidth;
689     SkScalar        fMiterLimit;
690     union {
691         struct {
692             unsigned    fAntiAlias : 1;
693             unsigned    fDither : 1;
694             unsigned    fCapType : 2;
695             unsigned    fJoinType : 2;
696             unsigned    fStyle : 2;
697             unsigned    fPadding : 24;  // 24 == 32 -1-1-2-2-2
698         } fBitfields;
699         uint32_t fBitfieldsUInt;
700     };
701
702     friend class SkPaintPriv;
703 };
704
705 #endif