Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8243009: SwingSet2 scrolling doesn't repaint properly on Catalina
  • Loading branch information
aghaisas committed May 14, 2020
1 parent bd03d4d commit 1773b20de20d1ccc009e48ac988c60cfd5486c3c
Showing with 24 additions and 3 deletions.
  1. +24 −3 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLBlitLoops.m
@@ -815,13 +815,34 @@ jboolean clipDestCoords(
J2dTraceImpl(J2D_TRACE_VERBOSE, JNI_TRUE, "MTLBlitLoops_CopyArea: bdst=%p [tex=%p] %dx%d | src (%d, %d), %dx%d -> dst (%d, %d)",
dstOps, dstOps->pTexture, ((id<MTLTexture>)dstOps->pTexture).width, ((id<MTLTexture>)dstOps->pTexture).height, x, y, width, height, dx, dy);
#endif //DEBUG
id <MTLBlitCommandEncoder> blitEncoder = [mtlc.encoderManager createBlitEncoder];
[blitEncoder
copyFromTexture:dstOps->pTexture

@autoreleasepool {
id<MTLCommandBuffer> cb = [mtlc createBlitCommandBuffer];
id<MTLBlitCommandEncoder> blitEncoder = [cb blitCommandEncoder];

// Create an intrermediate buffer
int totalBuffsize = width * height * 4;
id <MTLBuffer> buff = [mtlc.device newBufferWithLength:totalBuffsize options:MTLResourceStorageModePrivate];

[blitEncoder copyFromTexture:dstOps->pTexture
sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(x, y, 0) sourceSize:MTLSizeMake(width, height, 1)
toBuffer:buff destinationOffset:0 destinationBytesPerRow:(width * 4) destinationBytesPerImage:totalBuffsize];

[blitEncoder copyFromBuffer:buff
sourceOffset:0 sourceBytesPerRow:width*4 sourceBytesPerImage:totalBuffsize sourceSize:MTLSizeMake(width, height, 1)
toTexture:dstOps->pTexture destinationSlice:0 destinationLevel:0 destinationOrigin:MTLOriginMake(x + dx, y + dy, 0)];
[blitEncoder endEncoding];

[cb commit];
//[cb waitUntilCompleted];

/*[blitEncoder
copyFromTexture:dstOps->pTexture
sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(x, y, 0) sourceSize:MTLSizeMake(width, height, 1)
toTexture:dstOps->pTexture destinationSlice:0 destinationLevel:0 destinationOrigin:MTLOriginMake(x + dx, y + dy, 0)];
[blitEncoder endEncoding];*/

}
// TODO:
// 1. check rect bounds
// 2. support CopyArea with extra-alpha (and with custom Composite if necessary)

0 comments on commit 1773b20

Please sign in to comment.