180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/*
480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Copyright 2006 The Android Open Source Project
580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru *
680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * Use of this source code is governed by a BSD-style license that can be
780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru * found in the LICENSE file.
880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru */
980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifndef SkPaint_DEFINED
1280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#define SkPaint_DEFINED
1380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkColor.h"
1580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkDrawLooper.h"
1658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger#include "SkMatrix.h"
1780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#include "SkXfermode.h"
187839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger#ifdef SK_BUILD_FOR_ANDROID
197839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger#include "SkPaintOptionsAndroid.h"
207839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger#endif
2180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
2280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkAnnotation;
2380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkAutoGlyphCache;
2480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkColorFilter;
2580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkDescriptor;
26d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenbergerstruct SkDeviceProperties;
2780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkFlattenableReadBuffer;
2880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkFlattenableWriteBuffer;
2980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct SkGlyph;
3080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct SkRect;
3180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkGlyphCache;
3280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkImageFilter;
3380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkMaskFilter;
3480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPath;
3580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkPathEffect;
3680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querustruct SkPoint;
3780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkRasterizer;
3880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkShader;
3980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SkTypeface;
4080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querutypedef const SkGlyph& (*SkDrawCacheProc)(SkGlyphCache*, const char**,
4280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                           SkFixed x, SkFixed y);
4380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querutypedef const SkGlyph& (*SkMeasureCacheProc)(SkGlyphCache*, const char**);
4580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
4658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger#define kBicubicFilterBitmap_Flag kHighQualityFilterBitmap_Flag
4758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
4880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru/** \class SkPaint
4980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
5080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    The SkPaint class holds the style and color information about how to draw
5180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    geometries, text and bitmaps.
5280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru*/
5358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
5480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruclass SK_API SkPaint {
5558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    enum {
5658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        // DEPRECATED -- use setFilterLevel instead
5758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kFilterBitmap_Flag    = 0x02, // temporary flag
5858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        // DEPRECATED -- use setFilterLevel instead
5958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kHighQualityFilterBitmap_Flag = 0x4000, // temporary flag
6058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        // DEPRECATED -- use setFilterLevel instead
6158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kHighQualityDownsampleBitmap_Flag = 0x8000, // temporary flag
6258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    };
6380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Querupublic:
6480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkPaint();
6580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkPaint(const SkPaint& paint);
6680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ~SkPaint();
6780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
6880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkPaint& operator=(const SkPaint&);
6980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SK_API friend bool operator==(const SkPaint& a, const SkPaint& b);
7180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend bool operator!=(const SkPaint& a, const SkPaint& b) {
7280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return !(a == b);
7380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
7480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void flatten(SkFlattenableWriteBuffer&) const;
7680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void unflatten(SkFlattenableReadBuffer&);
7780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
7880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Restores the paint to its initial settings.
7980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
8080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void reset();
8180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
8280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Specifies the level of hinting to be performed. These names are taken
8380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        from the Gnome/Cairo names for the same. They are translated into
8480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Freetype concepts the same as in cairo-ft-font.c:
8580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru           kNo_Hinting     -> FT_LOAD_NO_HINTING
8680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru           kSlight_Hinting -> FT_LOAD_TARGET_LIGHT
8780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru           kNormal_Hinting -> <default, no option>
8880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru           kFull_Hinting   -> <same as kNormalHinting, unless we are rendering
8980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              subpixel glyphs, in which case TARGET_LCD or
9080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                              TARGET_LCD_V is used>
9180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
9280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Hinting {
9380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNo_Hinting            = 0,
9480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kSlight_Hinting        = 1,
9580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kNormal_Hinting        = 2,     //!< this is the default
9680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFull_Hinting          = 3
9780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
9880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
9980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Hinting getHinting() const {
10080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return static_cast<Hinting>(fHinting);
10180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
10280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setHinting(Hinting hintingLevel);
10480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
10580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Specifies the bit values that are stored in the paint's flags.
10680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
10780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Flags {
10880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kAntiAlias_Flag       = 0x01,   //!< mask to enable antialiasing
10980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDither_Flag          = 0x04,   //!< mask to enable dithering
11080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUnderlineText_Flag   = 0x08,   //!< mask to enable underline text
11180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kStrikeThruText_Flag  = 0x10,   //!< mask to enable strike-thru text
11280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFakeBoldText_Flag    = 0x20,   //!< mask to enable fake-bold text
11380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kLinearText_Flag      = 0x40,   //!< mask to enable linear-text
11480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kSubpixelText_Flag    = 0x80,   //!< mask to enable subpixel text positioning
11580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDevKernText_Flag     = 0x100,  //!< mask to enable device kerning text
11680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kLCDRenderText_Flag   = 0x200,  //!< mask to enable subpixel glyph renderering
11780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap strikes
11880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kAutoHinting_Flag     = 0x800,  //!< mask to force Freetype's autohinter
11980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kVerticalText_Flag    = 0x1000,
12080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGenA8FromLCD_Flag    = 0x2000, // hack for GDI -- do not use if you can help it
12180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // when adding extra flags, note that the fFlags member is specified
12280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // with a bit-width and you'll have to expand it.
12380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
12458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kAllFlags = 0xFFFF
12580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
12680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
12780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's flags. Use the Flag enum to test flag values.
12880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's flags (see enums ending in _Flag for bit masks)
12980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
13080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint32_t getFlags() const { return fFlags; }
13180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
13280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's flags. Use the Flag enum to specific flag values.
13380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param flags    The new flag bits for the paint (see Flags enum)
13480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
13580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setFlags(uint32_t flags);
13680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
13780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for getFlags(), returning true if kAntiAlias_Flag bit is set
13880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the antialias bit is set in the paint's flags.
13980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
14080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isAntiAlias() const {
14180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kAntiAlias_Flag);
14280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
14380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
14480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kAntiAlias_Flag bit
14580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param aa   true to enable antialiasing, false to disable it
14680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
14780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setAntiAlias(bool aa);
14880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
14980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for getFlags(), returning true if kDither_Flag bit is set
15080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the dithering bit is set in the paint's flags.
15180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
15280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isDither() const {
15380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kDither_Flag);
15480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
15580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
15680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kDither_Flag bit
15780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param dither   true to enable dithering, false to disable it
15880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
15980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setDither(bool dither);
16080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
16180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for getFlags(), returning true if kLinearText_Flag bit is set
16280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the lineartext bit is set in the paint's flags
16380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
16480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isLinearText() const {
16580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kLinearText_Flag);
16680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
16780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
16880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kLinearText_Flag bit
16980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param linearText true to set the linearText bit in the paint's flags,
17080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          false to clear it.
17180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
17280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setLinearText(bool linearText);
17380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
17480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for getFlags(), returning true if kSubpixelText_Flag bit is set
17580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the lineartext bit is set in the paint's flags
17680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
17780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isSubpixelText() const {
17880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kSubpixelText_Flag);
17980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
18080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
18180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
18280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Helper for setFlags(), setting or clearing the kSubpixelText_Flag.
18380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param subpixelText true to set the subpixelText bit in the paint's
18480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                      flags, false to clear it.
18580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
18680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setSubpixelText(bool subpixelText);
18780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
18880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isLCDRenderText() const {
18980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kLCDRenderText_Flag);
19080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
19180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
19280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
19380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Helper for setFlags(), setting or clearing the kLCDRenderText_Flag.
19480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Note: antialiasing must also be on for lcd rendering
19580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param lcdText true to set the LCDRenderText bit in the paint's flags,
19680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                 false to clear it.
19780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
19880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setLCDRenderText(bool lcdText);
19980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
20080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isEmbeddedBitmapText() const {
20180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kEmbeddedBitmapText_Flag);
20280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
20380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
20480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kEmbeddedBitmapText_Flag bit
20580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param useEmbeddedBitmapText true to set the kEmbeddedBitmapText bit in the paint's flags,
20680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                     false to clear it.
20780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
20880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setEmbeddedBitmapText(bool useEmbeddedBitmapText);
20980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
21080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isAutohinted() const {
21180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kAutoHinting_Flag);
21280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
21380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
21480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kAutoHinting_Flag bit
21580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param useAutohinter true to set the kEmbeddedBitmapText bit in the
21680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                  paint's flags,
21780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                             false to clear it.
21880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
21980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setAutohinted(bool useAutohinter);
22080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
22180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isVerticalText() const {
22280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kVerticalText_Flag);
22380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
22480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
22580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
22680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Helper for setting or clearing the kVerticalText_Flag bit in
22780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  setFlags(...).
22880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
22980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If this bit is set, then advances are treated as Y values rather than
23080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  X values, and drawText will places its glyphs vertically rather than
23180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  horizontally.
23280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
23380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setVerticalText(bool);
23480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
23580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for getFlags(), returning true if kUnderlineText_Flag bit is set
23680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the underlineText bit is set in the paint's flags.
23780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
23880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isUnderlineText() const {
23980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kUnderlineText_Flag);
24080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
24180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
24280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kUnderlineText_Flag bit
24380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param underlineText true to set the underlineText bit in the paint's
24480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                             flags, false to clear it.
24580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
24680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setUnderlineText(bool underlineText);
24780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
24880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for getFlags(), returns true if kStrikeThruText_Flag bit is set
24980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the strikeThruText bit is set in the paint's flags.
25080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
25180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isStrikeThruText() const {
25280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kStrikeThruText_Flag);
25380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
25480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
25580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kStrikeThruText_Flag bit
25680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param strikeThruText   true to set the strikeThruText bit in the
25780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                paint's flags, false to clear it.
25880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
25980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setStrikeThruText(bool strikeThruText);
26080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
26180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set
26280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the kFakeBoldText_Flag bit is set in the paint's flags.
26380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
26480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isFakeBoldText() const {
26580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kFakeBoldText_Flag);
26680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
26780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
26880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kFakeBoldText_Flag bit
26980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param fakeBoldText true to set the kFakeBoldText_Flag bit in the paint's
27080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            flags, false to clear it.
27180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
27280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setFakeBoldText(bool fakeBoldText);
27380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
27480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for getFlags(), returns true if kDevKernText_Flag bit is set
27580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return true if the kernText bit is set in the paint's flags.
27680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
27780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool isDevKernText() const {
27880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return SkToBool(this->getFlags() & kDevKernText_Flag);
27980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
28080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
28180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper for setFlags(), setting or clearing the kKernText_Flag bit
28280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param kernText true to set the kKernText_Flag bit in the paint's
28380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            flags, false to clear it.
28480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
28580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setDevKernText(bool devKernText);
28680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
28758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    enum FilterLevel {
28858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kNone_FilterLevel,
28958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kLow_FilterLevel,
29058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kMedium_FilterLevel,
29158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kHigh_FilterLevel
29258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    };
29358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
29458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    /**
29558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  Return the filter level. This affects the quality (and performance) of
29658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  drawing scaled images.
29758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     */
29858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    FilterLevel getFilterLevel() const;
29958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
30058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    /**
30158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  Set the filter level. This affects the quality (and performance) of
30258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  drawing scaled images.
30358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     */
30458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    void setFilterLevel(FilterLevel);
30558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
30658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    /**
30758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  If the predicate is true, set the filterLevel to Low, else set it to
30858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  None.
30958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     */
3100a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SK_ATTR_DEPRECATED("use setFilterLevel")
31158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    void setFilterBitmap(bool doFilter) {
31258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        this->setFilterLevel(doFilter ? kLow_FilterLevel : kNone_FilterLevel);
31380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
31480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
31558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    /**
31658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  Returns true if getFilterLevel() returns anything other than None.
31758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     */
3180a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SK_ATTR_DEPRECATED("use getFilterLevel")
31958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    bool isFilterBitmap() const {
32058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        return kNone_FilterLevel != this->getFilterLevel();
32158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
32280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
32380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Styles apply to rect, oval, path, and text.
32480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Bitmaps are always drawn in "fill", and lines are always drawn in
32580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        "stroke".
32680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
32780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Note: strokeandfill implicitly draws the result with
32880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkPath::kWinding_FillType, so if the original path is even-odd, the
32980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        results may not appear the same as if it was drawn twice, filled and
33080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        then stroked.
33180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
33280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Style {
33380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFill_Style,            //!< fill the geometry
33480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kStroke_Style,          //!< stroke the geometry
33580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kStrokeAndFill_Style,   //!< fill and stroke the geometry
336096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger    };
337096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger    enum {
338096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger        kStyleCount = kStrokeAndFill_Style + 1
33980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
34080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
34180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's style, used for controlling how primitives'
34280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        geometries are interpreted (except for drawBitmap, which always assumes
34380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kFill_Style).
34480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's Style
34580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
34680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Style getStyle() const { return (Style)fStyle; }
34780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
34880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's style, used for controlling how primitives'
34980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        geometries are interpreted (except for drawBitmap, which always assumes
35080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Fill).
35180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param style    The new style to set in the paint
35280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
35380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setStyle(Style style);
35480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
35580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's color. Note that the color is a 32bit value
35680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        containing alpha as well as r,g,b. This 32bit value is not
35780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        premultiplied, meaning that its alpha can be any value, regardless of
35880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the values of r,g,b.
35980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's color (and alpha).
36080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
36180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkColor getColor() const { return fColor; }
36280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
36380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's color. Note that the color is a 32bit value containing
36480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        alpha as well as r,g,b. This 32bit value is not premultiplied, meaning
36580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        that its alpha can be any value, regardless of the values of r,g,b.
36680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param color    The new color (including alpha) to set in the paint.
36780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
36880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setColor(SkColor color);
36980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
37080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper to getColor() that just returns the color's alpha value.
37180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the alpha component of the paint's color.
37280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
37380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); }
37480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
37580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper to setColor(), that only assigns the color's alpha value,
37680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        leaving its r,g,b values unchanged.
37780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param a    set the alpha component (0..255) of the paint's color.
37880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
37980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setAlpha(U8CPU a);
38080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
38180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Helper to setColor(), that takes a,r,g,b and constructs the color value
38280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        using SkColorSetARGB()
38380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param a    The new alpha component (0..255) of the paint's color.
38480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param r    The new red component (0..255) of the paint's color.
38580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param g    The new green component (0..255) of the paint's color.
38680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param b    The new blue component (0..255) of the paint's color.
38780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
38880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
38980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
39080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the width for stroking.
39180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
39280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        A value of 0 strokes in hairline mode.
39380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Hairlines always draw 1-pixel wide, regardless of the matrix.
39480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's stroke width, used whenever the paint's style is
39580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                Stroke or StrokeAndFill.
39680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
39780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar getStrokeWidth() const { return fWidth; }
39880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
39980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the width for stroking.
40080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Pass 0 to stroke in hairline mode.
40180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Hairlines always draw 1-pixel wide, regardless of the matrix.
40280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param width set the paint's stroke width, used whenever the paint's
40380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     style is Stroke or StrokeAndFill.
40480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
40580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setStrokeWidth(SkScalar width);
40680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
40780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's stroke miter value. This is used to control the
40880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        behavior of miter joins when the joins angle is sharp.
40980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's miter limit, used whenever the paint's style is
41080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                Stroke or StrokeAndFill.
41180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
41280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar getStrokeMiter() const { return fMiterLimit; }
41380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
41480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's stroke miter value. This is used to control the
41580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        behavior of miter joins when the joins angle is sharp. This value must
41680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        be >= 0.
41780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param miter    set the miter limit on the paint, used whenever the
41880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        paint's style is Stroke or StrokeAndFill.
41980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
42080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setStrokeMiter(SkScalar miter);
42180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
42280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Cap enum specifies the settings for the paint's strokecap. This is the
42380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        treatment that is applied to the beginning and end of each non-closed
42480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        contour (e.g. lines).
42580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
42680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Cap {
42780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kButt_Cap,      //!< begin/end contours with no extension
42880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kRound_Cap,     //!< begin/end contours with a semi-circle extension
42980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kSquare_Cap,    //!< begin/end contours with a half square extension
43080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
43180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kCapCount,
43280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDefault_Cap = kButt_Cap
43380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
43480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
43580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Join enum specifies the settings for the paint's strokejoin. This is
43680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the treatment that is applied to corners in paths and rectangles.
43780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
43880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Join {
43980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kMiter_Join,    //!< connect path segments with a sharp join
44080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kRound_Join,    //!< connect path segments with a round join
44180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBevel_Join,    //!< connect path segments with a flat bevel join
44280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
44380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kJoinCount,
44480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kDefault_Join = kMiter_Join
44580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
44680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
44780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's stroke cap type, controlling how the start and end
44880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        of stroked lines and paths are treated.
44980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the line cap style for the paint, used whenever the paint's
45080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                style is Stroke or StrokeAndFill.
45180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
45280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Cap getStrokeCap() const { return (Cap)fCapType; }
45380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
45480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's stroke cap type.
45580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param cap  set the paint's line cap style, used whenever the paint's
45680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    style is Stroke or StrokeAndFill.
45780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
45880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setStrokeCap(Cap cap);
45980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
46080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's stroke join type.
46180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's line join style, used whenever the paint's style is
46280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                Stroke or StrokeAndFill.
46380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
46480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Join getStrokeJoin() const { return (Join)fJoinType; }
46580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
46680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's stroke join type.
46780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param join set the paint's line join style, used whenever the paint's
46880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                    style is Stroke or StrokeAndFill.
46980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
47080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setStrokeJoin(Join join);
47180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
472d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger    /**
473d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *  Applies any/all effects (patheffect, stroking) to src, returning the
474d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *  result in dst. The result is that drawing src with this paint will be
475d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *  the same as drawing dst with a default paint (at least from the
476d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *  geometric perspective).
477d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *
478d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *  @param src  input path
479d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *  @param dst  output path (may be the same as src)
480d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *  @param cullRect If not null, the dst path may be culled to this rect.
481d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *  @return     true if the path should be filled, or false if it should be
482d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     *              drawn with a hairline (width == 0)
483d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger     */
484d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger    bool getFillPath(const SkPath& src, SkPath* dst,
485d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger                     const SkRect* cullRect = NULL) const;
48680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
48780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the paint's shader object.
48880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
48980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru      The shader's reference count is not affected.
49080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's shader (or NULL)
49180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
49280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkShader* getShader() const { return fShader; }
49380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
49480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set or clear the shader object.
49580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Shaders specify the source color(s) for what is being drawn. If a paint
49680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  has no shader, then the paint's color is used. If the paint has a
49780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  shader, then the shader's color(s) are use instead, but they are
49880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  modulated by the paint's alpha. This makes it easy to create a shader
49980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  once (e.g. bitmap tiling or gradient) and then change its transparency
50080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  w/o having to modify the original shader... only the paint's alpha needs
50180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  to be modified.
50280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  <p />
50380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Pass NULL to clear any previous shader.
50480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  As a convenience, the parameter passed is also returned.
50580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If a previous shader exists, its reference count is decremented.
50680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If shader is not NULL, its reference count is incremented.
50780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param shader   May be NULL. The shader to be installed in the paint
50880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @return         shader
50980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
51080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkShader* setShader(SkShader* shader);
51180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
51280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the paint's colorfilter. If there is a colorfilter, its reference
51380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        count is not changed.
51480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's colorfilter (or NULL)
51580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
51680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkColorFilter* getColorFilter() const { return fColorFilter; }
51780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
51880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set or clear the paint's colorfilter, returning the parameter.
51980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
52080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If the paint already has a filter, its reference count is decremented.
52180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If filter is not NULL, its reference count is incremented.
52280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param filter   May be NULL. The filter to be installed in the paint
52380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return         filter
52480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
52580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkColorFilter* setColorFilter(SkColorFilter* filter);
52680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
52780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the paint's xfermode object.
52880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
52980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru      The xfermode's reference count is not affected.
53080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's xfermode (or NULL)
53180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
53280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkXfermode* getXfermode() const { return fXfermode; }
53380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
53480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set or clear the xfermode object.
53580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
53680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Pass NULL to clear any previous xfermode.
53780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        As a convenience, the parameter passed is also returned.
53880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If a previous xfermode exists, its reference count is decremented.
53980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If xfermode is not NULL, its reference count is incremented.
54080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param xfermode May be NULL. The new xfermode to be installed in the
54180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        paint
54280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return         xfermode
54380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
54480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkXfermode* setXfermode(SkXfermode* xfermode);
54580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
54680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Create an xfermode based on the specified Mode, and assign it into the
54780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        paint, returning the mode that was set. If the Mode is SrcOver, then
54880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the paint's xfermode is set to null.
54980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
55080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkXfermode* setXfermodeMode(SkXfermode::Mode);
55180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
55280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the paint's patheffect object.
55380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
55480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru      The patheffect reference count is not affected.
55580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's patheffect (or NULL)
55680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
55780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkPathEffect* getPathEffect() const { return fPathEffect; }
55880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
55980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set or clear the patheffect object.
56080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
56180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Pass NULL to clear any previous patheffect.
56280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        As a convenience, the parameter passed is also returned.
56380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If a previous patheffect exists, its reference count is decremented.
56480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If patheffect is not NULL, its reference count is incremented.
56580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param effect   May be NULL. The new patheffect to be installed in the
56680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        paint
56780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return         effect
56880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
56980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkPathEffect* setPathEffect(SkPathEffect* effect);
57080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
57180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the paint's maskfilter object.
57280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
57380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru      The maskfilter reference count is not affected.
57480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's maskfilter (or NULL)
57580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
57680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkMaskFilter* getMaskFilter() const { return fMaskFilter; }
57780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
57880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set or clear the maskfilter object.
57980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
58080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Pass NULL to clear any previous maskfilter.
58180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        As a convenience, the parameter passed is also returned.
58280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If a previous maskfilter exists, its reference count is decremented.
58380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If maskfilter is not NULL, its reference count is incremented.
58480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param maskfilter   May be NULL. The new maskfilter to be installed in
58580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            the paint
58680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return             maskfilter
58780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
58880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkMaskFilter* setMaskFilter(SkMaskFilter* maskfilter);
58980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
59080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // These attributes are for text/fonts
59180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
59280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the paint's typeface object.
59380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
59480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        The typeface object identifies which font to use when drawing or
59580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        measuring text. The typeface reference count is not affected.
59680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's typeface (or NULL)
59780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
59880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTypeface* getTypeface() const { return fTypeface; }
59980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
60080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set or clear the typeface object.
60180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
60280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Pass NULL to clear any previous typeface.
60380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        As a convenience, the parameter passed is also returned.
60480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If a previous typeface exists, its reference count is decremented.
60580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If typeface is not NULL, its reference count is incremented.
60680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param typeface May be NULL. The new typeface to be installed in the
60780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        paint
60880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return         typeface
60980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
61080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTypeface* setTypeface(SkTypeface* typeface);
61180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
61280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Get the paint's rasterizer (or NULL).
61380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
61480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        The raster controls how paths/text are turned into alpha masks.
61580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's rasterizer (or NULL)
61680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
61780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkRasterizer* getRasterizer() const { return fRasterizer; }
61880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
61980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set or clear the rasterizer object.
62080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        <p />
62180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Pass NULL to clear any previous rasterizer.
62280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        As a convenience, the parameter passed is also returned.
62380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If a previous rasterizer exists in the paint, its reference count is
62480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        decremented. If rasterizer is not NULL, its reference count is
62580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        incremented.
62680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param rasterizer May be NULL. The new rasterizer to be installed in
62780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          the paint.
62880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return           rasterizer
62980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
63080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkRasterizer* setRasterizer(SkRasterizer* rasterizer);
63180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
63280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkImageFilter* getImageFilter() const { return fImageFilter; }
63380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkImageFilter* setImageFilter(SkImageFilter*);
63480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
63580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkAnnotation* getAnnotation() const { return fAnnotation; }
63680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkAnnotation* setAnnotation(SkAnnotation*);
63780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
63880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
63980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Returns true if there is an annotation installed on this paint, and
64080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  the annotation specifics no-drawing.
64180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
6420a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    SK_ATTR_DEPRECATED("use getAnnotation and check for non-null")
6430a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    bool isNoDrawAnnotation() const { return this->getAnnotation() != NULL; }
64480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
64580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
64680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Return the paint's SkDrawLooper (if any). Does not affect the looper's
64780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  reference count.
64880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
64980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDrawLooper* getLooper() const { return fLooper; }
65080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
65180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /**
65280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Set or clear the looper object.
65380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  <p />
65480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  Pass NULL to clear any previous looper.
65580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  As a convenience, the parameter passed is also returned.
65680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  If a previous looper exists in the paint, its reference count is
65780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  decremented. If looper is not NULL, its reference count is
65880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  incremented.
65980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param looper May be NULL. The new looper to be installed in the paint.
66080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @return looper
66180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
66280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDrawLooper* setLooper(SkDrawLooper* looper);
66380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
66480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum Align {
66580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kLeft_Align,
66680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kCenter_Align,
66780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kRight_Align,
66858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    };
66958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    enum {
67058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kAlignCount = 3
67180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
67280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
67380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's Align value for drawing text.
67480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's Align value for drawing text.
67580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
67680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    Align   getTextAlign() const { return (Align)fTextAlign; }
67780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
67880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's text alignment.
67980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param align set the paint's Align value for drawing text.
68080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
68180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void    setTextAlign(Align align);
68280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
68380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's text size.
68480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's text size.
68580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
68680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar getTextSize() const { return fTextSize; }
68780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
68880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's text size. This value must be > 0
68980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param textSize set the paint's text size.
69080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
69180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setTextSize(SkScalar textSize);
69280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
69380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's horizontal scale factor for text. The default value
69480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        is 1.0.
69580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's scale factor in X for drawing/measuring text
69680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
69780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar getTextScaleX() const { return fTextScaleX; }
69880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
69980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's horizontal scale factor for text. The default value
70080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will
70180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        stretch the text narrower.
70280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param scaleX   set the paint's scale factor in X for drawing/measuring
70380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        text.
70480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
70580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setTextScaleX(SkScalar scaleX);
70680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
70780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the paint's horizontal skew factor for text. The default value
70880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        is 0.
70980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @return the paint's skew factor in X for drawing text.
71080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
71180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar getTextSkewX() const { return fTextSkewX; }
71280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
71380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Set the paint's horizontal skew factor for text. The default value
71480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        is 0. For approximating oblique text, use values around -0.25.
71580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param skewX set the paint's skew factor in X for drawing text.
71680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
71780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setTextSkewX(SkScalar skewX);
71880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
71980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Describes how to interpret the text parameters that are passed to paint
72080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        methods like measureText() and getTextWidths().
72180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
72280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum TextEncoding {
72380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUTF8_TextEncoding,     //!< the text parameters are UTF8
72480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUTF16_TextEncoding,    //!< the text parameters are UTF16
72580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kUTF32_TextEncoding,    //!< the text parameters are UTF32
72680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kGlyphID_TextEncoding   //!< the text parameters are glyph indices
72780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
72880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
72980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    TextEncoding getTextEncoding() const { return (TextEncoding)fTextEncoding; }
73080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
73180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void setTextEncoding(TextEncoding encoding);
73280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
73380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    struct FontMetrics {
73480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fTop;       //!< The greatest distance above the baseline for any glyph (will be <= 0)
73580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fAscent;    //!< The recommended distance above the baseline (will be <= 0)
73680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fDescent;   //!< The recommended distance below the baseline (will be >= 0)
73780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fBottom;    //!< The greatest distance below the baseline for any glyph (will be >= 0)
73880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fLeading;   //!< The recommended distance to add between lines of text (will be >= 0)
73980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fAvgCharWidth;  //!< the average charactor width (>= 0)
74058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        SkScalar    fMaxCharWidth;  //!< the max charactor width (>= 0)
74180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fXMin;      //!< The minimum bounding box x value for all glyphs
74280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fXMax;      //!< The maximum bounding box x value for all glyphs
74380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkScalar    fXHeight;   //!< the height of an 'x' in px, or 0 if no 'x' in face
74480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
74580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
74680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the recommend spacing between lines (which will be
74780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fDescent - fAscent + fLeading).
74880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If metrics is not null, return in it the font metrics for the
74980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        typeface/pointsize/etc. currently set in the paint.
75080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param metrics      If not null, returns the font metrics for the
75180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            current typeface/pointsize/etc setting in this
75280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            paint.
75380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param scale        If not 0, return width as if the canvas were scaled
75480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                            by this value
75580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        @param return the recommended spacing between lines
75680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
75780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0) const;
75880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
75980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the recommend line spacing. This will be
76080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        fDescent - fAscent + fLeading
76180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
76280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar getFontSpacing() const { return this->getFontMetrics(NULL, 0); }
76380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
76480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Convert the specified text into glyph IDs, returning the number of
76580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        glyphs ID written. If glyphs is NULL, it is ignore and only the count
76680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        is returned.
76780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
76880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int textToGlyphs(const void* text, size_t byteLength,
76980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     uint16_t glyphs[]) const;
77080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
77180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return true if all of the specified text has a corresponding non-zero
77280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        glyph ID. If any of the code-points in the text are not supported in
77380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        the typeface (i.e. the glyph ID would be zero), then return false.
77480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
77580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        If the text encoding for the paint is kGlyph_TextEncoding, then this
77680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        returns true if all of the specified glyph IDs are non-zero.
77780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
77880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool containsText(const void* text, size_t byteLength) const;
77980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
78080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Convert the glyph array into Unichars. Unconvertable glyphs are mapped
78180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        to zero. Note: this does not look at the text-encoding setting in the
78280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        paint, only at the typeface.
78380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
78480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void glyphsToUnichars(const uint16_t glyphs[], int count,
78580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          SkUnichar text[]) const;
78680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
78780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the number of drawable units in the specified text buffer.
78880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        This looks at the current TextEncoding field of the paint. If you also
78980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        want to have the text converted into glyph IDs, call textToGlyphs
79080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        instead.
79180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
79280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int countText(const void* text, size_t byteLength) const {
79380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return this->textToGlyphs(text, byteLength, NULL);
79480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
79580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
79680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the width of the text. This will return the vertical measure
79780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  if isVerticalText() is true, in which case the returned value should
79880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  be treated has a height instead of a width.
79980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
80080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param text         The text to be measured
80180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param length       Number of bytes of text to measure
80280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param bounds       If not NULL, returns the bounds of the text,
80380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                      relative to (0, 0).
80480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param scale        If not 0, return width as if the canvas were scaled
80580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                      by this value
80680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @return             The advance width of the text
80780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
80880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar measureText(const void* text, size_t length,
80980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                         SkRect* bounds, SkScalar scale = 0) const;
81080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
81180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the width of the text. This will return the vertical measure
81280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  if isVerticalText() is true, in which case the returned value should
81380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  be treated has a height instead of a width.
81480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
81580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param text     Address of the text
81680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param length   Number of bytes of text to measure
81780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @return         The advance width of the text
81880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
81980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar measureText(const void* text, size_t length) const {
82080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return this->measureText(text, length, NULL, 0);
82180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
82280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
82380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Specify the direction the text buffer should be processed in breakText()
82480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
82580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum TextBufferDirection {
82680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** When measuring text for breakText(), begin at the start of the text
82780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            buffer and proceed forward through the data. This is the default.
82880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
82980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kForward_TextBufferDirection,
83080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        /** When measuring text for breakText(), begin at the end of the text
83180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            buffer and proceed backwards through the data.
83280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        */
83380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        kBackward_TextBufferDirection
83480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
83580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
83680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the number of bytes of text that were measured. If
83780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  isVerticalText() is true, then the vertical advances are used for
83880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  the measurement.
83980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
84080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param text     The text to be measured
84180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param length   Number of bytes of text to measure
84280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param maxWidth Maximum width. Only the subset of text whose accumulated
84380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                  widths are <= maxWidth are measured.
84480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param measuredWidth Optional. If non-null, this returns the actual
84580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                  width of the measured text.
84680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param tbd      Optional. The direction the text buffer should be
84780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                  traversed during measuring.
84880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @return         The number of bytes of text that were measured. Will be
84980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                  <= length.
85080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
85180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    size_t  breakText(const void* text, size_t length, SkScalar maxWidth,
85280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      SkScalar* measuredWidth = NULL,
85380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      TextBufferDirection tbd = kForward_TextBufferDirection)
85480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      const;
85580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
85680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the advances for the text. These will be vertical advances if
85780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  isVerticalText() returns true.
85880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *
85980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param text         the text
86080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param byteLength   number of bytes to of text
86180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param widths       If not null, returns the array of advances for
86280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                      the glyphs. If not NULL, must be at least a large
86380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                      as the number of unichars in the specified text.
86480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @param bounds       If not null, returns the bounds for each of
86580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *                      character, relative to (0, 0)
86680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     *  @return the number of unichars in the specified text.
86780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
86880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    int getTextWidths(const void* text, size_t byteLength, SkScalar widths[],
86980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                      SkRect bounds[] = NULL) const;
87080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
87180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Return the path (outline) for the specified text.
87280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        Note: just like SkCanvas::drawText, this will respect the Align setting
87380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru              in the paint.
87480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
87580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y,
87680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                     SkPath* path) const;
87780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
87880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    void getPosTextPath(const void* text, size_t length,
87980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        const SkPoint pos[], SkPath* path) const;
88080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
88180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_BUILD_FOR_ANDROID
882096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger    const SkGlyph& getUnicharMetrics(SkUnichar, const SkMatrix*);
883096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger    const SkGlyph& getGlyphMetrics(uint16_t, const SkMatrix*);
884096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger    const void* findImage(const SkGlyph&, const SkMatrix*);
88580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
88680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint32_t getGenerationID() const;
887096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger    void setGenerationID(uint32_t generationID);
88880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
88980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Returns the base glyph count for the strike associated with this paint
89080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    */
89180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unsigned getBaseGlyphCount(SkUnichar text) const;
8927839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger
8937839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    const SkPaintOptionsAndroid& getPaintOptionsAndroid() const {
8947839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger        return fPaintOptionsAndroid;
8957839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    }
8967839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    void setPaintOptionsAndroid(const SkPaintOptionsAndroid& options);
89780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
89880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
89980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // returns true if the paint's settings (e.g. xfermode + alpha) resolve to
90080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // mean that we need not draw at all (e.g. SrcOver + 0-alpha)
90180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool nothingToDraw() const;
90280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
90380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    ///////////////////////////////////////////////////////////////////////////
90480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // would prefer to make these private...
90580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
90680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Returns true if the current paint settings allow for fast computation of
90780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     bounds (i.e. there is nothing complex like a patheffect that would make
90880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     the bounds computation expensive.
90980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
91080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    bool canComputeFastBounds() const {
91180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (this->getLooper()) {
91280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            return this->getLooper()->canComputeFastBounds(*this);
91380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
91480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return !this->getRasterizer();
91580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
91680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
91780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    /** Only call this if canComputeFastBounds() returned true. This takes a
91880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     raw rectangle (the raw bounds of a shape), and adjusts it for stylistic
91980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     effects in the paint (e.g. stroking). If needed, it uses the storage
92080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     rect parameter. It returns the adjusted bounds that can then be used
92180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     for quickReject tests.
92280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
92380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     The returned rect will either be orig or storage, thus the caller
92480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     should not rely on storage being set to the result, but should always
92580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     use the retured value. It is legal for orig and storage to be the same
92680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     rect.
92780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
92880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     e.g.
92980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     if (paint.canComputeFastBounds()) {
93080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     SkRect r, storage;
93180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     path.computeBounds(&r, SkPath::kFast_BoundsType);
93280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     const SkRect& fastR = paint.computeFastBounds(r, &storage);
93380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     if (canvas->quickReject(fastR, ...)) {
93480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     // don't draw the path
93580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     }
93680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     }
93780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru     */
93880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const {
93980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        SkPaint::Style style = this->getStyle();
94080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        // ultra fast-case: filling with no effects that affect geometry
94180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        if (kFill_Style == style) {
94280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            uintptr_t effects = reinterpret_cast<uintptr_t>(this->getLooper());
94380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
94480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
94580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            if (!effects) {
94680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                return orig;
94780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru            }
94880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        }
94980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
95080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return this->doComputeFastBounds(orig, storage, style);
95180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
95280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
95380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkRect& computeFastStrokeBounds(const SkRect& orig,
95480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                          SkRect* storage) const {
95580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru        return this->doComputeFastBounds(orig, storage, kStroke_Style);
95680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    }
95780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
95880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // Take the style explicitly, so the caller can force us to be stroked
95980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // without having to make a copy of the paint just to change that field.
96080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
96180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                      Style) const;
96280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
96358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    /**
96458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     *  Return a matrix that applies the paint's text values: size, scale, skew
96558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger     */
96658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    static SkMatrix* SetTextMatrix(SkMatrix* matrix, SkScalar size,
96758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger                                   SkScalar scaleX, SkScalar skewX) {
96858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        matrix->setScale(size * scaleX, size);
96958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        if (skewX) {
97058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger            matrix->postSkew(skewX, 0);
97158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        }
97258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        return matrix;
97358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
97458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
97558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkMatrix* setTextMatrix(SkMatrix* matrix) const {
97658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        return SetTextMatrix(matrix, fTextSize, fTextScaleX, fTextSkewX);
97758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
97858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
979096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger    SkDEVCODE(void toString(SkString*) const;)
980096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger
98180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queruprivate:
98280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkTypeface*     fTypeface;
98380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar        fTextSize;
98480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar        fTextScaleX;
98580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar        fTextSkewX;
98680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
98780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkPathEffect*   fPathEffect;
98880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkShader*       fShader;
98980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkXfermode*     fXfermode;
99080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkMaskFilter*   fMaskFilter;
99180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkColorFilter*  fColorFilter;
99280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkRasterizer*   fRasterizer;
99380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDrawLooper*   fLooper;
99480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkImageFilter*  fImageFilter;
99580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkAnnotation*   fAnnotation;
99680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
99780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkColor         fColor;
99880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar        fWidth;
99980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar        fMiterLimit;
100080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // all of these bitfields should add up to 32
100180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unsigned        fFlags : 16;
100280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unsigned        fTextAlign : 2;
100380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unsigned        fCapType : 2;
100480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unsigned        fJoinType : 2;
100580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unsigned        fStyle : 2;
100680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unsigned        fTextEncoding : 2;  // 3 values
100780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    unsigned        fHinting : 2;
10080a657bbc2c6fc9daf699942e023050536d5ec95fDerek Sollenberger    //unsigned      fFreeBits : 4;
100980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
101080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
101180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkDrawCacheProc    getDrawCacheProc() const;
101280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkMeasureCacheProc getMeasureCacheProc(TextBufferDirection dir,
101380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                                           bool needFullMetrics) const;
101480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
101580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    SkScalar measure_text(SkGlyphCache*, const char* text, size_t length,
101680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                          int* count, SkRect* bounds) const;
101780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1018d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger    SkGlyphCache* detachCache(const SkDeviceProperties* deviceProperties, const SkMatrix*) const;
101980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
1020d686ac77c2c485c4a3302eda9c1de597a6f8c568Derek Sollenberger    void descriptorProc(const SkDeviceProperties* deviceProperties, const SkMatrix* deviceMatrix,
1021096defe64d408e54474fe19f418c95bf1a554fc7Derek Sollenberger                        void (*proc)(SkTypeface*, const SkDescriptor*, void*),
102280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru                        void* context, bool ignoreGamma = false) const;
102380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
102480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    static void Term();
102580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
102680bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    enum {
102758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        /*  This is the size we use when we ask for a glyph's path. We then
102858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  post-transform it as we draw to match the request.
102958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  This is done to try to re-use cache entries for the path.
103058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *
103158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  This value is somewhat arbitrary. In theory, it could be 1, since
103258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  we store paths as floats. However, we get the path from the font
103358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  scaler, and it may represent its paths as fixed-point (or 26.6),
103458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  so we shouldn't ask for something too big (might overflow 16.16)
103558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  or too small (underflow 26.6).
103658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *
103758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  This value could track kMaxSizeForGlyphCache, assuming the above
103858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  constraints, but since we ask for unhinted paths, the two values
103958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  need not match per-se.
104058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         */
104158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kCanonicalTextSizeForPaths  = 64,
104258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
104358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        /*
104458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  Above this size (taking into account CTM and textSize), we never use
104558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  the cache for bits or metrics (we might overflow), so we just ask
104658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         *  for a caononical size and post-transform that.
104758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger         */
104858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        kMaxSizeForGlyphCache       = 256,
104980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    };
105058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
105158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM);
105258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
105358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    bool tooBigToUseCache() const;
105458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    bool tooBigToUseCache(const SkMatrix& ctm) const;
105558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
105658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    // Set flags/hinting/textSize up to use for drawing text as paths.
105758190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    // Returns scale factor to restore the original textSize, since will will
105858190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    // have change it to kCanonicalTextSizeForPaths.
105958190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    SkScalar setupForAsPaths();
106058190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
106158190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    static SkScalar MaxCacheSize2() {
106258190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        static const SkScalar kMaxSize = SkIntToScalar(kMaxSizeForGlyphCache);
106358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        static const SkScalar kMag2Max = kMaxSize * kMaxSize;
106458190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger        return kMag2Max;
106558190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    }
106658190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger
106780bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkAutoGlyphCache;
106880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkCanvas;
106980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkDraw;
107080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkGraphics; // So Term() can be called.
107180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkPDFDevice;
107280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    friend class SkTextToPathIter;
107358190644c30e1c4aa8e527f3503c58f841e0fcf3Derek Sollenberger    friend class SkCanonicalizePaint;
107480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
107580bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#ifdef SK_BUILD_FOR_ANDROID
10767839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger    SkPaintOptionsAndroid fPaintOptionsAndroid;
10777839ce1af63bf12fe7b3caa866970bbbb3afb13dDerek Sollenberger
107880bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // In order for the == operator to work properly this must be the last field
107980bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    // in the struct so that we can do a memcmp to this field's offset.
108080bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru    uint32_t        fGenerationID;
108180bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
108280bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru};
108380bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru
108480bacfeb4bda06541e8695bd502229727bccfeaJean-Baptiste Queru#endif
1085