epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 1 | |
reed@google.com | e4f10a7 | 2012-05-15 20:47:50 +0000 | [diff] [blame] | 2 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 3 | /* |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 4 | * Copyright 2006 The Android Open Source Project |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 5 | * |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 6 | * Use of this source code is governed by a BSD-style license that can be |
| 7 | * found in the LICENSE file. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 10 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 11 | #ifndef SkPaint_DEFINED |
| 12 | #define SkPaint_DEFINED |
| 13 | |
| 14 | #include "SkColor.h" |
reed@google.com | 9efd9a0 | 2012-01-30 15:41:43 +0000 | [diff] [blame] | 15 | #include "SkDrawLooper.h" |
reed@google.com | ed43dff | 2013-06-04 16:56:27 +0000 | [diff] [blame^] | 16 | #include "SkMatrix.h" |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 17 | #include "SkXfermode.h" |
commit-bot@chromium.org | c7a20e4 | 2013-05-13 14:09:13 +0000 | [diff] [blame] | 18 | #ifdef SK_BUILD_FOR_ANDROID |
| 19 | #include "SkPaintOptionsAndroid.h" |
| 20 | #endif |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 21 | |
reed@google.com | b0a34d8 | 2012-07-11 19:57:55 +0000 | [diff] [blame] | 22 | class SkAnnotation; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 23 | class SkAutoGlyphCache; |
| 24 | class SkColorFilter; |
| 25 | class SkDescriptor; |
bungeman@google.com | 532470f | 2013-01-22 19:25:14 +0000 | [diff] [blame] | 26 | struct SkDeviceProperties; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 27 | class SkFlattenableReadBuffer; |
| 28 | class SkFlattenableWriteBuffer; |
| 29 | struct SkGlyph; |
| 30 | struct SkRect; |
| 31 | class SkGlyphCache; |
reed@google.com | 15356a6 | 2011-11-03 19:29:08 +0000 | [diff] [blame] | 32 | class SkImageFilter; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 33 | class SkMaskFilter; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 34 | class SkPath; |
| 35 | class SkPathEffect; |
djsollen@google.com | c73dd5c | 2012-08-07 15:54:32 +0000 | [diff] [blame] | 36 | struct SkPoint; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 37 | class SkRasterizer; |
| 38 | class SkShader; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 39 | class SkTypeface; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | |
| 41 | typedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**, |
| 42 | SkFixed x, SkFixed y); |
| 43 | |
| 44 | typedef const SkGlyph& (*SkMeasureCacheProc)(SkGlyphCache*, const char**); |
| 45 | |
| 46 | /** \class SkPaint |
| 47 | |
| 48 | The SkPaint class holds the style and color information about how to draw |
| 49 | geometries, text and bitmaps. |
| 50 | */ |
ctguil@chromium.org | 7ffb1b2 | 2011-03-15 21:27:08 +0000 | [diff] [blame] | 51 | class SK_API SkPaint { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 52 | public: |
| 53 | SkPaint(); |
| 54 | SkPaint(const SkPaint& paint); |
| 55 | ~SkPaint(); |
| 56 | |
| 57 | SkPaint& operator=(const SkPaint&); |
| 58 | |
reed@google.com | b530ef5 | 2011-07-20 19:55:42 +0000 | [diff] [blame] | 59 | SK_API friend bool operator==(const SkPaint& a, const SkPaint& b); |
| 60 | friend bool operator!=(const SkPaint& a, const SkPaint& b) { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 61 | return !(a == b); |
| 62 | } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 63 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 64 | void flatten(SkFlattenableWriteBuffer&) const; |
| 65 | void unflatten(SkFlattenableReadBuffer&); |
| 66 | |
| 67 | /** Restores the paint to its initial settings. |
| 68 | */ |
| 69 | void reset(); |
| 70 | |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 71 | /** Specifies the level of hinting to be performed. These names are taken |
| 72 | from the Gnome/Cairo names for the same. They are translated into |
| 73 | Freetype concepts the same as in cairo-ft-font.c: |
| 74 | kNo_Hinting -> FT_LOAD_NO_HINTING |
| 75 | kSlight_Hinting -> FT_LOAD_TARGET_LIGHT |
| 76 | kNormal_Hinting -> <default, no option> |
| 77 | kFull_Hinting -> <same as kNormalHinting, unless we are rendering |
| 78 | subpixel glyphs, in which case TARGET_LCD or |
| 79 | TARGET_LCD_V is used> |
| 80 | */ |
| 81 | enum Hinting { |
| 82 | kNo_Hinting = 0, |
| 83 | kSlight_Hinting = 1, |
| 84 | kNormal_Hinting = 2, //!< this is the default |
tomhudson@google.com | 1f90287 | 2012-06-01 13:15:47 +0000 | [diff] [blame] | 85 | kFull_Hinting = 3 |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 88 | Hinting getHinting() const { |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 89 | return static_cast<Hinting>(fHinting); |
| 90 | } |
| 91 | |
djsollen@google.com | f5dbe2f | 2011-04-15 13:41:26 +0000 | [diff] [blame] | 92 | void setHinting(Hinting hintingLevel); |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 93 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 94 | /** Specifies the bit values that are stored in the paint's flags. |
| 95 | */ |
| 96 | enum Flags { |
| 97 | kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing |
| 98 | kFilterBitmap_Flag = 0x02, //!< mask to enable bitmap filtering |
| 99 | kDither_Flag = 0x04, //!< mask to enable dithering |
| 100 | kUnderlineText_Flag = 0x08, //!< mask to enable underline text |
| 101 | kStrikeThruText_Flag = 0x10, //!< mask to enable strike-thru text |
| 102 | kFakeBoldText_Flag = 0x20, //!< mask to enable fake-bold text |
| 103 | kLinearText_Flag = 0x40, //!< mask to enable linear-text |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 104 | kSubpixelText_Flag = 0x80, //!< mask to enable subpixel text positioning |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 105 | kDevKernText_Flag = 0x100, //!< mask to enable device kerning text |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 106 | kLCDRenderText_Flag = 0x200, //!< mask to enable subpixel glyph renderering |
agl@chromium.org | e95c91e | 2010-01-04 18:27:55 +0000 | [diff] [blame] | 107 | kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap strikes |
agl@chromium.org | a2c71cb | 2010-06-17 20:49:17 +0000 | [diff] [blame] | 108 | kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter |
reed@google.com | 830a23e | 2011-11-10 15:20:49 +0000 | [diff] [blame] | 109 | kVerticalText_Flag = 0x1000, |
reed@google.com | 8351aab | 2012-01-18 17:06:35 +0000 | [diff] [blame] | 110 | kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it |
reed@google.com | 25b3bd5 | 2013-05-22 13:55:54 +0000 | [diff] [blame] | 111 | kBicubicFilterBitmap_Flag = 0x4000, // temporary flag |
reed@google.com | 3253898 | 2011-09-30 20:57:05 +0000 | [diff] [blame] | 112 | |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 113 | // when adding extra flags, note that the fFlags member is specified |
| 114 | // with a bit-width and you'll have to expand it. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 115 | |
reed@google.com | 25b3bd5 | 2013-05-22 13:55:54 +0000 | [diff] [blame] | 116 | kAllFlags = 0x7FFF |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 117 | }; |
| 118 | |
| 119 | /** Return the paint's flags. Use the Flag enum to test flag values. |
| 120 | @return the paint's flags (see enums ending in _Flag for bit masks) |
| 121 | */ |
| 122 | uint32_t getFlags() const { return fFlags; } |
| 123 | |
| 124 | /** Set the paint's flags. Use the Flag enum to specific flag values. |
| 125 | @param flags The new flag bits for the paint (see Flags enum) |
| 126 | */ |
| 127 | void setFlags(uint32_t flags); |
| 128 | |
| 129 | /** Helper for getFlags(), returning true if kAntiAlias_Flag bit is set |
| 130 | @return true if the antialias bit is set in the paint's flags. |
| 131 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 132 | bool isAntiAlias() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 133 | return SkToBool(this->getFlags() & kAntiAlias_Flag); |
| 134 | } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 135 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 136 | /** Helper for setFlags(), setting or clearing the kAntiAlias_Flag bit |
| 137 | @param aa true to enable antialiasing, false to disable it |
| 138 | */ |
| 139 | void setAntiAlias(bool aa); |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 140 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 141 | /** Helper for getFlags(), returning true if kDither_Flag bit is set |
| 142 | @return true if the dithering bit is set in the paint's flags. |
| 143 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 144 | bool isDither() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 145 | return SkToBool(this->getFlags() & kDither_Flag); |
| 146 | } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 147 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 148 | /** Helper for setFlags(), setting or clearing the kDither_Flag bit |
| 149 | @param dither true to enable dithering, false to disable it |
| 150 | */ |
| 151 | void setDither(bool dither); |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 152 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 153 | /** Helper for getFlags(), returning true if kLinearText_Flag bit is set |
| 154 | @return true if the lineartext bit is set in the paint's flags |
| 155 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 156 | bool isLinearText() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 157 | return SkToBool(this->getFlags() & kLinearText_Flag); |
| 158 | } |
| 159 | |
| 160 | /** Helper for setFlags(), setting or clearing the kLinearText_Flag bit |
| 161 | @param linearText true to set the linearText bit in the paint's flags, |
| 162 | false to clear it. |
| 163 | */ |
| 164 | void setLinearText(bool linearText); |
| 165 | |
| 166 | /** Helper for getFlags(), returning true if kSubpixelText_Flag bit is set |
| 167 | @return true if the lineartext bit is set in the paint's flags |
| 168 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 169 | bool isSubpixelText() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 170 | return SkToBool(this->getFlags() & kSubpixelText_Flag); |
| 171 | } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 172 | |
reed@google.com | 84b437e | 2011-08-01 12:45:35 +0000 | [diff] [blame] | 173 | /** |
| 174 | * Helper for setFlags(), setting or clearing the kSubpixelText_Flag. |
| 175 | * @param subpixelText true to set the subpixelText bit in the paint's |
| 176 | * flags, false to clear it. |
| 177 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 178 | void setSubpixelText(bool subpixelText); |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 179 | |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 180 | bool isLCDRenderText() const { |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 181 | return SkToBool(this->getFlags() & kLCDRenderText_Flag); |
| 182 | } |
| 183 | |
reed@google.com | 84b437e | 2011-08-01 12:45:35 +0000 | [diff] [blame] | 184 | /** |
| 185 | * Helper for setFlags(), setting or clearing the kLCDRenderText_Flag. |
| 186 | * Note: antialiasing must also be on for lcd rendering |
| 187 | * @param lcdText true to set the LCDRenderText bit in the paint's flags, |
| 188 | * false to clear it. |
| 189 | */ |
| 190 | void setLCDRenderText(bool lcdText); |
agl@chromium.org | 309485b | 2009-07-21 17:41:32 +0000 | [diff] [blame] | 191 | |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 192 | bool isEmbeddedBitmapText() const { |
agl@chromium.org | e95c91e | 2010-01-04 18:27:55 +0000 | [diff] [blame] | 193 | return SkToBool(this->getFlags() & kEmbeddedBitmapText_Flag); |
| 194 | } |
| 195 | |
| 196 | /** Helper for setFlags(), setting or clearing the kEmbeddedBitmapText_Flag bit |
| 197 | @param useEmbeddedBitmapText true to set the kEmbeddedBitmapText bit in the paint's flags, |
| 198 | false to clear it. |
| 199 | */ |
| 200 | void setEmbeddedBitmapText(bool useEmbeddedBitmapText); |
| 201 | |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 202 | bool isAutohinted() const { |
agl@chromium.org | a2c71cb | 2010-06-17 20:49:17 +0000 | [diff] [blame] | 203 | return SkToBool(this->getFlags() & kAutoHinting_Flag); |
| 204 | } |
| 205 | |
| 206 | /** Helper for setFlags(), setting or clearing the kAutoHinting_Flag bit |
| 207 | @param useAutohinter true to set the kEmbeddedBitmapText bit in the |
| 208 | paint's flags, |
| 209 | false to clear it. |
| 210 | */ |
| 211 | void setAutohinted(bool useAutohinter); |
| 212 | |
reed@google.com | 830a23e | 2011-11-10 15:20:49 +0000 | [diff] [blame] | 213 | bool isVerticalText() const { |
| 214 | return SkToBool(this->getFlags() & kVerticalText_Flag); |
| 215 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 216 | |
reed@google.com | 830a23e | 2011-11-10 15:20:49 +0000 | [diff] [blame] | 217 | /** |
| 218 | * Helper for setting or clearing the kVerticalText_Flag bit in |
| 219 | * setFlags(...). |
| 220 | * |
| 221 | * If this bit is set, then advances are treated as Y values rather than |
| 222 | * X values, and drawText will places its glyphs vertically rather than |
| 223 | * horizontally. |
| 224 | */ |
| 225 | void setVerticalText(bool); |
| 226 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 227 | /** Helper for getFlags(), returning true if kUnderlineText_Flag bit is set |
| 228 | @return true if the underlineText bit is set in the paint's flags. |
| 229 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 230 | bool isUnderlineText() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 231 | return SkToBool(this->getFlags() & kUnderlineText_Flag); |
| 232 | } |
| 233 | |
| 234 | /** Helper for setFlags(), setting or clearing the kUnderlineText_Flag bit |
| 235 | @param underlineText true to set the underlineText bit in the paint's |
| 236 | flags, false to clear it. |
| 237 | */ |
| 238 | void setUnderlineText(bool underlineText); |
| 239 | |
| 240 | /** Helper for getFlags(), returns true if kStrikeThruText_Flag bit is set |
| 241 | @return true if the strikeThruText bit is set in the paint's flags. |
| 242 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 243 | bool isStrikeThruText() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 244 | return SkToBool(this->getFlags() & kStrikeThruText_Flag); |
| 245 | } |
| 246 | |
| 247 | /** Helper for setFlags(), setting or clearing the kStrikeThruText_Flag bit |
| 248 | @param strikeThruText true to set the strikeThruText bit in the |
| 249 | paint's flags, false to clear it. |
| 250 | */ |
| 251 | void setStrikeThruText(bool strikeThruText); |
| 252 | |
| 253 | /** Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set |
| 254 | @return true if the kFakeBoldText_Flag bit is set in the paint's flags. |
| 255 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 256 | bool isFakeBoldText() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 257 | return SkToBool(this->getFlags() & kFakeBoldText_Flag); |
| 258 | } |
| 259 | |
| 260 | /** Helper for setFlags(), setting or clearing the kFakeBoldText_Flag bit |
| 261 | @param fakeBoldText true to set the kFakeBoldText_Flag bit in the paint's |
| 262 | flags, false to clear it. |
| 263 | */ |
| 264 | void setFakeBoldText(bool fakeBoldText); |
| 265 | |
| 266 | /** Helper for getFlags(), returns true if kDevKernText_Flag bit is set |
| 267 | @return true if the kernText bit is set in the paint's flags. |
| 268 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 269 | bool isDevKernText() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 270 | return SkToBool(this->getFlags() & kDevKernText_Flag); |
| 271 | } |
| 272 | |
| 273 | /** Helper for setFlags(), setting or clearing the kKernText_Flag bit |
| 274 | @param kernText true to set the kKernText_Flag bit in the paint's |
| 275 | flags, false to clear it. |
| 276 | */ |
| 277 | void setDevKernText(bool devKernText); |
| 278 | |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 279 | bool isFilterBitmap() const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 280 | return SkToBool(this->getFlags() & kFilterBitmap_Flag); |
| 281 | } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 282 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 283 | void setFilterBitmap(bool filterBitmap); |
| 284 | |
| 285 | /** Styles apply to rect, oval, path, and text. |
| 286 | Bitmaps are always drawn in "fill", and lines are always drawn in |
| 287 | "stroke". |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 288 | |
reed@android.com | ed881c2 | 2009-09-15 14:10:42 +0000 | [diff] [blame] | 289 | Note: strokeandfill implicitly draws the result with |
| 290 | SkPath::kWinding_FillType, so if the original path is even-odd, the |
| 291 | results may not appear the same as if it was drawn twice, filled and |
| 292 | then stroked. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 293 | */ |
| 294 | enum Style { |
reed@android.com | ed881c2 | 2009-09-15 14:10:42 +0000 | [diff] [blame] | 295 | kFill_Style, //!< fill the geometry |
| 296 | kStroke_Style, //!< stroke the geometry |
| 297 | kStrokeAndFill_Style, //!< fill and stroke the geometry |
mike@reedtribe.org | aac2fb8 | 2013-02-04 05:17:10 +0000 | [diff] [blame] | 298 | }; |
| 299 | enum { |
| 300 | kStyleCount = kStrokeAndFill_Style + 1 |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 301 | }; |
| 302 | |
| 303 | /** Return the paint's style, used for controlling how primitives' |
| 304 | geometries are interpreted (except for drawBitmap, which always assumes |
| 305 | kFill_Style). |
| 306 | @return the paint's Style |
| 307 | */ |
| 308 | Style getStyle() const { return (Style)fStyle; } |
| 309 | |
| 310 | /** Set the paint's style, used for controlling how primitives' |
| 311 | geometries are interpreted (except for drawBitmap, which always assumes |
| 312 | Fill). |
| 313 | @param style The new style to set in the paint |
| 314 | */ |
| 315 | void setStyle(Style style); |
| 316 | |
| 317 | /** Return the paint's color. Note that the color is a 32bit value |
| 318 | containing alpha as well as r,g,b. This 32bit value is not |
| 319 | premultiplied, meaning that its alpha can be any value, regardless of |
| 320 | the values of r,g,b. |
| 321 | @return the paint's color (and alpha). |
| 322 | */ |
| 323 | SkColor getColor() const { return fColor; } |
| 324 | |
| 325 | /** Set the paint's color. Note that the color is a 32bit value containing |
| 326 | alpha as well as r,g,b. This 32bit value is not premultiplied, meaning |
| 327 | that its alpha can be any value, regardless of the values of r,g,b. |
| 328 | @param color The new color (including alpha) to set in the paint. |
| 329 | */ |
| 330 | void setColor(SkColor color); |
| 331 | |
| 332 | /** Helper to getColor() that just returns the color's alpha value. |
| 333 | @return the alpha component of the paint's color. |
| 334 | */ |
| 335 | uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 336 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 337 | /** Helper to setColor(), that only assigns the color's alpha value, |
| 338 | leaving its r,g,b values unchanged. |
| 339 | @param a set the alpha component (0..255) of the paint's color. |
| 340 | */ |
| 341 | void setAlpha(U8CPU a); |
| 342 | |
| 343 | /** Helper to setColor(), that takes a,r,g,b and constructs the color value |
| 344 | using SkColorSetARGB() |
| 345 | @param a The new alpha component (0..255) of the paint's color. |
| 346 | @param r The new red component (0..255) of the paint's color. |
| 347 | @param g The new green component (0..255) of the paint's color. |
| 348 | @param b The new blue component (0..255) of the paint's color. |
| 349 | */ |
| 350 | void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b); |
| 351 | |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 352 | /** Return the width for stroking. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 353 | <p /> |
| 354 | A value of 0 strokes in hairline mode. |
| 355 | Hairlines always draw 1-pixel wide, regardless of the matrix. |
| 356 | @return the paint's stroke width, used whenever the paint's style is |
| 357 | Stroke or StrokeAndFill. |
| 358 | */ |
| 359 | SkScalar getStrokeWidth() const { return fWidth; } |
| 360 | |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 361 | /** Set the width for stroking. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 362 | Pass 0 to stroke in hairline mode. |
| 363 | Hairlines always draw 1-pixel wide, regardless of the matrix. |
| 364 | @param width set the paint's stroke width, used whenever the paint's |
| 365 | style is Stroke or StrokeAndFill. |
| 366 | */ |
| 367 | void setStrokeWidth(SkScalar width); |
| 368 | |
| 369 | /** Return the paint's stroke miter value. This is used to control the |
| 370 | behavior of miter joins when the joins angle is sharp. |
| 371 | @return the paint's miter limit, used whenever the paint's style is |
| 372 | Stroke or StrokeAndFill. |
| 373 | */ |
| 374 | SkScalar getStrokeMiter() const { return fMiterLimit; } |
| 375 | |
| 376 | /** Set the paint's stroke miter value. This is used to control the |
| 377 | behavior of miter joins when the joins angle is sharp. This value must |
| 378 | be >= 0. |
| 379 | @param miter set the miter limit on the paint, used whenever the |
| 380 | paint's style is Stroke or StrokeAndFill. |
| 381 | */ |
| 382 | void setStrokeMiter(SkScalar miter); |
| 383 | |
| 384 | /** Cap enum specifies the settings for the paint's strokecap. This is the |
| 385 | treatment that is applied to the beginning and end of each non-closed |
| 386 | contour (e.g. lines). |
| 387 | */ |
| 388 | enum Cap { |
| 389 | kButt_Cap, //!< begin/end contours with no extension |
| 390 | kRound_Cap, //!< begin/end contours with a semi-circle extension |
| 391 | kSquare_Cap, //!< begin/end contours with a half square extension |
| 392 | |
| 393 | kCapCount, |
| 394 | kDefault_Cap = kButt_Cap |
| 395 | }; |
| 396 | |
| 397 | /** Join enum specifies the settings for the paint's strokejoin. This is |
| 398 | the treatment that is applied to corners in paths and rectangles. |
| 399 | */ |
| 400 | enum Join { |
| 401 | kMiter_Join, //!< connect path segments with a sharp join |
| 402 | kRound_Join, //!< connect path segments with a round join |
| 403 | kBevel_Join, //!< connect path segments with a flat bevel join |
| 404 | |
| 405 | kJoinCount, |
| 406 | kDefault_Join = kMiter_Join |
| 407 | }; |
| 408 | |
| 409 | /** Return the paint's stroke cap type, controlling how the start and end |
| 410 | of stroked lines and paths are treated. |
| 411 | @return the line cap style for the paint, used whenever the paint's |
| 412 | style is Stroke or StrokeAndFill. |
| 413 | */ |
| 414 | Cap getStrokeCap() const { return (Cap)fCapType; } |
| 415 | |
| 416 | /** Set the paint's stroke cap type. |
| 417 | @param cap set the paint's line cap style, used whenever the paint's |
| 418 | style is Stroke or StrokeAndFill. |
| 419 | */ |
| 420 | void setStrokeCap(Cap cap); |
| 421 | |
| 422 | /** Return the paint's stroke join type. |
| 423 | @return the paint's line join style, used whenever the paint's style is |
| 424 | Stroke or StrokeAndFill. |
| 425 | */ |
| 426 | Join getStrokeJoin() const { return (Join)fJoinType; } |
| 427 | |
| 428 | /** Set the paint's stroke join type. |
| 429 | @param join set the paint's line join style, used whenever the paint's |
| 430 | style is Stroke or StrokeAndFill. |
| 431 | */ |
| 432 | void setStrokeJoin(Join join); |
| 433 | |
reed@google.com | 4bbdeac | 2013-01-24 21:03:11 +0000 | [diff] [blame] | 434 | /** |
| 435 | * Applies any/all effects (patheffect, stroking) to src, returning the |
| 436 | * result in dst. The result is that drawing src with this paint will be |
| 437 | * the same as drawing dst with a default paint (at least from the |
| 438 | * geometric perspective). |
| 439 | * |
| 440 | * @param src input path |
| 441 | * @param dst output path (may be the same as src) |
| 442 | * @param cullRect If not null, the dst path may be culled to this rect. |
| 443 | * @return true if the path should be filled, or false if it should be |
| 444 | * drawn with a hairline (width == 0) |
| 445 | */ |
| 446 | bool getFillPath(const SkPath& src, SkPath* dst, |
| 447 | const SkRect* cullRect = NULL) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 448 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 449 | /** Get the paint's shader object. |
| 450 | <p /> |
| 451 | The shader's reference count is not affected. |
| 452 | @return the paint's shader (or NULL) |
| 453 | */ |
| 454 | SkShader* getShader() const { return fShader; } |
| 455 | |
| 456 | /** Set or clear the shader object. |
reed@google.com | 880dc47 | 2012-05-11 14:47:03 +0000 | [diff] [blame] | 457 | * Shaders specify the source color(s) for what is being drawn. If a paint |
| 458 | * has no shader, then the paint's color is used. If the paint has a |
| 459 | * shader, then the shader's color(s) are use instead, but they are |
| 460 | * modulated by the paint's alpha. This makes it easy to create a shader |
| 461 | * once (e.g. bitmap tiling or gradient) and then change its transparency |
| 462 | * w/o having to modify the original shader... only the paint's alpha needs |
| 463 | * to be modified. |
| 464 | * <p /> |
| 465 | * Pass NULL to clear any previous shader. |
| 466 | * As a convenience, the parameter passed is also returned. |
| 467 | * If a previous shader exists, its reference count is decremented. |
| 468 | * If shader is not NULL, its reference count is incremented. |
| 469 | * @param shader May be NULL. The shader to be installed in the paint |
| 470 | * @return shader |
| 471 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 472 | SkShader* setShader(SkShader* shader); |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 473 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 474 | /** Get the paint's colorfilter. If there is a colorfilter, its reference |
| 475 | count is not changed. |
| 476 | @return the paint's colorfilter (or NULL) |
| 477 | */ |
| 478 | SkColorFilter* getColorFilter() const { return fColorFilter; } |
| 479 | |
| 480 | /** Set or clear the paint's colorfilter, returning the parameter. |
| 481 | <p /> |
| 482 | If the paint already has a filter, its reference count is decremented. |
| 483 | If filter is not NULL, its reference count is incremented. |
| 484 | @param filter May be NULL. The filter to be installed in the paint |
| 485 | @return filter |
| 486 | */ |
| 487 | SkColorFilter* setColorFilter(SkColorFilter* filter); |
| 488 | |
| 489 | /** Get the paint's xfermode object. |
| 490 | <p /> |
| 491 | The xfermode's reference count is not affected. |
| 492 | @return the paint's xfermode (or NULL) |
| 493 | */ |
| 494 | SkXfermode* getXfermode() const { return fXfermode; } |
| 495 | |
| 496 | /** Set or clear the xfermode object. |
| 497 | <p /> |
| 498 | Pass NULL to clear any previous xfermode. |
| 499 | As a convenience, the parameter passed is also returned. |
| 500 | If a previous xfermode exists, its reference count is decremented. |
| 501 | If xfermode is not NULL, its reference count is incremented. |
| 502 | @param xfermode May be NULL. The new xfermode to be installed in the |
| 503 | paint |
| 504 | @return xfermode |
| 505 | */ |
| 506 | SkXfermode* setXfermode(SkXfermode* xfermode); |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 507 | |
| 508 | /** Create an xfermode based on the specified Mode, and assign it into the |
| 509 | paint, returning the mode that was set. If the Mode is SrcOver, then |
| 510 | the paint's xfermode is set to null. |
| 511 | */ |
reed@android.com | 0baf193 | 2009-06-24 12:41:42 +0000 | [diff] [blame] | 512 | SkXfermode* setXfermodeMode(SkXfermode::Mode); |
reed@android.com | a0f5d15 | 2009-06-22 17:38:10 +0000 | [diff] [blame] | 513 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 514 | /** Get the paint's patheffect object. |
| 515 | <p /> |
| 516 | The patheffect reference count is not affected. |
| 517 | @return the paint's patheffect (or NULL) |
| 518 | */ |
| 519 | SkPathEffect* getPathEffect() const { return fPathEffect; } |
| 520 | |
| 521 | /** Set or clear the patheffect object. |
| 522 | <p /> |
| 523 | Pass NULL to clear any previous patheffect. |
| 524 | As a convenience, the parameter passed is also returned. |
| 525 | If a previous patheffect exists, its reference count is decremented. |
| 526 | If patheffect is not NULL, its reference count is incremented. |
| 527 | @param effect May be NULL. The new patheffect to be installed in the |
| 528 | paint |
| 529 | @return effect |
| 530 | */ |
| 531 | SkPathEffect* setPathEffect(SkPathEffect* effect); |
| 532 | |
| 533 | /** Get the paint's maskfilter object. |
| 534 | <p /> |
| 535 | The maskfilter reference count is not affected. |
| 536 | @return the paint's maskfilter (or NULL) |
| 537 | */ |
| 538 | SkMaskFilter* getMaskFilter() const { return fMaskFilter; } |
| 539 | |
| 540 | /** Set or clear the maskfilter object. |
| 541 | <p /> |
| 542 | Pass NULL to clear any previous maskfilter. |
| 543 | As a convenience, the parameter passed is also returned. |
| 544 | If a previous maskfilter exists, its reference count is decremented. |
| 545 | If maskfilter is not NULL, its reference count is incremented. |
| 546 | @param maskfilter May be NULL. The new maskfilter to be installed in |
| 547 | the paint |
| 548 | @return maskfilter |
| 549 | */ |
| 550 | SkMaskFilter* setMaskFilter(SkMaskFilter* maskfilter); |
| 551 | |
| 552 | // These attributes are for text/fonts |
| 553 | |
| 554 | /** Get the paint's typeface object. |
| 555 | <p /> |
| 556 | The typeface object identifies which font to use when drawing or |
| 557 | measuring text. The typeface reference count is not affected. |
| 558 | @return the paint's typeface (or NULL) |
| 559 | */ |
| 560 | SkTypeface* getTypeface() const { return fTypeface; } |
| 561 | |
| 562 | /** Set or clear the typeface object. |
| 563 | <p /> |
| 564 | Pass NULL to clear any previous typeface. |
| 565 | As a convenience, the parameter passed is also returned. |
| 566 | If a previous typeface exists, its reference count is decremented. |
| 567 | If typeface is not NULL, its reference count is incremented. |
| 568 | @param typeface May be NULL. The new typeface to be installed in the |
| 569 | paint |
| 570 | @return typeface |
| 571 | */ |
| 572 | SkTypeface* setTypeface(SkTypeface* typeface); |
| 573 | |
| 574 | /** Get the paint's rasterizer (or NULL). |
| 575 | <p /> |
| 576 | The raster controls how paths/text are turned into alpha masks. |
| 577 | @return the paint's rasterizer (or NULL) |
| 578 | */ |
| 579 | SkRasterizer* getRasterizer() const { return fRasterizer; } |
| 580 | |
| 581 | /** Set or clear the rasterizer object. |
| 582 | <p /> |
| 583 | Pass NULL to clear any previous rasterizer. |
| 584 | As a convenience, the parameter passed is also returned. |
| 585 | If a previous rasterizer exists in the paint, its reference count is |
| 586 | decremented. If rasterizer is not NULL, its reference count is |
| 587 | incremented. |
| 588 | @param rasterizer May be NULL. The new rasterizer to be installed in |
| 589 | the paint. |
| 590 | @return rasterizer |
| 591 | */ |
| 592 | SkRasterizer* setRasterizer(SkRasterizer* rasterizer); |
| 593 | |
reed@google.com | 15356a6 | 2011-11-03 19:29:08 +0000 | [diff] [blame] | 594 | SkImageFilter* getImageFilter() const { return fImageFilter; } |
| 595 | SkImageFilter* setImageFilter(SkImageFilter*); |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 596 | |
reed@google.com | b0a34d8 | 2012-07-11 19:57:55 +0000 | [diff] [blame] | 597 | SkAnnotation* getAnnotation() const { return fAnnotation; } |
| 598 | SkAnnotation* setAnnotation(SkAnnotation*); |
| 599 | |
| 600 | /** |
| 601 | * Returns true if there is an annotation installed on this paint, and |
| 602 | * the annotation specifics no-drawing. |
| 603 | */ |
| 604 | bool isNoDrawAnnotation() const { |
| 605 | return SkToBool(fPrivFlags & kNoDrawAnnotation_PrivFlag); |
| 606 | } |
reed@google.com | 15356a6 | 2011-11-03 19:29:08 +0000 | [diff] [blame] | 607 | |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 608 | /** |
| 609 | * Return the paint's SkDrawLooper (if any). Does not affect the looper's |
| 610 | * reference count. |
| 611 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 612 | SkDrawLooper* getLooper() const { return fLooper; } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 613 | |
| 614 | /** |
| 615 | * Set or clear the looper object. |
| 616 | * <p /> |
| 617 | * Pass NULL to clear any previous looper. |
| 618 | * As a convenience, the parameter passed is also returned. |
| 619 | * If a previous looper exists in the paint, its reference count is |
| 620 | * decremented. If looper is not NULL, its reference count is |
| 621 | * incremented. |
| 622 | * @param looper May be NULL. The new looper to be installed in the paint. |
| 623 | * @return looper |
| 624 | */ |
| 625 | SkDrawLooper* setLooper(SkDrawLooper* looper); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 626 | |
| 627 | enum Align { |
| 628 | kLeft_Align, |
| 629 | kCenter_Align, |
| 630 | kRight_Align, |
| 631 | |
| 632 | kAlignCount |
| 633 | }; |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 634 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 635 | /** Return the paint's Align value for drawing text. |
| 636 | @return the paint's Align value for drawing text. |
| 637 | */ |
| 638 | Align getTextAlign() const { return (Align)fTextAlign; } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 639 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 640 | /** Set the paint's text alignment. |
| 641 | @param align set the paint's Align value for drawing text. |
| 642 | */ |
| 643 | void setTextAlign(Align align); |
| 644 | |
| 645 | /** Return the paint's text size. |
| 646 | @return the paint's text size. |
| 647 | */ |
| 648 | SkScalar getTextSize() const { return fTextSize; } |
| 649 | |
| 650 | /** Set the paint's text size. This value must be > 0 |
| 651 | @param textSize set the paint's text size. |
| 652 | */ |
| 653 | void setTextSize(SkScalar textSize); |
| 654 | |
| 655 | /** Return the paint's horizontal scale factor for text. The default value |
| 656 | is 1.0. |
| 657 | @return the paint's scale factor in X for drawing/measuring text |
| 658 | */ |
| 659 | SkScalar getTextScaleX() const { return fTextScaleX; } |
| 660 | |
| 661 | /** Set the paint's horizontal scale factor for text. The default value |
| 662 | is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will |
| 663 | stretch the text narrower. |
| 664 | @param scaleX set the paint's scale factor in X for drawing/measuring |
| 665 | text. |
| 666 | */ |
| 667 | void setTextScaleX(SkScalar scaleX); |
| 668 | |
| 669 | /** Return the paint's horizontal skew factor for text. The default value |
| 670 | is 0. |
| 671 | @return the paint's skew factor in X for drawing text. |
| 672 | */ |
| 673 | SkScalar getTextSkewX() const { return fTextSkewX; } |
| 674 | |
| 675 | /** Set the paint's horizontal skew factor for text. The default value |
| 676 | is 0. For approximating oblique text, use values around -0.25. |
| 677 | @param skewX set the paint's skew factor in X for drawing text. |
| 678 | */ |
| 679 | void setTextSkewX(SkScalar skewX); |
| 680 | |
reed@google.com | 1f1543f | 2012-09-12 21:08:33 +0000 | [diff] [blame] | 681 | #ifdef SK_SUPPORT_HINTING_SCALE_FACTOR |
| 682 | /** Return the paint's scale factor used for correctly rendering |
| 683 | glyphs in high DPI mode without text subpixel positioning. |
| 684 | @return the scale factor used for rendering glyphs in high DPI mode. |
| 685 | */ |
| 686 | SkScalar getHintingScaleFactor() const { return fHintingScaleFactor; } |
| 687 | |
| 688 | /** Set the paint's scale factor used for correctly rendering |
| 689 | glyphs in high DPI mode without text subpixel positioning. |
| 690 | @param the scale factor used for rendering glyphs in high DPI mode. |
| 691 | */ |
| 692 | void setHintingScaleFactor(SkScalar hintingScaleFactor); |
| 693 | #endif |
| 694 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 695 | /** Describes how to interpret the text parameters that are passed to paint |
| 696 | methods like measureText() and getTextWidths(). |
| 697 | */ |
| 698 | enum TextEncoding { |
| 699 | kUTF8_TextEncoding, //!< the text parameters are UTF8 |
| 700 | kUTF16_TextEncoding, //!< the text parameters are UTF16 |
robertphillips@google.com | 6970557 | 2012-03-21 19:46:50 +0000 | [diff] [blame] | 701 | kUTF32_TextEncoding, //!< the text parameters are UTF32 |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 702 | kGlyphID_TextEncoding //!< the text parameters are glyph indices |
| 703 | }; |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 704 | |
| 705 | TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; } |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 706 | |
| 707 | void setTextEncoding(TextEncoding encoding); |
| 708 | |
| 709 | struct FontMetrics { |
| 710 | SkScalar fTop; //!< The greatest distance above the baseline for any glyph (will be <= 0) |
| 711 | SkScalar fAscent; //!< The recommended distance above the baseline (will be <= 0) |
| 712 | SkScalar fDescent; //!< The recommended distance below the baseline (will be >= 0) |
| 713 | SkScalar fBottom; //!< The greatest distance below the baseline for any glyph (will be >= 0) |
| 714 | SkScalar fLeading; //!< The recommended distance to add between lines of text (will be >= 0) |
agl@chromium.org | cc3096b | 2009-04-22 22:09:04 +0000 | [diff] [blame] | 715 | SkScalar fAvgCharWidth; //!< the average charactor width (>= 0) |
| 716 | SkScalar fXMin; //!< The minimum bounding box x value for all glyphs |
| 717 | SkScalar fXMax; //!< The maximum bounding box x value for all glyphs |
| 718 | SkScalar fXHeight; //!< the height of an 'x' in px, or 0 if no 'x' in face |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 719 | }; |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 720 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 721 | /** Return the recommend spacing between lines (which will be |
| 722 | fDescent - fAscent + fLeading). |
| 723 | If metrics is not null, return in it the font metrics for the |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 724 | typeface/pointsize/etc. currently set in the paint. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 725 | @param metrics If not null, returns the font metrics for the |
| 726 | current typeface/pointsize/etc setting in this |
| 727 | paint. |
| 728 | @param scale If not 0, return width as if the canvas were scaled |
| 729 | by this value |
| 730 | @param return the recommended spacing between lines |
| 731 | */ |
| 732 | SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0) const; |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 733 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 734 | /** Return the recommend line spacing. This will be |
| 735 | fDescent - fAscent + fLeading |
| 736 | */ |
| 737 | SkScalar getFontSpacing() const { return this->getFontMetrics(NULL, 0); } |
| 738 | |
| 739 | /** Convert the specified text into glyph IDs, returning the number of |
| 740 | glyphs ID written. If glyphs is NULL, it is ignore and only the count |
| 741 | is returned. |
| 742 | */ |
| 743 | int textToGlyphs(const void* text, size_t byteLength, |
| 744 | uint16_t glyphs[]) const; |
| 745 | |
reed@android.com | a5dcaf6 | 2010-02-05 17:12:32 +0000 | [diff] [blame] | 746 | /** Return true if all of the specified text has a corresponding non-zero |
| 747 | glyph ID. If any of the code-points in the text are not supported in |
| 748 | the typeface (i.e. the glyph ID would be zero), then return false. |
| 749 | |
| 750 | If the text encoding for the paint is kGlyph_TextEncoding, then this |
| 751 | returns true if all of the specified glyph IDs are non-zero. |
| 752 | */ |
| 753 | bool containsText(const void* text, size_t byteLength) const; |
| 754 | |
reed@android.com | 9d3a985 | 2010-01-08 14:07:42 +0000 | [diff] [blame] | 755 | /** Convert the glyph array into Unichars. Unconvertable glyphs are mapped |
| 756 | to zero. Note: this does not look at the text-encoding setting in the |
| 757 | paint, only at the typeface. |
| 758 | */ |
| 759 | void glyphsToUnichars(const uint16_t glyphs[], int count, |
| 760 | SkUnichar text[]) const; |
| 761 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 762 | /** Return the number of drawable units in the specified text buffer. |
| 763 | This looks at the current TextEncoding field of the paint. If you also |
| 764 | want to have the text converted into glyph IDs, call textToGlyphs |
| 765 | instead. |
| 766 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 767 | int countText(const void* text, size_t byteLength) const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 768 | return this->textToGlyphs(text, byteLength, NULL); |
| 769 | } |
| 770 | |
reed@google.com | 44da42e | 2011-11-10 20:04:47 +0000 | [diff] [blame] | 771 | /** Return the width of the text. This will return the vertical measure |
| 772 | * if isVerticalText() is true, in which case the returned value should |
| 773 | * be treated has a height instead of a width. |
| 774 | * |
| 775 | * @param text The text to be measured |
| 776 | * @param length Number of bytes of text to measure |
| 777 | * @param bounds If not NULL, returns the bounds of the text, |
| 778 | * relative to (0, 0). |
| 779 | * @param scale If not 0, return width as if the canvas were scaled |
| 780 | * by this value |
| 781 | * @return The advance width of the text |
| 782 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 783 | SkScalar measureText(const void* text, size_t length, |
| 784 | SkRect* bounds, SkScalar scale = 0) const; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 785 | |
reed@google.com | 44da42e | 2011-11-10 20:04:47 +0000 | [diff] [blame] | 786 | /** Return the width of the text. This will return the vertical measure |
| 787 | * if isVerticalText() is true, in which case the returned value should |
| 788 | * be treated has a height instead of a width. |
| 789 | * |
| 790 | * @param text Address of the text |
| 791 | * @param length Number of bytes of text to measure |
reed@google.com | 97ecd1d | 2012-05-15 19:25:17 +0000 | [diff] [blame] | 792 | * @return The advance width of the text |
reed@google.com | 44da42e | 2011-11-10 20:04:47 +0000 | [diff] [blame] | 793 | */ |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 794 | SkScalar measureText(const void* text, size_t length) const { |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 795 | return this->measureText(text, length, NULL, 0); |
| 796 | } |
reed@google.com | 9d07fec | 2011-03-16 20:02:59 +0000 | [diff] [blame] | 797 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 798 | /** Specify the direction the text buffer should be processed in breakText() |
| 799 | */ |
| 800 | enum TextBufferDirection { |
| 801 | /** When measuring text for breakText(), begin at the start of the text |
| 802 | buffer and proceed forward through the data. This is the default. |
| 803 | */ |
| 804 | kForward_TextBufferDirection, |
| 805 | /** When measuring text for breakText(), begin at the end of the text |
| 806 | buffer and proceed backwards through the data. |
| 807 | */ |
| 808 | kBackward_TextBufferDirection |
| 809 | }; |
| 810 | |
reed@google.com | 44da42e | 2011-11-10 20:04:47 +0000 | [diff] [blame] | 811 | /** Return the number of bytes of text that were measured. If |
| 812 | * isVerticalText() is true, then the vertical advances are used for |
| 813 | * the measurement. |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 814 | * |
reed@google.com | 44da42e | 2011-11-10 20:04:47 +0000 | [diff] [blame] | 815 | * @param text The text to be measured |
| 816 | * @param length Number of bytes of text to measure |
| 817 | * @param maxWidth Maximum width. Only the subset of text whose accumulated |
| 818 | * widths are <= maxWidth are measured. |
| 819 | * @param measuredWidth Optional. If non-null, this returns the actual |
| 820 | * width of the measured text. |
| 821 | * @param tbd Optional. The direction the text buffer should be |
| 822 | * traversed during measuring. |
| 823 | * @return The number of bytes of text that were measured. Will be |
| 824 | * <= length. |
| 825 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 826 | size_t breakText(const void* text, size_t length, SkScalar maxWidth, |
| 827 | SkScalar* measuredWidth = NULL, |
| 828 | TextBufferDirection tbd = kForward_TextBufferDirection) |
| 829 | const; |
| 830 | |
reed@google.com | 44da42e | 2011-11-10 20:04:47 +0000 | [diff] [blame] | 831 | /** Return the advances for the text. These will be vertical advances if |
| 832 | * isVerticalText() returns true. |
| 833 | * |
| 834 | * @param text the text |
| 835 | * @param byteLength number of bytes to of text |
| 836 | * @param widths If not null, returns the array of advances for |
| 837 | * the glyphs. If not NULL, must be at least a large |
| 838 | * as the number of unichars in the specified text. |
| 839 | * @param bounds If not null, returns the bounds for each of |
| 840 | * character, relative to (0, 0) |
| 841 | * @return the number of unichars in the specified text. |
| 842 | */ |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 843 | int getTextWidths(const void* text, size_t byteLength, SkScalar widths[], |
| 844 | SkRect bounds[] = NULL) const; |
| 845 | |
| 846 | /** Return the path (outline) for the specified text. |
| 847 | Note: just like SkCanvas::drawText, this will respect the Align setting |
| 848 | in the paint. |
| 849 | */ |
| 850 | void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y, |
| 851 | SkPath* path) const; |
| 852 | |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 853 | void getPosTextPath(const void* text, size_t length, |
reed@google.com | ca0062e | 2012-07-20 11:20:32 +0000 | [diff] [blame] | 854 | const SkPoint pos[], SkPath* path) const; |
| 855 | |
djsollen@google.com | 56c6977 | 2011-11-08 19:00:26 +0000 | [diff] [blame] | 856 | #ifdef SK_BUILD_FOR_ANDROID |
djsollen@google.com | 4bd2bdb | 2013-03-08 18:35:13 +0000 | [diff] [blame] | 857 | const SkGlyph& getUnicharMetrics(SkUnichar, const SkMatrix*); |
| 858 | const SkGlyph& getGlyphMetrics(uint16_t, const SkMatrix*); |
| 859 | const void* findImage(const SkGlyph&, const SkMatrix*); |
djsollen@google.com | f5dbe2f | 2011-04-15 13:41:26 +0000 | [diff] [blame] | 860 | |
| 861 | uint32_t getGenerationID() const; |
djsollen@google.com | 4bd2bdb | 2013-03-08 18:35:13 +0000 | [diff] [blame] | 862 | void setGenerationID(uint32_t generationID); |
djsollen@google.com | 60abb07 | 2012-02-15 18:49:15 +0000 | [diff] [blame] | 863 | |
| 864 | /** Returns the base glyph count for the strike associated with this paint |
| 865 | */ |
| 866 | unsigned getBaseGlyphCount(SkUnichar text) const; |
commit-bot@chromium.org | c7a20e4 | 2013-05-13 14:09:13 +0000 | [diff] [blame] | 867 | |
| 868 | const SkPaintOptionsAndroid& getPaintOptionsAndroid() const { |
| 869 | return fPaintOptionsAndroid; |
| 870 | } |
| 871 | void setPaintOptionsAndroid(const SkPaintOptionsAndroid& options); |
djsollen@google.com | f5dbe2f | 2011-04-15 13:41:26 +0000 | [diff] [blame] | 872 | #endif |
| 873 | |
reed@google.com | 632e1a2 | 2011-10-06 12:37:00 +0000 | [diff] [blame] | 874 | // returns true if the paint's settings (e.g. xfermode + alpha) resolve to |
| 875 | // mean that we need not draw at all (e.g. SrcOver + 0-alpha) |
| 876 | bool nothingToDraw() const; |
| 877 | |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 878 | /////////////////////////////////////////////////////////////////////////// |
reed@google.com | d5f2079 | 2012-05-16 14:15:02 +0000 | [diff] [blame] | 879 | // would prefer to make these private... |
| 880 | |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 881 | /** Returns true if the current paint settings allow for fast computation of |
| 882 | bounds (i.e. there is nothing complex like a patheffect that would make |
| 883 | the bounds computation expensive. |
| 884 | */ |
| 885 | bool canComputeFastBounds() const { |
| 886 | if (this->getLooper()) { |
| 887 | return this->getLooper()->canComputeFastBounds(*this); |
| 888 | } |
| 889 | return !this->getRasterizer(); |
| 890 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 891 | |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 892 | /** Only call this if canComputeFastBounds() returned true. This takes a |
| 893 | raw rectangle (the raw bounds of a shape), and adjusts it for stylistic |
| 894 | effects in the paint (e.g. stroking). If needed, it uses the storage |
| 895 | rect parameter. It returns the adjusted bounds that can then be used |
| 896 | for quickReject tests. |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 897 | |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 898 | The returned rect will either be orig or storage, thus the caller |
| 899 | should not rely on storage being set to the result, but should always |
| 900 | use the retured value. It is legal for orig and storage to be the same |
| 901 | rect. |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 902 | |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 903 | e.g. |
| 904 | if (paint.canComputeFastBounds()) { |
| 905 | SkRect r, storage; |
| 906 | path.computeBounds(&r, SkPath::kFast_BoundsType); |
| 907 | const SkRect& fastR = paint.computeFastBounds(r, &storage); |
| 908 | if (canvas->quickReject(fastR, ...)) { |
| 909 | // don't draw the path |
| 910 | } |
| 911 | } |
| 912 | */ |
| 913 | const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const { |
| 914 | SkPaint::Style style = this->getStyle(); |
| 915 | // ultra fast-case: filling with no effects that affect geometry |
| 916 | if (kFill_Style == style) { |
| 917 | uintptr_t effects = reinterpret_cast<uintptr_t>(this->getLooper()); |
| 918 | effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter()); |
| 919 | effects |= reinterpret_cast<uintptr_t>(this->getPathEffect()); |
| 920 | if (!effects) { |
| 921 | return orig; |
| 922 | } |
| 923 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 924 | |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 925 | return this->doComputeFastBounds(orig, storage, style); |
| 926 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 927 | |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 928 | const SkRect& computeFastStrokeBounds(const SkRect& orig, |
| 929 | SkRect* storage) const { |
reed@google.com | 73a0258 | 2012-05-16 19:21:12 +0000 | [diff] [blame] | 930 | return this->doComputeFastBounds(orig, storage, kStroke_Style); |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 931 | } |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 932 | |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 933 | // Take the style explicitly, so the caller can force us to be stroked |
| 934 | // without having to make a copy of the paint just to change that field. |
| 935 | const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage, |
| 936 | Style) const; |
rmistry@google.com | fbfcd56 | 2012-08-23 18:09:54 +0000 | [diff] [blame] | 937 | |
reed@google.com | ed43dff | 2013-06-04 16:56:27 +0000 | [diff] [blame^] | 938 | /** |
| 939 | * Return a matrix that applies the paint's text values: size, scale, skew |
| 940 | */ |
| 941 | static SkMatrix* SetTextMatrix(SkMatrix* matrix, SkScalar size, |
| 942 | SkScalar scaleX, SkScalar skewX) { |
| 943 | matrix->setScale(size * scaleX, size); |
| 944 | if (skewX) { |
| 945 | matrix->postSkew(skewX, 0); |
| 946 | } |
| 947 | return matrix; |
| 948 | } |
| 949 | |
| 950 | SkMatrix* setTextMatrix(SkMatrix* matrix) const { |
| 951 | return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX); |
| 952 | } |
| 953 | |
robertphillips@google.com | 791f12e | 2013-02-14 13:53:53 +0000 | [diff] [blame] | 954 | SkDEVCODE(void toString(SkString*) const;) |
| 955 | |
reed@google.com | d5f2079 | 2012-05-16 14:15:02 +0000 | [diff] [blame] | 956 | private: |
| 957 | SkTypeface* fTypeface; |
| 958 | SkScalar fTextSize; |
| 959 | SkScalar fTextScaleX; |
| 960 | SkScalar fTextSkewX; |
reed@google.com | 1f1543f | 2012-09-12 21:08:33 +0000 | [diff] [blame] | 961 | #ifdef SK_SUPPORT_HINTING_SCALE_FACTOR |
| 962 | SkScalar fHintingScaleFactor; |
| 963 | #endif |
reed@google.com | a584aed | 2012-05-16 14:06:02 +0000 | [diff] [blame] | 964 | |
reed@google.com | d5f2079 | 2012-05-16 14:15:02 +0000 | [diff] [blame] | 965 | SkPathEffect* fPathEffect; |
| 966 | SkShader* fShader; |
| 967 | SkXfermode* fXfermode; |
| 968 | SkMaskFilter* fMaskFilter; |
| 969 | SkColorFilter* fColorFilter; |
| 970 | SkRasterizer* fRasterizer; |
| 971 | SkDrawLooper* fLooper; |
| 972 | SkImageFilter* fImageFilter; |
reed@google.com | b0a34d8 | 2012-07-11 19:57:55 +0000 | [diff] [blame] | 973 | SkAnnotation* fAnnotation; |
reed@google.com | d5f2079 | 2012-05-16 14:15:02 +0000 | [diff] [blame] | 974 | |
| 975 | SkColor fColor; |
| 976 | SkScalar fWidth; |
| 977 | SkScalar fMiterLimit; |
reed@google.com | b0a34d8 | 2012-07-11 19:57:55 +0000 | [diff] [blame] | 978 | // all of these bitfields should add up to 32 |
| 979 | unsigned fFlags : 16; |
reed@google.com | d5f2079 | 2012-05-16 14:15:02 +0000 | [diff] [blame] | 980 | unsigned fTextAlign : 2; |
| 981 | unsigned fCapType : 2; |
| 982 | unsigned fJoinType : 2; |
| 983 | unsigned fStyle : 2; |
| 984 | unsigned fTextEncoding : 2; // 3 values |
| 985 | unsigned fHinting : 2; |
reed@google.com | b0a34d8 | 2012-07-11 19:57:55 +0000 | [diff] [blame] | 986 | unsigned fPrivFlags : 4; // these are not flattened/unflattened |
| 987 | |
| 988 | enum PrivFlags { |
| 989 | kNoDrawAnnotation_PrivFlag = 1 << 0, |
| 990 | }; |
reed@google.com | d5f2079 | 2012-05-16 14:15:02 +0000 | [diff] [blame] | 991 | |
| 992 | SkDrawCacheProc getDrawCacheProc() const; |
| 993 | SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir, |
| 994 | bool needFullMetrics) const; |
| 995 | |
| 996 | SkScalar measure_text(SkGlyphCache*, const char* text, size_t length, |
| 997 | int* count, SkRect* bounds) const; |
| 998 | |
bungeman@google.com | 532470f | 2013-01-22 19:25:14 +0000 | [diff] [blame] | 999 | SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*) const; |
reed@google.com | d5f2079 | 2012-05-16 14:15:02 +0000 | [diff] [blame] | 1000 | |
bungeman@google.com | 532470f | 2013-01-22 19:25:14 +0000 | [diff] [blame] | 1001 | void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatrix* deviceMatrix, |
reed@google.com | 90808e8 | 2013-03-19 14:44:54 +0000 | [diff] [blame] | 1002 | void (*proc)(SkTypeface*, const SkDescriptor*, void*), |
reed@google.com | d5f2079 | 2012-05-16 14:15:02 +0000 | [diff] [blame] | 1003 | void* context, bool ignoreGamma = false) const; |
reed@android.com | d252db0 | 2009-04-01 18:31:44 +0000 | [diff] [blame] | 1004 | |
bungeman@google.com | b24b4fa | 2012-09-04 13:49:59 +0000 | [diff] [blame] | 1005 | static void Term(); |
| 1006 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1007 | enum { |
reed@google.com | ed43dff | 2013-06-04 16:56:27 +0000 | [diff] [blame^] | 1008 | /* This is the size we use when we ask for a glyph's path. We then |
| 1009 | * post-transform it as we draw to match the request. |
| 1010 | * This is done to try to re-use cache entries for the path. |
| 1011 | * |
| 1012 | * This value is somewhat arbitrary. In theory, it could be 1, since |
| 1013 | * we store paths as floats. However, we get the path from the font |
| 1014 | * scaler, and it may represent its paths as fixed-point (or 26.6), |
| 1015 | * so we shouldn't ask for something too big (might overflow 16.16) |
| 1016 | * or too small (underflow 26.6). |
| 1017 | * |
| 1018 | * This value could track kMaxSizeForGlyphCache, assuming the above |
| 1019 | * constraints, but since we ask for unhinted paths, the two values |
| 1020 | * need not match per-se. |
| 1021 | */ |
| 1022 | kCanonicalTextSizeForPaths = 64, |
| 1023 | |
| 1024 | /* |
| 1025 | * Above this size (taking into account CTM and textSize), we never use |
| 1026 | * the cache for bits or metrics (we might overflow), so we just ask |
| 1027 | * for a caononical size and post-transform that. |
| 1028 | */ |
| 1029 | kMaxSizeForGlyphCache = 256, |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1030 | }; |
reed@google.com | ed43dff | 2013-06-04 16:56:27 +0000 | [diff] [blame^] | 1031 | |
| 1032 | static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM); |
| 1033 | |
| 1034 | bool tooBigToUseCache() const; |
| 1035 | bool tooBigToUseCache(const SkMatrix& ctm) const; |
| 1036 | |
| 1037 | // Set flags/hinting/textSize up to use for drawing text as paths. |
| 1038 | // Returns scale factor to restore the original textSize, since will will |
| 1039 | // have change it to kCanonicalTextSizeForPaths. |
| 1040 | SkScalar setupForAsPaths(); |
| 1041 | |
| 1042 | static SkScalar MaxCacheSize2() { |
| 1043 | static const SkScalar kMaxSize = SkIntToScalar(kMaxSizeForGlyphCache); |
| 1044 | static const SkScalar kMag2Max = kMaxSize * kMaxSize; |
| 1045 | return kMag2Max; |
| 1046 | } |
| 1047 | |
vandebo@chromium.org | 28be72b | 2010-11-11 21:37:00 +0000 | [diff] [blame] | 1048 | friend class SkAutoGlyphCache; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1049 | friend class SkCanvas; |
| 1050 | friend class SkDraw; |
bungeman@google.com | b24b4fa | 2012-09-04 13:49:59 +0000 | [diff] [blame] | 1051 | friend class SkGraphics; // So Term() can be called. |
vandebo@chromium.org | 28be72b | 2010-11-11 21:37:00 +0000 | [diff] [blame] | 1052 | friend class SkPDFDevice; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1053 | friend class SkTextToPathIter; |
reed@google.com | ed43dff | 2013-06-04 16:56:27 +0000 | [diff] [blame^] | 1054 | friend class SkCanonicalizePaint; |
djsollen@google.com | b44cd65 | 2011-12-01 17:09:21 +0000 | [diff] [blame] | 1055 | |
| 1056 | #ifdef SK_BUILD_FOR_ANDROID |
commit-bot@chromium.org | c7a20e4 | 2013-05-13 14:09:13 +0000 | [diff] [blame] | 1057 | SkPaintOptionsAndroid fPaintOptionsAndroid; |
| 1058 | |
djsollen@google.com | b44cd65 | 2011-12-01 17:09:21 +0000 | [diff] [blame] | 1059 | // In order for the == operator to work properly this must be the last field |
| 1060 | // in the struct so that we can do a memcmp to this field's offset. |
| 1061 | uint32_t fGenerationID; |
| 1062 | #endif |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1063 | }; |
| 1064 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 1065 | #endif |