Index: include/core/SkPaintParts.h |
diff --git a/include/core/SkPaintParts.h b/include/core/SkPaintParts.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..792c789f994901465ef9625503d6bbe1af0f71a1 |
--- /dev/null |
+++ b/include/core/SkPaintParts.h |
@@ -0,0 +1,209 @@ |
+/* |
+ * Copyright 2010 Google Inc. |
+ * |
+ * Use of this source code is governed by a BSD-style license that can be |
+ * found in the LICENSE file. |
+ */ |
+ |
+#ifndef SkPaintParts_DEFINED |
+#define SkPaintParts_DEFINED |
+ |
+#include "SkColor.h" |
+ |
+class SkAnnotation; |
+class SkAutoGlyphCache; |
+class SkColorFilter; |
+class SkDescriptor; |
+struct SkDeviceProperties; |
+class SkDrawLooper; |
+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; |
+class SkXfermode; |
+ |
+class SkPaintParts { |
+public: |
+ SkPaintParts() { |
+ sk_bzero(this, sizeof(*this)); |
+ } |
+ |
+ SkPaintParts(const SkPaintParts& other) { |
+ memcpy(this, &other, sizeof(other)); |
+ } |
+ |
+ SkPaintParts& operator=(const SkPaintParts& other) { |
+ memcpy(this, &other, sizeof(other)); |
+ return *this; |
+ } |
+ |
+ bool operator==(const SkPaintParts& other) const; |
+ bool operator!=(const SkPaintParts& other) const { |
+ return !(*this == other); |
+ } |
+ |
+ /** Specifies the bit values that are stored in the paint's flags. |
+ */ |
+ enum Flags { |
+ kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing |
+ // 0x02 -- available! |
+ kDither_Flag = 0x04, //!< mask to enable dithering |
+ kUnderlineText_Flag = 0x08, //!< mask to enable underline text |
+ kStrikeThruText_Flag = 0x10, //!< mask to enable strike-thru text |
+ kFakeBoldText_Flag = 0x20, //!< mask to enable fake-bold text |
+ kLinearText_Flag = 0x40, //!< mask to enable linear-text |
+ kSubpixelText_Flag = 0x80, //!< mask to enable subpixel text positioning |
+ kDevKernText_Flag = 0x100, //!< mask to enable device kerning text |
+ kLCDRenderText_Flag = 0x200, //!< mask to enable subpixel glyph renderering |
+ kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap strikes |
+ kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter |
+ kVerticalText_Flag = 0x1000, |
+ kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it |
+ kDistanceFieldTextTEMP_Flag = 0x4000, //!< TEMPORARY mask to enable distance fields |
+ // currently overrides LCD and subpixel rendering |
+ // when adding extra flags, note that the fFlags member is specified |
+ // with a bit-width and you'll have to expand it. |
+ |
+ kAllFlags = 0xFFFF |
+ }; |
+ |
+ uint32_t getFlags() const { return fFlags; } |
+ void setFlags(uint32_t flags) { fFlags = flags; } |
+ |
+ enum Hinting { |
+ kNo_Hinting = 0, |
+ kSlight_Hinting = 1, |
+ kNormal_Hinting = 2, //!< this is the default |
+ kFull_Hinting = 3 |
+ }; |
+ |
+ Hinting getHinting() const { |
+ return static_cast<Hinting>(fHinting); |
+ } |
+ void setHinting(Hinting hinting) { fHinting = hinting; } |
+ |
+ enum FilterLevel { |
+ kNone_FilterLevel, |
+ kLow_FilterLevel, |
+ kMedium_FilterLevel, |
+ kHigh_FilterLevel |
+ }; |
+ |
+ FilterLevel getFilterLevel() const { return static_cast<FilterLevel>(fFilterLevel); } |
+ void setFilterLevel(FilterLevel level) { fFilterLevel = level; } |
+ |
+ enum Style { |
+ kFill_Style, //!< fill the geometry |
+ kStroke_Style, //!< stroke the geometry |
+ kStrokeAndFill_Style, //!< fill and stroke the geometry |
+ }; |
+ |
+ Style getStyle() const { return static_cast<Style>(fStyle); } |
+ void setStyle(Style style) { fStyle = style; } |
+ |
+ SkColor getColor() const { return fColor; } |
+ void setColor(SkColor color) { fColor = color; } |
+ |
+ enum TextEncoding { |
+ kUTF8_TextEncoding, //!< the text parameters are UTF8 |
+ kUTF16_TextEncoding, //!< the text parameters are UTF16 |
+ kUTF32_TextEncoding, //!< the text parameters are UTF32 |
+ kGlyphID_TextEncoding //!< the text parameters are glyph indices |
+ }; |
+ |
+ TextEncoding getTextEncoding() const { return static_cast<TextEncoding>(fTextEncoding); } |
+ void setTextEncoding(TextEncoding encoding) { fTextEncoding = encoding; } |
+ |
+ enum Align { |
+ kLeft_Align, |
+ kCenter_Align, |
+ kRight_Align, |
+ }; |
+ |
+ Align getTextAlign() const { return static_cast<Align>(fTextAlign); } |
+ void setTextAlign(Align align) { fTextAlign = align; } |
+ |
+ SkScalar getTextSize() const { return fTextSize; } |
+ void setTextSize(SkScalar size) { fTextSize = size; } |
+ |
+ SkScalar getTextScaleX() const { return fTextScaleX; } |
+ void setTextScaleX(SkScalar scale) { fTextScaleX = scale; } |
+ |
+ SkScalar getTextSkewX() const { return fTextSkewX; } |
+ void setTextSkewX(SkScalar skew) { fTextSkewX = skew; } |
+ |
+ SkScalar getStrokeWidth() const { return fWidth; } |
+ void setStrokeWidth(SkScalar width) { fWidth = width; } |
+ |
+ SkScalar getStrokeMiter() const { return fMiterLimit; } |
+ void setStrokeMiter(SkScalar miter) { fMiterLimit = miter; } |
+ |
+ enum Cap { |
+ kButt_Cap, //!< begin/end contours with no extension |
+ kRound_Cap, //!< begin/end contours with a semi-circle extension |
+ kSquare_Cap, //!< begin/end contours with a half square extension |
+ |
+ kDefault_Cap = kButt_Cap |
+ }; |
+ |
+ Cap getStrokeCap() const { return static_cast<Cap>(fCapType); } |
+ void setStrokeCap(Cap cap) { fCapType = cap; } |
+ |
+ enum Join { |
+ kMiter_Join, //!< connect path segments with a sharp join |
+ kRound_Join, //!< connect path segments with a round join |
+ kBevel_Join, //!< connect path segments with a flat bevel join |
+ |
+ kDefault_Join = kMiter_Join |
+ }; |
+ |
+ Join getStrokeJoin() const { return static_cast<Join>(fJoinType); } |
+ void setStrokeJoin(Join join) { fJoinType = join; } |
+ |
+ SkTypeface* fTypeface; |
+ SkPathEffect* fPathEffect; |
+ SkShader* fShader; |
+ SkXfermode* fXfermode; |
+ SkMaskFilter* fMaskFilter; |
+ SkColorFilter* fColorFilter; |
+ SkRasterizer* fRasterizer; |
+ SkDrawLooper* fLooper; |
+ SkImageFilter* fImageFilter; |
+ SkAnnotation* fAnnotation; |
+ |
+private: |
+ friend class SkPaint; |
+ |
+ 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; |
+ }; |
+}; |
+ |
+#endif |