18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkPaint_DEFINED 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkPaint_DEFINED 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 11374772bd61951f01bf84fe17bf53d8867681c9aereed#include "SkBlendMode.h" 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkColor.h" 13f803da12cff1d9b6148fea319220351efebfd1e0reed#include "SkFilterQuality.h" 14ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com#include "SkMatrix.h" 1571fecc32b1b4f71ef3c6467b1f5e0b55c2a12428Mike Reed#include "SkRefCnt.h" 16a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com 172b6acb4ed52483bc2a89dbbaa6f0db4fdb217cd3joshualittclass SkAutoDescriptor; 188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkAutoGlyphCache; 198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkColorFilter; 20fd45079314b739979492601fc7a242aff24c58a3joshualittclass SkData; 218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkDescriptor; 220abdf766d395ed3b7059511425f431589eca05f6senorblancoclass SkDrawLooper; 238b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgclass SkReadBuffer; 248b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgclass SkWriteBuffer; 25b69d0e0ac45e13f667bc11a937dcb547072bc93dherbclass SkGlyph; 268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkRect; 278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkGlyphCache; 2815356a68b2a87e3ab9fc49392d085a4201ffeb62reed@google.comclass SkImageFilter; 298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkMaskFilter; 308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPath; 318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkPathEffect; 32c73dd5c6880739f26216f198c757028fd28df1a4djsollen@google.comstruct SkPoint; 338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkRasterizer; 34a9322c2d86aaef1085c267dfc43cf0747f170a86reedstruct SkScalerContextEffects; 358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkShader; 36fcf7829b67b798aff4c41c4688daa9c7381991e6robertphillipsclass SkSurfaceProps; 37eae6a9127707b9391546012d11bcc7d9920dfa6dfmalitaclass SkTextBlob; 388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkTypeface; 398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/** \class SkPaint 418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The SkPaint class holds the style and color information about how to draw 438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com geometries, text and bitmaps. 448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com*/ 457ffb1b21abcc7bbed5a0fc711f6dd7b9dbb4f577ctguil@chromium.orgclass SK_API SkPaint { 468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPaint(); 488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPaint(const SkPaint& paint); 49ccce0e02576100e1baaab6b18d91acaff624753ebungeman SkPaint(SkPaint&& paint); 508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com ~SkPaint(); 518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 520418a888d31689f5358b6b90fd09287aeba368dbCary Clark SkPaint& operator=(const SkPaint& paint); 530418a888d31689f5358b6b90fd09287aeba368dbCary Clark SkPaint& operator=(SkPaint&& paint); 548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 55bc97ef427196d630952461f22ff239b107f74b29mtklein /** operator== may give false negatives: two paints that draw equivalently 56bc97ef427196d630952461f22ff239b107f74b29mtklein may return false. It will never give false positives: two paints that 57bc97ef427196d630952461f22ff239b107f74b29mtklein are not equivalent always return false. 58bc97ef427196d630952461f22ff239b107f74b29mtklein */ 590e616cf9e34b306d53fb69a4db76fee02fd1dcc3Cary Clark // cc_unittests requires SK_API to make operator== visible 60b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com SK_API friend bool operator==(const SkPaint& a, const SkPaint& b); 61b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com friend bool operator!=(const SkPaint& a, const SkPaint& b) { 62b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com return !(a == b); 63b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com } 64b265741cc17f897b349caacdb890119e4111a415robertphillips@google.com 65fb1fe4f51820731f557e765f8c71cba9a0d28048mtklein /** getHash() is a shallow hash, with the same limitations as operator==. 66fb1fe4f51820731f557e765f8c71cba9a0d28048mtklein * If operator== returns true for two paints, getHash() returns the same value for each. 67fb1fe4f51820731f557e765f8c71cba9a0d28048mtklein */ 68fb1fe4f51820731f557e765f8c71cba9a0d28048mtklein uint32_t getHash() const; 69fb1fe4f51820731f557e765f8c71cba9a0d28048mtklein 700418a888d31689f5358b6b90fd09287aeba368dbCary Clark void flatten(SkWriteBuffer& buffer) const; 710418a888d31689f5358b6b90fd09287aeba368dbCary Clark void unflatten(SkReadBuffer& buffer); 728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Restores the paint to its initial settings. 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void reset(); 768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 77309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org /** Specifies the level of hinting to be performed. These names are taken 78309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org from the Gnome/Cairo names for the same. They are translated into 79309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org Freetype concepts the same as in cairo-ft-font.c: 80309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kNo_Hinting -> FT_LOAD_NO_HINTING 81309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kSlight_Hinting -> FT_LOAD_TARGET_LIGHT 82309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kNormal_Hinting -> <default, no option> 83309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kFull_Hinting -> <same as kNormalHinting, unless we are rendering 84309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org subpixel glyphs, in which case TARGET_LCD or 85309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org TARGET_LCD_V is used> 86309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org */ 87309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org enum Hinting { 88309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kNo_Hinting = 0, 89309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kSlight_Hinting = 1, 90309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kNormal_Hinting = 2, //!< this is the default 911f90287df3129cb267422e482c52ebeca6a8990ftomhudson@google.com kFull_Hinting = 3 92309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org }; 93309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org 949d07fec3745e1b41637795270439c45f43daec48reed@google.com Hinting getHinting() const { 95f59eab269350f36a0c2bf98d1c2a9757c77fc473reed return static_cast<Hinting>(fBitfields.fHinting); 96309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org } 97309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org 98f5dbe2f00f853c6a1719924bdd0c33335a53423adjsollen@google.com void setHinting(Hinting hintingLevel); 99309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org 1008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Specifies the bit values that are stored in the paint's flags. 1018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum Flags { 1038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing 104443531126ac7d281c49fca48674ec7e14436c2b6Mike Reed kDither_Flag = 0x04, //!< mask to enable dithering. see setDither() 1058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kFakeBoldText_Flag = 0x20, //!< mask to enable fake-bold text 1068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kLinearText_Flag = 0x40, //!< mask to enable linear-text 107309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kSubpixelText_Flag = 0x80, //!< mask to enable subpixel text positioning 1088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kDevKernText_Flag = 0x100, //!< mask to enable device kerning text 109309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org kLCDRenderText_Flag = 0x200, //!< mask to enable subpixel glyph renderering 110e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap strikes 111a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter 112830a23e39bb4a126e573940cd6e354732e295b10reed@google.com kVerticalText_Flag = 0x1000, 1138351aabbfe82a76a698fa2bde00d33c1174518cdreed@google.com kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it 114309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org // when adding extra flags, note that the fFlags member is specified 115309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org // with a bit-width and you'll have to expand it. 1168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 117bcfb8f639e516b673b6dbda41900efac69be2dafMike Reed kAllFlags = 0xFFFF, 1188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 120ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK 121ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed enum ReserveFlags { 122ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed // These are not used by paint, but the bits are reserved for private use by the 123ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed // android framework. 124ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed kUnderlineText_ReserveFlag = 0x08, //!< mask to enable underline text 125ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed kStrikeThruText_ReserveFlag = 0x10, //!< mask to enable strike-thru text 126ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed }; 127ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed#endif 128ddbd37eb68fc2dbe125df5399f17fe0f091dba41Mike Reed 1298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's flags. Use the Flag enum to test flag values. 1308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's flags (see enums ending in _Flag for bit masks) 1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 132f59eab269350f36a0c2bf98d1c2a9757c77fc473reed uint32_t getFlags() const { return fBitfields.fFlags; } 1338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's flags. Use the Flag enum to specific flag values. 1358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param flags The new flag bits for the paint (see Flags enum) 1368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setFlags(uint32_t flags); 1388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for getFlags(), returning true if kAntiAlias_Flag bit is set 1408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the antialias bit is set in the paint's flags. 1418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1429d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isAntiAlias() const { 1438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return SkToBool(this->getFlags() & kAntiAlias_Flag); 1448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1459d07fec3745e1b41637795270439c45f43daec48reed@google.com 1468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for setFlags(), setting or clearing the kAntiAlias_Flag bit 1478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param aa true to enable antialiasing, false to disable it 1488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setAntiAlias(bool aa); 1509d07fec3745e1b41637795270439c45f43daec48reed@google.com 1518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for getFlags(), returning true if kDither_Flag bit is set 1528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the dithering bit is set in the paint's flags. 1538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1549d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isDither() const { 1558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return SkToBool(this->getFlags() & kDither_Flag); 1568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1579d07fec3745e1b41637795270439c45f43daec48reed@google.com 158443531126ac7d281c49fca48674ec7e14436c2b6Mike Reed /** 159443531126ac7d281c49fca48674ec7e14436c2b6Mike Reed * Helper for setFlags(), setting or clearing the kDither_Flag bit 160443531126ac7d281c49fca48674ec7e14436c2b6Mike Reed * @param dither true to enable dithering, false to disable it 161443531126ac7d281c49fca48674ec7e14436c2b6Mike Reed * 162443531126ac7d281c49fca48674ec7e14436c2b6Mike Reed * Note: gradients ignore this setting and always dither. 163443531126ac7d281c49fca48674ec7e14436c2b6Mike Reed */ 1648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setDither(bool dither); 1659d07fec3745e1b41637795270439c45f43daec48reed@google.com 1668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for getFlags(), returning true if kLinearText_Flag bit is set 1678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the lineartext bit is set in the paint's flags 1688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1699d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isLinearText() const { 1708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return SkToBool(this->getFlags() & kLinearText_Flag); 1718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for setFlags(), setting or clearing the kLinearText_Flag bit 1748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param linearText true to set the linearText bit in the paint's flags, 1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com false to clear it. 1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setLinearText(bool linearText); 1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for getFlags(), returning true if kSubpixelText_Flag bit is set 1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the lineartext bit is set in the paint's flags 1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1829d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isSubpixelText() const { 1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return SkToBool(this->getFlags() & kSubpixelText_Flag); 1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 1859d07fec3745e1b41637795270439c45f43daec48reed@google.com 18684b437e6cecde391258c3a8b79159848fae5c55areed@google.com /** 18784b437e6cecde391258c3a8b79159848fae5c55areed@google.com * Helper for setFlags(), setting or clearing the kSubpixelText_Flag. 18884b437e6cecde391258c3a8b79159848fae5c55areed@google.com * @param subpixelText true to set the subpixelText bit in the paint's 18984b437e6cecde391258c3a8b79159848fae5c55areed@google.com * flags, false to clear it. 19084b437e6cecde391258c3a8b79159848fae5c55areed@google.com */ 1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setSubpixelText(bool subpixelText); 192309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org 1939d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isLCDRenderText() const { 194309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org return SkToBool(this->getFlags() & kLCDRenderText_Flag); 195309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org } 196309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org 19784b437e6cecde391258c3a8b79159848fae5c55areed@google.com /** 19884b437e6cecde391258c3a8b79159848fae5c55areed@google.com * Helper for setFlags(), setting or clearing the kLCDRenderText_Flag. 19984b437e6cecde391258c3a8b79159848fae5c55areed@google.com * Note: antialiasing must also be on for lcd rendering 20084b437e6cecde391258c3a8b79159848fae5c55areed@google.com * @param lcdText true to set the LCDRenderText bit in the paint's flags, 20184b437e6cecde391258c3a8b79159848fae5c55areed@google.com * false to clear it. 20284b437e6cecde391258c3a8b79159848fae5c55areed@google.com */ 20384b437e6cecde391258c3a8b79159848fae5c55areed@google.com void setLCDRenderText(bool lcdText); 204309485b7b51f4cae4c0361ab4da00fe9cc89515cagl@chromium.org 2059d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isEmbeddedBitmapText() const { 206e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org return SkToBool(this->getFlags() & kEmbeddedBitmapText_Flag); 207e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org } 208e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org 209e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org /** Helper for setFlags(), setting or clearing the kEmbeddedBitmapText_Flag bit 210e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org @param useEmbeddedBitmapText true to set the kEmbeddedBitmapText bit in the paint's flags, 211e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org false to clear it. 212e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org */ 213e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org void setEmbeddedBitmapText(bool useEmbeddedBitmapText); 214e95c91e6d9201d50d0b84fbc3d2f53f92f753e0bagl@chromium.org 2159d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isAutohinted() const { 216a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org return SkToBool(this->getFlags() & kAutoHinting_Flag); 217a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org } 218a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org 219a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org /** Helper for setFlags(), setting or clearing the kAutoHinting_Flag bit 220a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org @param useAutohinter true to set the kEmbeddedBitmapText bit in the 221a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org paint's flags, 222a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org false to clear it. 223a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org */ 224a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org void setAutohinted(bool useAutohinter); 225a2c71cbd51da8b7767d43fe8954e7a4c674b2005agl@chromium.org 226830a23e39bb4a126e573940cd6e354732e295b10reed@google.com bool isVerticalText() const { 227830a23e39bb4a126e573940cd6e354732e295b10reed@google.com return SkToBool(this->getFlags() & kVerticalText_Flag); 228830a23e39bb4a126e573940cd6e354732e295b10reed@google.com } 229fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 230830a23e39bb4a126e573940cd6e354732e295b10reed@google.com /** 231830a23e39bb4a126e573940cd6e354732e295b10reed@google.com * Helper for setting or clearing the kVerticalText_Flag bit in 232830a23e39bb4a126e573940cd6e354732e295b10reed@google.com * setFlags(...). 233830a23e39bb4a126e573940cd6e354732e295b10reed@google.com * 234830a23e39bb4a126e573940cd6e354732e295b10reed@google.com * If this bit is set, then advances are treated as Y values rather than 235830a23e39bb4a126e573940cd6e354732e295b10reed@google.com * X values, and drawText will places its glyphs vertically rather than 236830a23e39bb4a126e573940cd6e354732e295b10reed@google.com * horizontally. 237830a23e39bb4a126e573940cd6e354732e295b10reed@google.com */ 2380418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setVerticalText(bool verticalText); 239830a23e39bb4a126e573940cd6e354732e295b10reed@google.com 2408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set 2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the kFakeBoldText_Flag bit is set in the paint's flags. 2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2439d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isFakeBoldText() const { 2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return SkToBool(this->getFlags() & kFakeBoldText_Flag); 2458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 2468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for setFlags(), setting or clearing the kFakeBoldText_Flag bit 2488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param fakeBoldText true to set the kFakeBoldText_Flag bit in the paint's 2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com flags, false to clear it. 2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setFakeBoldText(bool fakeBoldText); 2528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for getFlags(), returns true if kDevKernText_Flag bit is set 2548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true if the kernText bit is set in the paint's flags. 2558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2569d07fec3745e1b41637795270439c45f43daec48reed@google.com bool isDevKernText() const { 2578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return SkToBool(this->getFlags() & kDevKernText_Flag); 2588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 2598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper for setFlags(), setting or clearing the kKernText_Flag bit 2618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param kernText true to set the kKernText_Flag bit in the paint's 2628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com flags, false to clear it. 2638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setDevKernText(bool devKernText); 2658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 266f803da12cff1d9b6148fea319220351efebfd1e0reed /** 267f803da12cff1d9b6148fea319220351efebfd1e0reed * Return the filter level. This affects the quality (and performance) of 268f803da12cff1d9b6148fea319220351efebfd1e0reed * drawing scaled images. 269f803da12cff1d9b6148fea319220351efebfd1e0reed */ 270f803da12cff1d9b6148fea319220351efebfd1e0reed SkFilterQuality getFilterQuality() const { 271f803da12cff1d9b6148fea319220351efebfd1e0reed return (SkFilterQuality)fBitfields.fFilterQuality; 272f803da12cff1d9b6148fea319220351efebfd1e0reed } 273fe81e2d274a4948491ed6d4bbce1c96ea0c8f9cdmtklein 274f803da12cff1d9b6148fea319220351efebfd1e0reed /** 275f803da12cff1d9b6148fea319220351efebfd1e0reed * Set the filter quality. This affects the quality (and performance) of 276f803da12cff1d9b6148fea319220351efebfd1e0reed * drawing scaled images. 277f803da12cff1d9b6148fea319220351efebfd1e0reed */ 278f803da12cff1d9b6148fea319220351efebfd1e0reed void setFilterQuality(SkFilterQuality quality); 279c9683151367b2033a26b1e2ebe6b3902d2064bdbreed@google.com 2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Styles apply to rect, oval, path, and text. 2818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Bitmaps are always drawn in "fill", and lines are always drawn in 2828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com "stroke". 2839d07fec3745e1b41637795270439c45f43daec48reed@google.com 284ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com Note: strokeandfill implicitly draws the result with 285ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com SkPath::kWinding_FillType, so if the original path is even-odd, the 286ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com results may not appear the same as if it was drawn twice, filled and 287ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com then stroked. 2888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum Style { 290ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com kFill_Style, //!< fill the geometry 291ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com kStroke_Style, //!< stroke the geometry 292ed881c2704bc81fe46a68c0cf9e292287313baa6reed@android.com kStrokeAndFill_Style, //!< fill and stroke the geometry 293aac2fb8019282e8933d76462b3bc62bf727e6627mike@reedtribe.org }; 294aac2fb8019282e8933d76462b3bc62bf727e6627mike@reedtribe.org enum { 295aac2fb8019282e8933d76462b3bc62bf727e6627mike@reedtribe.org kStyleCount = kStrokeAndFill_Style + 1 2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's style, used for controlling how primitives' 2998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com geometries are interpreted (except for drawBitmap, which always assumes 3008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kFill_Style). 3018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's Style 3028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 303f59eab269350f36a0c2bf98d1c2a9757c77fc473reed Style getStyle() const { return (Style)fBitfields.fStyle; } 3048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's style, used for controlling how primitives' 3068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com geometries are interpreted (except for drawBitmap, which always assumes 3078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Fill). 3088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param style The new style to set in the paint 3098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setStyle(Style style); 3118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's color. Note that the color is a 32bit value 3138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com containing alpha as well as r,g,b. This 32bit value is not 3148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com premultiplied, meaning that its alpha can be any value, regardless of 3158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the values of r,g,b. 3168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's color (and alpha). 3178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkColor getColor() const { return fColor; } 3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's color. Note that the color is a 32bit value containing 3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com alpha as well as r,g,b. This 32bit value is not premultiplied, meaning 3228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com that its alpha can be any value, regardless of the values of r,g,b. 3238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param color The new color (including alpha) to set in the paint. 3248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setColor(SkColor color); 3268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper to getColor() that just returns the color's alpha value. 3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the alpha component of the paint's color. 3298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); } 3319d07fec3745e1b41637795270439c45f43daec48reed@google.com 3328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper to setColor(), that only assigns the color's alpha value, 3338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com leaving its r,g,b values unchanged. 3348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param a set the alpha component (0..255) of the paint's color. 3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setAlpha(U8CPU a); 3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Helper to setColor(), that takes a,r,g,b and constructs the color value 3398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com using SkColorSetARGB() 3408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param a The new alpha component (0..255) of the paint's color. 3418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param r The new red component (0..255) of the paint's color. 3428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param g The new green component (0..255) of the paint's color. 3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param b The new blue component (0..255) of the paint's color. 3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b); 3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3479d07fec3745e1b41637795270439c45f43daec48reed@google.com /** Return the width for stroking. 3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 3498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com A value of 0 strokes in hairline mode. 3508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Hairlines always draw 1-pixel wide, regardless of the matrix. 3518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's stroke width, used whenever the paint's style is 3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Stroke or StrokeAndFill. 3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getStrokeWidth() const { return fWidth; } 3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3569d07fec3745e1b41637795270439c45f43daec48reed@google.com /** Set the width for stroking. 3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Pass 0 to stroke in hairline mode. 3588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Hairlines always draw 1-pixel wide, regardless of the matrix. 3598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param width set the paint's stroke width, used whenever the paint's 3608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com style is Stroke or StrokeAndFill. 3618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setStrokeWidth(SkScalar width); 3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's stroke miter value. This is used to control the 3658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com behavior of miter joins when the joins angle is sharp. 3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's miter limit, used whenever the paint's style is 3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Stroke or StrokeAndFill. 3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getStrokeMiter() const { return fMiterLimit; } 3708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's stroke miter value. This is used to control the 3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com behavior of miter joins when the joins angle is sharp. This value must 3738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com be >= 0. 3748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param miter set the miter limit on the paint, used whenever the 3758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com paint's style is Stroke or StrokeAndFill. 3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setStrokeMiter(SkScalar miter); 3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Cap enum specifies the settings for the paint's strokecap. This is the 3808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com treatment that is applied to the beginning and end of each non-closed 3818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com contour (e.g. lines). 3825cb00a95734143ca068960ead1ae94d0440c61dacaryclark 3835cb00a95734143ca068960ead1ae94d0440c61dacaryclark If the cap is round or square, the caps are drawn when the contour has 3845cb00a95734143ca068960ead1ae94d0440c61dacaryclark a zero length. Zero length contours can be created by following moveTo 3855cb00a95734143ca068960ead1ae94d0440c61dacaryclark with a lineTo at the same point, or a moveTo followed by a close. 3865cb00a95734143ca068960ead1ae94d0440c61dacaryclark 3875cb00a95734143ca068960ead1ae94d0440c61dacaryclark A dash with an on interval of zero also creates a zero length contour. 3885cb00a95734143ca068960ead1ae94d0440c61dacaryclark 3895cb00a95734143ca068960ead1ae94d0440c61dacaryclark The zero length contour draws the square cap without rotation, since 3905cb00a95734143ca068960ead1ae94d0440c61dacaryclark the no direction can be inferred. 3918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum Cap { 3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kButt_Cap, //!< begin/end contours with no extension 3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kRound_Cap, //!< begin/end contours with a semi-circle extension 3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kSquare_Cap, //!< begin/end contours with a half square extension 3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 397a7d85ba138ee09739defbd277b04c479fdef82a6bsalomon kLast_Cap = kSquare_Cap, 3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kDefault_Cap = kButt_Cap 3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 400a7d85ba138ee09739defbd277b04c479fdef82a6bsalomon static constexpr int kCapCount = kLast_Cap + 1; 4018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Join enum specifies the settings for the paint's strokejoin. This is 4038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the treatment that is applied to corners in paths and rectangles. 4048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum Join { 4068a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kMiter_Join, //!< connect path segments with a sharp join 4078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kRound_Join, //!< connect path segments with a round join 4088a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kBevel_Join, //!< connect path segments with a flat bevel join 4098a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 410a7d85ba138ee09739defbd277b04c479fdef82a6bsalomon kLast_Join = kBevel_Join, 4118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kDefault_Join = kMiter_Join 4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 413a7d85ba138ee09739defbd277b04c479fdef82a6bsalomon static constexpr int kJoinCount = kLast_Join + 1; 4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's stroke cap type, controlling how the start and end 4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com of stroked lines and paths are treated. 4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the line cap style for the paint, used whenever the paint's 4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com style is Stroke or StrokeAndFill. 4198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 420f59eab269350f36a0c2bf98d1c2a9757c77fc473reed Cap getStrokeCap() const { return (Cap)fBitfields.fCapType; } 4218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's stroke cap type. 4238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param cap set the paint's line cap style, used whenever the paint's 4248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com style is Stroke or StrokeAndFill. 4258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setStrokeCap(Cap cap); 4278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's stroke join type. 4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's line join style, used whenever the paint's style is 4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Stroke or StrokeAndFill. 4318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 432f59eab269350f36a0c2bf98d1c2a9757c77fc473reed Join getStrokeJoin() const { return (Join)fBitfields.fJoinType; } 4338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's stroke join type. 4358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param join set the paint's line join style, used whenever the paint's 4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com style is Stroke or StrokeAndFill. 4378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 4388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setStrokeJoin(Join join); 4398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4404bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com /** 4414bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * Applies any/all effects (patheffect, stroking) to src, returning the 4424bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * result in dst. The result is that drawing src with this paint will be 4434bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * the same as drawing dst with a default paint (at least from the 4444bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * geometric perspective). 4454bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * 4464bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * @param src input path 4474bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * @param dst output path (may be the same as src) 4484bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * @param cullRect If not null, the dst path may be culled to this rect. 44905d9044de4f1c6e791df66a425638752daac4c6breed * @param resScale If > 1, increase precision, else if (0 < res < 1) reduce precision 45005d9044de4f1c6e791df66a425638752daac4c6breed * in favor of speed/size. 4514bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * @return true if the path should be filled, or false if it should be 4524bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com * drawn with a hairline (width == 0) 4534bbdeac58cc928dc66296bde3bd06e78070d96b7reed@google.com */ 45405d9044de4f1c6e791df66a425638752daac4c6breed bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect, 45505d9044de4f1c6e791df66a425638752daac4c6breed SkScalar resScale = 1) const; 45605d9044de4f1c6e791df66a425638752daac4c6breed 45705d9044de4f1c6e791df66a425638752daac4c6breed bool getFillPath(const SkPath& src, SkPath* dst) const { 45805d9044de4f1c6e791df66a425638752daac4c6breed return this->getFillPath(src, dst, NULL, 1); 45905d9044de4f1c6e791df66a425638752daac4c6breed } 4608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the paint's shader object. 4628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 4638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The shader's reference count is not affected. 4648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's shader (or NULL) 4658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 466a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed SkShader* getShader() const { return fShader.get(); } 467693fdbd6b81a860657612e7604430dd55d6e721bMike Reed sk_sp<SkShader> refShader() const; 4688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set or clear the shader object. 470880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * Shaders specify the source color(s) for what is being drawn. If a paint 471880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * has no shader, then the paint's color is used. If the paint has a 472880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * shader, then the shader's color(s) are use instead, but they are 473880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * modulated by the paint's alpha. This makes it easy to create a shader 474880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * once (e.g. bitmap tiling or gradient) and then change its transparency 475880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * w/o having to modify the original shader... only the paint's alpha needs 476880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * to be modified. 477e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org * 478e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org * There is an exception to this only-respect-paint's-alpha rule: If the shader only generates 479e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org * alpha (e.g. SkShader::CreateBitmapShader(bitmap, ...) where bitmap's colortype is kAlpha_8) 480e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org * then the shader will use the paint's entire color to "colorize" its output (modulating the 481e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org * bitmap's alpha with the paint's color+alpha). 482e5957f67d00c04c0fbf88809df510426e74fe40acommit-bot@chromium.org * 483880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * Pass NULL to clear any previous shader. 484880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * As a convenience, the parameter passed is also returned. 485880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * If a previous shader exists, its reference count is decremented. 486880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * If shader is not NULL, its reference count is incremented. 487880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com * @param shader May be NULL. The shader to be installed in the paint 488880dc472ab2c987083db9eb83efb2930787f0b26reed@google.com */ 4890418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setShader(sk_sp<SkShader> shader); 4909d07fec3745e1b41637795270439c45f43daec48reed@google.com 4918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the paint's colorfilter. If there is a colorfilter, its reference 4928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com count is not changed. 4938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's colorfilter (or NULL) 4948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 495a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed SkColorFilter* getColorFilter() const { return fColorFilter.get(); } 496693fdbd6b81a860657612e7604430dd55d6e721bMike Reed sk_sp<SkColorFilter> refColorFilter() const; 4978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 498958788ab461bf84e8c604a17dba5ebc2d6c27dfaMike Reed /** Set or clear the paint's colorfilter. 4998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If the paint already has a filter, its reference count is decremented. 5018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If filter is not NULL, its reference count is incremented. 5028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param filter May be NULL. The filter to be installed in the paint 5038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5040418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setColorFilter(sk_sp<SkColorFilter> colorFilter); 5058a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 506374772bd61951f01bf84fe17bf53d8867681c9aereed SkBlendMode getBlendMode() const { return (SkBlendMode)fBlendMode; } 507374772bd61951f01bf84fe17bf53d8867681c9aereed bool isSrcOver() const { return (SkBlendMode)fBlendMode == SkBlendMode::kSrcOver; } 508374772bd61951f01bf84fe17bf53d8867681c9aereed void setBlendMode(SkBlendMode mode) { fBlendMode = (unsigned)mode; } 509a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com 5108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the paint's patheffect object. 5118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The patheffect reference count is not affected. 5138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's patheffect (or NULL) 5148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 515a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed SkPathEffect* getPathEffect() const { return fPathEffect.get(); } 516693fdbd6b81a860657612e7604430dd55d6e721bMike Reed sk_sp<SkPathEffect> refPathEffect() const; 5178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set or clear the patheffect object. 5198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Pass NULL to clear any previous patheffect. 5218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com As a convenience, the parameter passed is also returned. 5228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If a previous patheffect exists, its reference count is decremented. 5238a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If patheffect is not NULL, its reference count is incremented. 5248a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param effect May be NULL. The new patheffect to be installed in the 5258a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com paint 5268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return effect 5278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5280418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setPathEffect(sk_sp<SkPathEffect> pathEffect); 5298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the paint's maskfilter object. 5318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The maskfilter reference count is not affected. 5338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's maskfilter (or NULL) 5348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 535a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); } 536693fdbd6b81a860657612e7604430dd55d6e721bMike Reed sk_sp<SkMaskFilter> refMaskFilter() const; 5378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set or clear the maskfilter object. 5398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Pass NULL to clear any previous maskfilter. 5418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com As a convenience, the parameter passed is also returned. 5428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If a previous maskfilter exists, its reference count is decremented. 5438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If maskfilter is not NULL, its reference count is incremented. 5448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param maskfilter May be NULL. The new maskfilter to be installed in 5458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the paint 5468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return maskfilter 5478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5480418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setMaskFilter(sk_sp<SkMaskFilter> maskFilter); 5498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // These attributes are for text/fonts 5518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the paint's typeface object. 5538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The typeface object identifies which font to use when drawing or 5558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com measuring text. The typeface reference count is not affected. 5568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's typeface (or NULL) 5578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 558a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed SkTypeface* getTypeface() const { return fTypeface.get(); } 559693fdbd6b81a860657612e7604430dd55d6e721bMike Reed sk_sp<SkTypeface> refTypeface() const; 5608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set or clear the typeface object. 5628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Pass NULL to clear any previous typeface. 5648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com As a convenience, the parameter passed is also returned. 5658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If a previous typeface exists, its reference count is decremented. 5668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If typeface is not NULL, its reference count is incremented. 5678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param typeface May be NULL. The new typeface to be installed in the 5688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com paint 5698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return typeface 5708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5710418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setTypeface(sk_sp<SkTypeface> typeface); 5728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Get the paint's rasterizer (or NULL). 5748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com The raster controls how paths/text are turned into alpha masks. 5768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's rasterizer (or NULL) 5778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 578a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed SkRasterizer* getRasterizer() const { return fRasterizer.get(); } 579693fdbd6b81a860657612e7604430dd55d6e721bMike Reed sk_sp<SkRasterizer> refRasterizer() const; 5808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 5818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set or clear the rasterizer object. 5828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com <p /> 5838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Pass NULL to clear any previous rasterizer. 5848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com As a convenience, the parameter passed is also returned. 5858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If a previous rasterizer exists in the paint, its reference count is 5868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com decremented. If rasterizer is not NULL, its reference count is 5878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com incremented. 5888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param rasterizer May be NULL. The new rasterizer to be installed in 5898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com the paint. 5908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return rasterizer 5918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 5920418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setRasterizer(sk_sp<SkRasterizer> rasterizer); 5938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 594a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed SkImageFilter* getImageFilter() const { return fImageFilter.get(); } 595693fdbd6b81a860657612e7604430dd55d6e721bMike Reed sk_sp<SkImageFilter> refImageFilter() const; 5960418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setImageFilter(sk_sp<SkImageFilter> imageFilter); 597fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 598b0a34d80c5c7b06db8083a547f8e499781a9c169reed@google.com /** 5999d07fec3745e1b41637795270439c45f43daec48reed@google.com * Return the paint's SkDrawLooper (if any). Does not affect the looper's 6009d07fec3745e1b41637795270439c45f43daec48reed@google.com * reference count. 6019d07fec3745e1b41637795270439c45f43daec48reed@google.com */ 60246f2d0ad0d0e4f4cf0e7d6f158b3fb9fe4f615fareed SkDrawLooper* getDrawLooper() const { return fDrawLooper.get(); } 603693fdbd6b81a860657612e7604430dd55d6e721bMike Reed sk_sp<SkDrawLooper> refDrawLooper() const; 604693fdbd6b81a860657612e7604430dd55d6e721bMike Reed 60546f2d0ad0d0e4f4cf0e7d6f158b3fb9fe4f615fareed SkDrawLooper* getLooper() const { return fDrawLooper.get(); } 6069d07fec3745e1b41637795270439c45f43daec48reed@google.com /** 6079d07fec3745e1b41637795270439c45f43daec48reed@google.com * Set or clear the looper object. 6089d07fec3745e1b41637795270439c45f43daec48reed@google.com * <p /> 6099d07fec3745e1b41637795270439c45f43daec48reed@google.com * Pass NULL to clear any previous looper. 6109d07fec3745e1b41637795270439c45f43daec48reed@google.com * If a previous looper exists in the paint, its reference count is 6119d07fec3745e1b41637795270439c45f43daec48reed@google.com * decremented. If looper is not NULL, its reference count is 6129d07fec3745e1b41637795270439c45f43daec48reed@google.com * incremented. 6139d07fec3745e1b41637795270439c45f43daec48reed@google.com * @param looper May be NULL. The new looper to be installed in the paint. 6149d07fec3745e1b41637795270439c45f43daec48reed@google.com */ 6150418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setDrawLooper(sk_sp<SkDrawLooper> drawLooper); 61609d9435835f48b06954904f16d14c1c2eeaaad2eMike Reed 6170418a888d31689f5358b6b90fd09287aeba368dbCary Clark void setLooper(sk_sp<SkDrawLooper> drawLooper); 6188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum Align { 6208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kLeft_Align, 6218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kCenter_Align, 6228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kRight_Align, 623ddc813b0def5a79d0eb5011240fecce6147ce9efmike@reedtribe.org }; 624ddc813b0def5a79d0eb5011240fecce6147ce9efmike@reedtribe.org enum { 625ddc813b0def5a79d0eb5011240fecce6147ce9efmike@reedtribe.org kAlignCount = 3 6268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 6279d07fec3745e1b41637795270439c45f43daec48reed@google.com 6288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's Align value for drawing text. 6298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's Align value for drawing text. 6308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 631f59eab269350f36a0c2bf98d1c2a9757c77fc473reed Align getTextAlign() const { return (Align)fBitfields.fTextAlign; } 6329d07fec3745e1b41637795270439c45f43daec48reed@google.com 6338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's text alignment. 6348a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param align set the paint's Align value for drawing text. 6358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setTextAlign(Align align); 6378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's text size. 6398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's text size. 6408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getTextSize() const { return fTextSize; } 6428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's text size. This value must be > 0 6448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param textSize set the paint's text size. 6458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setTextSize(SkScalar textSize); 6478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's horizontal scale factor for text. The default value 6498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is 1.0. 6508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's scale factor in X for drawing/measuring text 6518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getTextScaleX() const { return fTextScaleX; } 6538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's horizontal scale factor for text. The default value 6558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will 6568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com stretch the text narrower. 6578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param scaleX set the paint's scale factor in X for drawing/measuring 6588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com text. 6598a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setTextScaleX(SkScalar scaleX); 6618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the paint's horizontal skew factor for text. The default value 6638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is 0. 6648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return the paint's skew factor in X for drawing text. 6658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getTextSkewX() const { return fTextSkewX; } 6678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Set the paint's horizontal skew factor for text. The default value 6698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is 0. For approximating oblique text, use values around -0.25. 6708a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param skewX set the paint's skew factor in X for drawing text. 6718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setTextSkewX(SkScalar skewX); 6738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Describes how to interpret the text parameters that are passed to paint 6758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com methods like measureText() and getTextWidths(). 6768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 6778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum TextEncoding { 6788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kUTF8_TextEncoding, //!< the text parameters are UTF8 6798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kUTF16_TextEncoding, //!< the text parameters are UTF16 6806970557055acaed619d7bb89451868e1570249b2robertphillips@google.com kUTF32_TextEncoding, //!< the text parameters are UTF32 6818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com kGlyphID_TextEncoding //!< the text parameters are glyph indices 6828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 6839d07fec3745e1b41637795270439c45f43daec48reed@google.com 684f59eab269350f36a0c2bf98d1c2a9757c77fc473reed TextEncoding getTextEncoding() const { 685f59eab269350f36a0c2bf98d1c2a9757c77fc473reed return (TextEncoding)fBitfields.fTextEncoding; 686f59eab269350f36a0c2bf98d1c2a9757c77fc473reed } 6878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setTextEncoding(TextEncoding encoding); 6898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 6908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com struct FontMetrics { 6910bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org /** Flags which indicate the confidence level of various metrics. 6920bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org A set flag indicates that the metric may be trusted. 6930bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org */ 6940bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org enum FontMetricsFlags { 6953318da5d1aa19533dd034f90d4bc29a2d2e86b66Ben Wagner kUnderlineThicknessIsValid_Flag = 1 << 0, 6960bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org kUnderlinePositionIsValid_Flag = 1 << 1, 6970bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org }; 6980bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org 6990bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org uint32_t fFlags; //!< Bit field to identify which values are unknown 7008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fTop; //!< The greatest distance above the baseline for any glyph (will be <= 0) 7018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fAscent; //!< The recommended distance above the baseline (will be <= 0) 7028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fDescent; //!< The recommended distance below the baseline (will be >= 0) 7038a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fBottom; //!< The greatest distance below the baseline for any glyph (will be >= 0) 7048a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar fLeading; //!< The recommended distance to add between lines of text (will be >= 0) 7050bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org SkScalar fAvgCharWidth; //!< the average character width (>= 0) 7060bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org SkScalar fMaxCharWidth; //!< the max character width (>= 0) 707cc3096ba6d437b29f1cbd34c237607419cbed72bagl@chromium.org SkScalar fXMin; //!< The minimum bounding box x value for all glyphs 708cc3096ba6d437b29f1cbd34c237607419cbed72bagl@chromium.org SkScalar fXMax; //!< The maximum bounding box x value for all glyphs 709cbe1b54c30b9a1061577c91e0b914dbe9acdc563bungeman@google.com SkScalar fXHeight; //!< The height of an 'x' in px, or 0 if no 'x' in face 710cbe1b54c30b9a1061577c91e0b914dbe9acdc563bungeman@google.com SkScalar fCapHeight; //!< The cap height (> 0), or 0 if cannot be determined. 7110bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org SkScalar fUnderlineThickness; //!< underline thickness, or 0 if cannot be determined 7120bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org 7130bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org /** Underline Position - position of the top of the Underline stroke 7140bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org relative to the baseline, this can have following values 7150bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org - Negative - means underline should be drawn above baseline. 7160bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org - Positive - means below baseline. 7170bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org - Zero - mean underline should be drawn on baseline. 7180bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org */ 7190bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org SkScalar fUnderlinePosition; //!< underline position, or 0 if cannot be determined 7200bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org 7213318da5d1aa19533dd034f90d4bc29a2d2e86b66Ben Wagner /** If the fontmetrics has a valid underline thickness, return true, and set the 7220bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org thickness param to that value. If it doesn't return false and ignore the 7230bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org thickness param. 7240bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org */ 7250bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org bool hasUnderlineThickness(SkScalar* thickness) const { 7263318da5d1aa19533dd034f90d4bc29a2d2e86b66Ben Wagner if (SkToBool(fFlags & kUnderlineThicknessIsValid_Flag)) { 7270bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org *thickness = fUnderlineThickness; 7280bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org return true; 7290bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org } 7300bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org return false; 7310bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org } 7320bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org 7333318da5d1aa19533dd034f90d4bc29a2d2e86b66Ben Wagner /** If the fontmetrics has a valid underline position, return true, and set the 7343318da5d1aa19533dd034f90d4bc29a2d2e86b66Ben Wagner position param to that value. If it doesn't return false and ignore the 7353318da5d1aa19533dd034f90d4bc29a2d2e86b66Ben Wagner position param. 7360bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org */ 7370bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org bool hasUnderlinePosition(SkScalar* position) const { 7380bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org if (SkToBool(fFlags & kUnderlinePositionIsValid_Flag)) { 7390bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org *position = fUnderlinePosition; 7400bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org return true; 7410bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org } 7420bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org return false; 7430bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org } 7440bc406df48ac6f358ab8dcff08f71fe9c32b79decommit-bot@chromium.org 7458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 7469d07fec3745e1b41637795270439c45f43daec48reed@google.com 7478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the recommend spacing between lines (which will be 7488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fDescent - fAscent + fLeading). 7498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com If metrics is not null, return in it the font metrics for the 7509d07fec3745e1b41637795270439c45f43daec48reed@google.com typeface/pointsize/etc. currently set in the paint. 7518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param metrics If not null, returns the font metrics for the 7528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com current typeface/pointsize/etc setting in this 7538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com paint. 7548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param scale If not 0, return width as if the canvas were scaled 7558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com by this value 7568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param return the recommended spacing between lines 7578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0) const; 7599d07fec3745e1b41637795270439c45f43daec48reed@google.com 7608a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the recommend line spacing. This will be 7618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com fDescent - fAscent + fLeading 7628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar getFontSpacing() const { return this->getFontMetrics(NULL, 0); } 7648a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 7658a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Convert the specified text into glyph IDs, returning the number of 7668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com glyphs ID written. If glyphs is NULL, it is ignore and only the count 7678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com is returned. 7688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int textToGlyphs(const void* text, size_t byteLength, 770d0e95a524c20932e0f4e68bab43995188a281395halcanary SkGlyphID glyphs[]) const; 7718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 772a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com /** Return true if all of the specified text has a corresponding non-zero 773a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com glyph ID. If any of the code-points in the text are not supported in 774a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com the typeface (i.e. the glyph ID would be zero), then return false. 775a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com 776a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com If the text encoding for the paint is kGlyph_TextEncoding, then this 777a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com returns true if all of the specified glyph IDs are non-zero. 778a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com */ 779a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com bool containsText(const void* text, size_t byteLength) const; 780a5dcaf6fd8115fb9c6028ca4e9848b968375abcdreed@android.com 7819d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com /** Convert the glyph array into Unichars. Unconvertable glyphs are mapped 7829d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com to zero. Note: this does not look at the text-encoding setting in the 7839d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com paint, only at the typeface. 7849d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com */ 785d0e95a524c20932e0f4e68bab43995188a281395halcanary void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const; 7869d3a985aa3c82605346ed1518375a8c384b925e5reed@android.com 7878a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the number of drawable units in the specified text buffer. 7888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com This looks at the current TextEncoding field of the paint. If you also 7898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com want to have the text converted into glyph IDs, call textToGlyphs 7908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com instead. 7918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 7929d07fec3745e1b41637795270439c45f43daec48reed@google.com int countText(const void* text, size_t byteLength) const { 7938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com return this->textToGlyphs(text, byteLength, NULL); 7948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 7958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 79644da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com /** Return the width of the text. This will return the vertical measure 79744da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * if isVerticalText() is true, in which case the returned value should 79844da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * be treated has a height instead of a width. 79944da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * 80044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param text The text to be measured 80144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param length Number of bytes of text to measure 80244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param bounds If not NULL, returns the bounds of the text, 80344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * relative to (0, 0). 80444da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @return The advance width of the text 80544da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com */ 80699ae881a7f55a03c2b16fb5704e6e90ea86d965dreed SkScalar measureText(const void* text, size_t length, SkRect* bounds) const; 8078a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 80844da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com /** Return the width of the text. This will return the vertical measure 80944da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * if isVerticalText() is true, in which case the returned value should 81044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * be treated has a height instead of a width. 81144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * 81244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param text Address of the text 81344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param length Number of bytes of text to measure 81497ecd1d454fc3fd3703724ae108a542f5f271fb0reed@google.com * @return The advance width of the text 81544da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com */ 8169d07fec3745e1b41637795270439c45f43daec48reed@google.com SkScalar measureText(const void* text, size_t length) const { 81799ae881a7f55a03c2b16fb5704e6e90ea86d965dreed return this->measureText(text, length, NULL); 8188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com } 8199d07fec3745e1b41637795270439c45f43daec48reed@google.com 82044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com /** Return the number of bytes of text that were measured. If 82144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * isVerticalText() is true, then the vertical advances are used for 82244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * the measurement. 823fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com * 82444da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param text The text to be measured 82544da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param length Number of bytes of text to measure 82644da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param maxWidth Maximum width. Only the subset of text whose accumulated 82744da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * widths are <= maxWidth are measured. 82844da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param measuredWidth Optional. If non-null, this returns the actual 82944da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * width of the measured text. 83044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @return The number of bytes of text that were measured. Will be 83144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * <= length. 83244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com */ 8338a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com size_t breakText(const void* text, size_t length, SkScalar maxWidth, 8349e96aa07dbf1210fd35ae8e0c54d4d9822544e89reed SkScalar* measuredWidth = NULL) const; 8358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 83644da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com /** Return the advances for the text. These will be vertical advances if 83744da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * isVerticalText() returns true. 83844da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * 83944da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param text the text 84044da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param byteLength number of bytes to of text 84144da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param widths If not null, returns the array of advances for 84244da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * the glyphs. If not NULL, must be at least a large 84344da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * as the number of unichars in the specified text. 84444da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @param bounds If not null, returns the bounds for each of 84544da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * character, relative to (0, 0) 84644da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com * @return the number of unichars in the specified text. 84744da42e92f46cae9e96003999f02db04b8b5ff2dreed@google.com */ 8488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int getTextWidths(const void* text, size_t byteLength, SkScalar widths[], 8498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkRect bounds[] = NULL) const; 8508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8518a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Return the path (outline) for the specified text. 8520449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * Note: just like SkCanvas::drawText, this will respect the Align setting 8530449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * in the paint. 8540449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * 8550449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param text the text 8560449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param length number of bytes of text 8570449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param x The x-coordinate of the origin of the text. 8580449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param y The y-coordinate of the origin of the text. 8590449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param path The outline of the text. 8600449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark */ 8618a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y, 8628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkPath* path) const; 8638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 8640449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark /** Return the path (outline) for the specified text. 8650449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * Note: just like SkCanvas::drawText, this will respect the Align setting 8660449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * in the paint. 8670449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * 8680449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param text the text 8690449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param length number of bytes of text 8700449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param pos array of positions, used to position each character 8710449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param path The outline of the text. 8720449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark */ 873fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com void getPosTextPath(const void* text, size_t length, 874ca0062ee5e74eddff886ada2a200d25946ea52cfreed@google.com const SkPoint pos[], SkPath* path) const; 875ca0062ee5e74eddff886ada2a200d25946ea52cfreed@google.com 8760449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark /** Return the number of intervals that intersect the intercept along the axis of the advance. 8770449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in 8780449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * the string. The caller may pass nullptr for intervals to determine the size of the interval 8790449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * array, or may conservatively pre-allocate an array with length * 2 entries. The computed 8800449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * intervals are cached by glyph to improve performance for multiple calls. 8810449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * This permits constructing an underline that skips the descenders. 8820449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * 8830449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param text the text 8840449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param length number of bytes of text 8850449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param x The x-coordinate of the origin of the text. 8860449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param y The y-coordinate of the origin of the text. 8870449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param bounds The lower and upper line parallel to the advance. 8880449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param array If not null, the found intersections. 8890449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * 8900449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @return The number of intersections, which may be zero. 8910449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark */ 8920449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark int getTextIntercepts(const void* text, size_t length, SkScalar x, SkScalar y, 8930449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark const SkScalar bounds[2], SkScalar* intervals) const; 8940449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark 8950449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark /** Return the number of intervals that intersect the intercept along the axis of the advance. 8960449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in 8970449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * string. The caller may pass nullptr for intervals to determine the size of the interval 8980449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * array, or may conservatively pre-allocate an array with length * 2 entries. The computed 8990449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * intervals are cached by glyph to improve performance for multiple calls. 9000449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * This permits constructing an underline that skips the descenders. 9010449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * 9020449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param text the text 9030449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param length number of bytes of text 9040449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param pos array of positions, used to position each character 9050449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param bounds The lower and upper line parallel to the advance. 9060449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @param array If not null, the glyph bounds contained by the advance parallel lines. 9070449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * 9080449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark * @return The number of intersections, which may be zero. 9090449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark */ 9100449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark int getPosTextIntercepts(const void* text, size_t length, const SkPoint pos[], 9110449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark const SkScalar bounds[2], SkScalar* intervals) const; 9120449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark 913eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita /** Return the number of intervals that intersect the intercept along the axis of the advance. 914eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in 915eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * string. The caller may pass nullptr for intervals to determine the size of the interval 916eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * array, or may conservatively pre-allocate an array with length * 2 entries. The computed 917eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * intervals are cached by glyph to improve performance for multiple calls. 918eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * This permits constructing an underline that skips the descenders. 919eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * 920eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param text The text. 921eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param length Number of bytes of text. 922eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param xpos Array of x-positions, used to position each character. 923eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param constY The shared Y coordinate for all of the positions. 924eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param bounds The lower and upper line parallel to the advance. 925eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param array If not null, the glyph bounds contained by the advance parallel lines. 926eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * 927eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @return The number of intersections, which may be zero. 928eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita */ 929eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita int getPosTextHIntercepts(const void* text, size_t length, const SkScalar xpos[], 930eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita SkScalar constY, const SkScalar bounds[2], SkScalar* intervals) const; 931eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita 932eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita /** Return the number of intervals that intersect the intercept along the axis of the advance. 933eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in 934eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * text blob. The caller may pass nullptr for intervals to determine the size of the interval 935eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * array. The computed intervals are cached by glyph to improve performance for multiple calls. 936eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * This permits constructing an underline that skips the descenders. 937eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * 938eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param blob The text blob. 939eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param bounds The lower and upper line parallel to the advance. 940eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @param array If not null, the glyph bounds contained by the advance parallel lines. 941eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * 942eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita * @return The number of intersections, which may be zero. 943eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita */ 944eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita int getTextBlobIntercepts(const SkTextBlob* blob, const SkScalar bounds[2], 945eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita SkScalar* intervals) const; 946eae6a9127707b9391546012d11bcc7d9920dfa6dfmalita 9478893e5f030cb2f6c3bdf698c1767a244ae098a5creed /** 9488893e5f030cb2f6c3bdf698c1767a244ae098a5creed * Return a rectangle that represents the union of the bounds of all 9498893e5f030cb2f6c3bdf698c1767a244ae098a5creed * of the glyphs, but each one positioned at (0,0). This may be conservatively large, and 9508893e5f030cb2f6c3bdf698c1767a244ae098a5creed * will not take into account any hinting, but will respect any text-scale-x or text-skew-x 9518893e5f030cb2f6c3bdf698c1767a244ae098a5creed * on this paint. 9528893e5f030cb2f6c3bdf698c1767a244ae098a5creed */ 9538893e5f030cb2f6c3bdf698c1767a244ae098a5creed SkRect getFontBounds() const; 9548893e5f030cb2f6c3bdf698c1767a244ae098a5creed 955632e1a281bc66fb545dce690dff27b51cef41a8ereed@google.com // returns true if the paint's settings (e.g. xfermode + alpha) resolve to 956632e1a281bc66fb545dce690dff27b51cef41a8ereed@google.com // mean that we need not draw at all (e.g. SrcOver + 0-alpha) 957632e1a281bc66fb545dce690dff27b51cef41a8ereed@google.com bool nothingToDraw() const; 958632e1a281bc66fb545dce690dff27b51cef41a8ereed@google.com 959a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com /////////////////////////////////////////////////////////////////////////// 960d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com // would prefer to make these private... 961d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com 962a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com /** Returns true if the current paint settings allow for fast computation of 963a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com bounds (i.e. there is nothing complex like a patheffect that would make 964a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com the bounds computation expensive. 965a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com */ 9660abdf766d395ed3b7059511425f431589eca05f6senorblanco bool canComputeFastBounds() const; 967fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 968a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com /** Only call this if canComputeFastBounds() returned true. This takes a 969a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com raw rectangle (the raw bounds of a shape), and adjusts it for stylistic 970a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com effects in the paint (e.g. stroking). If needed, it uses the storage 971a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com rect parameter. It returns the adjusted bounds that can then be used 972a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com for quickReject tests. 973fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 974a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com The returned rect will either be orig or storage, thus the caller 975a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com should not rely on storage being set to the result, but should always 976a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com use the retured value. It is legal for orig and storage to be the same 977a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com rect. 978fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 979a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com e.g. 980a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com if (paint.canComputeFastBounds()) { 981a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com SkRect r, storage; 982a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com path.computeBounds(&r, SkPath::kFast_BoundsType); 983a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com const SkRect& fastR = paint.computeFastBounds(r, &storage); 984a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com if (canvas->quickReject(fastR, ...)) { 985a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com // don't draw the path 986a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com } 987a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com } 988a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com */ 989a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const { 99060751d7a069fb540aa468068f792fb6f4999832dBrian Osman // Things like stroking, etc... will do math on the bounds rect, assuming that it's sorted. 99160751d7a069fb540aa468068f792fb6f4999832dBrian Osman SkASSERT(orig.isSorted()); 992a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com SkPaint::Style style = this->getStyle(); 993a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com // ultra fast-case: filling with no effects that affect geometry 994a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com if (kFill_Style == style) { 995a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com uintptr_t effects = reinterpret_cast<uintptr_t>(this->getLooper()); 996a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter()); 997a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com effects |= reinterpret_cast<uintptr_t>(this->getPathEffect()); 998336d1d759590d9bedcbc5a96d0fff79861cf8f7asenorblanco@chromium.org effects |= reinterpret_cast<uintptr_t>(this->getImageFilter()); 999a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com if (!effects) { 1000a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com return orig; 1001a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com } 1002a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com } 1003fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 1004a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com return this->doComputeFastBounds(orig, storage, style); 1005a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com } 1006fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 1007a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com const SkRect& computeFastStrokeBounds(const SkRect& orig, 1008a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com SkRect* storage) const { 100973a025811c202fee3248bc7756fba6deb79bfdd1reed@google.com return this->doComputeFastBounds(orig, storage, kStroke_Style); 1010a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com } 1011fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 1012a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com // Take the style explicitly, so the caller can force us to be stroked 1013a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com // without having to make a copy of the paint just to change that field. 1014a584aed5f709ff9655fd3326e23cd6f602ac7ae4reed@google.com const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage, 10150418a888d31689f5358b6b90fd09287aeba368dbCary Clark Style style) const; 10160418a888d31689f5358b6b90fd09287aeba368dbCary Clark 1017fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 1018d936f63c35fb7dfb2b6c20802206adbfc3cc48d0benjaminwagner 10190f10f7bf1fb43ca6346dc220a076773b1f19a367commit-bot@chromium.org SK_TO_STRING_NONVIRT() 1020791f12e6cf558e0dd1689fbb0a6b5eddac9f42adrobertphillips@google.com 1021d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.comprivate: 10220418a888d31689f5358b6b90fd09287aeba368dbCary Clark typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**); 10230418a888d31689f5358b6b90fd09287aeba368dbCary Clark 1024a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed sk_sp<SkTypeface> fTypeface; 1025a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed sk_sp<SkPathEffect> fPathEffect; 1026a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed sk_sp<SkShader> fShader; 1027a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed sk_sp<SkMaskFilter> fMaskFilter; 1028a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed sk_sp<SkColorFilter> fColorFilter; 1029a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed sk_sp<SkRasterizer> fRasterizer; 103046f2d0ad0d0e4f4cf0e7d6f158b3fb9fe4f615fareed sk_sp<SkDrawLooper> fDrawLooper; 1031a5ab9ec295b2e6dca166775a98db67a9a8c18c37reed sk_sp<SkImageFilter> fImageFilter; 1032d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com 1033e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org SkScalar fTextSize; 1034e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org SkScalar fTextScaleX; 1035e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org SkScalar fTextSkewX; 1036d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com SkColor fColor; 1037d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com SkScalar fWidth; 1038d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com SkScalar fMiterLimit; 103971fecc32b1b4f71ef3c6467b1f5e0b55c2a12428Mike Reed uint32_t fBlendMode; // just need 5-6 bits 1040aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org union { 1041aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org struct { 1042aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org // all of these bitfields should add up to 32 1043aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org unsigned fFlags : 16; 1044aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org unsigned fTextAlign : 2; 1045aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org unsigned fCapType : 2; 1046aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org unsigned fJoinType : 2; 1047aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org unsigned fStyle : 2; 1048aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org unsigned fTextEncoding : 2; // 3 values 1049aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org unsigned fHinting : 2; 1050f803da12cff1d9b6148fea319220351efebfd1e0reed unsigned fFilterQuality : 2; 105185faf50875fcf6008880a98aaa05d12ae8dad343commit-bot@chromium.org //unsigned fFreeBits : 2; 1052f59eab269350f36a0c2bf98d1c2a9757c77fc473reed } fBitfields; 1053f59eab269350f36a0c2bf98d1c2a9757c77fc473reed uint32_t fBitfieldsUInt; 1054aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org }; 1055e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org 1056e34f17d23699abfc672289f51319b37294b3c257robertphillips static GlyphCacheProc GetGlyphCacheProc(TextEncoding encoding, 1057e34f17d23699abfc672289f51319b37294b3c257robertphillips bool isDevKern, 1058e34f17d23699abfc672289f51319b37294b3c257robertphillips bool needFullMetrics); 1059d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com 1060d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com SkScalar measure_text(SkGlyphCache*, const char* text, size_t length, 1061d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com int* count, SkRect* bounds) const; 1062d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com 1063a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman enum ScalerContextFlags : uint32_t { 1064a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman kNone_ScalerContextFlags = 0, 1065a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman 1066a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman kFakeGamma_ScalerContextFlag = 1 << 0, 1067a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman kBoostContrast_ScalerContextFlag = 1 << 1, 1068a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman 1069a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman kFakeGammaAndBoostContrast_ScalerContextFlags = 1070a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman kFakeGamma_ScalerContextFlag | kBoostContrast_ScalerContextFlag, 1071f6d1e605317917146362706ed460b5ed6624fcc5bungeman }; 1072f6d1e605317917146362706ed460b5ed6624fcc5bungeman 1073fd45079314b739979492601fc7a242aff24c58a3joshualitt /* 1074fd45079314b739979492601fc7a242aff24c58a3joshualitt * Allocs an SkDescriptor on the heap and return it to the caller as a refcnted 1075fd45079314b739979492601fc7a242aff24c58a3joshualitt * SkData. Caller is responsible for managing the lifetime of this object. 1076fd45079314b739979492601fc7a242aff24c58a3joshualitt */ 1077a9322c2d86aaef1085c267dfc43cf0747f170a86reed void getScalerContextDescriptor(SkScalerContextEffects*, SkAutoDescriptor*, 1078a9322c2d86aaef1085c267dfc43cf0747f170a86reed const SkSurfaceProps& surfaceProps, 1079a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman uint32_t scalerContextFlags, const SkMatrix*) const; 1080fd45079314b739979492601fc7a242aff24c58a3joshualitt 1081a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman SkGlyphCache* detachCache(const SkSurfaceProps* surfaceProps, uint32_t scalerContextFlags, 1082f6d1e605317917146362706ed460b5ed6624fcc5bungeman const SkMatrix*) const; 1083d5f20797e1f4781b8a0e5baa55ecaaf68fa7980breed@google.com 1084a1e8f8d8f1a0b7141136d7d49df1cc2fec0528dfbrianosman void descriptorProc(const SkSurfaceProps* surfaceProps, uint32_t scalerContextFlags, 1085f6d1e605317917146362706ed460b5ed6624fcc5bungeman const SkMatrix* deviceMatrix, 1086a9322c2d86aaef1085c267dfc43cf0747f170a86reed void (*proc)(SkTypeface*, const SkScalerContextEffects&, 1087a9322c2d86aaef1085c267dfc43cf0747f170a86reed const SkDescriptor*, void*), 1088f6d1e605317917146362706ed460b5ed6624fcc5bungeman void* context) const; 1089d252db03d9650013b545ef9781fe993c07f8f314reed@android.com 10909e36c1a9306f052331550dab4728b9875127bfb5joshualitt /* 10919e36c1a9306f052331550dab4728b9875127bfb5joshualitt * The luminance color is used to determine which Gamma Canonical color to map to. This is 10929e36c1a9306f052331550dab4728b9875127bfb5joshualitt * really only used by backends which want to cache glyph masks, and need some way to know if 10939e36c1a9306f052331550dab4728b9875127bfb5joshualitt * they need to generate new masks based off a given color. 10949e36c1a9306f052331550dab4728b9875127bfb5joshualitt */ 10959e36c1a9306f052331550dab4728b9875127bfb5joshualitt SkColor computeLuminanceColor() const; 10969e36c1a9306f052331550dab4728b9875127bfb5joshualitt 10978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com enum { 1098ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com /* This is the size we use when we ask for a glyph's path. We then 1099ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * post-transform it as we draw to match the request. 1100ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * This is done to try to re-use cache entries for the path. 1101ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * 1102ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * This value is somewhat arbitrary. In theory, it could be 1, since 1103ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * we store paths as floats. However, we get the path from the font 1104ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * scaler, and it may represent its paths as fixed-point (or 26.6), 1105ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * so we shouldn't ask for something too big (might overflow 16.16) 1106ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * or too small (underflow 26.6). 1107ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * 1108ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * This value could track kMaxSizeForGlyphCache, assuming the above 1109ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * constraints, but since we ask for unhinted paths, the two values 1110ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com * need not match per-se. 1111ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com */ 1112ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com kCanonicalTextSizeForPaths = 64, 11138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com }; 1114ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com 1115ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM); 1116ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com 1117ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com // Set flags/hinting/textSize up to use for drawing text as paths. 1118ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com // Returns scale factor to restore the original textSize, since will will 1119ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com // have change it to kCanonicalTextSizeForPaths. 1120ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com SkScalar setupForAsPaths(); 1121ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com 1122d5bee5d50c60eedda697ac305658d3817125e147Mike Reed static SkScalar MaxCacheSize2(); 1123ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com 112428be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org friend class SkAutoGlyphCache; 11252d2a68c51b4a71bd60760510bf2b2e58bc9890b2jvanverth friend class SkAutoGlyphCacheNoGamma; 11268a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkCanvas; 11278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com friend class SkDraw; 112828be72b63e457c680c192a34fb9f58e1c693363fvandebo@chromium.org friend class SkPDFDevice; 1129e76b4bb3ae03ae85119055eac44f2721578e8202joshualitt friend class GrAtlasTextBlob; 1130dbd3593e0b0cfb04f23b9d7bce623e6e32364b3fjoshualitt friend class GrAtlasTextContext; 1131c6cb56f36c4aad8ed45486a3bb4de614bb822f1bkkinnunen friend class GrStencilAndCoverTextContext; 1132855d83ff79c6c822b2ad653f2f890178ad0f637bcdalton friend class GrPathRendering; 11330a42e6827b178468105343ffdf40b011b7ba283cjoshualitt friend class GrTextUtils; 1134855d83ff79c6c822b2ad653f2f890178ad0f637bcdalton friend class GrGLPathRendering; 11359e36c1a9306f052331550dab4728b9875127bfb5joshualitt friend class SkScalerContext; 11360449bcfb2fa1dd33cb3a4c0c8b17960d17edf01acaryclark friend class SkTextBaseIter; 1137ed43dffbf140cebc0575bed7b4dff1b32430ad21reed@google.com friend class SkCanonicalizePaint; 11388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 11398a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 11408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 1141