summaryrefslogtreecommitdiffstats
path: root/skia/sgl
diff options
context:
space:
mode:
authorsenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 18:37:42 +0000
committersenorblanco@chromium.org <senorblanco@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-30 18:37:42 +0000
commitbcc94a375c5fd8385473dbaabb3df75151aae17b (patch)
tree3a7ff15d407f3106465f45105dc260b314119b2d /skia/sgl
parent416caa1f78707656fdbe4c5e3ee50985e2ad0ad0 (diff)
downloadchromium_src-bcc94a375c5fd8385473dbaabb3df75151aae17b.zip
chromium_src-bcc94a375c5fd8385473dbaabb3df75151aae17b.tar.gz
chromium_src-bcc94a375c5fd8385473dbaabb3df75151aae17b.tar.bz2
In certain cases, the coordinates used for pattern rendering can go
negative, eg., when a negative translation is applied in the shader matrix. This causes the rasterizer to blow up, since it accesses memory outside the pattern bitmap. Since the integer modulus operator for C++ has unspecified behaviour with negative arguments, its value may go negative. In this case, we must offset by the modulus to make it positive again. I decided to do this at a low level in skia, since it seems better to make skia robust than to pray that you get strictly non-negative translations. (There is a fix for this in src/skia/tile_patch.diff, but it's wrong.) This patch should be upstreamed to skia. Review URL: http://codereview.chromium.org/55044 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/sgl')
-rw-r--r--skia/sgl/SkBitmapProcState_matrixProcs.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/skia/sgl/SkBitmapProcState_matrixProcs.cpp b/skia/sgl/SkBitmapProcState_matrixProcs.cpp
index a16c8b3..c3787a0 100644
--- a/skia/sgl/SkBitmapProcState_matrixProcs.cpp
+++ b/skia/sgl/SkBitmapProcState_matrixProcs.cpp
@@ -37,8 +37,9 @@ void decal_filter_scale(uint32_t dst[], SkFixed fx, SkFixed dx, int count);
#define TILEY_PROCF(fy, max) (((fy) & 0xFFFF) * ((max) + 1) >> 16)
#define TILEX_LOW_BITS(fx, max) ((((fx) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
#define TILEY_LOW_BITS(fy, max) ((((fy) & 0xFFFF) * ((max) + 1) >> 12) & 0xF)
-#define TILEX_TRANS(x, max) ((x) % ((max) + 1))
-#define TILEY_TRANS(y, max) ((y) % ((max) + 1))
+#define SK_MOD(a, b) (((a)%(b)) < 0 ? ((a)%(b) + (b)) : (a)%(b))
+#define TILEX_TRANS(x, max) (SK_MOD((x), ((max) + 1)))
+#define TILEY_TRANS(y, max) (SK_MOD((y), ((max) + 1)))
#include "SkBitmapProcState_matrix.h"
#define MAKENAME(suffix) GeneralXY ## suffix