8218877: Help transform transformers
authoralitvinov
Fri, 31 May 2019 18:16:57 +0100
changeset 58626 a9ed3d93cca3
parent 58625 9b54aee889b4
child 58627 92a18902b92c
8218877: Help transform transformers Reviewed-by: serb, prr, mschoene, bpb, ssahoo
src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c
src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h
src/java.desktop/share/native/libawt/java2d/loops/LoopMacros.h
src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp
--- a/src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c	Mon May 27 01:36:04 2019 -0700
+++ b/src/java.desktop/share/native/common/java2d/opengl/OGLBlitLoops.c	Fri May 31 18:16:57 2019 +0100
@@ -710,8 +710,8 @@
     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);
@@ -733,7 +733,7 @@
     }
     // 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]);
         }
@@ -806,7 +806,7 @@
             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);
--- a/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h	Mon May 27 01:36:04 2019 -0700
+++ b/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h	Fri May 31 18:16:57 2019 +0100
@@ -490,6 +490,8 @@
 #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
--- a/src/java.desktop/share/native/libawt/java2d/loops/LoopMacros.h	Mon May 27 01:36:04 2019 -0700
+++ b/src/java.desktop/share/native/libawt/java2d/loops/LoopMacros.h	Fri May 31 18:16:57 2019 +0100
@@ -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); \
@@ -2067,7 +2067,7 @@
  \
     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++; \
@@ -2115,7 +2115,7 @@
         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); \
@@ -2173,7 +2173,7 @@
         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        ); \
--- a/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp	Mon May 27 01:36:04 2019 -0700
+++ b/src/java.desktop/windows/native/libawt/java2d/d3d/D3DContext.cpp	Fri May 31 18:16:57 2019 +0100
@@ -1092,7 +1092,9 @@
 {
 #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;