Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(266)

Side by Side Diff: include/core/SkPaintParts.h

Issue 239163002: WIP -- separate out Parts from SkPaint (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: links and runs Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/core/SkPaint.h ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2010 Google Inc.
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 SkPaintParts_DEFINED
9 #define SkPaintParts_DEFINED
10
11 #include "SkColor.h"
12
13 class SkAnnotation;
14 class SkAutoGlyphCache;
15 class SkColorFilter;
16 class SkDescriptor;
17 struct SkDeviceProperties;
18 class SkDrawLooper;
19 class SkReadBuffer;
20 class SkWriteBuffer;
21 struct SkGlyph;
22 struct SkRect;
23 class SkGlyphCache;
24 class SkImageFilter;
25 class SkMaskFilter;
26 class SkPath;
27 class SkPathEffect;
28 struct SkPoint;
29 class SkRasterizer;
30 class SkShader;
31 class SkTypeface;
32 class SkXfermode;
33
34 class SkPaintParts {
35 public:
36 SkPaintParts() {
37 sk_bzero(this, sizeof(*this));
38 }
39
40 SkPaintParts(const SkPaintParts& other) {
41 memcpy(this, &other, sizeof(other));
42 }
43
44 SkPaintParts& operator=(const SkPaintParts& other) {
45 memcpy(this, &other, sizeof(other));
46 return *this;
47 }
48
49 bool operator==(const SkPaintParts& other) const;
50 bool operator!=(const SkPaintParts& other) const {
51 return !(*this == other);
52 }
53
54 /** Specifies the bit values that are stored in the paint's flags.
55 */
56 enum Flags {
57 kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing
58 // 0x02 -- available!
59 kDither_Flag = 0x04, //!< mask to enable dithering
60 kUnderlineText_Flag = 0x08, //!< mask to enable underline text
61 kStrikeThruText_Flag = 0x10, //!< mask to enable strike-thru text
62 kFakeBoldText_Flag = 0x20, //!< mask to enable fake-bold text
63 kLinearText_Flag = 0x40, //!< mask to enable linear-text
64 kSubpixelText_Flag = 0x80, //!< mask to enable subpixel text positi oning
65 kDevKernText_Flag = 0x100, //!< mask to enable device kerning text
66 kLCDRenderText_Flag = 0x200, //!< mask to enable subpixel glyph rende rering
67 kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap st rikes
68 kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter
69 kVerticalText_Flag = 0x1000,
70 kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it
71 kDistanceFieldTextTEMP_Flag = 0x4000, //!< TEMPORARY mask to enable dist ance fields
72 // currently overrides LCD and subpixel rendering
73 // when adding extra flags, note that the fFlags member is specified
74 // with a bit-width and you'll have to expand it.
75
76 kAllFlags = 0xFFFF
77 };
78
79 uint32_t getFlags() const { return fFlags; }
80 void setFlags(uint32_t flags) { fFlags = flags; }
81
82 enum Hinting {
83 kNo_Hinting = 0,
84 kSlight_Hinting = 1,
85 kNormal_Hinting = 2, //!< this is the default
86 kFull_Hinting = 3
87 };
88
89 Hinting getHinting() const {
90 return static_cast<Hinting>(fHinting);
91 }
92 void setHinting(Hinting hinting) { fHinting = hinting; }
93
94 enum FilterLevel {
95 kNone_FilterLevel,
96 kLow_FilterLevel,
97 kMedium_FilterLevel,
98 kHigh_FilterLevel
99 };
100
101 FilterLevel getFilterLevel() const { return static_cast<FilterLevel>(fFilter Level); }
102 void setFilterLevel(FilterLevel level) { fFilterLevel = level; }
103
104 enum Style {
105 kFill_Style, //!< fill the geometry
106 kStroke_Style, //!< stroke the geometry
107 kStrokeAndFill_Style, //!< fill and stroke the geometry
108 };
109
110 Style getStyle() const { return static_cast<Style>(fStyle); }
111 void setStyle(Style style) { fStyle = style; }
112
113 SkColor getColor() const { return fColor; }
114 void setColor(SkColor color) { fColor = color; }
115
116 enum TextEncoding {
117 kUTF8_TextEncoding, //!< the text parameters are UTF8
118 kUTF16_TextEncoding, //!< the text parameters are UTF16
119 kUTF32_TextEncoding, //!< the text parameters are UTF32
120 kGlyphID_TextEncoding //!< the text parameters are glyph indices
121 };
122
123 TextEncoding getTextEncoding() const { return static_cast<TextEncoding>(fTex tEncoding); }
124 void setTextEncoding(TextEncoding encoding) { fTextEncoding = encoding; }
125
126 enum Align {
127 kLeft_Align,
128 kCenter_Align,
129 kRight_Align,
130 };
131
132 Align getTextAlign() const { return static_cast<Align>(fTextAlign); }
133 void setTextAlign(Align align) { fTextAlign = align; }
134
135 SkScalar getTextSize() const { return fTextSize; }
136 void setTextSize(SkScalar size) { fTextSize = size; }
137
138 SkScalar getTextScaleX() const { return fTextScaleX; }
139 void setTextScaleX(SkScalar scale) { fTextScaleX = scale; }
140
141 SkScalar getTextSkewX() const { return fTextSkewX; }
142 void setTextSkewX(SkScalar skew) { fTextSkewX = skew; }
143
144 SkScalar getStrokeWidth() const { return fWidth; }
145 void setStrokeWidth(SkScalar width) { fWidth = width; }
146
147 SkScalar getStrokeMiter() const { return fMiterLimit; }
148 void setStrokeMiter(SkScalar miter) { fMiterLimit = miter; }
149
150 enum Cap {
151 kButt_Cap, //!< begin/end contours with no extension
152 kRound_Cap, //!< begin/end contours with a semi-circle extension
153 kSquare_Cap, //!< begin/end contours with a half square extension
154
155 kDefault_Cap = kButt_Cap
156 };
157
158 Cap getStrokeCap() const { return static_cast<Cap>(fCapType); }
159 void setStrokeCap(Cap cap) { fCapType = cap; }
160
161 enum Join {
162 kMiter_Join, //!< connect path segments with a sharp join
163 kRound_Join, //!< connect path segments with a round join
164 kBevel_Join, //!< connect path segments with a flat bevel join
165
166 kDefault_Join = kMiter_Join
167 };
168
169 Join getStrokeJoin() const { return static_cast<Join>(fJoinType); }
170 void setStrokeJoin(Join join) { fJoinType = join; }
171
172 SkTypeface* fTypeface;
173 SkPathEffect* fPathEffect;
174 SkShader* fShader;
175 SkXfermode* fXfermode;
176 SkMaskFilter* fMaskFilter;
177 SkColorFilter* fColorFilter;
178 SkRasterizer* fRasterizer;
179 SkDrawLooper* fLooper;
180 SkImageFilter* fImageFilter;
181 SkAnnotation* fAnnotation;
182
183 private:
184 friend class SkPaint;
185
186 SkScalar fTextSize;
187 SkScalar fTextScaleX;
188 SkScalar fTextSkewX;
189 SkColor fColor;
190 SkScalar fWidth;
191 SkScalar fMiterLimit;
192 union {
193 struct {
194 // all of these bitfields should add up to 32
195 unsigned fFlags : 16;
196 unsigned fTextAlign : 2;
197 unsigned fCapType : 2;
198 unsigned fJoinType : 2;
199 unsigned fStyle : 2;
200 unsigned fTextEncoding : 2; // 3 values
201 unsigned fHinting : 2;
202 unsigned fFilterLevel : 2;
203 //unsigned fFreeBits : 2;
204 };
205 uint32_t fBitfields;
206 };
207 };
208
209 #endif
OLDNEW
« no previous file with comments | « include/core/SkPaint.h ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698