1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
2e4f10a70807166484e5a6303a5cd0034e5e87abareed@google.com
38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/*
4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project
58a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com *
6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be
7ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file.
88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */
98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
10ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com
118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkPaint_DEFINED
128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkPaint_DEFINED
138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkColor.h"
159efd9a048aebaa6681afb76b18e1a7dd642078d3reed@google.com#include "SkDrawLooper.h"
16ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com#include "SkMatrix.h"
17a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com#include "SkXfermode.h"
18c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org#ifdef SK_BUILD_FOR_ANDROID
19c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org#include "SkPaintOptionsAndroid.h"
20c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org#endif
21a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com
22b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.comclass SkAnnotation;
238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAutoGlyphCache;
248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkColorFilter;
258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDescriptor;
26532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.comstruct SkDeviceProperties;
278b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgclass SkReadBuffer;
288b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgclass SkWriteBuffer;
298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkGlyph;
308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkRect;
318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkGlyphCache;
3215356a68b2a87e3ab9fc49392d085a4201ffeb62reed@google.comclass SkImageFilter;
338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkMaskFilter;
348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPath;
358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPathEffect;
36c73dd5c6880739f26216f198c757028fd28df1a4djsollen@google.comstruct SkPoint;
378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkRasterizer;
388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkShader;
398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkTypeface;
408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comtypedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**,
428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                           SkFixed x, SkFixed y);
438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comtypedef const SkGlyph& (*SkMeasureCacheProc)(SkGlyphCache*, const char**);
458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
46b088947f27496a9b9dc48a7cfb170f9d59589825humper@google.com#define kBicubicFilterBitmap_Flag kHighQualityFilterBitmap_Flag
47b088947f27496a9b9dc48a7cfb170f9d59589825humper@google.com
488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPaint
498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    The SkPaint class holds the style and color information about how to draw
518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    geometries, text and bitmaps.
528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/
53b088947f27496a9b9dc48a7cfb170f9d59589825humper@google.com
547ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkPaint {
558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic:
568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPaint();
578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPaint(const SkPaint& paint);
588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    ~SkPaint();
598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPaint& operator=(const SkPaint&);
618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
62b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com    SK_API friend bool operator==(const SkPaint& a, const SkPaint& b);
63b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com    friend bool operator!=(const SkPaint& a, const SkPaint& b) {
64b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com        return !(a == b);
65b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com    }
66b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com
678b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org    void flatten(SkWriteBuffer&) const;
688b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org    void unflatten(SkReadBuffer&);
698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Restores the paint to its initial settings.
718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void reset();
738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
74309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org    /** Specifies the level of hinting to be performed. These names are taken
75309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        from the Gnome/Cairo names for the same. They are translated into
76309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        Freetype concepts the same as in cairo-ft-font.c:
77309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org           kNo_Hinting     -> FT_LOAD_NO_HINTING
78309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org           kSlight_Hinting -> FT_LOAD_TARGET_LIGHT
79309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org           kNormal_Hinting -> <default, no option>
80309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org           kFull_Hinting   -> <same as kNormalHinting, unless we are rendering
81309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org                              subpixel glyphs, in which case TARGET_LCD or
82309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org                              TARGET_LCD_V is used>
83309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org    */
84309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org    enum Hinting {
85309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        kNo_Hinting            = 0,
86309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        kSlight_Hinting        = 1,
87309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        kNormal_Hinting        = 2,     //!< this is the default
881f90287df3129cb267422e482c52ebeca6a8990ftomhudson@google.com        kFull_Hinting          = 3
89309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org    };
90309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org
919d07fec3745e1b41637795270439c45f43daec48reed@google.com    Hinting getHinting() const {
92309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        return static_cast<Hinting>(fHinting);
93309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org    }
94309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org
95f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    void setHinting(Hinting hintingLevel);
96309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org
978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Specifies the bit values that are stored in the paint's flags.
988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Flags {
1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kAntiAlias_Flag       = 0x01,   //!< mask to enable antialiasing
1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kDither_Flag          = 0x04,   //!< mask to enable dithering
1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kUnderlineText_Flag   = 0x08,   //!< mask to enable underline text
1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kStrikeThruText_Flag  = 0x10,   //!< mask to enable strike-thru text
1048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kFakeBoldText_Flag    = 0x20,   //!< mask to enable fake-bold text
1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kLinearText_Flag      = 0x40,   //!< mask to enable linear-text
106309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        kSubpixelText_Flag    = 0x80,   //!< mask to enable subpixel text positioning
1078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kDevKernText_Flag     = 0x100,  //!< mask to enable device kerning text
108309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        kLCDRenderText_Flag   = 0x200,  //!< mask to enable subpixel glyph renderering
109e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org        kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap strikes
110a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org        kAutoHinting_Flag     = 0x800,  //!< mask to force Freetype's autohinter
111830a23e39bb4a126e573940cd6e354732e295b10reed@google.com        kVerticalText_Flag    = 0x1000,
1128351aabbfe82a76a698fa2bde00d33c1174518cdreed@google.com        kGenA8FromLCD_Flag    = 0x2000, // hack for GDI -- do not use if you can help it
113b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org        kDistanceFieldTextTEMP_Flag = 0x4000, //!< TEMPORARY mask to enable distance fields
114b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org                                              // currently overrides LCD and subpixel rendering
115309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        // when adding extra flags, note that the fFlags member is specified
116309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        // with a bit-width and you'll have to expand it.
1178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
118387db0a2e516ca01508f7d16433f84da2ea3b93bhumper@google.com        kAllFlags = 0xFFFF
1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
1208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's flags. Use the Flag enum to test flag values.
1228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's flags (see enums ending in _Flag for bit masks)
1238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint32_t getFlags() const { return fFlags; }
1258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's flags. Use the Flag enum to specific flag values.
1278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param flags    The new flag bits for the paint (see Flags enum)
1288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setFlags(uint32_t flags);
1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for getFlags(), returning true if kAntiAlias_Flag bit is set
1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the antialias bit is set in the paint's flags.
1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
1349d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isAntiAlias() const {
1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkToBool(this->getFlags() & kAntiAlias_Flag);
1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1379d07fec3745e1b41637795270439c45f43daec48reed@google.com
1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for setFlags(), setting or clearing the kAntiAlias_Flag bit
1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param aa   true to enable antialiasing, false to disable it
1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setAntiAlias(bool aa);
1429d07fec3745e1b41637795270439c45f43daec48reed@google.com
1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for getFlags(), returning true if kDither_Flag bit is set
1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the dithering bit is set in the paint's flags.
1458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
1469d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isDither() const {
1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkToBool(this->getFlags() & kDither_Flag);
1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1499d07fec3745e1b41637795270439c45f43daec48reed@google.com
1508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for setFlags(), setting or clearing the kDither_Flag bit
1518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param dither   true to enable dithering, false to disable it
1528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
1538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setDither(bool dither);
1549d07fec3745e1b41637795270439c45f43daec48reed@google.com
1558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for getFlags(), returning true if kLinearText_Flag bit is set
1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the lineartext bit is set in the paint's flags
1578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1589d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isLinearText() const {
1598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkToBool(this->getFlags() & kLinearText_Flag);
1608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for setFlags(), setting or clearing the kLinearText_Flag bit
1638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param linearText true to set the linearText bit in the paint's flags,
1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                          false to clear it.
1658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setLinearText(bool linearText);
1678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
1688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for getFlags(), returning true if kSubpixelText_Flag bit is set
1698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the lineartext bit is set in the paint's flags
1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
1719d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isSubpixelText() const {
1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkToBool(this->getFlags() & kSubpixelText_Flag);
1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
1749d07fec3745e1b41637795270439c45f43daec48reed@google.com
17584b437e6cecde391258c3a8b79159848fae5c55areed@google.com    /**
17684b437e6cecde391258c3a8b79159848fae5c55areed@google.com     *  Helper for setFlags(), setting or clearing the kSubpixelText_Flag.
17784b437e6cecde391258c3a8b79159848fae5c55areed@google.com     *  @param subpixelText true to set the subpixelText bit in the paint's
17884b437e6cecde391258c3a8b79159848fae5c55areed@google.com     *                      flags, false to clear it.
17984b437e6cecde391258c3a8b79159848fae5c55areed@google.com     */
1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setSubpixelText(bool subpixelText);
181309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org
1829d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isLCDRenderText() const {
183309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org        return SkToBool(this->getFlags() & kLCDRenderText_Flag);
184309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org    }
185309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org
18684b437e6cecde391258c3a8b79159848fae5c55areed@google.com    /**
18784b437e6cecde391258c3a8b79159848fae5c55areed@google.com     *  Helper for setFlags(), setting or clearing the kLCDRenderText_Flag.
18884b437e6cecde391258c3a8b79159848fae5c55areed@google.com     *  Note: antialiasing must also be on for lcd rendering
18984b437e6cecde391258c3a8b79159848fae5c55areed@google.com     *  @param lcdText true to set the LCDRenderText bit in the paint's flags,
19084b437e6cecde391258c3a8b79159848fae5c55areed@google.com     *                 false to clear it.
19184b437e6cecde391258c3a8b79159848fae5c55areed@google.com     */
19284b437e6cecde391258c3a8b79159848fae5c55areed@google.com    void setLCDRenderText(bool lcdText);
193309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org
1949d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isEmbeddedBitmapText() const {
195e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org        return SkToBool(this->getFlags() & kEmbeddedBitmapText_Flag);
196e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org    }
197e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org
198e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org    /** Helper for setFlags(), setting or clearing the kEmbeddedBitmapText_Flag bit
199e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org        @param useEmbeddedBitmapText true to set the kEmbeddedBitmapText bit in the paint's flags,
200e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org                                     false to clear it.
201e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org    */
202e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org    void setEmbeddedBitmapText(bool useEmbeddedBitmapText);
203e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org
2049d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isAutohinted() const {
205a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org        return SkToBool(this->getFlags() & kAutoHinting_Flag);
206a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org    }
207a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org
208a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org    /** Helper for setFlags(), setting or clearing the kAutoHinting_Flag bit
209a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org        @param useAutohinter true to set the kEmbeddedBitmapText bit in the
210a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org                                  paint's flags,
211a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org                             false to clear it.
212a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org    */
213a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org    void setAutohinted(bool useAutohinter);
214a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org
215830a23e39bb4a126e573940cd6e354732e295b10reed@google.com    bool isVerticalText() const {
216830a23e39bb4a126e573940cd6e354732e295b10reed@google.com        return SkToBool(this->getFlags() & kVerticalText_Flag);
217830a23e39bb4a126e573940cd6e354732e295b10reed@google.com    }
218fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
219830a23e39bb4a126e573940cd6e354732e295b10reed@google.com    /**
220830a23e39bb4a126e573940cd6e354732e295b10reed@google.com     *  Helper for setting or clearing the kVerticalText_Flag bit in
221830a23e39bb4a126e573940cd6e354732e295b10reed@google.com     *  setFlags(...).
222830a23e39bb4a126e573940cd6e354732e295b10reed@google.com     *
223830a23e39bb4a126e573940cd6e354732e295b10reed@google.com     *  If this bit is set, then advances are treated as Y values rather than
224830a23e39bb4a126e573940cd6e354732e295b10reed@google.com     *  X values, and drawText will places its glyphs vertically rather than
225830a23e39bb4a126e573940cd6e354732e295b10reed@google.com     *  horizontally.
226830a23e39bb4a126e573940cd6e354732e295b10reed@google.com     */
227830a23e39bb4a126e573940cd6e354732e295b10reed@google.com    void setVerticalText(bool);
228830a23e39bb4a126e573940cd6e354732e295b10reed@google.com
2298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for getFlags(), returning true if kUnderlineText_Flag bit is set
2308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the underlineText bit is set in the paint's flags.
2318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2329d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isUnderlineText() const {
2338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkToBool(this->getFlags() & kUnderlineText_Flag);
2348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for setFlags(), setting or clearing the kUnderlineText_Flag bit
2378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param underlineText true to set the underlineText bit in the paint's
2388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                             flags, false to clear it.
2398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setUnderlineText(bool underlineText);
2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for getFlags(), returns true if kStrikeThruText_Flag bit is set
2438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the strikeThruText bit is set in the paint's flags.
2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2459d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isStrikeThruText() const {
2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkToBool(this->getFlags() & kStrikeThruText_Flag);
2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for setFlags(), setting or clearing the kStrikeThruText_Flag bit
2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param strikeThruText   true to set the strikeThruText bit in the
2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                                paint's flags, false to clear it.
2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setStrikeThruText(bool strikeThruText);
2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set
2568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the kFakeBoldText_Flag bit is set in the paint's flags.
2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2589d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isFakeBoldText() const {
2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkToBool(this->getFlags() & kFakeBoldText_Flag);
2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for setFlags(), setting or clearing the kFakeBoldText_Flag bit
2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param fakeBoldText true to set the kFakeBoldText_Flag bit in the paint's
2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            flags, false to clear it.
2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setFakeBoldText(bool fakeBoldText);
2678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for getFlags(), returns true if kDevKernText_Flag bit is set
2698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return true if the kernText bit is set in the paint's flags.
2708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2719d07fec3745e1b41637795270439c45f43daec48reed@google.com    bool isDevKernText() const {
2728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return SkToBool(this->getFlags() & kDevKernText_Flag);
2738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
2758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper for setFlags(), setting or clearing the kKernText_Flag bit
2768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param kernText true to set the kKernText_Flag bit in the paint's
2778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            flags, false to clear it.
2788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
2798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setDevKernText(bool devKernText);
2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
281b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org    /** Helper for getFlags(), returns true if kDistanceFieldTextTEMP_Flag bit is set
282b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org     @return true if the distanceFieldText bit is set in the paint's flags.
283b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org     */
284b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org    bool isDistanceFieldTextTEMP() const {
285b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org        return SkToBool(this->getFlags() & kDistanceFieldTextTEMP_Flag);
286b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org    }
287b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org
288b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org    /** Helper for setFlags(), setting or clearing the kDistanceFieldTextTEMP_Flag bit
289b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org     @param distanceFieldText true to set the kDistanceFieldTextTEMP_Flag bit in the paint's
290b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org     flags, false to clear it.
291b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org     */
292b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org    void setDistanceFieldTextTEMP(bool distanceFieldText);
293b97c3ffddf15ac65a0aae6823eb408b3b2772751commit-bot@chromium.org
294c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    enum FilterLevel {
295c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com        kNone_FilterLevel,
296c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com        kLow_FilterLevel,
297c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com        kMedium_FilterLevel,
298c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com        kHigh_FilterLevel
299c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    };
300c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com
301c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    /**
302c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     *  Return the filter level. This affects the quality (and performance) of
303c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     *  drawing scaled images.
304c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     */
30585faf50875fcf6008880a98aaa05d12ae8dad343commit-bot@chromium.org    FilterLevel getFilterLevel() const { return (FilterLevel)fFilterLevel; }
306c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com
307c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    /**
308c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     *  Set the filter level. This affects the quality (and performance) of
309c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     *  drawing scaled images.
310c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     */
311c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    void setFilterLevel(FilterLevel);
312c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com
313c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    /**
314c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     *  If the predicate is true, set the filterLevel to Low, else set it to
315c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     *  None.
316c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     */
3174469938e92d779dff05e745559e67907bbf21e78reed@google.com    SK_ATTR_DEPRECATED("use setFilterLevel")
318c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    void setFilterBitmap(bool doFilter) {
319c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com        this->setFilterLevel(doFilter ? kLow_FilterLevel : kNone_FilterLevel);
3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
3219d07fec3745e1b41637795270439c45f43daec48reed@google.com
322c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    /**
323c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     *  Returns true if getFilterLevel() returns anything other than None.
324c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com     */
3254469938e92d779dff05e745559e67907bbf21e78reed@google.com    SK_ATTR_DEPRECATED("use getFilterLevel")
326c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    bool isFilterBitmap() const {
327c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com        return kNone_FilterLevel != this->getFilterLevel();
328c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com    }
3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Styles apply to rect, oval, path, and text.
3318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Bitmaps are always drawn in "fill", and lines are always drawn in
3328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        "stroke".
3339d07fec3745e1b41637795270439c45f43daec48reed@google.com
334ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com        Note: strokeandfill implicitly draws the result with
335ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com        SkPath::kWinding_FillType, so if the original path is even-odd, the
336ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com        results may not appear the same as if it was drawn twice, filled and
337ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com        then stroked.
3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Style {
340ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com        kFill_Style,            //!< fill the geometry
341ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com        kStroke_Style,          //!< stroke the geometry
342ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com        kStrokeAndFill_Style,   //!< fill and stroke the geometry
343aac2fb8019282e8933d76462b3bc62bf727e6627mike@reedtribe.org    };
344aac2fb8019282e8933d76462b3bc62bf727e6627mike@reedtribe.org    enum {
345aac2fb8019282e8933d76462b3bc62bf727e6627mike@reedtribe.org        kStyleCount = kStrokeAndFill_Style + 1
3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
3478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's style, used for controlling how primitives'
3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        geometries are interpreted (except for drawBitmap, which always assumes
3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kFill_Style).
3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's Style
3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Style getStyle() const { return (Style)fStyle; }
3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's style, used for controlling how primitives'
3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        geometries are interpreted (except for drawBitmap, which always assumes
3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Fill).
3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param style    The new style to set in the paint
3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setStyle(Style style);
3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's color. Note that the color is a 32bit value
3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        containing alpha as well as r,g,b. This 32bit value is not
3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        premultiplied, meaning that its alpha can be any value, regardless of
3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the values of r,g,b.
3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's color (and alpha).
3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkColor getColor() const { return fColor; }
3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's color. Note that the color is a 32bit value containing
3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        alpha as well as r,g,b. This 32bit value is not premultiplied, meaning
3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        that its alpha can be any value, regardless of the values of r,g,b.
3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param color    The new color (including alpha) to set in the paint.
3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setColor(SkColor color);
3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper to getColor() that just returns the color's alpha value.
3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the alpha component of the paint's color.
3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); }
3819d07fec3745e1b41637795270439c45f43daec48reed@google.com
3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper to setColor(), that only assigns the color's alpha value,
3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        leaving its r,g,b values unchanged.
3848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param a    set the alpha component (0..255) of the paint's color.
3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setAlpha(U8CPU a);
3878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Helper to setColor(), that takes a,r,g,b and constructs the color value
3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        using SkColorSetARGB()
3908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param a    The new alpha component (0..255) of the paint's color.
3918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param r    The new red component (0..255) of the paint's color.
3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param g    The new green component (0..255) of the paint's color.
3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param b    The new blue component (0..255) of the paint's color.
3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
3979d07fec3745e1b41637795270439c45f43daec48reed@google.com    /** Return the width for stroking.
3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        A value of 0 strokes in hairline mode.
4008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Hairlines always draw 1-pixel wide, regardless of the matrix.
4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's stroke width, used whenever the paint's style is
4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                Stroke or StrokeAndFill.
4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar getStrokeWidth() const { return fWidth; }
4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4069d07fec3745e1b41637795270439c45f43daec48reed@google.com    /** Set the width for stroking.
4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Pass 0 to stroke in hairline mode.
4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Hairlines always draw 1-pixel wide, regardless of the matrix.
4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param width set the paint's stroke width, used whenever the paint's
4108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     style is Stroke or StrokeAndFill.
4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setStrokeWidth(SkScalar width);
4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's stroke miter value. This is used to control the
4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        behavior of miter joins when the joins angle is sharp.
4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's miter limit, used whenever the paint's style is
4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                Stroke or StrokeAndFill.
4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar getStrokeMiter() const { return fMiterLimit; }
4208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's stroke miter value. This is used to control the
4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        behavior of miter joins when the joins angle is sharp. This value must
4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        be >= 0.
4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param miter    set the miter limit on the paint, used whenever the
4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        paint's style is Stroke or StrokeAndFill.
4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setStrokeMiter(SkScalar miter);
4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Cap enum specifies the settings for the paint's strokecap. This is the
4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        treatment that is applied to the beginning and end of each non-closed
4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        contour (e.g. lines).
4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Cap {
4348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kButt_Cap,      //!< begin/end contours with no extension
4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kRound_Cap,     //!< begin/end contours with a semi-circle extension
4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kSquare_Cap,    //!< begin/end contours with a half square extension
4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCapCount,
4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kDefault_Cap = kButt_Cap
4408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
4418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Join enum specifies the settings for the paint's strokejoin. This is
4438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        the treatment that is applied to corners in paths and rectangles.
4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Join {
4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kMiter_Join,    //!< connect path segments with a sharp join
4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kRound_Join,    //!< connect path segments with a round join
4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kBevel_Join,    //!< connect path segments with a flat bevel join
4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kJoinCount,
4518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kDefault_Join = kMiter_Join
4528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
4538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's stroke cap type, controlling how the start and end
4558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        of stroked lines and paths are treated.
4568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the line cap style for the paint, used whenever the paint's
4578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                style is Stroke or StrokeAndFill.
4588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Cap getStrokeCap() const { return (Cap)fCapType; }
4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's stroke cap type.
4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param cap  set the paint's line cap style, used whenever the paint's
4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    style is Stroke or StrokeAndFill.
4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setStrokeCap(Cap cap);
4668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's stroke join type.
4688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's line join style, used whenever the paint's style is
4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                Stroke or StrokeAndFill.
4708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Join getStrokeJoin() const { return (Join)fJoinType; }
4728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's stroke join type.
4748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param join set the paint's line join style, used whenever the paint's
4758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                    style is Stroke or StrokeAndFill.
4768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setStrokeJoin(Join join);
4788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4794bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com    /**
4804bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *  Applies any/all effects (patheffect, stroking) to src, returning the
4814bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *  result in dst. The result is that drawing src with this paint will be
4824bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *  the same as drawing dst with a default paint (at least from the
4834bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *  geometric perspective).
4844bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *
4854bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *  @param src  input path
4864bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *  @param dst  output path (may be the same as src)
4874bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *  @param cullRect If not null, the dst path may be culled to this rect.
4884bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *  @return     true if the path should be filled, or false if it should be
4894bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     *              drawn with a hairline (width == 0)
4904bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com     */
4914bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com    bool getFillPath(const SkPath& src, SkPath* dst,
4924bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com                     const SkRect* cullRect = NULL) const;
4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Get the paint's shader object.
4958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
4968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      The shader's reference count is not affected.
4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's shader (or NULL)
4988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkShader* getShader() const { return fShader; }
5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set or clear the shader object.
502880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  Shaders specify the source color(s) for what is being drawn. If a paint
503880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  has no shader, then the paint's color is used. If the paint has a
504880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  shader, then the shader's color(s) are use instead, but they are
505880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  modulated by the paint's alpha. This makes it easy to create a shader
506880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  once (e.g. bitmap tiling or gradient) and then change its transparency
507880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  w/o having to modify the original shader... only the paint's alpha needs
508880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  to be modified.
509e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org     *
510e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org     *  There is an exception to this only-respect-paint's-alpha rule: If the shader only generates
511e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org     *  alpha (e.g. SkShader::CreateBitmapShader(bitmap, ...) where bitmap's colortype is kAlpha_8)
512e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org     *  then the shader will use the paint's entire color to "colorize" its output (modulating the
513e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org     *  bitmap's alpha with the paint's color+alpha).
514e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org     *
515880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  Pass NULL to clear any previous shader.
516880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  As a convenience, the parameter passed is also returned.
517880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  If a previous shader exists, its reference count is decremented.
518880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  If shader is not NULL, its reference count is incremented.
519880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  @param shader   May be NULL. The shader to be installed in the paint
520880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     *  @return         shader
521880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com     */
5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkShader* setShader(SkShader* shader);
5239d07fec3745e1b41637795270439c45f43daec48reed@google.com
5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Get the paint's colorfilter. If there is a colorfilter, its reference
5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        count is not changed.
5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's colorfilter (or NULL)
5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkColorFilter* getColorFilter() const { return fColorFilter; }
5298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set or clear the paint's colorfilter, returning the parameter.
5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If the paint already has a filter, its reference count is decremented.
5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If filter is not NULL, its reference count is incremented.
5348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param filter   May be NULL. The filter to be installed in the paint
5358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return         filter
5368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkColorFilter* setColorFilter(SkColorFilter* filter);
5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Get the paint's xfermode object.
5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      The xfermode's reference count is not affected.
5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's xfermode (or NULL)
5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkXfermode* getXfermode() const { return fXfermode; }
5458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set or clear the xfermode object.
5478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
5488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Pass NULL to clear any previous xfermode.
5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        As a convenience, the parameter passed is also returned.
5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If a previous xfermode exists, its reference count is decremented.
5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If xfermode is not NULL, its reference count is incremented.
5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param xfermode May be NULL. The new xfermode to be installed in the
5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        paint
5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return         xfermode
5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkXfermode* setXfermode(SkXfermode* xfermode);
557a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com
558a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com    /** Create an xfermode based on the specified Mode, and assign it into the
559a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com        paint, returning the mode that was set. If the Mode is SrcOver, then
560a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com        the paint's xfermode is set to null.
561a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com     */
5620baf19375466cfc24c96532df406e7c5b1d1aae8reed@android.com    SkXfermode* setXfermodeMode(SkXfermode::Mode);
563a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com
5648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Get the paint's patheffect object.
5658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
5668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      The patheffect reference count is not affected.
5678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's patheffect (or NULL)
5688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPathEffect* getPathEffect() const { return fPathEffect; }
5708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set or clear the patheffect object.
5728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
5738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Pass NULL to clear any previous patheffect.
5748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        As a convenience, the parameter passed is also returned.
5758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If a previous patheffect exists, its reference count is decremented.
5768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If patheffect is not NULL, its reference count is incremented.
5778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param effect   May be NULL. The new patheffect to be installed in the
5788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        paint
5798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return         effect
5808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkPathEffect* setPathEffect(SkPathEffect* effect);
5828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Get the paint's maskfilter object.
5848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
5858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com      The maskfilter reference count is not affected.
5868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's maskfilter (or NULL)
5878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
5888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkMaskFilter* getMaskFilter() const { return fMaskFilter; }
5898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
5908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set or clear the maskfilter object.
5918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
5928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Pass NULL to clear any previous maskfilter.
5938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        As a convenience, the parameter passed is also returned.
5948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If a previous maskfilter exists, its reference count is decremented.
5958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If maskfilter is not NULL, its reference count is incremented.
5968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param maskfilter   May be NULL. The new maskfilter to be installed in
5978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            the paint
5988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return             maskfilter
5998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkMaskFilter* setMaskFilter(SkMaskFilter* maskfilter);
6018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    // These attributes are for text/fonts
6038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Get the paint's typeface object.
6058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
6068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        The typeface object identifies which font to use when drawing or
6078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        measuring text. The typeface reference count is not affected.
6088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's typeface (or NULL)
6098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkTypeface* getTypeface() const { return fTypeface; }
6118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set or clear the typeface object.
6138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
6148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Pass NULL to clear any previous typeface.
6158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        As a convenience, the parameter passed is also returned.
6168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If a previous typeface exists, its reference count is decremented.
6178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If typeface is not NULL, its reference count is incremented.
6188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param typeface May be NULL. The new typeface to be installed in the
6198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        paint
6208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return         typeface
6218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkTypeface* setTypeface(SkTypeface* typeface);
6238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Get the paint's rasterizer (or NULL).
6258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
6268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        The raster controls how paths/text are turned into alpha masks.
6278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's rasterizer (or NULL)
6288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkRasterizer* getRasterizer() const { return fRasterizer; }
6308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set or clear the rasterizer object.
6328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        <p />
6338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Pass NULL to clear any previous rasterizer.
6348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        As a convenience, the parameter passed is also returned.
6358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If a previous rasterizer exists in the paint, its reference count is
6368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        decremented. If rasterizer is not NULL, its reference count is
6378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        incremented.
6388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param rasterizer May be NULL. The new rasterizer to be installed in
6398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                          the paint.
6408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return           rasterizer
6418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkRasterizer* setRasterizer(SkRasterizer* rasterizer);
6438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
64415356a68b2a87e3ab9fc49392d085a4201ffeb62reed@google.com    SkImageFilter* getImageFilter() const { return fImageFilter; }
64515356a68b2a87e3ab9fc49392d085a4201ffeb62reed@google.com    SkImageFilter* setImageFilter(SkImageFilter*);
646fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
647b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com    SkAnnotation* getAnnotation() const { return fAnnotation; }
648b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com    SkAnnotation* setAnnotation(SkAnnotation*);
649b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com
650b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com    /**
651b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com     *  Returns true if there is an annotation installed on this paint, and
652b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com     *  the annotation specifics no-drawing.
653b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com     */
6544469938e92d779dff05e745559e67907bbf21e78reed@google.com    SK_ATTR_DEPRECATED("use getAnnotation and check for non-null")
655950923b43761c10d9c8ffc1dfc0c878100d1e702commit-bot@chromium.org    bool isNoDrawAnnotation() const { return this->getAnnotation() != NULL; }
65615356a68b2a87e3ab9fc49392d085a4201ffeb62reed@google.com
6579d07fec3745e1b41637795270439c45f43daec48reed@google.com    /**
6589d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  Return the paint's SkDrawLooper (if any). Does not affect the looper's
6599d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  reference count.
6609d07fec3745e1b41637795270439c45f43daec48reed@google.com     */
6618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkDrawLooper* getLooper() const { return fLooper; }
6629d07fec3745e1b41637795270439c45f43daec48reed@google.com
6639d07fec3745e1b41637795270439c45f43daec48reed@google.com    /**
6649d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  Set or clear the looper object.
6659d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  <p />
6669d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  Pass NULL to clear any previous looper.
6679d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  As a convenience, the parameter passed is also returned.
6689d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  If a previous looper exists in the paint, its reference count is
6699d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  decremented. If looper is not NULL, its reference count is
6709d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  incremented.
6719d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  @param looper May be NULL. The new looper to be installed in the paint.
6729d07fec3745e1b41637795270439c45f43daec48reed@google.com     *  @return looper
6739d07fec3745e1b41637795270439c45f43daec48reed@google.com     */
6749d07fec3745e1b41637795270439c45f43daec48reed@google.com    SkDrawLooper* setLooper(SkDrawLooper* looper);
6758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum Align {
6778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kLeft_Align,
6788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kCenter_Align,
6798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kRight_Align,
680ddc813b0def5a79d0eb5011240fecce6147ce9efmike@reedtribe.org    };
681ddc813b0def5a79d0eb5011240fecce6147ce9efmike@reedtribe.org    enum {
682ddc813b0def5a79d0eb5011240fecce6147ce9efmike@reedtribe.org        kAlignCount = 3
6838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
6849d07fec3745e1b41637795270439c45f43daec48reed@google.com
6858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's Align value for drawing text.
6868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's Align value for drawing text.
6878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    Align   getTextAlign() const { return (Align)fTextAlign; }
6899d07fec3745e1b41637795270439c45f43daec48reed@google.com
6908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's text alignment.
6918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param align set the paint's Align value for drawing text.
6928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void    setTextAlign(Align align);
6948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
6958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's text size.
6968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's text size.
6978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
6988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar getTextSize() const { return fTextSize; }
6998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's text size. This value must be > 0
7018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param textSize set the paint's text size.
7028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setTextSize(SkScalar textSize);
7048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's horizontal scale factor for text. The default value
7068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is 1.0.
7078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's scale factor in X for drawing/measuring text
7088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar getTextScaleX() const { return fTextScaleX; }
7108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's horizontal scale factor for text. The default value
7128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will
7138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        stretch the text narrower.
7148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param scaleX   set the paint's scale factor in X for drawing/measuring
7158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                        text.
7168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setTextScaleX(SkScalar scaleX);
7188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the paint's horizontal skew factor for text. The default value
7208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is 0.
7218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @return the paint's skew factor in X for drawing text.
7228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar getTextSkewX() const { return fTextSkewX; }
7248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Set the paint's horizontal skew factor for text. The default value
7268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is 0. For approximating oblique text, use values around -0.25.
7278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param skewX set the paint's skew factor in X for drawing text.
7288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setTextSkewX(SkScalar skewX);
7308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Describes how to interpret the text parameters that are passed to paint
7328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        methods like measureText() and getTextWidths().
7338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
7348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum TextEncoding {
7358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kUTF8_TextEncoding,     //!< the text parameters are UTF8
7368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kUTF16_TextEncoding,    //!< the text parameters are UTF16
7376970557055acaed619d7bb89451868e1570249b2robertphillips@google.com        kUTF32_TextEncoding,    //!< the text parameters are UTF32
7388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kGlyphID_TextEncoding   //!< the text parameters are glyph indices
7398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
7409d07fec3745e1b41637795270439c45f43daec48reed@google.com
7419d07fec3745e1b41637795270439c45f43daec48reed@google.com    TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; }
7428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void setTextEncoding(TextEncoding encoding);
7448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
7458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    struct FontMetrics {
7460bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        /** Flags which indicate the confidence level of various metrics.
7470bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            A set flag indicates that the metric may be trusted.
7480bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        */
7490bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        enum FontMetricsFlags {
7500bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            kUnderlineThinknessIsValid_Flag = 1 << 0,
7510bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            kUnderlinePositionIsValid_Flag = 1 << 1,
7520bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        };
7530bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org
7540bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        uint32_t    fFlags;       //!< Bit field to identify which values are unknown
7558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkScalar    fTop;       //!< The greatest distance above the baseline for any glyph (will be <= 0)
7568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkScalar    fAscent;    //!< The recommended distance above the baseline (will be <= 0)
7578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkScalar    fDescent;   //!< The recommended distance below the baseline (will be >= 0)
7588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkScalar    fBottom;    //!< The greatest distance below the baseline for any glyph (will be >= 0)
7598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        SkScalar    fLeading;   //!< The recommended distance to add between lines of text (will be >= 0)
7600bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        SkScalar    fAvgCharWidth;  //!< the average character width (>= 0)
7610bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        SkScalar    fMaxCharWidth;  //!< the max character width (>= 0)
762cc3096ba6d437b29f1cbd34c237607419cbed72bagl@chromium.org        SkScalar    fXMin;      //!< The minimum bounding box x value for all glyphs
763cc3096ba6d437b29f1cbd34c237607419cbed72bagl@chromium.org        SkScalar    fXMax;      //!< The maximum bounding box x value for all glyphs
764cbe1b54c30b9a1061577c91e0b914dbe9acdc563bungeman@google.com        SkScalar    fXHeight;   //!< The height of an 'x' in px, or 0 if no 'x' in face
765cbe1b54c30b9a1061577c91e0b914dbe9acdc563bungeman@google.com        SkScalar    fCapHeight;  //!< The cap height (> 0), or 0 if cannot be determined.
7660bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        SkScalar    fUnderlineThickness; //!< underline thickness, or 0 if cannot be determined
7670bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org
7680bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        /**  Underline Position - position of the top of the Underline stroke
7690bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                relative to the baseline, this can have following values
7700bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                - Negative - means underline should be drawn above baseline.
7710bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                - Positive - means below baseline.
7720bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                - Zero     - mean underline should be drawn on baseline.
7730bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org         */
7740bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        SkScalar    fUnderlinePosition; //!< underline position, or 0 if cannot be determined
7750bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org
7760bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        /**  If the fontmetrics has a valid underlinethickness, return true, and set the
7770bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                thickness param to that value. If it doesn't return false and ignore the
7780bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                thickness param.
7790bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        */
7800bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        bool hasUnderlineThickness(SkScalar* thickness) const {
7810bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            if (SkToBool(fFlags & kUnderlineThinknessIsValid_Flag)) {
7820bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                *thickness = fUnderlineThickness;
7830bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                return true;
7840bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            }
7850bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            return false;
7860bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        }
7870bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org
7880bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        /**  If the fontmetrics has a valid underlineposition, return true, and set the
7890bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                thickness param to that value. If it doesn't return false and ignore the
7900bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                thickness param.
7910bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        */
7920bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        bool hasUnderlinePosition(SkScalar* position) const {
7930bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            if (SkToBool(fFlags & kUnderlinePositionIsValid_Flag)) {
7940bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                *position = fUnderlinePosition;
7950bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org                return true;
7960bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            }
7970bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org            return false;
7980bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org        }
7990bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org
8008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
8019d07fec3745e1b41637795270439c45f43daec48reed@google.com
8028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the recommend spacing between lines (which will be
8038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fDescent - fAscent + fLeading).
8048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        If metrics is not null, return in it the font metrics for the
8059d07fec3745e1b41637795270439c45f43daec48reed@google.com        typeface/pointsize/etc. currently set in the paint.
8068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param metrics      If not null, returns the font metrics for the
8078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            current typeface/pointsize/etc setting in this
8088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            paint.
8098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param scale        If not 0, return width as if the canvas were scaled
8108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                            by this value
8118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        @param return the recommended spacing between lines
8128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0) const;
8149d07fec3745e1b41637795270439c45f43daec48reed@google.com
8158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the recommend line spacing. This will be
8168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        fDescent - fAscent + fLeading
8178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    SkScalar getFontSpacing() const { return this->getFontMetrics(NULL, 0); }
8198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
8208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Convert the specified text into glyph IDs, returning the number of
8218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        glyphs ID written. If glyphs is NULL, it is ignore and only the count
8228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        is returned.
8238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int textToGlyphs(const void* text, size_t byteLength,
8258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     uint16_t glyphs[]) const;
8268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
827a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com    /** Return true if all of the specified text has a corresponding non-zero
828a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com        glyph ID. If any of the code-points in the text are not supported in
829a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com        the typeface (i.e. the glyph ID would be zero), then return false.
830a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com
831a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com        If the text encoding for the paint is kGlyph_TextEncoding, then this
832a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com        returns true if all of the specified glyph IDs are non-zero.
833a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com     */
834a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com    bool containsText(const void* text, size_t byteLength) const;
835a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com
8369d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com    /** Convert the glyph array into Unichars. Unconvertable glyphs are mapped
8379d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com        to zero. Note: this does not look at the text-encoding setting in the
8389d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com        paint, only at the typeface.
8399d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com    */
8409d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com    void glyphsToUnichars(const uint16_t glyphs[], int count,
8419d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com                          SkUnichar text[]) const;
8429d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com
8438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the number of drawable units in the specified text buffer.
8448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        This looks at the current TextEncoding field of the paint. If you also
8458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        want to have the text converted into glyph IDs, call textToGlyphs
8468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        instead.
8478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8489d07fec3745e1b41637795270439c45f43daec48reed@google.com    int countText(const void* text, size_t byteLength) const {
8498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return this->textToGlyphs(text, byteLength, NULL);
8508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
8518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
85244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com    /** Return the width of the text. This will return the vertical measure
85344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  if isVerticalText() is true, in which case the returned value should
85444da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  be treated has a height instead of a width.
85544da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *
85644da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param text         The text to be measured
85744da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param length       Number of bytes of text to measure
85844da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param bounds       If not NULL, returns the bounds of the text,
85944da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                      relative to (0, 0).
86044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param scale        If not 0, return width as if the canvas were scaled
86144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                      by this value
86244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @return             The advance width of the text
86344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     */
8649d07fec3745e1b41637795270439c45f43daec48reed@google.com    SkScalar measureText(const void* text, size_t length,
8659d07fec3745e1b41637795270439c45f43daec48reed@google.com                         SkRect* bounds, SkScalar scale = 0) const;
8668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
86744da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com    /** Return the width of the text. This will return the vertical measure
86844da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  if isVerticalText() is true, in which case the returned value should
86944da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  be treated has a height instead of a width.
87044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *
87144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param text     Address of the text
87244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param length   Number of bytes of text to measure
87397ecd1d454fc3fd3703724ae108a542f5f271fb0reed@google.com     *  @return         The advance width of the text
87444da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     */
8759d07fec3745e1b41637795270439c45f43daec48reed@google.com    SkScalar measureText(const void* text, size_t length) const {
8768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        return this->measureText(text, length, NULL, 0);
8778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    }
8789d07fec3745e1b41637795270439c45f43daec48reed@google.com
8798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Specify the direction the text buffer should be processed in breakText()
8808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
8818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum TextBufferDirection {
8828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** When measuring text for breakText(), begin at the start of the text
8838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            buffer and proceed forward through the data. This is the default.
8848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
8858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kForward_TextBufferDirection,
8868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        /** When measuring text for breakText(), begin at the end of the text
8878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com            buffer and proceed backwards through the data.
8888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        */
8898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        kBackward_TextBufferDirection
8908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
8918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
89244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com    /** Return the number of bytes of text that were measured. If
89344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  isVerticalText() is true, then the vertical advances are used for
89444da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  the measurement.
895fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com     *
89644da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param text     The text to be measured
89744da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param length   Number of bytes of text to measure
89844da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param maxWidth Maximum width. Only the subset of text whose accumulated
89944da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                  widths are <= maxWidth are measured.
90044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param measuredWidth Optional. If non-null, this returns the actual
90144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                  width of the measured text.
90244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param tbd      Optional. The direction the text buffer should be
90344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                  traversed during measuring.
90444da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @return         The number of bytes of text that were measured. Will be
90544da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                  <= length.
90644da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     */
9078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    size_t  breakText(const void* text, size_t length, SkScalar maxWidth,
9088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                      SkScalar* measuredWidth = NULL,
9098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                      TextBufferDirection tbd = kForward_TextBufferDirection)
9108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                      const;
9118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
91244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com    /** Return the advances for the text. These will be vertical advances if
91344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  isVerticalText() returns true.
91444da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *
91544da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param text         the text
91644da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param byteLength   number of bytes to of text
91744da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param widths       If not null, returns the array of advances for
91844da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                      the glyphs. If not NULL, must be at least a large
91944da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                      as the number of unichars in the specified text.
92044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @param bounds       If not null, returns the bounds for each of
92144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *                      character, relative to (0, 0)
92244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     *  @return the number of unichars in the specified text.
92344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com     */
9248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    int getTextWidths(const void* text, size_t byteLength, SkScalar widths[],
9258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                      SkRect bounds[] = NULL) const;
9268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
9278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    /** Return the path (outline) for the specified text.
9288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com        Note: just like SkCanvas::drawText, this will respect the Align setting
9298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com              in the paint.
9308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    */
9318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y,
9328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com                     SkPath* path) const;
9338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
934fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com    void getPosTextPath(const void* text, size_t length,
935ca0062ee5e74eddff886ada2a200d25946ea52cfreed@google.com                        const SkPoint pos[], SkPath* path) const;
936ca0062ee5e74eddff886ada2a200d25946ea52cfreed@google.com
93756c69773aea56c6c6bd47bc7e7970dd081205184djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
938f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com    uint32_t getGenerationID() const;
9394bd2bdbf04f21237337616aa931e34d7c8991edcdjsollen@google.com    void setGenerationID(uint32_t generationID);
94060abb078e5597c9c6ceaba1ef495c4916ff4df0ddjsollen@google.com
94160abb078e5597c9c6ceaba1ef495c4916ff4df0ddjsollen@google.com    /** Returns the base glyph count for the strike associated with this paint
94260abb078e5597c9c6ceaba1ef495c4916ff4df0ddjsollen@google.com    */
94360abb078e5597c9c6ceaba1ef495c4916ff4df0ddjsollen@google.com    unsigned getBaseGlyphCount(SkUnichar text) const;
944c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org
945c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org    const SkPaintOptionsAndroid& getPaintOptionsAndroid() const {
946c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org        return fPaintOptionsAndroid;
947c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org    }
948c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org    void setPaintOptionsAndroid(const SkPaintOptionsAndroid& options);
949f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com#endif
950f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com
951632e1a281bc66fb545dce690dff27b51cef41a8ereed@google.com    // returns true if the paint's settings (e.g. xfermode + alpha) resolve to
952632e1a281bc66fb545dce690dff27b51cef41a8ereed@google.com    // mean that we need not draw at all (e.g. SrcOver + 0-alpha)
953632e1a281bc66fb545dce690dff27b51cef41a8ereed@google.com    bool nothingToDraw() const;
954632e1a281bc66fb545dce690dff27b51cef41a8ereed@google.com
955a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    ///////////////////////////////////////////////////////////////////////////
956d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    // would prefer to make these private...
957d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com
958a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    /** Returns true if the current paint settings allow for fast computation of
959a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     bounds (i.e. there is nothing complex like a patheffect that would make
960a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     the bounds computation expensive.
961a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     */
962a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    bool canComputeFastBounds() const {
963a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com        if (this->getLooper()) {
964a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com            return this->getLooper()->canComputeFastBounds(*this);
965a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com        }
966a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com        return !this->getRasterizer();
967a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    }
968fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
969a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    /** Only call this if canComputeFastBounds() returned true. This takes a
970a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     raw rectangle (the raw bounds of a shape), and adjusts it for stylistic
971a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     effects in the paint (e.g. stroking). If needed, it uses the storage
972a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     rect parameter. It returns the adjusted bounds that can then be used
973a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     for quickReject tests.
974fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
975a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     The returned rect will either be orig or storage, thus the caller
976a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     should not rely on storage being set to the result, but should always
977a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     use the retured value. It is legal for orig and storage to be the same
978a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     rect.
979fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
980a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     e.g.
981a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     if (paint.canComputeFastBounds()) {
982a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     SkRect r, storage;
983a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     path.computeBounds(&r, SkPath::kFast_BoundsType);
984a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     const SkRect& fastR = paint.computeFastBounds(r, &storage);
985a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     if (canvas->quickReject(fastR, ...)) {
986a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     // don't draw the path
987a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     }
988a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     }
989a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com     */
990a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const {
991a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com        SkPaint::Style style = this->getStyle();
992a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com        // ultra fast-case: filling with no effects that affect geometry
993a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com        if (kFill_Style == style) {
994a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com            uintptr_t effects = reinterpret_cast<uintptr_t>(this->getLooper());
995a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com            effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
996a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com            effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
997336d1d759590d9bedcbc5a96d0fff79861cf8f7asenorblanco@chromium.org            effects |= reinterpret_cast<uintptr_t>(this->getImageFilter());
998a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com            if (!effects) {
999a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com                return orig;
1000a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com            }
1001a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com        }
1002fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1003a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com        return this->doComputeFastBounds(orig, storage, style);
1004a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    }
1005fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1006a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    const SkRect& computeFastStrokeBounds(const SkRect& orig,
1007a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com                                          SkRect* storage) const {
100873a025811c202fee3248bc7756fba6deb79bfdd1reed@google.com        return this->doComputeFastBounds(orig, storage, kStroke_Style);
1009a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    }
1010fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1011a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    // Take the style explicitly, so the caller can force us to be stroked
1012a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    // without having to make a copy of the paint just to change that field.
1013a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com    const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
1014a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com                                      Style) const;
1015fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com
1016ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    /**
1017ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com     *  Return a matrix that applies the paint's text values: size, scale, skew
1018ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com     */
1019ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    static SkMatrix* SetTextMatrix(SkMatrix* matrix, SkScalar size,
1020ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com                                   SkScalar scaleX, SkScalar skewX) {
1021ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        matrix->setScale(size * scaleX, size);
1022ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        if (skewX) {
1023ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com            matrix->postSkew(skewX, 0);
1024ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        }
1025ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        return matrix;
1026ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    }
10278f6ef4010f6835c5ce9ede180e50a6a58512a81eskia.committer@gmail.com
1028ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    SkMatrix* setTextMatrix(SkMatrix* matrix) const {
1029ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX);
1030ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    }
10318f6ef4010f6835c5ce9ede180e50a6a58512a81eskia.committer@gmail.com
10320f10f7bf1fb43ca6346dc220a076773b1f19a367commit-bot@chromium.org    SK_TO_STRING_NONVIRT()
1033791f12e6cf558e0dd1689fbb0a6b5eddac9f42adrobertphillips@google.com
1034aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org    struct FlatteningTraits {
1035aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org        static void Flatten(SkWriteBuffer& buffer, const SkPaint& paint);
1036aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org        static void Unflatten(SkReadBuffer& buffer, SkPaint* paint);
1037aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org    };
1038aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org
1039d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.comprivate:
1040d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkTypeface*     fTypeface;
1041d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkPathEffect*   fPathEffect;
1042d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkShader*       fShader;
1043d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkXfermode*     fXfermode;
1044d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkMaskFilter*   fMaskFilter;
1045d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkColorFilter*  fColorFilter;
1046d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkRasterizer*   fRasterizer;
1047d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkDrawLooper*   fLooper;
1048d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkImageFilter*  fImageFilter;
1049b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com    SkAnnotation*   fAnnotation;
1050d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com
1051e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org    SkScalar        fTextSize;
1052e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org    SkScalar        fTextScaleX;
1053e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org    SkScalar        fTextSkewX;
1054d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkColor         fColor;
1055d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkScalar        fWidth;
1056d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkScalar        fMiterLimit;
1057aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org    union {
1058aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org        struct {
1059aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org            // all of these bitfields should add up to 32
1060aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org            unsigned        fFlags : 16;
1061aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org            unsigned        fTextAlign : 2;
1062aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org            unsigned        fCapType : 2;
1063aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org            unsigned        fJoinType : 2;
1064aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org            unsigned        fStyle : 2;
1065aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org            unsigned        fTextEncoding : 2;  // 3 values
1066aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org            unsigned        fHinting : 2;
106785faf50875fcf6008880a98aaa05d12ae8dad343commit-bot@chromium.org            unsigned        fFilterLevel : 2;
106885faf50875fcf6008880a98aaa05d12ae8dad343commit-bot@chromium.org            //unsigned      fFreeBits : 2;
1069aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org        };
1070aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org        uint32_t fBitfields;
1071aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org    };
1072e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org    uint32_t fDirtyBits;
1073e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org
1074aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org    uint32_t getBitfields() const { return fBitfields; }
1075aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org    void setBitfields(uint32_t bitfields);
1076aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org
1077d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkDrawCacheProc    getDrawCacheProc() const;
1078d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir,
1079d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com                                           bool needFullMetrics) const;
1080d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com
1081d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com    SkScalar measure_text(SkGlyphCache*, const char* text, size_t length,
1082d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com                          int* count, SkRect* bounds) const;
1083d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com
10842d2a68c51b4a71bd60760510bf2b2e58bc9890b2jvanverth    SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*,
10852d2a68c51b4a71bd60760510bf2b2e58bc9890b2jvanverth                              bool ignoreGamma) const;
1086d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com
1087532470f34dbe9fc0b8b71e3917eca8894feaf336bungeman@google.com    void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatrix* deviceMatrix,
108890808e87c21e93b8e670360655e0b0eb12cb2f87reed@google.com                        void (*proc)(SkTypeface*, const SkDescriptor*, void*),
1089d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com                        void* context, bool ignoreGamma = false) const;
1090d252db03d9650013b545ef9781fe993c07f8f314reed@android.com
1091b24b4fa12be03807a0c3c710ec5ad102f3a8e145bungeman@google.com    static void Term();
1092b24b4fa12be03807a0c3c710ec5ad102f3a8e145bungeman@google.com
10938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    enum {
1094ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        /*  This is the size we use when we ask for a glyph's path. We then
1095ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  post-transform it as we draw to match the request.
1096ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  This is done to try to re-use cache entries for the path.
1097ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *
1098ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  This value is somewhat arbitrary. In theory, it could be 1, since
1099ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  we store paths as floats. However, we get the path from the font
1100ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  scaler, and it may represent its paths as fixed-point (or 26.6),
1101ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  so we shouldn't ask for something too big (might overflow 16.16)
1102ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  or too small (underflow 26.6).
1103ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *
1104ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  This value could track kMaxSizeForGlyphCache, assuming the above
1105ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  constraints, but since we ask for unhinted paths, the two values
1106ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  need not match per-se.
1107ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         */
1108ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        kCanonicalTextSizeForPaths  = 64,
1109ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com
1110ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        /*
1111ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  Above this size (taking into account CTM and textSize), we never use
1112ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  the cache for bits or metrics (we might overflow), so we just ask
1113ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         *  for a caononical size and post-transform that.
1114ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com         */
1115ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        kMaxSizeForGlyphCache       = 256,
11168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    };
1117ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com
1118ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM);
1119ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com
1120ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    bool tooBigToUseCache() const;
1121ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    bool tooBigToUseCache(const SkMatrix& ctm) const;
11228f6ef4010f6835c5ce9ede180e50a6a58512a81eskia.committer@gmail.com
1123ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    // Set flags/hinting/textSize up to use for drawing text as paths.
1124ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    // Returns scale factor to restore the original textSize, since will will
1125ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    // have change it to kCanonicalTextSizeForPaths.
1126ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    SkScalar setupForAsPaths();
1127ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com
1128ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    static SkScalar MaxCacheSize2() {
1129ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        static const SkScalar kMaxSize = SkIntToScalar(kMaxSizeForGlyphCache);
1130ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        static const SkScalar kMag2Max = kMaxSize * kMaxSize;
1131ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com        return kMag2Max;
1132ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    }
1133ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com
113428be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org    friend class SkAutoGlyphCache;
11352d2a68c51b4a71bd60760510bf2b2e58bc9890b2jvanverth    friend class SkAutoGlyphCacheNoGamma;
11368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkCanvas;
11378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkDraw;
1138b24b4fa12be03807a0c3c710ec5ad102f3a8e145bungeman@google.com    friend class SkGraphics; // So Term() can be called.
113928be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org    friend class SkPDFDevice;
1140e8612d9a8d616c2ed0195421a0675e10b0c2d230commit-bot@chromium.org    friend class GrBitmapTextContext;
11418128d8c119382279918b90ad8d80ccb3aaebb8a0commit-bot@chromium.org    friend class GrDistanceFieldTextContext;
11428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com    friend class SkTextToPathIter;
1143ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com    friend class SkCanonicalizePaint;
1144b44cd65a53fa016a238e2bd3d01b5434dbc05da3djsollen@google.com
1145b44cd65a53fa016a238e2bd3d01b5434dbc05da3djsollen@google.com#ifdef SK_BUILD_FOR_ANDROID
1146c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org    SkPaintOptionsAndroid fPaintOptionsAndroid;
1147c7a20e40938ae031368e3a9e4df33ce90a765abacommit-bot@chromium.org
1148b44cd65a53fa016a238e2bd3d01b5434dbc05da3djsollen@google.com    // In order for the == operator to work properly this must be the last field
1149b44cd65a53fa016a238e2bd3d01b5434dbc05da3djsollen@google.com    // in the struct so that we can do a memcmp to this field's offset.
1150b44cd65a53fa016a238e2bd3d01b5434dbc05da3djsollen@google.com    uint32_t        fGenerationID;
1151b44cd65a53fa016a238e2bd3d01b5434dbc05da3djsollen@google.com#endif
11528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com};
11538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com
11548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif
1155