8264475: CopyArea ignores clip state in metal rendering pipeline
8251036: SwingSet2 - Dragging internal frame inside jframe leaves artifacts with MetalLookAndFeel Reviewed-by: aghaisas, psadhukhan
This commit is contained in:
parent
f084bd2f61
commit
0039c18e08
@ -800,23 +800,45 @@ MTLBlitLoops_CopyArea(JNIEnv *env,
|
|||||||
(dstBounds.x1 < dstBounds.x2 && dstBounds.y1 < dstBounds.y2))
|
(dstBounds.x1 < dstBounds.x2 && dstBounds.y1 < dstBounds.y2))
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
id<MTLCommandBuffer> cb = [mtlc createCommandBuffer];
|
struct TxtVertex quadTxVerticesBuffer[6];
|
||||||
id<MTLBlitCommandEncoder> blitEncoder = [cb blitCommandEncoder];
|
MTLPooledTextureHandle * interHandle =
|
||||||
|
[mtlc.texturePool getTexture:texWidth
|
||||||
|
height:texHeight
|
||||||
|
format:MTLPixelFormatBGRA8Unorm];
|
||||||
|
if (interHandle == nil) {
|
||||||
|
J2dTraceLn(J2D_TRACE_ERROR,
|
||||||
|
"MTLBlitLoops_CopyArea: texture handle is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
[[mtlc getCommandBufferWrapper] registerPooledTexture:interHandle];
|
||||||
|
|
||||||
// Create an intrermediate buffer
|
id<MTLTexture> interTexture = interHandle.texture;
|
||||||
int totalBuffsize = srcWidth * srcHeight * 4;
|
|
||||||
id <MTLBuffer> buff = [[mtlc.device newBufferWithLength:totalBuffsize options:MTLResourceStorageModePrivate] autorelease];
|
|
||||||
|
|
||||||
[blitEncoder copyFromTexture:dstOps->pTexture
|
/*
|
||||||
sourceSlice:0 sourceLevel:0 sourceOrigin:MTLOriginMake(srcBounds.x1, srcBounds.y1, 0) sourceSize:MTLSizeMake(srcWidth, srcHeight, 1)
|
* We need to consider common states like clipping while
|
||||||
toBuffer:buff destinationOffset:0 destinationBytesPerRow:(srcWidth * 4) destinationBytesPerImage:totalBuffsize];
|
* performing copyArea, thats why we use drawTex2Tex and
|
||||||
|
* get encoder with appropriate state from EncoderManager
|
||||||
|
* and not directly use MTLBlitCommandEncoder for texture copy.
|
||||||
|
*/
|
||||||
|
|
||||||
[blitEncoder copyFromBuffer:buff
|
// copy content to intermediate texture
|
||||||
sourceOffset:0 sourceBytesPerRow:srcWidth*4 sourceBytesPerImage:totalBuffsize sourceSize:MTLSizeMake(srcWidth, srcHeight, 1)
|
drawTex2Tex(mtlc, dstOps->pTexture, interTexture, dstOps->isOpaque,
|
||||||
toTexture:dstOps->pTexture destinationSlice:0 destinationLevel:0 destinationOrigin:MTLOriginMake(dstBounds.x1, dstBounds.y1, 0)];
|
JNI_FALSE, INTERPOLATION_NEAREST_NEIGHBOR,
|
||||||
[blitEncoder endEncoding];
|
0, 0, texWidth, texHeight, 0, 0, texWidth, texHeight);
|
||||||
|
|
||||||
[cb commit];
|
// copy content with appropriate bounds to destination texture
|
||||||
|
drawTex2Tex(mtlc, interTexture, dstOps->pTexture, JNI_FALSE,
|
||||||
|
dstOps->isOpaque, INTERPOLATION_NEAREST_NEIGHBOR,
|
||||||
|
srcBounds.x1, srcBounds.y1, srcBounds.x2, srcBounds.y2,
|
||||||
|
dstBounds.x1, dstBounds.y1, dstBounds.x2, dstBounds.y2);
|
||||||
|
[mtlc.encoderManager endEncoder];
|
||||||
|
MTLCommandBufferWrapper * cbwrapper =
|
||||||
|
[mtlc pullCommandBufferWrapper];
|
||||||
|
id<MTLCommandBuffer> commandbuf = [cbwrapper getCommandBuffer];
|
||||||
|
[commandbuf addCompletedHandler:^(id <MTLCommandBuffer> commandbuf) {
|
||||||
|
[cbwrapper release];
|
||||||
|
}];
|
||||||
|
[commandbuf commit];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -202,6 +202,8 @@
|
|||||||
width:(NSUInteger) width
|
width:(NSUInteger) width
|
||||||
height:(NSUInteger) height
|
height:(NSUInteger) height
|
||||||
mipmapped:NO];
|
mipmapped:NO];
|
||||||
|
textureDescriptor.usage = MTLTextureUsageRenderTarget |
|
||||||
|
MTLTextureUsageShaderRead;
|
||||||
if (isMultiSample) {
|
if (isMultiSample) {
|
||||||
textureDescriptor.textureType = MTLTextureType2DMultisample;
|
textureDescriptor.textureType = MTLTextureType2DMultisample;
|
||||||
textureDescriptor.sampleCount = MTLAASampleCount;
|
textureDescriptor.sampleCount = MTLAASampleCount;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user