2008-12-17 15:59:43 +00:00
|
|
|
/*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Copyright 2006 The Android Open Source Project
|
2008-12-17 15:59:43 +00:00
|
|
|
*
|
2011-07-28 14:26:00 +00:00
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SkPaint_DEFINED
|
|
|
|
#define SkPaint_DEFINED
|
|
|
|
|
2016-10-06 00:33:02 +00:00
|
|
|
#include "SkBlendMode.h"
|
2008-12-17 15:59:43 +00:00
|
|
|
#include "SkColor.h"
|
2015-01-23 13:58:07 +00:00
|
|
|
#include "SkFilterQuality.h"
|
2013-06-04 16:56:27 +00:00
|
|
|
#include "SkMatrix.h"
|
2016-11-18 22:19:54 +00:00
|
|
|
#include "SkRefCnt.h"
|
2009-06-22 17:38:10 +00:00
|
|
|
|
2015-04-01 18:30:27 +00:00
|
|
|
class SkAutoDescriptor;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkAutoGlyphCache;
|
|
|
|
class SkColorFilter;
|
2015-03-13 15:38:43 +00:00
|
|
|
class SkData;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkDescriptor;
|
2015-08-20 18:10:41 +00:00
|
|
|
class SkDrawLooper;
|
2014-01-30 18:58:24 +00:00
|
|
|
class SkReadBuffer;
|
|
|
|
class SkWriteBuffer;
|
2015-02-25 14:47:06 +00:00
|
|
|
class SkGlyph;
|
2008-12-17 15:59:43 +00:00
|
|
|
struct SkRect;
|
|
|
|
class SkGlyphCache;
|
2011-11-03 19:29:08 +00:00
|
|
|
class SkImageFilter;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkMaskFilter;
|
|
|
|
class SkPath;
|
|
|
|
class SkPathEffect;
|
2012-08-07 15:54:32 +00:00
|
|
|
struct SkPoint;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkRasterizer;
|
2016-04-12 13:47:05 +00:00
|
|
|
struct SkScalerContextEffects;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkShader;
|
2015-06-19 18:49:52 +00:00
|
|
|
class SkSurfaceProps;
|
2016-07-28 16:47:24 +00:00
|
|
|
class SkTextBlob;
|
2008-12-17 15:59:43 +00:00
|
|
|
class SkTypeface;
|
|
|
|
|
|
|
|
/** \class SkPaint
|
|
|
|
|
|
|
|
The SkPaint class holds the style and color information about how to draw
|
|
|
|
geometries, text and bitmaps.
|
|
|
|
*/
|
2011-03-15 21:27:08 +00:00
|
|
|
class SK_API SkPaint {
|
2008-12-17 15:59:43 +00:00
|
|
|
public:
|
|
|
|
SkPaint();
|
|
|
|
SkPaint(const SkPaint& paint);
|
2016-02-07 22:37:23 +00:00
|
|
|
SkPaint(SkPaint&& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
~SkPaint();
|
|
|
|
|
2017-05-10 13:07:42 +00:00
|
|
|
SkPaint& operator=(const SkPaint& paint);
|
|
|
|
SkPaint& operator=(SkPaint&& paint);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2014-08-25 17:10:47 +00:00
|
|
|
/** operator== may give false negatives: two paints that draw equivalently
|
|
|
|
may return false. It will never give false positives: two paints that
|
|
|
|
are not equivalent always return false.
|
|
|
|
*/
|
2017-05-18 19:27:57 +00:00
|
|
|
// cc_unittests requires SK_API to make operator== visible
|
2013-08-07 22:36:29 +00:00
|
|
|
SK_API friend bool operator==(const SkPaint& a, const SkPaint& b);
|
|
|
|
friend bool operator!=(const SkPaint& a, const SkPaint& b) {
|
|
|
|
return !(a == b);
|
|
|
|
}
|
|
|
|
|
2014-10-07 16:26:10 +00:00
|
|
|
/** getHash() is a shallow hash, with the same limitations as operator==.
|
|
|
|
* If operator== returns true for two paints, getHash() returns the same value for each.
|
|
|
|
*/
|
|
|
|
uint32_t getHash() const;
|
|
|
|
|
2017-05-10 13:07:42 +00:00
|
|
|
void flatten(SkWriteBuffer& buffer) const;
|
|
|
|
void unflatten(SkReadBuffer& buffer);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Restores the paint to its initial settings.
|
|
|
|
*/
|
|
|
|
void reset();
|
|
|
|
|
2009-07-21 17:41:32 +00:00
|
|
|
/** Specifies the level of hinting to be performed. These names are taken
|
|
|
|
from the Gnome/Cairo names for the same. They are translated into
|
|
|
|
Freetype concepts the same as in cairo-ft-font.c:
|
|
|
|
kNo_Hinting -> FT_LOAD_NO_HINTING
|
|
|
|
kSlight_Hinting -> FT_LOAD_TARGET_LIGHT
|
|
|
|
kNormal_Hinting -> <default, no option>
|
|
|
|
kFull_Hinting -> <same as kNormalHinting, unless we are rendering
|
|
|
|
subpixel glyphs, in which case TARGET_LCD or
|
|
|
|
TARGET_LCD_V is used>
|
|
|
|
*/
|
|
|
|
enum Hinting {
|
|
|
|
kNo_Hinting = 0,
|
|
|
|
kSlight_Hinting = 1,
|
|
|
|
kNormal_Hinting = 2, //!< this is the default
|
2012-06-01 13:15:47 +00:00
|
|
|
kFull_Hinting = 3
|
2009-07-21 17:41:32 +00:00
|
|
|
};
|
|
|
|
|
2011-03-16 20:02:59 +00:00
|
|
|
Hinting getHinting() const {
|
2014-07-14 21:39:15 +00:00
|
|
|
return static_cast<Hinting>(fBitfields.fHinting);
|
2009-07-21 17:41:32 +00:00
|
|
|
}
|
|
|
|
|
2011-04-15 13:41:26 +00:00
|
|
|
void setHinting(Hinting hintingLevel);
|
2009-07-21 17:41:32 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Specifies the bit values that are stored in the paint's flags.
|
|
|
|
*/
|
|
|
|
enum Flags {
|
|
|
|
kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing
|
2017-05-09 16:20:02 +00:00
|
|
|
kDither_Flag = 0x04, //!< mask to enable dithering. see setDither()
|
2008-12-17 15:59:43 +00:00
|
|
|
kFakeBoldText_Flag = 0x20, //!< mask to enable fake-bold text
|
|
|
|
kLinearText_Flag = 0x40, //!< mask to enable linear-text
|
2009-07-21 17:41:32 +00:00
|
|
|
kSubpixelText_Flag = 0x80, //!< mask to enable subpixel text positioning
|
2008-12-17 15:59:43 +00:00
|
|
|
kDevKernText_Flag = 0x100, //!< mask to enable device kerning text
|
2009-07-21 17:41:32 +00:00
|
|
|
kLCDRenderText_Flag = 0x200, //!< mask to enable subpixel glyph renderering
|
2010-01-04 18:27:55 +00:00
|
|
|
kEmbeddedBitmapText_Flag = 0x400, //!< mask to enable embedded bitmap strikes
|
2010-06-17 20:49:17 +00:00
|
|
|
kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter
|
2011-11-10 15:20:49 +00:00
|
|
|
kVerticalText_Flag = 0x1000,
|
2012-01-18 17:06:35 +00:00
|
|
|
kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it
|
2009-07-21 17:41:32 +00:00
|
|
|
// when adding extra flags, note that the fFlags member is specified
|
|
|
|
// with a bit-width and you'll have to expand it.
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2017-02-23 14:19:35 +00:00
|
|
|
kAllFlags = 0xFFFF,
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
2017-02-21 20:07:44 +00:00
|
|
|
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
|
|
|
enum ReserveFlags {
|
|
|
|
// These are not used by paint, but the bits are reserved for private use by the
|
|
|
|
// android framework.
|
|
|
|
kUnderlineText_ReserveFlag = 0x08, //!< mask to enable underline text
|
|
|
|
kStrikeThruText_ReserveFlag = 0x10, //!< mask to enable strike-thru text
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the paint's flags. Use the Flag enum to test flag values.
|
|
|
|
@return the paint's flags (see enums ending in _Flag for bit masks)
|
|
|
|
*/
|
2014-07-14 21:39:15 +00:00
|
|
|
uint32_t getFlags() const { return fBitfields.fFlags; }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set the paint's flags. Use the Flag enum to specific flag values.
|
|
|
|
@param flags The new flag bits for the paint (see Flags enum)
|
|
|
|
*/
|
|
|
|
void setFlags(uint32_t flags);
|
|
|
|
|
|
|
|
/** Helper for getFlags(), returning true if kAntiAlias_Flag bit is set
|
|
|
|
@return true if the antialias bit is set in the paint's flags.
|
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isAntiAlias() const {
|
2008-12-17 15:59:43 +00:00
|
|
|
return SkToBool(this->getFlags() & kAntiAlias_Flag);
|
|
|
|
}
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Helper for setFlags(), setting or clearing the kAntiAlias_Flag bit
|
|
|
|
@param aa true to enable antialiasing, false to disable it
|
|
|
|
*/
|
|
|
|
void setAntiAlias(bool aa);
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Helper for getFlags(), returning true if kDither_Flag bit is set
|
|
|
|
@return true if the dithering bit is set in the paint's flags.
|
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isDither() const {
|
2008-12-17 15:59:43 +00:00
|
|
|
return SkToBool(this->getFlags() & kDither_Flag);
|
|
|
|
}
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2017-05-09 16:20:02 +00:00
|
|
|
/**
|
|
|
|
* Helper for setFlags(), setting or clearing the kDither_Flag bit
|
|
|
|
* @param dither true to enable dithering, false to disable it
|
|
|
|
*
|
|
|
|
* Note: gradients ignore this setting and always dither.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void setDither(bool dither);
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Helper for getFlags(), returning true if kLinearText_Flag bit is set
|
|
|
|
@return true if the lineartext bit is set in the paint's flags
|
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isLinearText() const {
|
2008-12-17 15:59:43 +00:00
|
|
|
return SkToBool(this->getFlags() & kLinearText_Flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Helper for setFlags(), setting or clearing the kLinearText_Flag bit
|
|
|
|
@param linearText true to set the linearText bit in the paint's flags,
|
|
|
|
false to clear it.
|
|
|
|
*/
|
|
|
|
void setLinearText(bool linearText);
|
|
|
|
|
|
|
|
/** Helper for getFlags(), returning true if kSubpixelText_Flag bit is set
|
|
|
|
@return true if the lineartext bit is set in the paint's flags
|
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isSubpixelText() const {
|
2008-12-17 15:59:43 +00:00
|
|
|
return SkToBool(this->getFlags() & kSubpixelText_Flag);
|
|
|
|
}
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2011-08-01 12:45:35 +00:00
|
|
|
/**
|
|
|
|
* Helper for setFlags(), setting or clearing the kSubpixelText_Flag.
|
|
|
|
* @param subpixelText true to set the subpixelText bit in the paint's
|
|
|
|
* flags, false to clear it.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void setSubpixelText(bool subpixelText);
|
2009-07-21 17:41:32 +00:00
|
|
|
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isLCDRenderText() const {
|
2009-07-21 17:41:32 +00:00
|
|
|
return SkToBool(this->getFlags() & kLCDRenderText_Flag);
|
|
|
|
}
|
|
|
|
|
2011-08-01 12:45:35 +00:00
|
|
|
/**
|
|
|
|
* Helper for setFlags(), setting or clearing the kLCDRenderText_Flag.
|
|
|
|
* Note: antialiasing must also be on for lcd rendering
|
|
|
|
* @param lcdText true to set the LCDRenderText bit in the paint's flags,
|
|
|
|
* false to clear it.
|
|
|
|
*/
|
|
|
|
void setLCDRenderText(bool lcdText);
|
2009-07-21 17:41:32 +00:00
|
|
|
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isEmbeddedBitmapText() const {
|
2010-01-04 18:27:55 +00:00
|
|
|
return SkToBool(this->getFlags() & kEmbeddedBitmapText_Flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Helper for setFlags(), setting or clearing the kEmbeddedBitmapText_Flag bit
|
|
|
|
@param useEmbeddedBitmapText true to set the kEmbeddedBitmapText bit in the paint's flags,
|
|
|
|
false to clear it.
|
|
|
|
*/
|
|
|
|
void setEmbeddedBitmapText(bool useEmbeddedBitmapText);
|
|
|
|
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isAutohinted() const {
|
2010-06-17 20:49:17 +00:00
|
|
|
return SkToBool(this->getFlags() & kAutoHinting_Flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Helper for setFlags(), setting or clearing the kAutoHinting_Flag bit
|
|
|
|
@param useAutohinter true to set the kEmbeddedBitmapText bit in the
|
|
|
|
paint's flags,
|
|
|
|
false to clear it.
|
|
|
|
*/
|
|
|
|
void setAutohinted(bool useAutohinter);
|
|
|
|
|
2011-11-10 15:20:49 +00:00
|
|
|
bool isVerticalText() const {
|
|
|
|
return SkToBool(this->getFlags() & kVerticalText_Flag);
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2011-11-10 15:20:49 +00:00
|
|
|
/**
|
|
|
|
* Helper for setting or clearing the kVerticalText_Flag bit in
|
|
|
|
* setFlags(...).
|
|
|
|
*
|
|
|
|
* If this bit is set, then advances are treated as Y values rather than
|
|
|
|
* X values, and drawText will places its glyphs vertically rather than
|
|
|
|
* horizontally.
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setVerticalText(bool verticalText);
|
2011-11-10 15:20:49 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Helper for getFlags(), returns true if kFakeBoldText_Flag bit is set
|
|
|
|
@return true if the kFakeBoldText_Flag bit is set in the paint's flags.
|
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isFakeBoldText() const {
|
2008-12-17 15:59:43 +00:00
|
|
|
return SkToBool(this->getFlags() & kFakeBoldText_Flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Helper for setFlags(), setting or clearing the kFakeBoldText_Flag bit
|
|
|
|
@param fakeBoldText true to set the kFakeBoldText_Flag bit in the paint's
|
|
|
|
flags, false to clear it.
|
|
|
|
*/
|
|
|
|
void setFakeBoldText(bool fakeBoldText);
|
|
|
|
|
|
|
|
/** Helper for getFlags(), returns true if kDevKernText_Flag bit is set
|
|
|
|
@return true if the kernText bit is set in the paint's flags.
|
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
bool isDevKernText() const {
|
2008-12-17 15:59:43 +00:00
|
|
|
return SkToBool(this->getFlags() & kDevKernText_Flag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Helper for setFlags(), setting or clearing the kKernText_Flag bit
|
|
|
|
@param kernText true to set the kKernText_Flag bit in the paint's
|
|
|
|
flags, false to clear it.
|
|
|
|
*/
|
|
|
|
void setDevKernText(bool devKernText);
|
|
|
|
|
2015-01-23 13:58:07 +00:00
|
|
|
/**
|
|
|
|
* Return the filter level. This affects the quality (and performance) of
|
|
|
|
* drawing scaled images.
|
|
|
|
*/
|
|
|
|
SkFilterQuality getFilterQuality() const {
|
|
|
|
return (SkFilterQuality)fBitfields.fFilterQuality;
|
|
|
|
}
|
2015-09-09 14:35:42 +00:00
|
|
|
|
2015-01-23 13:58:07 +00:00
|
|
|
/**
|
|
|
|
* Set the filter quality. This affects the quality (and performance) of
|
|
|
|
* drawing scaled images.
|
|
|
|
*/
|
|
|
|
void setFilterQuality(SkFilterQuality quality);
|
2013-07-18 13:47:01 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Styles apply to rect, oval, path, and text.
|
|
|
|
Bitmaps are always drawn in "fill", and lines are always drawn in
|
|
|
|
"stroke".
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2009-09-15 14:10:42 +00:00
|
|
|
Note: strokeandfill implicitly draws the result with
|
|
|
|
SkPath::kWinding_FillType, so if the original path is even-odd, the
|
|
|
|
results may not appear the same as if it was drawn twice, filled and
|
|
|
|
then stroked.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
enum Style {
|
2009-09-15 14:10:42 +00:00
|
|
|
kFill_Style, //!< fill the geometry
|
|
|
|
kStroke_Style, //!< stroke the geometry
|
|
|
|
kStrokeAndFill_Style, //!< fill and stroke the geometry
|
2013-02-04 05:17:10 +00:00
|
|
|
};
|
|
|
|
enum {
|
|
|
|
kStyleCount = kStrokeAndFill_Style + 1
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/** Return the paint's style, used for controlling how primitives'
|
|
|
|
geometries are interpreted (except for drawBitmap, which always assumes
|
|
|
|
kFill_Style).
|
|
|
|
@return the paint's Style
|
|
|
|
*/
|
2014-07-14 21:39:15 +00:00
|
|
|
Style getStyle() const { return (Style)fBitfields.fStyle; }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set the paint's style, used for controlling how primitives'
|
|
|
|
geometries are interpreted (except for drawBitmap, which always assumes
|
|
|
|
Fill).
|
|
|
|
@param style The new style to set in the paint
|
|
|
|
*/
|
|
|
|
void setStyle(Style style);
|
|
|
|
|
|
|
|
/** Return the paint's color. Note that the color is a 32bit value
|
|
|
|
containing alpha as well as r,g,b. This 32bit value is not
|
|
|
|
premultiplied, meaning that its alpha can be any value, regardless of
|
|
|
|
the values of r,g,b.
|
|
|
|
@return the paint's color (and alpha).
|
|
|
|
*/
|
|
|
|
SkColor getColor() const { return fColor; }
|
|
|
|
|
|
|
|
/** Set the paint's color. Note that the color is a 32bit value containing
|
|
|
|
alpha as well as r,g,b. This 32bit value is not premultiplied, meaning
|
|
|
|
that its alpha can be any value, regardless of the values of r,g,b.
|
|
|
|
@param color The new color (including alpha) to set in the paint.
|
|
|
|
*/
|
|
|
|
void setColor(SkColor color);
|
|
|
|
|
|
|
|
/** Helper to getColor() that just returns the color's alpha value.
|
|
|
|
@return the alpha component of the paint's color.
|
|
|
|
*/
|
|
|
|
uint8_t getAlpha() const { return SkToU8(SkColorGetA(fColor)); }
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Helper to setColor(), that only assigns the color's alpha value,
|
|
|
|
leaving its r,g,b values unchanged.
|
|
|
|
@param a set the alpha component (0..255) of the paint's color.
|
|
|
|
*/
|
|
|
|
void setAlpha(U8CPU a);
|
|
|
|
|
|
|
|
/** Helper to setColor(), that takes a,r,g,b and constructs the color value
|
|
|
|
using SkColorSetARGB()
|
|
|
|
@param a The new alpha component (0..255) of the paint's color.
|
|
|
|
@param r The new red component (0..255) of the paint's color.
|
|
|
|
@param g The new green component (0..255) of the paint's color.
|
|
|
|
@param b The new blue component (0..255) of the paint's color.
|
|
|
|
*/
|
|
|
|
void setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b);
|
|
|
|
|
2011-03-16 20:02:59 +00:00
|
|
|
/** Return the width for stroking.
|
2008-12-17 15:59:43 +00:00
|
|
|
<p />
|
|
|
|
A value of 0 strokes in hairline mode.
|
|
|
|
Hairlines always draw 1-pixel wide, regardless of the matrix.
|
|
|
|
@return the paint's stroke width, used whenever the paint's style is
|
|
|
|
Stroke or StrokeAndFill.
|
|
|
|
*/
|
|
|
|
SkScalar getStrokeWidth() const { return fWidth; }
|
|
|
|
|
2011-03-16 20:02:59 +00:00
|
|
|
/** Set the width for stroking.
|
2008-12-17 15:59:43 +00:00
|
|
|
Pass 0 to stroke in hairline mode.
|
|
|
|
Hairlines always draw 1-pixel wide, regardless of the matrix.
|
|
|
|
@param width set the paint's stroke width, used whenever the paint's
|
|
|
|
style is Stroke or StrokeAndFill.
|
|
|
|
*/
|
|
|
|
void setStrokeWidth(SkScalar width);
|
|
|
|
|
|
|
|
/** Return the paint's stroke miter value. This is used to control the
|
|
|
|
behavior of miter joins when the joins angle is sharp.
|
|
|
|
@return the paint's miter limit, used whenever the paint's style is
|
|
|
|
Stroke or StrokeAndFill.
|
|
|
|
*/
|
|
|
|
SkScalar getStrokeMiter() const { return fMiterLimit; }
|
|
|
|
|
|
|
|
/** Set the paint's stroke miter value. This is used to control the
|
|
|
|
behavior of miter joins when the joins angle is sharp. This value must
|
|
|
|
be >= 0.
|
|
|
|
@param miter set the miter limit on the paint, used whenever the
|
|
|
|
paint's style is Stroke or StrokeAndFill.
|
|
|
|
*/
|
|
|
|
void setStrokeMiter(SkScalar miter);
|
|
|
|
|
|
|
|
/** Cap enum specifies the settings for the paint's strokecap. This is the
|
|
|
|
treatment that is applied to the beginning and end of each non-closed
|
|
|
|
contour (e.g. lines).
|
2015-08-26 16:04:55 +00:00
|
|
|
|
|
|
|
If the cap is round or square, the caps are drawn when the contour has
|
|
|
|
a zero length. Zero length contours can be created by following moveTo
|
|
|
|
with a lineTo at the same point, or a moveTo followed by a close.
|
|
|
|
|
|
|
|
A dash with an on interval of zero also creates a zero length contour.
|
|
|
|
|
|
|
|
The zero length contour draws the square cap without rotation, since
|
|
|
|
the no direction can be inferred.
|
2008-12-17 15:59:43 +00:00
|
|
|
*/
|
|
|
|
enum Cap {
|
|
|
|
kButt_Cap, //!< begin/end contours with no extension
|
|
|
|
kRound_Cap, //!< begin/end contours with a semi-circle extension
|
|
|
|
kSquare_Cap, //!< begin/end contours with a half square extension
|
|
|
|
|
2016-07-06 18:54:59 +00:00
|
|
|
kLast_Cap = kSquare_Cap,
|
2008-12-17 15:59:43 +00:00
|
|
|
kDefault_Cap = kButt_Cap
|
|
|
|
};
|
2016-07-06 18:54:59 +00:00
|
|
|
static constexpr int kCapCount = kLast_Cap + 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Join enum specifies the settings for the paint's strokejoin. This is
|
|
|
|
the treatment that is applied to corners in paths and rectangles.
|
|
|
|
*/
|
|
|
|
enum Join {
|
|
|
|
kMiter_Join, //!< connect path segments with a sharp join
|
|
|
|
kRound_Join, //!< connect path segments with a round join
|
|
|
|
kBevel_Join, //!< connect path segments with a flat bevel join
|
|
|
|
|
2016-07-06 18:54:59 +00:00
|
|
|
kLast_Join = kBevel_Join,
|
2008-12-17 15:59:43 +00:00
|
|
|
kDefault_Join = kMiter_Join
|
|
|
|
};
|
2016-07-06 18:54:59 +00:00
|
|
|
static constexpr int kJoinCount = kLast_Join + 1;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Return the paint's stroke cap type, controlling how the start and end
|
|
|
|
of stroked lines and paths are treated.
|
|
|
|
@return the line cap style for the paint, used whenever the paint's
|
|
|
|
style is Stroke or StrokeAndFill.
|
|
|
|
*/
|
2014-07-14 21:39:15 +00:00
|
|
|
Cap getStrokeCap() const { return (Cap)fBitfields.fCapType; }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set the paint's stroke cap type.
|
|
|
|
@param cap set the paint's line cap style, used whenever the paint's
|
|
|
|
style is Stroke or StrokeAndFill.
|
|
|
|
*/
|
|
|
|
void setStrokeCap(Cap cap);
|
|
|
|
|
|
|
|
/** Return the paint's stroke join type.
|
|
|
|
@return the paint's line join style, used whenever the paint's style is
|
|
|
|
Stroke or StrokeAndFill.
|
|
|
|
*/
|
2014-07-14 21:39:15 +00:00
|
|
|
Join getStrokeJoin() const { return (Join)fBitfields.fJoinType; }
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set the paint's stroke join type.
|
|
|
|
@param join set the paint's line join style, used whenever the paint's
|
|
|
|
style is Stroke or StrokeAndFill.
|
|
|
|
*/
|
|
|
|
void setStrokeJoin(Join join);
|
|
|
|
|
2013-01-24 21:03:11 +00:00
|
|
|
/**
|
|
|
|
* Applies any/all effects (patheffect, stroking) to src, returning the
|
|
|
|
* result in dst. The result is that drawing src with this paint will be
|
|
|
|
* the same as drawing dst with a default paint (at least from the
|
|
|
|
* geometric perspective).
|
|
|
|
*
|
|
|
|
* @param src input path
|
|
|
|
* @param dst output path (may be the same as src)
|
|
|
|
* @param cullRect If not null, the dst path may be culled to this rect.
|
2015-02-12 21:35:52 +00:00
|
|
|
* @param resScale If > 1, increase precision, else if (0 < res < 1) reduce precision
|
|
|
|
* in favor of speed/size.
|
2013-01-24 21:03:11 +00:00
|
|
|
* @return true if the path should be filled, or false if it should be
|
|
|
|
* drawn with a hairline (width == 0)
|
|
|
|
*/
|
2015-02-12 21:35:52 +00:00
|
|
|
bool getFillPath(const SkPath& src, SkPath* dst, const SkRect* cullRect,
|
|
|
|
SkScalar resScale = 1) const;
|
|
|
|
|
|
|
|
bool getFillPath(const SkPath& src, SkPath* dst) const {
|
|
|
|
return this->getFillPath(src, dst, NULL, 1);
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Get the paint's shader object.
|
|
|
|
<p />
|
|
|
|
The shader's reference count is not affected.
|
|
|
|
@return the paint's shader (or NULL)
|
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkShader* getShader() const { return fShader.get(); }
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkShader> refShader() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set or clear the shader object.
|
2012-05-11 14:47:03 +00:00
|
|
|
* Shaders specify the source color(s) for what is being drawn. If a paint
|
|
|
|
* has no shader, then the paint's color is used. If the paint has a
|
|
|
|
* shader, then the shader's color(s) are use instead, but they are
|
|
|
|
* modulated by the paint's alpha. This makes it easy to create a shader
|
|
|
|
* once (e.g. bitmap tiling or gradient) and then change its transparency
|
|
|
|
* w/o having to modify the original shader... only the paint's alpha needs
|
|
|
|
* to be modified.
|
2014-03-18 16:28:12 +00:00
|
|
|
*
|
|
|
|
* There is an exception to this only-respect-paint's-alpha rule: If the shader only generates
|
|
|
|
* alpha (e.g. SkShader::CreateBitmapShader(bitmap, ...) where bitmap's colortype is kAlpha_8)
|
|
|
|
* then the shader will use the paint's entire color to "colorize" its output (modulating the
|
|
|
|
* bitmap's alpha with the paint's color+alpha).
|
|
|
|
*
|
2012-05-11 14:47:03 +00:00
|
|
|
* Pass NULL to clear any previous shader.
|
|
|
|
* As a convenience, the parameter passed is also returned.
|
|
|
|
* If a previous shader exists, its reference count is decremented.
|
|
|
|
* If shader is not NULL, its reference count is incremented.
|
|
|
|
* @param shader May be NULL. The shader to be installed in the paint
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setShader(sk_sp<SkShader> shader);
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Get the paint's colorfilter. If there is a colorfilter, its reference
|
|
|
|
count is not changed.
|
|
|
|
@return the paint's colorfilter (or NULL)
|
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkColorFilter* getColorFilter() const { return fColorFilter.get(); }
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkColorFilter> refColorFilter() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2016-10-20 20:40:26 +00:00
|
|
|
/** Set or clear the paint's colorfilter.
|
2008-12-17 15:59:43 +00:00
|
|
|
<p />
|
|
|
|
If the paint already has a filter, its reference count is decremented.
|
|
|
|
If filter is not NULL, its reference count is incremented.
|
|
|
|
@param filter May be NULL. The filter to be installed in the paint
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setColorFilter(sk_sp<SkColorFilter> colorFilter);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2016-10-06 00:33:02 +00:00
|
|
|
SkBlendMode getBlendMode() const { return (SkBlendMode)fBlendMode; }
|
|
|
|
bool isSrcOver() const { return (SkBlendMode)fBlendMode == SkBlendMode::kSrcOver; }
|
|
|
|
void setBlendMode(SkBlendMode mode) { fBlendMode = (unsigned)mode; }
|
2009-06-22 17:38:10 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Get the paint's patheffect object.
|
|
|
|
<p />
|
|
|
|
The patheffect reference count is not affected.
|
|
|
|
@return the paint's patheffect (or NULL)
|
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkPathEffect* getPathEffect() const { return fPathEffect.get(); }
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkPathEffect> refPathEffect() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set or clear the patheffect object.
|
|
|
|
<p />
|
|
|
|
Pass NULL to clear any previous patheffect.
|
|
|
|
As a convenience, the parameter passed is also returned.
|
|
|
|
If a previous patheffect exists, its reference count is decremented.
|
|
|
|
If patheffect is not NULL, its reference count is incremented.
|
|
|
|
@param effect May be NULL. The new patheffect to be installed in the
|
|
|
|
paint
|
|
|
|
@return effect
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setPathEffect(sk_sp<SkPathEffect> pathEffect);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Get the paint's maskfilter object.
|
|
|
|
<p />
|
|
|
|
The maskfilter reference count is not affected.
|
|
|
|
@return the paint's maskfilter (or NULL)
|
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkMaskFilter* getMaskFilter() const { return fMaskFilter.get(); }
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkMaskFilter> refMaskFilter() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set or clear the maskfilter object.
|
|
|
|
<p />
|
|
|
|
Pass NULL to clear any previous maskfilter.
|
|
|
|
As a convenience, the parameter passed is also returned.
|
|
|
|
If a previous maskfilter exists, its reference count is decremented.
|
|
|
|
If maskfilter is not NULL, its reference count is incremented.
|
|
|
|
@param maskfilter May be NULL. The new maskfilter to be installed in
|
|
|
|
the paint
|
|
|
|
@return maskfilter
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setMaskFilter(sk_sp<SkMaskFilter> maskFilter);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
// These attributes are for text/fonts
|
|
|
|
|
|
|
|
/** Get the paint's typeface object.
|
|
|
|
<p />
|
|
|
|
The typeface object identifies which font to use when drawing or
|
|
|
|
measuring text. The typeface reference count is not affected.
|
|
|
|
@return the paint's typeface (or NULL)
|
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkTypeface* getTypeface() const { return fTypeface.get(); }
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkTypeface> refTypeface() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set or clear the typeface object.
|
|
|
|
<p />
|
|
|
|
Pass NULL to clear any previous typeface.
|
|
|
|
As a convenience, the parameter passed is also returned.
|
|
|
|
If a previous typeface exists, its reference count is decremented.
|
|
|
|
If typeface is not NULL, its reference count is incremented.
|
|
|
|
@param typeface May be NULL. The new typeface to be installed in the
|
|
|
|
paint
|
|
|
|
@return typeface
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setTypeface(sk_sp<SkTypeface> typeface);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Get the paint's rasterizer (or NULL).
|
|
|
|
<p />
|
|
|
|
The raster controls how paths/text are turned into alpha masks.
|
|
|
|
@return the paint's rasterizer (or NULL)
|
|
|
|
*/
|
2016-03-07 02:10:48 +00:00
|
|
|
SkRasterizer* getRasterizer() const { return fRasterizer.get(); }
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkRasterizer> refRasterizer() const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
/** Set or clear the rasterizer object.
|
|
|
|
<p />
|
|
|
|
Pass NULL to clear any previous rasterizer.
|
|
|
|
As a convenience, the parameter passed is also returned.
|
|
|
|
If a previous rasterizer exists in the paint, its reference count is
|
|
|
|
decremented. If rasterizer is not NULL, its reference count is
|
|
|
|
incremented.
|
|
|
|
@param rasterizer May be NULL. The new rasterizer to be installed in
|
|
|
|
the paint.
|
|
|
|
@return rasterizer
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setRasterizer(sk_sp<SkRasterizer> rasterizer);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2016-03-07 02:10:48 +00:00
|
|
|
SkImageFilter* getImageFilter() const { return fImageFilter.get(); }
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkImageFilter> refImageFilter() const;
|
2017-05-10 13:07:42 +00:00
|
|
|
void setImageFilter(sk_sp<SkImageFilter> imageFilter);
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2011-03-16 20:02:59 +00:00
|
|
|
/**
|
|
|
|
* Return the paint's SkDrawLooper (if any). Does not affect the looper's
|
|
|
|
* reference count.
|
|
|
|
*/
|
2016-09-11 12:40:31 +00:00
|
|
|
SkDrawLooper* getDrawLooper() const { return fDrawLooper.get(); }
|
2017-01-12 15:13:40 +00:00
|
|
|
sk_sp<SkDrawLooper> refDrawLooper() const;
|
|
|
|
|
2016-09-11 12:40:31 +00:00
|
|
|
SkDrawLooper* getLooper() const { return fDrawLooper.get(); }
|
2011-03-16 20:02:59 +00:00
|
|
|
/**
|
|
|
|
* Set or clear the looper object.
|
|
|
|
* <p />
|
|
|
|
* Pass NULL to clear any previous looper.
|
|
|
|
* If a previous looper exists in the paint, its reference count is
|
|
|
|
* decremented. If looper is not NULL, its reference count is
|
|
|
|
* incremented.
|
|
|
|
* @param looper May be NULL. The new looper to be installed in the paint.
|
|
|
|
*/
|
2017-05-10 13:07:42 +00:00
|
|
|
void setDrawLooper(sk_sp<SkDrawLooper> drawLooper);
|
2016-10-31 19:11:04 +00:00
|
|
|
|
2017-05-10 13:07:42 +00:00
|
|
|
void setLooper(sk_sp<SkDrawLooper> drawLooper);
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
enum Align {
|
|
|
|
kLeft_Align,
|
|
|
|
kCenter_Align,
|
|
|
|
kRight_Align,
|
2013-06-08 12:58:19 +00:00
|
|
|
};
|
|
|
|
enum {
|
|
|
|
kAlignCount = 3
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the paint's Align value for drawing text.
|
|
|
|
@return the paint's Align value for drawing text.
|
|
|
|
*/
|
2014-07-14 21:39:15 +00:00
|
|
|
Align getTextAlign() const { return (Align)fBitfields.fTextAlign; }
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Set the paint's text alignment.
|
|
|
|
@param align set the paint's Align value for drawing text.
|
|
|
|
*/
|
|
|
|
void setTextAlign(Align align);
|
|
|
|
|
|
|
|
/** Return the paint's text size.
|
|
|
|
@return the paint's text size.
|
|
|
|
*/
|
|
|
|
SkScalar getTextSize() const { return fTextSize; }
|
|
|
|
|
|
|
|
/** Set the paint's text size. This value must be > 0
|
|
|
|
@param textSize set the paint's text size.
|
|
|
|
*/
|
|
|
|
void setTextSize(SkScalar textSize);
|
|
|
|
|
|
|
|
/** Return the paint's horizontal scale factor for text. The default value
|
|
|
|
is 1.0.
|
|
|
|
@return the paint's scale factor in X for drawing/measuring text
|
|
|
|
*/
|
|
|
|
SkScalar getTextScaleX() const { return fTextScaleX; }
|
|
|
|
|
|
|
|
/** Set the paint's horizontal scale factor for text. The default value
|
|
|
|
is 1.0. Values > 1.0 will stretch the text wider. Values < 1.0 will
|
|
|
|
stretch the text narrower.
|
|
|
|
@param scaleX set the paint's scale factor in X for drawing/measuring
|
|
|
|
text.
|
|
|
|
*/
|
|
|
|
void setTextScaleX(SkScalar scaleX);
|
|
|
|
|
|
|
|
/** Return the paint's horizontal skew factor for text. The default value
|
|
|
|
is 0.
|
|
|
|
@return the paint's skew factor in X for drawing text.
|
|
|
|
*/
|
|
|
|
SkScalar getTextSkewX() const { return fTextSkewX; }
|
|
|
|
|
|
|
|
/** Set the paint's horizontal skew factor for text. The default value
|
|
|
|
is 0. For approximating oblique text, use values around -0.25.
|
|
|
|
@param skewX set the paint's skew factor in X for drawing text.
|
|
|
|
*/
|
|
|
|
void setTextSkewX(SkScalar skewX);
|
|
|
|
|
|
|
|
/** Describes how to interpret the text parameters that are passed to paint
|
|
|
|
methods like measureText() and getTextWidths().
|
|
|
|
*/
|
|
|
|
enum TextEncoding {
|
|
|
|
kUTF8_TextEncoding, //!< the text parameters are UTF8
|
|
|
|
kUTF16_TextEncoding, //!< the text parameters are UTF16
|
2012-03-21 19:46:50 +00:00
|
|
|
kUTF32_TextEncoding, //!< the text parameters are UTF32
|
2008-12-17 15:59:43 +00:00
|
|
|
kGlyphID_TextEncoding //!< the text parameters are glyph indices
|
|
|
|
};
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2014-07-14 21:39:15 +00:00
|
|
|
TextEncoding getTextEncoding() const {
|
|
|
|
return (TextEncoding)fBitfields.fTextEncoding;
|
|
|
|
}
|
2008-12-17 15:59:43 +00:00
|
|
|
|
|
|
|
void setTextEncoding(TextEncoding encoding);
|
|
|
|
|
|
|
|
struct FontMetrics {
|
2014-03-01 20:12:26 +00:00
|
|
|
/** Flags which indicate the confidence level of various metrics.
|
|
|
|
A set flag indicates that the metric may be trusted.
|
|
|
|
*/
|
|
|
|
enum FontMetricsFlags {
|
2017-03-23 18:01:22 +00:00
|
|
|
kUnderlineThicknessIsValid_Flag = 1 << 0,
|
2014-03-01 20:12:26 +00:00
|
|
|
kUnderlinePositionIsValid_Flag = 1 << 1,
|
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t fFlags; //!< Bit field to identify which values are unknown
|
2008-12-17 15:59:43 +00:00
|
|
|
SkScalar fTop; //!< The greatest distance above the baseline for any glyph (will be <= 0)
|
|
|
|
SkScalar fAscent; //!< The recommended distance above the baseline (will be <= 0)
|
|
|
|
SkScalar fDescent; //!< The recommended distance below the baseline (will be >= 0)
|
|
|
|
SkScalar fBottom; //!< The greatest distance below the baseline for any glyph (will be >= 0)
|
|
|
|
SkScalar fLeading; //!< The recommended distance to add between lines of text (will be >= 0)
|
2014-03-01 20:12:26 +00:00
|
|
|
SkScalar fAvgCharWidth; //!< the average character width (>= 0)
|
|
|
|
SkScalar fMaxCharWidth; //!< the max character width (>= 0)
|
2009-04-22 22:09:04 +00:00
|
|
|
SkScalar fXMin; //!< The minimum bounding box x value for all glyphs
|
|
|
|
SkScalar fXMax; //!< The maximum bounding box x value for all glyphs
|
2013-12-16 17:02:39 +00:00
|
|
|
SkScalar fXHeight; //!< The height of an 'x' in px, or 0 if no 'x' in face
|
|
|
|
SkScalar fCapHeight; //!< The cap height (> 0), or 0 if cannot be determined.
|
2014-03-01 20:12:26 +00:00
|
|
|
SkScalar fUnderlineThickness; //!< underline thickness, or 0 if cannot be determined
|
|
|
|
|
|
|
|
/** Underline Position - position of the top of the Underline stroke
|
|
|
|
relative to the baseline, this can have following values
|
|
|
|
- Negative - means underline should be drawn above baseline.
|
|
|
|
- Positive - means below baseline.
|
|
|
|
- Zero - mean underline should be drawn on baseline.
|
|
|
|
*/
|
|
|
|
SkScalar fUnderlinePosition; //!< underline position, or 0 if cannot be determined
|
|
|
|
|
2017-03-23 18:01:22 +00:00
|
|
|
/** If the fontmetrics has a valid underline thickness, return true, and set the
|
2014-03-01 20:12:26 +00:00
|
|
|
thickness param to that value. If it doesn't return false and ignore the
|
|
|
|
thickness param.
|
|
|
|
*/
|
|
|
|
bool hasUnderlineThickness(SkScalar* thickness) const {
|
2017-03-23 18:01:22 +00:00
|
|
|
if (SkToBool(fFlags & kUnderlineThicknessIsValid_Flag)) {
|
2014-03-01 20:12:26 +00:00
|
|
|
*thickness = fUnderlineThickness;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-03-23 18:01:22 +00:00
|
|
|
/** If the fontmetrics has a valid underline position, return true, and set the
|
|
|
|
position param to that value. If it doesn't return false and ignore the
|
|
|
|
position param.
|
2014-03-01 20:12:26 +00:00
|
|
|
*/
|
|
|
|
bool hasUnderlinePosition(SkScalar* position) const {
|
|
|
|
if (SkToBool(fFlags & kUnderlinePositionIsValid_Flag)) {
|
|
|
|
*position = fUnderlinePosition;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the recommend spacing between lines (which will be
|
|
|
|
fDescent - fAscent + fLeading).
|
|
|
|
If metrics is not null, return in it the font metrics for the
|
2011-03-16 20:02:59 +00:00
|
|
|
typeface/pointsize/etc. currently set in the paint.
|
2008-12-17 15:59:43 +00:00
|
|
|
@param metrics If not null, returns the font metrics for the
|
|
|
|
current typeface/pointsize/etc setting in this
|
|
|
|
paint.
|
|
|
|
@param scale If not 0, return width as if the canvas were scaled
|
|
|
|
by this value
|
|
|
|
@param return the recommended spacing between lines
|
|
|
|
*/
|
|
|
|
SkScalar getFontMetrics(FontMetrics* metrics, SkScalar scale = 0) const;
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the recommend line spacing. This will be
|
|
|
|
fDescent - fAscent + fLeading
|
|
|
|
*/
|
|
|
|
SkScalar getFontSpacing() const { return this->getFontMetrics(NULL, 0); }
|
|
|
|
|
|
|
|
/** Convert the specified text into glyph IDs, returning the number of
|
|
|
|
glyphs ID written. If glyphs is NULL, it is ignore and only the count
|
|
|
|
is returned.
|
|
|
|
*/
|
|
|
|
int textToGlyphs(const void* text, size_t byteLength,
|
2016-07-25 14:18:12 +00:00
|
|
|
SkGlyphID glyphs[]) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2010-02-05 17:12:32 +00:00
|
|
|
/** Return true if all of the specified text has a corresponding non-zero
|
|
|
|
glyph ID. If any of the code-points in the text are not supported in
|
|
|
|
the typeface (i.e. the glyph ID would be zero), then return false.
|
|
|
|
|
|
|
|
If the text encoding for the paint is kGlyph_TextEncoding, then this
|
|
|
|
returns true if all of the specified glyph IDs are non-zero.
|
|
|
|
*/
|
|
|
|
bool containsText(const void* text, size_t byteLength) const;
|
|
|
|
|
2010-01-08 14:07:42 +00:00
|
|
|
/** Convert the glyph array into Unichars. Unconvertable glyphs are mapped
|
|
|
|
to zero. Note: this does not look at the text-encoding setting in the
|
|
|
|
paint, only at the typeface.
|
|
|
|
*/
|
2016-07-25 14:18:12 +00:00
|
|
|
void glyphsToUnichars(const SkGlyphID glyphs[], int count, SkUnichar text[]) const;
|
2010-01-08 14:07:42 +00:00
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
/** Return the number of drawable units in the specified text buffer.
|
|
|
|
This looks at the current TextEncoding field of the paint. If you also
|
|
|
|
want to have the text converted into glyph IDs, call textToGlyphs
|
|
|
|
instead.
|
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
int countText(const void* text, size_t byteLength) const {
|
2008-12-17 15:59:43 +00:00
|
|
|
return this->textToGlyphs(text, byteLength, NULL);
|
|
|
|
}
|
|
|
|
|
2011-11-10 20:04:47 +00:00
|
|
|
/** Return the width of the text. This will return the vertical measure
|
|
|
|
* if isVerticalText() is true, in which case the returned value should
|
|
|
|
* be treated has a height instead of a width.
|
|
|
|
*
|
|
|
|
* @param text The text to be measured
|
|
|
|
* @param length Number of bytes of text to measure
|
|
|
|
* @param bounds If not NULL, returns the bounds of the text,
|
|
|
|
* relative to (0, 0).
|
|
|
|
* @return The advance width of the text
|
|
|
|
*/
|
2014-08-26 18:30:01 +00:00
|
|
|
SkScalar measureText(const void* text, size_t length, SkRect* bounds) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-11-10 20:04:47 +00:00
|
|
|
/** Return the width of the text. This will return the vertical measure
|
|
|
|
* if isVerticalText() is true, in which case the returned value should
|
|
|
|
* be treated has a height instead of a width.
|
|
|
|
*
|
|
|
|
* @param text Address of the text
|
|
|
|
* @param length Number of bytes of text to measure
|
2012-05-15 19:25:17 +00:00
|
|
|
* @return The advance width of the text
|
2011-11-10 20:04:47 +00:00
|
|
|
*/
|
2011-03-16 20:02:59 +00:00
|
|
|
SkScalar measureText(const void* text, size_t length) const {
|
2014-08-26 18:30:01 +00:00
|
|
|
return this->measureText(text, length, NULL);
|
2008-12-17 15:59:43 +00:00
|
|
|
}
|
2011-03-16 20:02:59 +00:00
|
|
|
|
2011-11-10 20:04:47 +00:00
|
|
|
/** Return the number of bytes of text that were measured. If
|
|
|
|
* isVerticalText() is true, then the vertical advances are used for
|
|
|
|
* the measurement.
|
2012-08-23 18:09:54 +00:00
|
|
|
*
|
2011-11-10 20:04:47 +00:00
|
|
|
* @param text The text to be measured
|
|
|
|
* @param length Number of bytes of text to measure
|
|
|
|
* @param maxWidth Maximum width. Only the subset of text whose accumulated
|
|
|
|
* widths are <= maxWidth are measured.
|
|
|
|
* @param measuredWidth Optional. If non-null, this returns the actual
|
|
|
|
* width of the measured text.
|
|
|
|
* @return The number of bytes of text that were measured. Will be
|
|
|
|
* <= length.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
size_t breakText(const void* text, size_t length, SkScalar maxWidth,
|
2014-10-03 19:44:37 +00:00
|
|
|
SkScalar* measuredWidth = NULL) const;
|
2008-12-17 15:59:43 +00:00
|
|
|
|
2011-11-10 20:04:47 +00:00
|
|
|
/** Return the advances for the text. These will be vertical advances if
|
|
|
|
* isVerticalText() returns true.
|
|
|
|
*
|
|
|
|
* @param text the text
|
|
|
|
* @param byteLength number of bytes to of text
|
|
|
|
* @param widths If not null, returns the array of advances for
|
|
|
|
* the glyphs. If not NULL, must be at least a large
|
|
|
|
* as the number of unichars in the specified text.
|
|
|
|
* @param bounds If not null, returns the bounds for each of
|
|
|
|
* character, relative to (0, 0)
|
|
|
|
* @return the number of unichars in the specified text.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
int getTextWidths(const void* text, size_t byteLength, SkScalar widths[],
|
|
|
|
SkRect bounds[] = NULL) const;
|
|
|
|
|
|
|
|
/** Return the path (outline) for the specified text.
|
2016-02-09 21:25:45 +00:00
|
|
|
* Note: just like SkCanvas::drawText, this will respect the Align setting
|
|
|
|
* in the paint.
|
|
|
|
*
|
|
|
|
* @param text the text
|
|
|
|
* @param length number of bytes of text
|
|
|
|
* @param x The x-coordinate of the origin of the text.
|
|
|
|
* @param y The y-coordinate of the origin of the text.
|
|
|
|
* @param path The outline of the text.
|
|
|
|
*/
|
2008-12-17 15:59:43 +00:00
|
|
|
void getTextPath(const void* text, size_t length, SkScalar x, SkScalar y,
|
|
|
|
SkPath* path) const;
|
|
|
|
|
2016-02-09 21:25:45 +00:00
|
|
|
/** Return the path (outline) for the specified text.
|
|
|
|
* Note: just like SkCanvas::drawText, this will respect the Align setting
|
|
|
|
* in the paint.
|
|
|
|
*
|
|
|
|
* @param text the text
|
|
|
|
* @param length number of bytes of text
|
|
|
|
* @param pos array of positions, used to position each character
|
|
|
|
* @param path The outline of the text.
|
|
|
|
*/
|
2012-08-23 18:09:54 +00:00
|
|
|
void getPosTextPath(const void* text, size_t length,
|
2012-07-20 11:20:32 +00:00
|
|
|
const SkPoint pos[], SkPath* path) const;
|
|
|
|
|
2016-02-09 21:25:45 +00:00
|
|
|
/** Return the number of intervals that intersect the intercept along the axis of the advance.
|
|
|
|
* The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in
|
|
|
|
* the string. The caller may pass nullptr for intervals to determine the size of the interval
|
|
|
|
* array, or may conservatively pre-allocate an array with length * 2 entries. The computed
|
|
|
|
* intervals are cached by glyph to improve performance for multiple calls.
|
|
|
|
* This permits constructing an underline that skips the descenders.
|
|
|
|
*
|
|
|
|
* @param text the text
|
|
|
|
* @param length number of bytes of text
|
|
|
|
* @param x The x-coordinate of the origin of the text.
|
|
|
|
* @param y The y-coordinate of the origin of the text.
|
|
|
|
* @param bounds The lower and upper line parallel to the advance.
|
|
|
|
* @param array If not null, the found intersections.
|
|
|
|
*
|
|
|
|
* @return The number of intersections, which may be zero.
|
|
|
|
*/
|
|
|
|
int getTextIntercepts(const void* text, size_t length, SkScalar x, SkScalar y,
|
|
|
|
const SkScalar bounds[2], SkScalar* intervals) const;
|
|
|
|
|
|
|
|
/** Return the number of intervals that intersect the intercept along the axis of the advance.
|
|
|
|
* The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in
|
|
|
|
* string. The caller may pass nullptr for intervals to determine the size of the interval
|
|
|
|
* array, or may conservatively pre-allocate an array with length * 2 entries. The computed
|
|
|
|
* intervals are cached by glyph to improve performance for multiple calls.
|
|
|
|
* This permits constructing an underline that skips the descenders.
|
|
|
|
*
|
|
|
|
* @param text the text
|
|
|
|
* @param length number of bytes of text
|
|
|
|
* @param pos array of positions, used to position each character
|
|
|
|
* @param bounds The lower and upper line parallel to the advance.
|
|
|
|
* @param array If not null, the glyph bounds contained by the advance parallel lines.
|
|
|
|
*
|
|
|
|
* @return The number of intersections, which may be zero.
|
|
|
|
*/
|
|
|
|
int getPosTextIntercepts(const void* text, size_t length, const SkPoint pos[],
|
|
|
|
const SkScalar bounds[2], SkScalar* intervals) const;
|
|
|
|
|
2016-07-28 16:47:24 +00:00
|
|
|
/** Return the number of intervals that intersect the intercept along the axis of the advance.
|
|
|
|
* The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in
|
|
|
|
* string. The caller may pass nullptr for intervals to determine the size of the interval
|
|
|
|
* array, or may conservatively pre-allocate an array with length * 2 entries. The computed
|
|
|
|
* intervals are cached by glyph to improve performance for multiple calls.
|
|
|
|
* This permits constructing an underline that skips the descenders.
|
|
|
|
*
|
|
|
|
* @param text The text.
|
|
|
|
* @param length Number of bytes of text.
|
|
|
|
* @param xpos Array of x-positions, used to position each character.
|
|
|
|
* @param constY The shared Y coordinate for all of the positions.
|
|
|
|
* @param bounds The lower and upper line parallel to the advance.
|
|
|
|
* @param array If not null, the glyph bounds contained by the advance parallel lines.
|
|
|
|
*
|
|
|
|
* @return The number of intersections, which may be zero.
|
|
|
|
*/
|
|
|
|
int getPosTextHIntercepts(const void* text, size_t length, const SkScalar xpos[],
|
|
|
|
SkScalar constY, const SkScalar bounds[2], SkScalar* intervals) const;
|
|
|
|
|
|
|
|
/** Return the number of intervals that intersect the intercept along the axis of the advance.
|
|
|
|
* The return count is zero or a multiple of two, and is at most the number of glyphs * 2 in
|
|
|
|
* text blob. The caller may pass nullptr for intervals to determine the size of the interval
|
|
|
|
* array. The computed intervals are cached by glyph to improve performance for multiple calls.
|
|
|
|
* This permits constructing an underline that skips the descenders.
|
|
|
|
*
|
|
|
|
* @param blob The text blob.
|
|
|
|
* @param bounds The lower and upper line parallel to the advance.
|
|
|
|
* @param array If not null, the glyph bounds contained by the advance parallel lines.
|
|
|
|
*
|
|
|
|
* @return The number of intersections, which may be zero.
|
|
|
|
*/
|
|
|
|
int getTextBlobIntercepts(const SkTextBlob* blob, const SkScalar bounds[2],
|
|
|
|
SkScalar* intervals) const;
|
|
|
|
|
2014-12-15 21:27:26 +00:00
|
|
|
/**
|
|
|
|
* Return a rectangle that represents the union of the bounds of all
|
|
|
|
* of the glyphs, but each one positioned at (0,0). This may be conservatively large, and
|
|
|
|
* will not take into account any hinting, but will respect any text-scale-x or text-skew-x
|
|
|
|
* on this paint.
|
|
|
|
*/
|
|
|
|
SkRect getFontBounds() const;
|
|
|
|
|
2011-10-06 12:37:00 +00:00
|
|
|
// returns true if the paint's settings (e.g. xfermode + alpha) resolve to
|
|
|
|
// mean that we need not draw at all (e.g. SrcOver + 0-alpha)
|
|
|
|
bool nothingToDraw() const;
|
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2012-05-16 14:15:02 +00:00
|
|
|
// would prefer to make these private...
|
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
/** Returns true if the current paint settings allow for fast computation of
|
|
|
|
bounds (i.e. there is nothing complex like a patheffect that would make
|
|
|
|
the bounds computation expensive.
|
|
|
|
*/
|
2015-08-20 18:10:41 +00:00
|
|
|
bool canComputeFastBounds() const;
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
/** Only call this if canComputeFastBounds() returned true. This takes a
|
|
|
|
raw rectangle (the raw bounds of a shape), and adjusts it for stylistic
|
|
|
|
effects in the paint (e.g. stroking). If needed, it uses the storage
|
|
|
|
rect parameter. It returns the adjusted bounds that can then be used
|
|
|
|
for quickReject tests.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
The returned rect will either be orig or storage, thus the caller
|
|
|
|
should not rely on storage being set to the result, but should always
|
|
|
|
use the retured value. It is legal for orig and storage to be the same
|
|
|
|
rect.
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
e.g.
|
|
|
|
if (paint.canComputeFastBounds()) {
|
|
|
|
SkRect r, storage;
|
|
|
|
path.computeBounds(&r, SkPath::kFast_BoundsType);
|
|
|
|
const SkRect& fastR = paint.computeFastBounds(r, &storage);
|
|
|
|
if (canvas->quickReject(fastR, ...)) {
|
|
|
|
// don't draw the path
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
const SkRect& computeFastBounds(const SkRect& orig, SkRect* storage) const {
|
2017-05-12 15:21:36 +00:00
|
|
|
// Things like stroking, etc... will do math on the bounds rect, assuming that it's sorted.
|
|
|
|
SkASSERT(orig.isSorted());
|
2012-05-16 14:06:02 +00:00
|
|
|
SkPaint::Style style = this->getStyle();
|
|
|
|
// ultra fast-case: filling with no effects that affect geometry
|
|
|
|
if (kFill_Style == style) {
|
|
|
|
uintptr_t effects = reinterpret_cast<uintptr_t>(this->getLooper());
|
|
|
|
effects |= reinterpret_cast<uintptr_t>(this->getMaskFilter());
|
|
|
|
effects |= reinterpret_cast<uintptr_t>(this->getPathEffect());
|
2014-01-27 21:03:17 +00:00
|
|
|
effects |= reinterpret_cast<uintptr_t>(this->getImageFilter());
|
2012-05-16 14:06:02 +00:00
|
|
|
if (!effects) {
|
|
|
|
return orig;
|
|
|
|
}
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
return this->doComputeFastBounds(orig, storage, style);
|
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
const SkRect& computeFastStrokeBounds(const SkRect& orig,
|
|
|
|
SkRect* storage) const {
|
2012-05-16 19:21:12 +00:00
|
|
|
return this->doComputeFastBounds(orig, storage, kStroke_Style);
|
2012-05-16 14:06:02 +00:00
|
|
|
}
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2012-05-16 14:06:02 +00:00
|
|
|
// Take the style explicitly, so the caller can force us to be stroked
|
|
|
|
// without having to make a copy of the paint just to change that field.
|
|
|
|
const SkRect& doComputeFastBounds(const SkRect& orig, SkRect* storage,
|
2017-05-10 13:07:42 +00:00
|
|
|
Style style) const;
|
|
|
|
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2016-02-23 18:44:31 +00:00
|
|
|
|
2014-03-13 18:02:17 +00:00
|
|
|
SK_TO_STRING_NONVIRT()
|
2013-02-14 13:53:53 +00:00
|
|
|
|
2012-05-16 14:15:02 +00:00
|
|
|
private:
|
2017-05-10 13:07:42 +00:00
|
|
|
typedef const SkGlyph& (*GlyphCacheProc)(SkGlyphCache*, const char**);
|
|
|
|
|
2016-03-07 02:10:48 +00:00
|
|
|
sk_sp<SkTypeface> fTypeface;
|
|
|
|
sk_sp<SkPathEffect> fPathEffect;
|
|
|
|
sk_sp<SkShader> fShader;
|
|
|
|
sk_sp<SkMaskFilter> fMaskFilter;
|
|
|
|
sk_sp<SkColorFilter> fColorFilter;
|
|
|
|
sk_sp<SkRasterizer> fRasterizer;
|
2016-09-11 12:40:31 +00:00
|
|
|
sk_sp<SkDrawLooper> fDrawLooper;
|
2016-03-07 02:10:48 +00:00
|
|
|
sk_sp<SkImageFilter> fImageFilter;
|
2012-05-16 14:15:02 +00:00
|
|
|
|
2014-03-24 23:03:11 +00:00
|
|
|
SkScalar fTextSize;
|
|
|
|
SkScalar fTextScaleX;
|
|
|
|
SkScalar fTextSkewX;
|
2012-05-16 14:15:02 +00:00
|
|
|
SkColor fColor;
|
|
|
|
SkScalar fWidth;
|
|
|
|
SkScalar fMiterLimit;
|
2016-11-18 22:19:54 +00:00
|
|
|
uint32_t fBlendMode; // just need 5-6 bits
|
2014-02-21 18:18:05 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
// all of these bitfields should add up to 32
|
|
|
|
unsigned fFlags : 16;
|
|
|
|
unsigned fTextAlign : 2;
|
|
|
|
unsigned fCapType : 2;
|
|
|
|
unsigned fJoinType : 2;
|
|
|
|
unsigned fStyle : 2;
|
|
|
|
unsigned fTextEncoding : 2; // 3 values
|
|
|
|
unsigned fHinting : 2;
|
2015-01-23 13:58:07 +00:00
|
|
|
unsigned fFilterQuality : 2;
|
2014-04-16 12:58:02 +00:00
|
|
|
//unsigned fFreeBits : 2;
|
2014-07-14 21:39:15 +00:00
|
|
|
} fBitfields;
|
|
|
|
uint32_t fBitfieldsUInt;
|
2014-02-21 18:18:05 +00:00
|
|
|
};
|
2014-03-24 23:03:11 +00:00
|
|
|
|
2016-07-19 14:59:22 +00:00
|
|
|
static GlyphCacheProc GetGlyphCacheProc(TextEncoding encoding,
|
|
|
|
bool isDevKern,
|
|
|
|
bool needFullMetrics);
|
2012-05-16 14:15:02 +00:00
|
|
|
|
|
|
|
SkScalar measure_text(SkGlyphCache*, const char* text, size_t length,
|
|
|
|
int* count, SkRect* bounds) const;
|
|
|
|
|
2016-04-08 13:47:54 +00:00
|
|
|
enum ScalerContextFlags : uint32_t {
|
|
|
|
kNone_ScalerContextFlags = 0,
|
|
|
|
|
|
|
|
kFakeGamma_ScalerContextFlag = 1 << 0,
|
|
|
|
kBoostContrast_ScalerContextFlag = 1 << 1,
|
|
|
|
|
|
|
|
kFakeGammaAndBoostContrast_ScalerContextFlags =
|
|
|
|
kFakeGamma_ScalerContextFlag | kBoostContrast_ScalerContextFlag,
|
2016-02-22 21:20:28 +00:00
|
|
|
};
|
|
|
|
|
2015-03-13 15:38:43 +00:00
|
|
|
/*
|
|
|
|
* Allocs an SkDescriptor on the heap and return it to the caller as a refcnted
|
|
|
|
* SkData. Caller is responsible for managing the lifetime of this object.
|
|
|
|
*/
|
2016-04-12 13:47:05 +00:00
|
|
|
void getScalerContextDescriptor(SkScalerContextEffects*, SkAutoDescriptor*,
|
|
|
|
const SkSurfaceProps& surfaceProps,
|
2016-04-08 13:47:54 +00:00
|
|
|
uint32_t scalerContextFlags, const SkMatrix*) const;
|
2015-03-13 15:38:43 +00:00
|
|
|
|
2016-04-08 13:47:54 +00:00
|
|
|
SkGlyphCache* detachCache(const SkSurfaceProps* surfaceProps, uint32_t scalerContextFlags,
|
2016-02-22 21:20:28 +00:00
|
|
|
const SkMatrix*) const;
|
2012-05-16 14:15:02 +00:00
|
|
|
|
2016-04-08 13:47:54 +00:00
|
|
|
void descriptorProc(const SkSurfaceProps* surfaceProps, uint32_t scalerContextFlags,
|
2016-02-22 21:20:28 +00:00
|
|
|
const SkMatrix* deviceMatrix,
|
2016-04-12 13:47:05 +00:00
|
|
|
void (*proc)(SkTypeface*, const SkScalerContextEffects&,
|
|
|
|
const SkDescriptor*, void*),
|
2016-02-22 21:20:28 +00:00
|
|
|
void* context) const;
|
2009-04-01 18:31:44 +00:00
|
|
|
|
2015-04-14 19:17:27 +00:00
|
|
|
/*
|
|
|
|
* The luminance color is used to determine which Gamma Canonical color to map to. This is
|
|
|
|
* really only used by backends which want to cache glyph masks, and need some way to know if
|
|
|
|
* they need to generate new masks based off a given color.
|
|
|
|
*/
|
|
|
|
SkColor computeLuminanceColor() const;
|
|
|
|
|
2008-12-17 15:59:43 +00:00
|
|
|
enum {
|
2013-06-04 16:56:27 +00:00
|
|
|
/* This is the size we use when we ask for a glyph's path. We then
|
|
|
|
* post-transform it as we draw to match the request.
|
|
|
|
* This is done to try to re-use cache entries for the path.
|
|
|
|
*
|
|
|
|
* This value is somewhat arbitrary. In theory, it could be 1, since
|
|
|
|
* we store paths as floats. However, we get the path from the font
|
|
|
|
* scaler, and it may represent its paths as fixed-point (or 26.6),
|
|
|
|
* so we shouldn't ask for something too big (might overflow 16.16)
|
|
|
|
* or too small (underflow 26.6).
|
|
|
|
*
|
|
|
|
* This value could track kMaxSizeForGlyphCache, assuming the above
|
|
|
|
* constraints, but since we ask for unhinted paths, the two values
|
|
|
|
* need not match per-se.
|
|
|
|
*/
|
|
|
|
kCanonicalTextSizeForPaths = 64,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Above this size (taking into account CTM and textSize), we never use
|
|
|
|
* the cache for bits or metrics (we might overflow), so we just ask
|
|
|
|
* for a caononical size and post-transform that.
|
|
|
|
*/
|
|
|
|
kMaxSizeForGlyphCache = 256,
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
2013-06-04 16:56:27 +00:00
|
|
|
|
|
|
|
static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM);
|
|
|
|
|
|
|
|
// Set flags/hinting/textSize up to use for drawing text as paths.
|
|
|
|
// Returns scale factor to restore the original textSize, since will will
|
|
|
|
// have change it to kCanonicalTextSizeForPaths.
|
|
|
|
SkScalar setupForAsPaths();
|
|
|
|
|
|
|
|
static SkScalar MaxCacheSize2() {
|
|
|
|
static const SkScalar kMaxSize = SkIntToScalar(kMaxSizeForGlyphCache);
|
|
|
|
static const SkScalar kMag2Max = kMaxSize * kMaxSize;
|
|
|
|
return kMag2Max;
|
|
|
|
}
|
|
|
|
|
PDF: Add text support with a font framework (font embedding to come).
Supports fakeBold, underline, strikethrough, mode (fill, stroke, both), size, skew, alignment (left, center, right).
Missing is drawFontOnPath and font lookup and embedding.
Changed SkPDFString to support how it is used from drawText methods.
Moved compile assert into SkTypes.
Moved constants and utility function used to support fakeBold, underline, and strikethrough into higher level locations.
Review URL: http://codereview.appspot.com/2946041
git-svn-id: http://skia.googlecode.com/svn/trunk@624 2bbb7eff-a529-9590-31e7-b0007b416f81
2010-11-11 21:37:00 +00:00
|
|
|
friend class SkAutoGlyphCache;
|
2014-06-10 13:42:56 +00:00
|
|
|
friend class SkAutoGlyphCacheNoGamma;
|
2008-12-17 15:59:43 +00:00
|
|
|
friend class SkCanvas;
|
|
|
|
friend class SkDraw;
|
PDF: Add text support with a font framework (font embedding to come).
Supports fakeBold, underline, strikethrough, mode (fill, stroke, both), size, skew, alignment (left, center, right).
Missing is drawFontOnPath and font lookup and embedding.
Changed SkPDFString to support how it is used from drawText methods.
Moved compile assert into SkTypes.
Moved constants and utility function used to support fakeBold, underline, and strikethrough into higher level locations.
Review URL: http://codereview.appspot.com/2946041
git-svn-id: http://skia.googlecode.com/svn/trunk@624 2bbb7eff-a529-9590-31e7-b0007b416f81
2010-11-11 21:37:00 +00:00
|
|
|
friend class SkPDFDevice;
|
2015-12-28 15:23:58 +00:00
|
|
|
friend class GrAtlasTextBlob;
|
2015-04-02 16:19:04 +00:00
|
|
|
friend class GrAtlasTextContext;
|
2014-06-24 07:12:27 +00:00
|
|
|
friend class GrStencilAndCoverTextContext;
|
2014-09-18 20:51:53 +00:00
|
|
|
friend class GrPathRendering;
|
2015-12-10 21:20:58 +00:00
|
|
|
friend class GrTextUtils;
|
2014-09-18 20:51:53 +00:00
|
|
|
friend class GrGLPathRendering;
|
2015-04-14 19:17:27 +00:00
|
|
|
friend class SkScalerContext;
|
2016-02-09 21:25:45 +00:00
|
|
|
friend class SkTextBaseIter;
|
2013-06-04 16:56:27 +00:00
|
|
|
friend class SkCanonicalizePaint;
|
2008-12-17 15:59:43 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|