Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 #ifdef SK_BUILD_FOR_ANDROID | |
| 14 #include "SkPaintOptionsAndroid.h" | |
| 15 #endif | |
| 16 | |
| 17 class SkAnnotation; | |
| 18 class SkAutoGlyphCache; | |
| 19 class SkColorFilter; | |
| 20 class SkDescriptor; | |
| 21 struct SkDeviceProperties; | |
| 22 class SkDrawLooper; | |
| 23 class SkReadBuffer; | |
| 24 class SkWriteBuffer; | |
| 25 struct SkGlyph; | |
| 26 struct SkRect; | |
| 27 class SkGlyphCache; | |
| 28 class SkImageFilter; | |
| 29 class SkMaskFilter; | |
| 30 class SkPath; | |
| 31 class SkPathEffect; | |
| 32 struct SkPoint; | |
| 33 class SkRasterizer; | |
| 34 class SkShader; | |
| 35 class SkTypeface; | |
| 36 class SkXfermode; | |
| 37 | |
| 38 class SkPaintParts { | |
|
scroggo
2014/04/15 17:21:07
Comments would be nice. If I understand correctly,
tomhudson
2014/04/16 11:41:31
...and if this is somehow avoiding touching the re
reed1
2014/04/18 14:04:31
Absolutely this will need to be documented. (but m
| |
| 39 public: | |
| 40 SkPaintParts() { | |
| 41 sk_bzero(this, sizeof(*this)); | |
|
mtklein
2014/04/15 14:32:44
Tsk tsk. We know this bzero/memcpy stuff is bad n
reed1
2014/04/18 14:04:31
Tsk tsk... premature optimization until the fields
| |
| 42 } | |
| 43 | |
| 44 SkPaintParts(const SkPaintParts& other) { | |
|
mtklein
2014/04/15 14:32:44
Maybe we should just write these two as
// Inten
reed1
2014/04/18 14:04:31
Agreed, will remove these.
| |
| 45 memcpy(this, &other, sizeof(other)); | |
| 46 } | |
| 47 | |
| 48 SkPaintParts& operator=(const SkPaintParts& other) { | |
| 49 memcpy(this, &other, sizeof(other)); | |
| 50 return *this; | |
| 51 } | |
| 52 | |
| 53 bool operator==(const SkPaintParts& other) const; | |
| 54 bool operator!=(const SkPaintParts& other) const { | |
| 55 return !(*this == other); | |
| 56 } | |
| 57 | |
| 58 /** Specifies the bit values that are stored in the paint's flags. | |
| 59 */ | |
| 60 enum Flags { | |
|
scroggo
2014/04/15 17:21:07
I'm pretty opposed to having all these enums dupli
| |
| 61 kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing | |
|
mtklein
2014/04/15 14:32:44
Can you note if 0x02 available for future use or s
scroggo
2014/04/17 15:27:54
0x02 used to be kFilterBitmap_Flag, and Android tr
reed1
2014/04/18 14:04:31
Will do that also in a diff CL for the current SkP
| |
| 62 kDither_Flag = 0x04, //!< mask to enable dithering | |
| 63 kUnderlineText_Flag = 0x08, //!< mask to enable underline text | |
| 64 kStrikeThruText_Flag = 0x10, //!< mask to enable strike-thru text | |
| 65 kFakeBoldText_Flag = 0x20, //!< mask to enable fake-bold text | |
| 66 kLinearText_Flag = 0x40, //!< mask to enable linear-text | |
| 67 kSubpixelText_Flag = 0x80, //!< mask to enable subpixel text positi oning | |
| 68 kDevKernText_Flag = 0x100, //!< mask to enable device kerning text | |
| 69 kLCDRenderText_Flag = 0x200, //!< mask to enable subpixel glyph rende rering | |
| 70 kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap st rikes | |
| 71 kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter | |
| 72 kVerticalText_Flag = 0x1000, | |
| 73 kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it | |
| 74 kDistanceFieldTextTEMP_Flag = 0x4000, //!< TEMPORARY mask to enable dist ance fields | |
|
mtklein
2014/04/15 14:32:44
Can't hurt to align everyone to the widest =?
| |
| 75 // currently overrides LCD and subpixel rendering | |
| 76 // when adding extra flags, note that the fFlags member is specified | |
| 77 // with a bit-width and you'll have to expand it. | |
| 78 | |
| 79 kAllFlags = 0xFFFF | |
| 80 }; | |
| 81 | |
| 82 uint32_t getFlags() const { return fFlags; } | |
| 83 void setFlags(uint32_t flags); | |
| 84 | |
| 85 enum Hinting { | |
| 86 kNo_Hinting = 0, | |
| 87 kSlight_Hinting = 1, | |
| 88 kNormal_Hinting = 2, //!< this is the default | |
|
mtklein
2014/04/15 14:32:44
Doesn't bzero make this comment wrong?
If the ide
| |
| 89 kFull_Hinting = 3 | |
| 90 }; | |
| 91 | |
| 92 Hinting getHinting() const { | |
| 93 return static_cast<Hinting>(fHinting); | |
|
mtklein
2014/04/15 14:32:44
Might take the opportunity to make some things con
scroggo
2014/04/15 17:21:07
I vote for C++ style casts.
reed1
2014/04/18 14:04:31
Will do (before committing)
| |
| 94 } | |
| 95 void setHinting(Hinting hinting) { fHinting = hinting; } | |
| 96 | |
| 97 enum Style { | |
| 98 kFill_Style, //!< fill the geometry | |
| 99 kStroke_Style, //!< stroke the geometry | |
| 100 kStrokeAndFill_Style, //!< fill and stroke the geometry | |
| 101 }; | |
| 102 | |
| 103 Style getStyle() const { return (Style)fStyle; } | |
| 104 void setStyle(Style style) { fStyle = style; } | |
| 105 | |
| 106 SkColor getColor() const { return fColor; } | |
| 107 void setColor(SkColor color) { fColor = color; } | |
| 108 | |
| 109 enum TextEncoding { | |
| 110 kUTF8_TextEncoding, //!< the text parameters are UTF8 | |
| 111 kUTF16_TextEncoding, //!< the text parameters are UTF16 | |
| 112 kUTF32_TextEncoding, //!< the text parameters are UTF32 | |
| 113 kGlyphID_TextEncoding //!< the text parameters are glyph indices | |
| 114 }; | |
| 115 | |
| 116 TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; } | |
| 117 void setTextEncoding(TextEncoding encoding); | |
| 118 | |
| 119 enum Align { | |
| 120 kLeft_Align, | |
| 121 kCenter_Align, | |
| 122 kRight_Align, | |
| 123 }; | |
| 124 | |
| 125 Align getTextAlign() const { return (Align)fTextAlign; } | |
| 126 void setTextAlign(Align align) { fTextAlign = align; } | |
| 127 | |
| 128 SkScalar getTextSize() const { return fTextSize; } | |
| 129 void setTextSize(SkScalar size) { fTextSize = size; } | |
| 130 | |
| 131 SkScalar getTextScaleX() const { return fTextScaleX; } | |
| 132 void setTextScaleX(SkScalar scale) { fTextScaleX = scale; } | |
| 133 | |
| 134 SkScalar getTextSkewX() const { return fTextSkewX; } | |
| 135 void setTextSkewX(SkScalar skew) { fTextSkewX = skew; } | |
| 136 | |
| 137 SkScalar getStrokeWidth() const { return fWidth; } | |
| 138 void setStrokeWidth(SkScalar width) { fWidth = width; } | |
| 139 | |
| 140 SkScalar getStrokeMiter() const { return fMiterLimit; } | |
| 141 void setStrokeMiter(SkScalar miter) { fMiterLimit = miter; } | |
| 142 | |
| 143 enum Cap { | |
| 144 kButt_Cap, //!< begin/end contours with no extension | |
| 145 kRound_Cap, //!< begin/end contours with a semi-circle extension | |
| 146 kSquare_Cap, //!< begin/end contours with a half square extension | |
| 147 | |
| 148 kDefault_Cap = kButt_Cap | |
| 149 }; | |
| 150 | |
| 151 Cap getStrokeCap() const { return (Cap)fCapType; } | |
| 152 void setStrokeCap(Cap cap) { fCapType = cap; } | |
| 153 | |
| 154 enum Join { | |
| 155 kMiter_Join, //!< connect path segments with a sharp join | |
| 156 kRound_Join, //!< connect path segments with a round join | |
| 157 kBevel_Join, //!< connect path segments with a flat bevel join | |
| 158 | |
| 159 kDefault_Join = kMiter_Join | |
| 160 }; | |
| 161 | |
| 162 Join getStrokeJoin() const { return (Join)fJoinType; } | |
| 163 void setStrokeJoin(Join join) { fJoinType = join; } | |
| 164 | |
| 165 SkTypeface* fTypeface; | |
|
mtklein
2014/04/15 14:32:44
Shall we go whole-hog here and make everything jus
reed1
2014/04/18 14:04:31
This is meant to be our new PUBLIC api. History ha
| |
| 166 SkPathEffect* fPathEffect; | |
| 167 SkShader* fShader; | |
| 168 SkXfermode* fXfermode; | |
| 169 SkMaskFilter* fMaskFilter; | |
| 170 SkColorFilter* fColorFilter; | |
| 171 SkRasterizer* fRasterizer; | |
| 172 SkDrawLooper* fLooper; | |
| 173 SkImageFilter* fImageFilter; | |
| 174 SkAnnotation* fAnnotation; | |
| 175 | |
| 176 private: | |
| 177 friend class SkPaint; | |
| 178 | |
| 179 SkScalar fTextSize; | |
| 180 SkScalar fTextScaleX; | |
| 181 SkScalar fTextSkewX; | |
| 182 SkColor fColor; | |
| 183 SkScalar fWidth; | |
| 184 SkScalar fMiterLimit; | |
| 185 union { | |
| 186 struct { | |
| 187 // all of these bitfields should add up to 32 | |
| 188 unsigned fFlags : 16; | |
| 189 unsigned fTextAlign : 2; | |
| 190 unsigned fCapType : 2; | |
| 191 unsigned fJoinType : 2; | |
| 192 unsigned fStyle : 2; | |
| 193 unsigned fTextEncoding : 2; // 3 values | |
| 194 unsigned fHinting : 2; | |
| 195 //unsigned fFreeBits : 4; | |
| 196 }; | |
| 197 uint32_t fBitfields; | |
| 198 }; | |
| 199 }; | |
| 200 | |
| 201 #endif | |
| OLD | NEW |