Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit 3fe2535

Browse files
committed
8251242: Tile based rendering results in artifacts in last column while using metal pipeline
1 parent ecf4165 commit 3fe2535

File tree

1 file changed

+16
-10
lines changed
  • src/java.desktop/macosx/native/libawt_lwawt/java2d/metal

1 file changed

+16
-10
lines changed

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLBlitLoops.m

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ jboolean clipDestCoords(
696696

697697
SurfaceData_IntersectBoundsXYXY(&srcInfo.bounds,
698698
0, 0, srcOps->width, srcOps->height);
699+
699700
SurfaceData_IntersectBlitBounds(&dstInfo.bounds, &srcInfo.bounds,
700701
srcx - dstx, srcy - dsty);
701702

@@ -721,15 +722,6 @@ jboolean clipDestCoords(
721722
srcy = srcOps->yOffset + srcy;
722723
const int srcLength = width * height * 4; // NOTE: assume that src format is MTLPixelFormatBGRA8Unorm
723724

724-
#ifdef DEBUG
725-
void *pDstEnd = dstInfo.rasBase + (height - 1)*dstInfo.scanStride + width*dstInfo.pixelStride;
726-
if (pDst + srcLength > pDstEnd) {
727-
J2dTraceLn6(J2D_TRACE_ERROR, "MTLBlitLoops_SurfaceToSwBlit: length mismatch: dstx=%d, dsty=%d, w=%d, h=%d, pixStride=%d, scanStride=%d",
728-
dstx, dsty, width, height, dstInfo.pixelStride, dstInfo.scanStride);
729-
return;
730-
}
731-
#endif //DEBUG
732-
733725
// Create MTLBuffer (or use static)
734726
MTLRasterFormatInfo rfi = RasterFormatInfos[dsttype];
735727
const jboolean directCopy = rfi.permuteMap == NULL;
@@ -789,7 +781,21 @@ jboolean clipDestCoords(
789781

790782
// Perform conversion if necessary
791783
if (directCopy) {
792-
memcpy(pDst, mtlbuf.contents, srcLength);
784+
if ((dstInfo.scanStride == width * dstInfo.pixelStride) &&
785+
(height == (dstInfo.bounds.y2 - dstInfo.bounds.y1))) {
786+
// mtlbuf.contents have same dimensions as of pDst
787+
memcpy(pDst, mtlbuf.contents, srcLength);
788+
} else {
789+
// mtlbuf.contents have smaller dimensions than pDst
790+
// copy each row from mtlbuf.contents at appropriate position in pDst
791+
// Note : pDst is already addjusted for offsets using PtrAddBytes above
792+
793+
int rowSize = width * dstInfo.pixelStride;
794+
for (int y = 0; y < height; y++) {
795+
memcpy(pDst, mtlbuf.contents + (y * rowSize), rowSize);
796+
pDst = PtrAddBytes(pDst, dstInfo.scanStride);
797+
}
798+
}
793799
} else {
794800
J2dTraceLn6(J2D_TRACE_VERBOSE,"MTLBlitLoops_SurfaceToSwBlit: dsttype=%d, raster conversion will be performed, dest rfi: %d, %d, %d, %d, hasA=%d",
795801
dsttype, rfi.permuteMap[0], rfi.permuteMap[1], rfi.permuteMap[2], rfi.permuteMap[3], rfi.hasAlpha);

0 commit comments

Comments
 (0)