add FilterLevel API to SkPaint, replacing various Flag bits
BUG= R=bsalomon@google.com Review URL: https://codereview.chromium.org/19769005 git-svn-id: http://skia.googlecode.com/svn/trunk@10138 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
620edc5039
commit
c968315136
@ -98,7 +98,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
enum Flags {
|
enum Flags {
|
||||||
kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing
|
kAntiAlias_Flag = 0x01, //!< mask to enable antialiasing
|
||||||
kFilterBitmap_Flag = 0x02, //!< mask to enable bitmap filtering
|
|
||||||
|
// DEPRECATED -- use setFilterLevel instead
|
||||||
|
kFilterBitmap_Flag = 0x02, // temporary flag
|
||||||
|
|
||||||
kDither_Flag = 0x04, //!< mask to enable dithering
|
kDither_Flag = 0x04, //!< mask to enable dithering
|
||||||
kUnderlineText_Flag = 0x08, //!< mask to enable underline text
|
kUnderlineText_Flag = 0x08, //!< mask to enable underline text
|
||||||
kStrikeThruText_Flag = 0x10, //!< mask to enable strike-thru text
|
kStrikeThruText_Flag = 0x10, //!< mask to enable strike-thru text
|
||||||
@ -111,7 +114,10 @@ public:
|
|||||||
kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter
|
kAutoHinting_Flag = 0x800, //!< mask to force Freetype's autohinter
|
||||||
kVerticalText_Flag = 0x1000,
|
kVerticalText_Flag = 0x1000,
|
||||||
kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it
|
kGenA8FromLCD_Flag = 0x2000, // hack for GDI -- do not use if you can help it
|
||||||
|
|
||||||
|
// DEPRECATED -- use setFilterLevel instead
|
||||||
kHighQualityFilterBitmap_Flag = 0x4000, // temporary flag
|
kHighQualityFilterBitmap_Flag = 0x4000, // temporary flag
|
||||||
|
// DEPRECATED -- use setFilterLevel instead
|
||||||
kHighQualityDownsampleBitmap_Flag = 0x8000, // temporary flag
|
kHighQualityDownsampleBitmap_Flag = 0x8000, // temporary flag
|
||||||
|
|
||||||
// when adding extra flags, note that the fFlags member is specified
|
// when adding extra flags, note that the fFlags member is specified
|
||||||
@ -280,11 +286,41 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setDevKernText(bool devKernText);
|
void setDevKernText(bool devKernText);
|
||||||
|
|
||||||
bool isFilterBitmap() const {
|
enum FilterLevel {
|
||||||
return SkToBool(this->getFlags() & kFilterBitmap_Flag);
|
kNone_FilterLevel,
|
||||||
|
kLow_FilterLevel,
|
||||||
|
kMedium_FilterLevel,
|
||||||
|
kHigh_FilterLevel
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the filter level. This affects the quality (and performance) of
|
||||||
|
* drawing scaled images.
|
||||||
|
*/
|
||||||
|
FilterLevel getFilterLevel() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the filter level. This affects the quality (and performance) of
|
||||||
|
* drawing scaled images.
|
||||||
|
*/
|
||||||
|
void setFilterLevel(FilterLevel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DEPRECATED: use setFilterLevel instead.
|
||||||
|
* If the predicate is true, set the filterLevel to Low, else set it to
|
||||||
|
* None.
|
||||||
|
*/
|
||||||
|
void setFilterBitmap(bool doFilter) {
|
||||||
|
this->setFilterLevel(doFilter ? kLow_FilterLevel : kNone_FilterLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFilterBitmap(bool filterBitmap);
|
/**
|
||||||
|
* DEPRECATED: call getFilterLevel() instead.
|
||||||
|
* Returns true if getFilterLevel() returns anything other than None.
|
||||||
|
*/
|
||||||
|
bool isFilterBitmap() const {
|
||||||
|
return kNone_FilterLevel != this->getFilterLevel();
|
||||||
|
}
|
||||||
|
|
||||||
/** Styles apply to rect, oval, path, and text.
|
/** Styles apply to rect, oval, path, and text.
|
||||||
Bitmaps are always drawn in "fill", and lines are always drawn in
|
Bitmaps are always drawn in "fill", and lines are always drawn in
|
||||||
|
@ -205,6 +205,29 @@ void SkPaint::setPaintOptionsAndroid(const SkPaintOptionsAndroid& options) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SkPaint::FilterLevel SkPaint::getFilterLevel() const {
|
||||||
|
int level = 0;
|
||||||
|
if (fFlags & kFilterBitmap_Flag) {
|
||||||
|
level |= 1;
|
||||||
|
}
|
||||||
|
if (fFlags & kHighQualityFilterBitmap_Flag) {
|
||||||
|
level |= 2;
|
||||||
|
}
|
||||||
|
return (FilterLevel)level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SkPaint::setFilterLevel(FilterLevel level) {
|
||||||
|
unsigned mask = kFilterBitmap_Flag | kHighQualityFilterBitmap_Flag;
|
||||||
|
unsigned flags = 0;
|
||||||
|
if (level & 1) {
|
||||||
|
flags |= kFilterBitmap_Flag;
|
||||||
|
}
|
||||||
|
if (level & 2) {
|
||||||
|
flags |= kHighQualityFilterBitmap_Flag;
|
||||||
|
}
|
||||||
|
this->setFlags((fFlags & ~mask) | flags);
|
||||||
|
}
|
||||||
|
|
||||||
void SkPaint::setHinting(Hinting hintingLevel) {
|
void SkPaint::setHinting(Hinting hintingLevel) {
|
||||||
GEN_ID_INC_EVAL((unsigned) hintingLevel != fHinting);
|
GEN_ID_INC_EVAL((unsigned) hintingLevel != fHinting);
|
||||||
fHinting = hintingLevel;
|
fHinting = hintingLevel;
|
||||||
@ -263,10 +286,6 @@ void SkPaint::setDevKernText(bool doDevKern) {
|
|||||||
this->setFlags(SkSetClearMask(fFlags, doDevKern, kDevKernText_Flag));
|
this->setFlags(SkSetClearMask(fFlags, doDevKern, kDevKernText_Flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkPaint::setFilterBitmap(bool doFilter) {
|
|
||||||
this->setFlags(SkSetClearMask(fFlags, doFilter, kFilterBitmap_Flag));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SkPaint::setStyle(Style style) {
|
void SkPaint::setStyle(Style style) {
|
||||||
if ((unsigned)style < kStyleCount) {
|
if ((unsigned)style < kStyleCount) {
|
||||||
GEN_ID_INC_EVAL((unsigned)style != fStyle);
|
GEN_ID_INC_EVAL((unsigned)style != fStyle);
|
||||||
|
Loading…
Reference in New Issue
Block a user