diff options
author | Cary Clark <caryclark@skia.org> | 2018-04-26 08:32:37 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-26 17:11:53 +0000 |
commit | d98f78cd019d96f902197711c5e7e43afec3c3de (patch) | |
tree | 376d0bae10124bc51f150a8834c1e54d989d6a7e /include/core/SkMatrix.h | |
parent | ba37e5b1c9bd24a86584a3e80347a82175a2403a (diff) |
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>
Diffstat (limited to 'include/core/SkMatrix.h')
-rw-r--r-- | include/core/SkMatrix.h | 84 |
1 files changed, 38 insertions, 46 deletions
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h index 333bcbf487..6a990526ab 100644 --- a/include/core/SkMatrix.h +++ b/include/core/SkMatrix.h @@ -263,34 +263,28 @@ public: */ bool preservesRightAngles(SkScalar tol = SK_ScalarNearlyZero) const; - /** \enum - SkMatrix organizes its values in row order. These members correspond to + /** SkMatrix organizes its values in row order. These members correspond to each value in SkMatrix. */ - enum { - kMScaleX, //!< horizontal scale factor - kMSkewX, //!< horizontal skew factor - kMTransX, //!< horizontal translation - kMSkewY, //!< vertical skew factor - kMScaleY, //!< vertical scale factor - kMTransY, //!< vertical translation - kMPersp0, //!< input x perspective factor - kMPersp1, //!< input y perspective factor - kMPersp2, //!< perspective bias - }; - - /** \enum - Affine arrays are in column major order to match the matrix used by + static constexpr int kMScaleX = 0; //!< horizontal scale factor + static constexpr int kMSkewX = 1; //!< horizontal skew factor + static constexpr int kMTransX = 2; //!< horizontal translation + static constexpr int kMSkewY = 3; //!< vertical skew factor + static constexpr int kMScaleY = 4; //!< vertical scale factor + static constexpr int kMTransY = 5; //!< vertical translation + static constexpr int kMPersp0 = 6; //!< input x perspective factor + static constexpr int kMPersp1 = 7; //!< input y perspective factor + static constexpr int kMPersp2 = 8; //!< perspective bias + + /** Affine arrays are in column major order to match the matrix used by PDF and XPS. */ - enum { - kAScaleX, //!< horizontal scale factor - kASkewY, //!< vertical skew factor - kASkewX, //!< horizontal skew factor - kAScaleY, //!< vertical scale factor - kATransX, //!< horizontal translation - kATransY, //!< vertical translation - }; + static constexpr int kAScaleX = 0; //!< horizontal scale factor + static constexpr int kASkewY = 1; //!< vertical skew factor + static constexpr int kASkewX = 2; //!< horizontal skew factor + static constexpr int kAScaleY = 3; //!< vertical scale factor + static constexpr int kATransX = 4; //!< horizontal translation + static constexpr int kATransY = 5; //!< vertical translation /** Returns one matrix value. Asserts if index is out of range and SK_DEBUG is defined. @@ -1722,33 +1716,31 @@ public: bool isFinite() const { return SkScalarsAreFinite(fMat, 9); } private: - enum { - /** Set if the matrix will map a rectangle to another rectangle. This - can be true if the matrix is scale-only, or rotates a multiple of - 90 degrees. + /** Set if the matrix will map a rectangle to another rectangle. This + can be true if the matrix is scale-only, or rotates a multiple of + 90 degrees. - This bit will be set on identity matrices - */ - kRectStaysRect_Mask = 0x10, + This bit will be set on identity matrices + */ + static constexpr int kRectStaysRect_Mask = 0x10; - /** Set if the perspective bit is valid even though the rest of - the matrix is Unknown. - */ - kOnlyPerspectiveValid_Mask = 0x40, + /** Set if the perspective bit is valid even though the rest of + the matrix is Unknown. + */ + static constexpr int kOnlyPerspectiveValid_Mask = 0x40; - kUnknown_Mask = 0x80, + static constexpr int kUnknown_Mask = 0x80; - kORableMasks = kTranslate_Mask | - kScale_Mask | - kAffine_Mask | - kPerspective_Mask, + static constexpr int kORableMasks = kTranslate_Mask | + kScale_Mask | + kAffine_Mask | + kPerspective_Mask; - kAllMasks = kTranslate_Mask | - kScale_Mask | - kAffine_Mask | - kPerspective_Mask | - kRectStaysRect_Mask, - }; + static constexpr int kAllMasks = kTranslate_Mask | + kScale_Mask | + kAffine_Mask | + kPerspective_Mask | + kRectStaysRect_Mask; SkScalar fMat[9]; mutable uint32_t fTypeMask; |