Chromium Code Reviews| Index: include/core/SkPaint.h |
| diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h |
| index 7a647f0ea2aff89f998ac206656214099afeed32..e5deb66fb7ad2f98b91ba6441ab938dc968e3b20 100644 |
| --- a/include/core/SkPaint.h |
| +++ b/include/core/SkPaint.h |
| @@ -11,32 +11,10 @@ |
| #ifndef SkPaint_DEFINED |
| #define SkPaint_DEFINED |
| -#include "SkColor.h" |
| +#include "SkPaintParts.h" |
| #include "SkDrawLooper.h" |
| #include "SkMatrix.h" |
| #include "SkXfermode.h" |
| -#ifdef SK_BUILD_FOR_ANDROID |
| -#include "SkPaintOptionsAndroid.h" |
| -#endif |
| - |
| -class SkAnnotation; |
| -class SkAutoGlyphCache; |
| -class SkColorFilter; |
| -class SkDescriptor; |
| -struct SkDeviceProperties; |
| -class SkReadBuffer; |
| -class SkWriteBuffer; |
| -struct SkGlyph; |
| -struct SkRect; |
| -class SkGlyphCache; |
| -class SkImageFilter; |
| -class SkMaskFilter; |
| -class SkPath; |
| -class SkPathEffect; |
| -struct SkPoint; |
| -class SkRasterizer; |
| -class SkShader; |
| -class SkTypeface; |
| typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**, |
| SkFixed x, SkFixed y); |
| @@ -65,6 +43,8 @@ public: |
| SkPaint(const SkPaint& paint); |
| ~SkPaint(); |
| + operator const SkPaintParts& () const { return fParts; } |
| + |
| SkPaint& operator=(const SkPaint&); |
| SK_API friend bool operator==(const SkPaint& a, const SkPaint& b); |
| @@ -96,10 +76,7 @@ public: |
| kFull_Hinting = 3 |
| }; |
| - Hinting getHinting() const { |
| - return static_cast<Hinting>(fHinting); |
| - } |
| - |
| + Hinting getHinting() const { return (Hinting)fParts.getHinting(); } |
| void setHinting(Hinting hintingLevel); |
| /** Specifies the bit values that are stored in the paint's flags. |
| @@ -129,7 +106,7 @@ public: |
| /** Return the paint's flags. Use the Flag enum to test flag values. |
| @return the paint's flags (see enums ending in _Flag for bit masks) |
| */ |
| - uint32_t getFlags() const { return fFlags; } |
| + uint32_t getFlags() const { return fParts.getFlags(); } |
| /** Set the paint's flags. Use the Flag enum to specific flag values. |
| @param flags The new flag bits for the paint (see Flags enum) |
| @@ -358,7 +335,7 @@ public: |
| kFill_Style). |
| @return the paint's Style |
| */ |
| - Style getStyle() const { return (Style)fStyle; } |
| + Style getStyle() const { return (Style)fParts.getStyle(); } |
| /** Set the paint's style, used for controlling how primitives' |
| geometries are interpreted (except for drawBitmap, which always assumes |
| @@ -373,7 +350,7 @@ public: |
| the values of r,g,b. |
| @return the paint's color (and alpha). |
| */ |
| - SkColor getColor() const { return fColor; } |
| + SkColor getColor() const { return fParts.fColor; } |
| /** Set the paint's color. Note that the color is a 32bit value containing |
| alpha as well as r,g,b. This 32bit value is not premultiplied, meaning |
| @@ -385,7 +362,7 @@ public: |
| /** Helper to getColor() that just returns the color's alpha value. |
| @return the alpha component of the paint's color. |
| */ |
| - uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); } |
| + uint8_t getAlpha() const { return SkToU8(SkColorGetA(this->getColor())); } |
| /** Helper to setColor(), that only assigns the color's alpha value, |
| leaving its r,g,b values unchanged. |
| @@ -409,7 +386,7 @@ public: |
| @return the paint's stroke width, used whenever the paint's style is |
| Stroke or StrokeAndFill. |
| */ |
| - SkScalar getStrokeWidth() const { return fWidth; } |
| + SkScalar getStrokeWidth() const { return fParts.getStrokeWidth(); } |
| /** Set the width for stroking. |
| Pass 0 to stroke in hairline mode. |
| @@ -424,7 +401,7 @@ public: |
| @return the paint's miter limit, used whenever the paint's style is |
| Stroke or StrokeAndFill. |
| */ |
| - SkScalar getStrokeMiter() const { return fMiterLimit; } |
| + SkScalar getStrokeMiter() const { return fParts.getStrokeMiter(); } |
| /** Set the paint's stroke miter value. This is used to control the |
| behavior of miter joins when the joins angle is sharp. This value must |
| @@ -464,7 +441,7 @@ public: |
| @return the line cap style for the paint, used whenever the paint's |
| style is Stroke or StrokeAndFill. |
| */ |
| - Cap getStrokeCap() const { return (Cap)fCapType; } |
| + Cap getStrokeCap() const { return (Cap)fParts.getStrokeCap(); } |
| /** Set the paint's stroke cap type. |
| @param cap set the paint's line cap style, used whenever the paint's |
| @@ -476,7 +453,7 @@ public: |
| @return the paint's line join style, used whenever the paint's style is |
| Stroke or StrokeAndFill. |
| */ |
| - Join getStrokeJoin() const { return (Join)fJoinType; } |
| + Join getStrokeJoin() const { return (Join)fParts.getStrokeJoin(); } |
|
scroggo
2014/04/15 17:21:07
Wait, are you casting from an SkPaintParts::Join t
reed1
2014/04/18 14:04:31
Temporary, to simplify all 1000+ callsites of SkPa
|
| /** Set the paint's stroke join type. |
| @param join set the paint's line join style, used whenever the paint's |
| @@ -504,7 +481,7 @@ public: |
| The shader's reference count is not affected. |
| @return the paint's shader (or NULL) |
| */ |
| - SkShader* getShader() const { return fShader; } |
| + SkShader* getShader() const { return fParts.fShader; } |
| /** Set or clear the shader object. |
| * Shaders specify the source color(s) for what is being drawn. If a paint |
| @@ -533,7 +510,7 @@ public: |
| count is not changed. |
| @return the paint's colorfilter (or NULL) |
| */ |
| - SkColorFilter* getColorFilter() const { return fColorFilter; } |
| + SkColorFilter* getColorFilter() const { return fParts.fColorFilter; } |
| /** Set or clear the paint's colorfilter, returning the parameter. |
| <p /> |
| @@ -549,7 +526,7 @@ public: |
| The xfermode's reference count is not affected. |
| @return the paint's xfermode (or NULL) |
| */ |
| - SkXfermode* getXfermode() const { return fXfermode; } |
| + SkXfermode* getXfermode() const { return fParts.fXfermode; } |
| /** Set or clear the xfermode object. |
| <p /> |
| @@ -574,7 +551,7 @@ public: |
| The patheffect reference count is not affected. |
| @return the paint's patheffect (or NULL) |
| */ |
| - SkPathEffect* getPathEffect() const { return fPathEffect; } |
| + SkPathEffect* getPathEffect() const { return fParts.fPathEffect; } |
| /** Set or clear the patheffect object. |
| <p /> |
| @@ -593,7 +570,7 @@ public: |
| The maskfilter reference count is not affected. |
| @return the paint's maskfilter (or NULL) |
| */ |
| - SkMaskFilter* getMaskFilter() const { return fMaskFilter; } |
| + SkMaskFilter* getMaskFilter() const { return fParts.fMaskFilter; } |
| /** Set or clear the maskfilter object. |
| <p /> |
| @@ -615,7 +592,7 @@ public: |
| measuring text. The typeface reference count is not affected. |
| @return the paint's typeface (or NULL) |
| */ |
| - SkTypeface* getTypeface() const { return fTypeface; } |
| + SkTypeface* getTypeface() const { return fParts.fTypeface; } |
| /** Set or clear the typeface object. |
| <p /> |
| @@ -634,7 +611,7 @@ public: |
| The raster controls how paths/text are turned into alpha masks. |
| @return the paint's rasterizer (or NULL) |
| */ |
| - SkRasterizer* getRasterizer() const { return fRasterizer; } |
| + SkRasterizer* getRasterizer() const { return fParts.fRasterizer; } |
| /** Set or clear the rasterizer object. |
| <p /> |
| @@ -649,10 +626,10 @@ public: |
| */ |
| SkRasterizer* setRasterizer(SkRasterizer* rasterizer); |
| - SkImageFilter* getImageFilter() const { return fImageFilter; } |
| + SkImageFilter* getImageFilter() const { return fParts.fImageFilter; } |
| SkImageFilter* setImageFilter(SkImageFilter*); |
| - SkAnnotation* getAnnotation() const { return fAnnotation; } |
| + SkAnnotation* getAnnotation() const { return fParts.fAnnotation; } |
| SkAnnotation* setAnnotation(SkAnnotation*); |
| /** |
| @@ -666,7 +643,7 @@ public: |
| * Return the paint's SkDrawLooper (if any). Does not affect the looper's |
| * reference count. |
| */ |
| - SkDrawLooper* getLooper() const { return fLooper; } |
| + SkDrawLooper* getLooper() const { return fParts.fLooper; } |
| /** |
| * Set or clear the looper object. |
| @@ -693,7 +670,7 @@ public: |
| /** Return the paint's Align value for drawing text. |
| @return the paint's Align value for drawing text. |
| */ |
| - Align getTextAlign() const { return (Align)fTextAlign; } |
| + Align getTextAlign() const { return (Align)fParts.getTextAlign(); } |
|
scroggo
2014/04/15 17:21:07
If we remove the duplication, this cast is unneces
|
| /** Set the paint's text alignment. |
| @param align set the paint's Align value for drawing text. |
| @@ -703,7 +680,7 @@ public: |
| /** Return the paint's text size. |
| @return the paint's text size. |
| */ |
| - SkScalar getTextSize() const { return fTextSize; } |
| + SkScalar getTextSize() const { return fParts.getTextSize(); } |
| /** Set the paint's text size. This value must be > 0 |
| @param textSize set the paint's text size. |
| @@ -714,7 +691,7 @@ public: |
| is 1.0. |
| @return the paint's scale factor in X for drawing/measuring text |
| */ |
| - SkScalar getTextScaleX() const { return fTextScaleX; } |
| + SkScalar getTextScaleX() const { return fParts.getTextScaleX(); } |
| /** Set the paint's horizontal scale factor for text. The default value |
| is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will |
| @@ -728,7 +705,7 @@ public: |
| is 0. |
| @return the paint's skew factor in X for drawing text. |
| */ |
| - SkScalar getTextSkewX() const { return fTextSkewX; } |
| + SkScalar getTextSkewX() const { return fParts.getTextSkewX(); } |
| /** Set the paint's horizontal skew factor for text. The default value |
| is 0. For approximating oblique text, use values around -0.25. |
| @@ -746,7 +723,7 @@ public: |
| kGlyphID_TextEncoding //!< the text parameters are glyph indices |
| }; |
| - TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; } |
| + TextEncoding getTextEncoding() const { return (TextEncoding)fParts.getTextEncoding(); } |
|
scroggo
2014/04/15 17:21:07
Same casting issue.
|
| void setTextEncoding(TextEncoding encoding); |
| @@ -1034,7 +1011,7 @@ public: |
| } |
| SkMatrix* setTextMatrix(SkMatrix* matrix) const { |
| - return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX); |
| + return SetTextMatrix(matrix, fParts.fTextSize, fParts.fTextScaleX, fParts.fTextSkewX); |
| } |
| SK_TO_STRING_NONVIRT() |
| @@ -1045,40 +1022,17 @@ public: |
| }; |
| private: |
| - SkTypeface* fTypeface; |
| - SkPathEffect* fPathEffect; |
| - SkShader* fShader; |
| - SkXfermode* fXfermode; |
| - SkMaskFilter* fMaskFilter; |
| - SkColorFilter* fColorFilter; |
| - SkRasterizer* fRasterizer; |
| - SkDrawLooper* fLooper; |
| - SkImageFilter* fImageFilter; |
| - SkAnnotation* fAnnotation; |
| - |
| - SkScalar fTextSize; |
| - SkScalar fTextScaleX; |
| - SkScalar fTextSkewX; |
| - SkColor fColor; |
| - SkScalar fWidth; |
| - SkScalar fMiterLimit; |
| - union { |
| - struct { |
| - // all of these bitfields should add up to 32 |
| - unsigned fFlags : 16; |
| - unsigned fTextAlign : 2; |
| - unsigned fCapType : 2; |
| - unsigned fJoinType : 2; |
| - unsigned fStyle : 2; |
| - unsigned fTextEncoding : 2; // 3 values |
| - unsigned fHinting : 2; |
| - //unsigned fFreeBits : 4; |
| - }; |
| - uint32_t fBitfields; |
| - }; |
| - uint32_t fDirtyBits; |
| + SkPaintParts fParts; |
| + uint32_t fDirtyBits; |
| + |
| +#ifdef SK_BUILD_FOR_ANDROID |
| + SkPaintOptionsAndroid fPaintOptionsAndroid; |
| + // In order for the == operator to work properly this must be the last field |
| + // in the struct so that we can do a memcmp to this field's offset. |
| + uint32_t fGenerationID; |
| +#endif |
| - uint32_t getBitfields() const { return fBitfields; } |
| + uint32_t getBitfields() const { return fParts.fBitfields; } |
| void setBitfields(uint32_t bitfields); |
| SkDrawCacheProc getDrawCacheProc() const; |
| @@ -1146,14 +1100,6 @@ private: |
| friend class GrDistanceFieldTextContext; |
| friend class SkTextToPathIter; |
| friend class SkCanonicalizePaint; |
| - |
| -#ifdef SK_BUILD_FOR_ANDROID |
| - SkPaintOptionsAndroid fPaintOptionsAndroid; |
| - |
| - // In order for the == operator to work properly this must be the last field |
| - // in the struct so that we can do a memcmp to this field's offset. |
| - uint32_t fGenerationID; |
| -#endif |
| }; |
| #endif |