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 /docs | |
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 'docs')
-rw-r--r-- | docs/SkCanvas_Reference.bmh | 9 | ||||
-rw-r--r-- | docs/SkMatrix_Reference.bmh | 42 | ||||
-rw-r--r-- | docs/SkPaint_Reference.bmh | 27 |
3 files changed, 32 insertions, 46 deletions
diff --git a/docs/SkCanvas_Reference.bmh b/docs/SkCanvas_Reference.bmh index 0bce15e947..f4672c4dc5 100644 --- a/docs/SkCanvas_Reference.bmh +++ b/docs/SkCanvas_Reference.bmh @@ -1678,15 +1678,17 @@ add new markup to associate typedef SaveLayerFlags with Enum so that, for documentation purposes, this enum is named rather than anonymous ## -#Enum +#Enum SaveLayerFlagsSet #Line # sets SaveLayerRec options ## #Code - enum { + enum SaveLayerFlagsSet { kPreserveLCDText_SaveLayerFlag = 1 << 1, kInitWithPrevious_SaveLayerFlag = 1 << 2, kMaskAgainstCoverage_EXPERIMENTAL_DONT_USE_SaveLayerFlag = 1 << 3, kDontClipToLayer_Legacy_SaveLayerFlag = kDontClipToLayer_PrivateSaveLayerFlag, }; + + typedef uint32_t SaveLayerFlags; ## SaveLayerFlags provides options that may be used in any combination in SaveLayerRec, @@ -1838,7 +1840,8 @@ Sets fBounds, fPaint, and fBackdrop to nullptr. Clears fSaveLayerFlags. ## -#Method SaveLayerRec(const SkRect* bounds, const SkPaint* paint, SaveLayerFlags saveLayerFlags = 0) +#Method SaveLayerRec(const SkRect* bounds, const SkPaint* paint, + SaveLayerFlags saveLayerFlags = 0) Sets fBounds, fPaint, and fSaveLayerFlags; sets fBackdrop to nullptr. diff --git a/docs/SkMatrix_Reference.bmh b/docs/SkMatrix_Reference.bmh index 63040e8a21..ba3cf79a1d 100644 --- a/docs/SkMatrix_Reference.bmh +++ b/docs/SkMatrix_Reference.bmh @@ -619,20 +619,20 @@ for (SkScalar sx : { 1, 2 } ) { # ------------------------------------------------------------------------------ -#Enum +#Subtopic MemberIndex +#In Constant +#Line # member indices ## #Code - enum { - kMScaleX, - kMSkewX, - kMTransX, - kMSkewY, - kMScaleY, - kMTransY, - kMPersp0, - kMPersp1, - kMPersp2, - }; + static constexpr int kMScaleX = 0; + static constexpr int kMSkewX = 1; + static constexpr int kMTransX = 2; + static constexpr int kMSkewY = 3; + static constexpr int kMScaleY = 4; + static constexpr int kMTransY = 5; + static constexpr int kMPersp0 = 6; + static constexpr int kMPersp1 = 7; + static constexpr int kMPersp2 = 8; ## Matrix organizes its values in row order. These members correspond to @@ -693,17 +693,17 @@ for (int i : { SkMatrix::kMScaleX, SkMatrix::kMSkewX, SkMatrix::kMTransX, # ------------------------------------------------------------------------------ -#Enum +#Subtopic AffineIndex +#In Constant +#Line # affine member indices ## #Code - enum { - kAScaleX, - kASkewY, - kASkewX, - kAScaleY, - kATransX, - kATransY, - }; + static constexpr int kAScaleX = 0; + static constexpr int kASkewY = 1; + static constexpr int kASkewX = 2; + static constexpr int kAScaleY = 3; + static constexpr int kATransX = 4; + static constexpr int kATransY = 5; ## Affine arrays are in column major order to match the matrix used by diff --git a/docs/SkPaint_Reference.bmh b/docs/SkPaint_Reference.bmh index 1467b5338c..47627361d4 100644 --- a/docs/SkPaint_Reference.bmh +++ b/docs/SkPaint_Reference.bmh @@ -1897,6 +1897,8 @@ while stroking. kStroke_Style, kStrokeAndFill_Style, }; + + static constexpr int kStyleCount = kStrokeAndFill_Style + 1; ## Set Style to fill, stroke, or both fill and stroke geometry. @@ -1931,22 +1933,12 @@ a fill draw. and the set Path_Fill_Type is ignored. ## -#Enum Style ## - -#Enum -#Line # number of Style defines ## -#Code - enum { - kStyleCount = kStrokeAndFill_Style + 1, - }; -## - #Const kStyleCount 3 The number of different Style values defined. May be used to verify that Style is a legal value. ## -#Enum ## +#Enum Style ## #Method Style getStyle() const @@ -3493,6 +3485,8 @@ Increments drawLooper Reference_Count by one. kCenter_Align, kRight_Align, }; + + static constexpr int kAlignCount = 3; ## Align adjusts the text relative to the text position. @@ -3526,17 +3520,6 @@ Align defaults to kLeft_Align. and by its height if Flags has kVerticalText_Flag set. ## -#Enum ## - -#Enum -#Line # number of Text_Align values ## - -#Code - enum { - kAlignCount = 3, - }; -## - #Const kAlignCount 3 The number of different Text_Align values defined. ## |