diff --git a/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h b/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h index 6c674612f0371f65524eac3cd687ba519a4d941b..1e7a97713f266db49b91d43a5009d544449e11b3 100644 --- a/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h +++ b/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.h @@ -489,6 +489,8 @@ extern struct _CompositeTypes { #define PtrCoord(p, x, xinc, y, yinc) PtrAddBytes(p, \ ((ptrdiff_t)(y))*(yinc) + \ ((ptrdiff_t)(x))*(xinc)) +#define PtrPixelsRow(p, y, scanStride) PtrAddBytes(p, \ + ((intptr_t) (y)) * (scanStride)) /* * The function to call with an array of NativePrimitive structures diff --git a/src/share/native/sun/java2d/loops/LoopMacros.h b/src/share/native/sun/java2d/loops/LoopMacros.h index 370d024966f2538b89c8e020dcc532ebe072e37d..e4c634c699185223f95b3bee937bdeacfc1fa6c6 100644 --- a/src/share/native/sun/java2d/loops/LoopMacros.h +++ b/src/share/native/sun/java2d/loops/LoopMacros.h @@ -137,7 +137,7 @@ do { \ juint w = WIDTH; \ jint tmpsxloc = SXLOC; \ - SRCPTR = PtrAddBytes(SRCBASE, ((SYLOC >> SHIFT) * srcScan)); \ + SRCPTR = PtrPixelsRow(SRCBASE, (SYLOC >> SHIFT), srcScan); \ Init ## DSTTYPE ## StoreVarsX(DSTPREFIX, DSTINFO); \ do { \ jint XVAR = (tmpsxloc >> SHIFT); \ @@ -2015,7 +2015,7 @@ void NAME_TRANSFORMHELPER_NN(SRC)(SurfaceDataRasInfo *pSrcInfo, \ \ Init ## SRC ## LoadVars(SrcRead, pSrcInfo); \ while (pRGB < pEnd) { \ - SRC ## DataType *pRow = PtrAddBytes(pBase, WholeOfLong(ylong) * scan); \ + SRC ## DataType *pRow = PtrPixelsRow(pBase, WholeOfLong(ylong), scan); \ Copy ## SRC ## ToIntArgbPre(pRGB, 0, \ SrcRead, pRow, WholeOfLong(xlong)); \ pRGB++; \ @@ -2063,7 +2063,7 @@ void NAME_TRANSFORMHELPER_BL(SRC)(SurfaceDataRasInfo *pSrcInfo, \ ydelta &= scan; \ \ xwhole += cx; \ - pRow = PtrAddBytes(pSrcInfo->rasBase, (ywhole + cy) * scan); \ + pRow = PtrPixelsRow(pSrcInfo->rasBase, (ywhole + cy), scan); \ Copy ## SRC ## ToIntArgbPre(pRGB, 0, SrcRead, pRow, xwhole); \ Copy ## SRC ## ToIntArgbPre(pRGB, 1, SrcRead, pRow, xwhole+xdelta); \ pRow = PtrAddBytes(pRow, ydelta); \ @@ -2121,7 +2121,7 @@ void NAME_TRANSFORMHELPER_BC(SRC)(SurfaceDataRasInfo *pSrcInfo, \ ydelta1 += (isneg & -scan); \ \ xwhole += cx; \ - pRow = PtrAddBytes(pSrcInfo->rasBase, (ywhole + cy) * scan); \ + pRow = PtrPixelsRow(pSrcInfo->rasBase, (ywhole + cy), scan); \ pRow = PtrAddBytes(pRow, ydelta0); \ Copy ## SRC ## ToIntArgbPre(pRGB, 0, SrcRead, pRow, xwhole+xdelta0); \ Copy ## SRC ## ToIntArgbPre(pRGB, 1, SrcRead, pRow, xwhole ); \ diff --git a/src/share/native/sun/java2d/opengl/OGLBlitLoops.c b/src/share/native/sun/java2d/opengl/OGLBlitLoops.c index c96791f76cc54d1f110ce87284218400f6000cdc..5e36606e986f762d1eb239efbe5d4ab1d87fedb1 100644 --- a/src/share/native/sun/java2d/opengl/OGLBlitLoops.c +++ b/src/share/native/sun/java2d/opengl/OGLBlitLoops.c @@ -717,8 +717,8 @@ void flip(void *pDst, juint w, juint h, jint scanStride, jboolean convert) { juint step = 0; // vertical flip and convert argbpre to argb if necessary for (; i < h / 2; ++i) { - juint *r1 = PtrAddBytes(pDst, (i * scanStride)); - juint *r2 = PtrAddBytes(pDst, (h - i - 1) * scanStride); + juint *r1 = PtrPixelsRow(pDst, i, scanStride); + juint *r2 = PtrPixelsRow(pDst, h - i - 1, scanStride); if (tempRow) { // fast path memcpy(tempRow, r1, clippedStride); @@ -740,7 +740,7 @@ void flip(void *pDst, juint w, juint h, jint scanStride, jboolean convert) { } // convert the middle line if necessary if (convert && h % 2) { - juint *r1 = PtrAddBytes(pDst, (i * scanStride)); + juint *r1 = PtrPixelsRow(pDst, i, scanStride); for (step = 0; step < w; ++step) { LoadIntArgbPreTo1IntArgb(r1, 0, step, r1[step]); } @@ -813,7 +813,7 @@ OGLBlitLoops_SurfaceToSwBlit(JNIEnv *env, OGLContext *oglc, height = srcInfo.bounds.y2 - srcInfo.bounds.y1; pDst = PtrAddBytes(pDst, dstx * dstInfo.pixelStride); - pDst = PtrAddBytes(pDst, dsty * dstInfo.scanStride); + pDst = PtrPixelsRow(pDst, dsty, dstInfo.scanStride); j2d_glPixelStorei(GL_PACK_ROW_LENGTH, dstInfo.scanStride / dstInfo.pixelStride); diff --git a/src/windows/native/sun/java2d/d3d/D3DContext.cpp b/src/windows/native/sun/java2d/d3d/D3DContext.cpp index 8722d549bad9ac91ae5f43e5fb8ef44255dd958b..9d62f4ce37ec269f2ec02cbcc37a6cb58cd5e3a8 100644 --- a/src/windows/native/sun/java2d/d3d/D3DContext.cpp +++ b/src/windows/native/sun/java2d/d3d/D3DContext.cpp @@ -1156,7 +1156,9 @@ D3DContext::UploadTileToTexture(D3DResource *pTextureRes, void *pixels, { #ifndef PtrAddBytes #define PtrAddBytes(p, b) ((void *) (((intptr_t) (p)) + (b))) -#define PtrCoord(p, x, xinc, y, yinc) PtrAddBytes(p, (y)*(yinc) + (x)*(xinc)) +#define PtrCoord(p, x, xinc, y, yinc) PtrAddBytes(p, \ + ((ptrdiff_t)(y))*(yinc) + \ + ((ptrdiff_t)(x))*(xinc)) #endif // PtrAddBytes HRESULT res = S_OK;