| Index: src/effects/gradients/SkGradientShaderPriv.h
|
| diff --git a/src/effects/gradients/SkGradientShaderPriv.h b/src/effects/gradients/SkGradientShaderPriv.h
|
| index 5b1b09b9fccece7273a90d25d3414c00f8788523..ef16250dc189fa583b39b12b9c3dcddf7b99c414 100644
|
| --- a/src/effects/gradients/SkGradientShaderPriv.h
|
| +++ b/src/effects/gradients/SkGradientShaderPriv.h
|
| @@ -8,6 +8,8 @@
|
| #ifndef SkGradientShaderPriv_DEFINED
|
| #define SkGradientShaderPriv_DEFINED
|
|
|
| +#include "math.h"
|
| +
|
| #include "SkGradientBitmapCache.h"
|
| #include "SkGradientShader.h"
|
| #include "SkClampRange.h"
|
| @@ -39,14 +41,23 @@ static inline void sk_memset32_dither(uint32_t dst[], uint32_t v0, uint32_t v1,
|
|
|
| // Clamp
|
|
|
| -static inline SkFixed clamp_tileproc(SkFixed x) {
|
| - return SkClampMax(x, 0xFFFF);
|
| +static inline unsigned clamp_tileproc(float x) {
|
| + unsigned result = (unsigned)(0xFFFF * SkTPin(x, 0.0f, 1.0f));
|
| + if (result > 0xFFFF) {
|
| + SkDebugf("clamp_tileproc: x: %f result: %d\n", x, result);
|
| + }
|
| + return result;
|
| }
|
|
|
| // Repeat
|
|
|
| -static inline SkFixed repeat_tileproc(SkFixed x) {
|
| - return x & 0xFFFF;
|
| +static inline unsigned repeat_tileproc(float x) {
|
| + float modulo = fmod(x, 1.0f);
|
| + unsigned result = (unsigned)(0xFFFF * modulo);
|
| + if (result > 0xFFFF) {
|
| + SkDebugf("repeat_tileproc: x: %f modulo: %f result: %d\n", x, modulo, result);
|
| + }
|
| + return result;
|
| }
|
|
|
| // Mirror
|
| @@ -57,9 +68,17 @@ static inline SkFixed repeat_tileproc(SkFixed x) {
|
| #pragma optimize("", off)
|
| #endif
|
|
|
| -static inline SkFixed mirror_tileproc(SkFixed x) {
|
| - int s = SkLeftShift(x, 15) >> 31;
|
| - return (x ^ s) & 0xFFFF;
|
| +static inline unsigned mirror_tileproc(float x) {
|
| + const float x_mod_2 = fmod(x, 2.0f);
|
| + int x_17bits = (int)(x_mod_2 * 0x10000);
|
| + if (x_17bits & 0x10000) {
|
| + x_17bits = ~x_17bits;
|
| + }
|
| + unsigned result = x_17bits & 0xFFFF;
|
| + if (result > 0xFFFF) {
|
| + SkDebugf("mirror_tileproc: x: %f x_mod_2: %f x_17bits: %d result: %d\n", x, x_mod_2, x_17bits, result);
|
| + }
|
| + return result;
|
| }
|
|
|
| #if defined(_MSC_VER) && (_MSC_VER >= 1600)
|
| @@ -68,7 +87,7 @@ static inline SkFixed mirror_tileproc(SkFixed x) {
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
| -typedef SkFixed (*TileProc)(SkFixed);
|
| +typedef unsigned (*TileProc)(float);
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|