alternative no anonymous enums
Anonymous enums play havoc with documentation;
there's no name to refer to. It may be that all
enums may either be named or replaced with constexpr
without breaking anything. Try replacing all
anonymous enums in include/core to see what happens.
This names SkCanvas::SaveLayerFlagsSet but leaves
SkCanvas::SaveLayerFlags as a uint32_t, to reduce
risk as compared to review.skia.org/123584.
There's also some chance that external linkage will
break if some client refers to anonymous enum in a way
that could require its address: see
https://stackoverflow.com/questions/22867654/enum-vs-constexpr-for-actual-static-constants-inside-classes
(This CL does not require definitions + declarations)
Brought bookmaker docs in line with this change.
This also tripped over missing code in bookmaker
handling constexpr so added that as well.
R=reed@google.com,bsalomon@google.com
Docs-Preview: https://skia.org/?cl=123920
Docs-Preview: https://skia.org/?cl=123584
Bug: skia:6898
Change-Id: I14a342edcfd59e139ef9e4501f562417c4c60391
Reviewed-on: https://skia-review.googlesource.com/123920
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Cary Clark <caryclark@skia.org>
diff --git a/include/core/SkPaint.h b/include/core/SkPaint.h
index a77d84d..7a65e2c 100644
--- a/include/core/SkPaint.h
+++ b/include/core/SkPaint.h
@@ -518,12 +518,10 @@
kStrokeAndFill_Style,
};
- enum {
- /** The number of different Style values defined.
- May be used to verify that Style is a legal value.
- */
- kStyleCount = kStrokeAndFill_Style + 1,
- };
+ /** The number of different Style values defined.
+ May be used to verify that Style is a legal value.
+ */
+ static constexpr int kStyleCount = kStrokeAndFill_Style + 1;
/** Whether the geometry is filled, stroked, or filled and stroked.
@@ -949,9 +947,7 @@
kRight_Align,
};
- enum {
- kAlignCount = 3, //!< The number of different Align values defined.
- };
+ static constexpr int kAlignCount = 3; //!< The number of different Align values defined.
/** Returns SkPaint::Align.
Returns kLeft_Align if SkPaint::Align has not been set.
@@ -1662,23 +1658,21 @@
*/
SkColor computeLuminanceColor() const;
- enum {
- /* 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,
- };
+ /* 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.
+ */
+ static constexpr int kCanonicalTextSizeForPaths = 64;
static bool TooBigToUseCache(const SkMatrix& ctm, const SkMatrix& textM, SkScalar maxLimit);