From d7a4bea20aa7d3a4bbf6efd135b21521b0cf8183 Mon Sep 17 00:00:00 2001 From: Mike Reed Date: Fri, 9 Nov 2018 21:59:13 +0000 Subject: [PATCH] Revert "rm legacy flags for hinting enum" This reverts commit 5cd242b4fc8fb926d1233bb4561c0607755c4e05. Reason for revert: breaking google3 Original change's description: > rm legacy flags for hinting enum > > Bug: skia: > Change-Id: I56ad33fa30aa8cec8a60cd70d4e4767defb923ca > Reviewed-on: https://skia-review.googlesource.com/c/170105 > Reviewed-by: Mike Reed > Commit-Queue: Mike Reed TBR=reed@google.com Change-Id: Iffa9b20d77455b4554aae132268af8a0cf252496 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: skia: Reviewed-on: https://skia-review.googlesource.com/c/170270 Reviewed-by: Mike Reed Commit-Queue: Mike Reed --- fuzz/FuzzDrawFunctions.cpp | 2 +- include/core/SkFont.h | 10 ++++++++- include/core/SkFontTypes.h | 9 ++++++++ include/core/SkPaint.h | 42 +++++++++++++++++++++++++++++++++----- 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/fuzz/FuzzDrawFunctions.cpp b/fuzz/FuzzDrawFunctions.cpp index f9a2f2e9fb..56e6cdf147 100644 --- a/fuzz/FuzzDrawFunctions.cpp +++ b/fuzz/FuzzDrawFunctions.cpp @@ -47,7 +47,7 @@ static void init_paint(Fuzz* fuzz, SkPaint* p) { fuzz->nextRange(&tmp_u8, 0, (int)kHigh_SkFilterQuality); p->setFilterQuality(static_cast(tmp_u8)); - fuzz->nextRange(&tmp_u8, 0, (int)SkFontHinting::kFull); + fuzz->nextRange(&tmp_u8, 0, (int)SkPaint::kFull_Hinting); p->setHinting(static_cast(tmp_u8)); fuzz->nextRange(&tmp_u8, 0, (int)SkPaint::kLast_Cap); diff --git a/include/core/SkFont.h b/include/core/SkFont.h index d7fc3a6458..7ef02dc5b4 100644 --- a/include/core/SkFont.h +++ b/include/core/SkFont.h @@ -66,9 +66,17 @@ public: void DEPRECATED_setAntiAlias(bool); void DEPRECATED_setLCDRender(bool); - SkFontHinting getHinting() const { return (SkFontHinting)fHinting; } void setHinting(SkFontHinting); +#ifdef SK_SUPPORT_LEGACY_NESTED_HINTINGENUM + Hinting getHinting() const { return (Hinting)fHinting; } + void setHinting(Hinting hinting) { + this->setHinting((SkFontHinting)hinting); + } +#else + SkFontHinting getHinting() const { return (SkFontHinting)fHinting; } +#endif + /** * Return a font with the same attributes of this font, but with the specified size. * If size is not supported (e.g. <= 0 or non-finite) NULL will be returned. diff --git a/include/core/SkFontTypes.h b/include/core/SkFontTypes.h index 00b108b340..ed7e157391 100644 --- a/include/core/SkFontTypes.h +++ b/include/core/SkFontTypes.h @@ -18,6 +18,14 @@ enum SkTextEncoding : uint8_t { kGlyphID_SkTextEncoding, }; +#ifdef SK_SUPPORT_LEGACY_NONCLASS_HINTINGENUM +enum SkFontHinting : uint8_t { + kNo_SkFontHinting = 0, //!< glyph outlines unchanged + kSlight_SkFontHinting = 1, //!< minimal modification to improve constrast + kNormal_SkFontHinting = 2, //!< glyph outlines modified to improve constrast + kFull_SkFontHinting = 3, //!< modifies glyph outlines for maximum constrast +}; +#else enum class SkFontHinting { kNone, //!< glyph outlines unchanged kSlight, //!< minimal modification to improve constrast @@ -29,5 +37,6 @@ enum class SkFontHinting { #define kSlight_SkFontHinting SkFontHinting::kSlight #define kNormal_SkFontHinting SkFontHinting::kNormal #define kFull_SkFontHinting SkFontHinting::kFull +#endif #endif diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h index 66bc83cac7..db892b78f5 100644 --- a/include/core/SkPaint.h +++ b/include/core/SkPaint.h @@ -183,12 +183,20 @@ public: */ void reset(); - /** Returns level of glyph outline adjustment. + /** \enum SkPaint::Hinting + Hinting adjusts the glyph outlines so that the shape provides a uniform + look at a given point size on font engines that support it. Hinting may have a + muted effect or no effect at all depending on the platform. - @return one of: SkFontHinting::kNone, SkFontHinting::kSlight, SkFontHinting::kNormal, - SkFontHinting::kFull - */ - SkFontHinting getHinting() const { return (SkFontHinting)fBitfields.fHinting; } + The four levels roughly control corresponding features on platforms that use FreeType + as the font engine. + */ + enum Hinting : uint8_t { + kNo_Hinting = 0, //!< glyph outlines unchanged + kSlight_Hinting = 1, //!< minimal modification to improve constrast + kNormal_Hinting = 2, //!< glyph outlines modified to improve constrast + kFull_Hinting = 3, //!< modifies glyph outlines for maximum constrast + }; /** Sets level of glyph outline adjustment. Does not check for valid values of hintingLevel. @@ -198,6 +206,30 @@ public: */ void setHinting(SkFontHinting hintingLevel); +#ifdef SK_SUPPORT_LEGACY_NESTED_HINTINGENUM + /** Returns level of glyph outline adjustment. + + @return one of: kNo_Hinting, kSlight_Hinting, kNormal_Hinting, kFull_Hinting + */ + Hinting getHinting() const { return (Hinting)fBitfields.fHinting; } + + /** Sets level of glyph outline adjustment. + Does not check for valid values of h. + + @param h one of: kNo_Hinting, kSlight_Hinting, kNormal_Hinting, kFull_Hinting + */ + void setHinting(Hinting h) { + this->setHinting((SkFontHinting)h); + } +#else + /** Returns level of glyph outline adjustment. + + @return one of: SkFontHinting::kNone, SkFontHinting::kSlight, SkFontHinting::kNormal, + SkFontHinting::kFull + */ + SkFontHinting getHinting() const { return (SkFontHinting)fBitfields.fHinting; } +#endif + /** \enum SkPaint::Flags The bit values stored in Flags. The default value for Flags, normally zero, can be changed at compile time