Index: include/core/SkPaint.h |
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h |
index 95fc0b87ad0be45dc85cd0569849c24e766d50d6..94173e8dd3640be39e259396c4c50db3d145163e 100644 |
--- a/include/core/SkPaint.h |
+++ b/include/core/SkPaint.h |
@@ -1,5 +1,3 @@ |
- |
- |
/* |
* Copyright 2006 The Android Open Source Project |
* |
@@ -7,37 +5,18 @@ |
* found in the LICENSE file. |
*/ |
- |
#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" |
+ #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); |
@@ -57,6 +36,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); |
@@ -88,10 +69,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. |
@@ -121,7 +99,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) |
@@ -302,7 +280,7 @@ public: |
* Return the filter level. This affects the quality (and performance) of |
* drawing scaled images. |
*/ |
- FilterLevel getFilterLevel() const { return (FilterLevel)fFilterLevel; } |
+ FilterLevel getFilterLevel() const { return (FilterLevel)fParts.getFilterLevel(); } |
/** |
* Set the filter level. This affects the quality (and performance) of |
@@ -350,7 +328,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 |
@@ -365,7 +343,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 |
@@ -377,7 +355,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. |
@@ -401,7 +379,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. |
@@ -416,7 +394,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 |
@@ -456,7 +434,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 |
@@ -468,7 +446,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(); } |
/** Set the paint's stroke join type. |
@param join set the paint's line join style, used whenever the paint's |
@@ -496,7 +474,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 |
@@ -525,7 +503,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 /> |
@@ -541,7 +519,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 /> |
@@ -566,7 +544,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 /> |
@@ -585,7 +563,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 /> |
@@ -607,7 +585,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 /> |
@@ -626,7 +604,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 /> |
@@ -641,10 +619,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*); |
/** |
@@ -658,7 +636,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. |
@@ -685,7 +663,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(); } |
/** Set the paint's text alignment. |
@param align set the paint's Align value for drawing text. |
@@ -695,7 +673,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. |
@@ -706,7 +684,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 |
@@ -720,7 +698,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. |
@@ -738,7 +716,7 @@ public: |
kGlyphID_TextEncoding //!< the text parameters are glyph indices |
}; |
- TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; } |
+ TextEncoding getTextEncoding() const { return (TextEncoding)fParts.getTextEncoding(); } |
void setTextEncoding(TextEncoding encoding); |
@@ -1026,7 +1004,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() |
@@ -1037,41 +1015,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 fFilterLevel : 2; |
- //unsigned fFreeBits : 2; |
- }; |
- 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; |
@@ -1139,14 +1093,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 |