diff options
author | Jim Van Verth <jvanverth@google.com> | 2017-02-10 15:24:39 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-10 21:26:33 +0000 |
commit | 6e83b13c226246041a33dc7bf0e92626581b5e79 (patch) | |
tree | 555310ae893c0e52c440e1163bb43dace38e4afa /src/core/SkMathPriv.h | |
parent | 368af4605db18f7197ed3289d2ebdc93bbb5879b (diff) |
Use SDF path miplevels based on the original path's size.
Should produce sharper results than arbitrary fixed sizes.
Adds a new test to pathfill GM.
BUG=chromium:682918
Change-Id: I5a394098665d01e995a244fde278236f1471e6c9
Reviewed-on: https://skia-review.googlesource.com/8328
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Jim Van Verth <jvanverth@google.com>
Diffstat (limited to 'src/core/SkMathPriv.h')
-rw-r--r-- | src/core/SkMathPriv.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/core/SkMathPriv.h b/src/core/SkMathPriv.h index 14ebeb17b7..5ef0cb25e4 100644 --- a/src/core/SkMathPriv.h +++ b/src/core/SkMathPriv.h @@ -132,6 +132,16 @@ static inline int SkNextPow2(int value) { } /** +* Returns the largest power-of-2 that is <= the specified value. If value +* is already a power of 2, then it is returned unchanged. It is undefined +* if value is <= 0. +*/ +static inline int SkPrevPow2(int value) { + SkASSERT(value > 0); + return 1 << (32 - SkCLZ(value >> 1)); +} + +/** * Returns the log2 of the specified value, were that value to be rounded up * to the next power of 2. It is undefined to pass 0. Examples: * SkNextLog2(1) -> 0 @@ -145,6 +155,20 @@ static inline int SkNextLog2(uint32_t value) { return 32 - SkCLZ(value - 1); } +/** +* Returns the log2 of the specified value, were that value to be rounded down +* to the previous power of 2. It is undefined to pass 0. Examples: +* SkPrevLog2(1) -> 0 +* SkPrevLog2(2) -> 1 +* SkPrevLog2(3) -> 1 +* SkPrevLog2(4) -> 2 +* SkPrevLog2(5) -> 2 +*/ +static inline int SkPrevLog2(uint32_t value) { + SkASSERT(value != 0); + return 32 - SkCLZ(value >> 1); +} + /////////////////////////////////////////////////////////////////////////////// /** |