# HG changeset patch # User jdv # Date 1562839973 -19800 # Node ID c43fb5314415f43d362cfbdc3ed1c2099d0686ad # Parent 0cdde100278a687a3f4ad1809d0a2e15d9bcb790 Minor performance improvement and cleanup diff -r 0cdde100278a -r c43fb5314415 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.m --- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.m Thu Jul 11 15:40:29 2019 +0530 +++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.m Thu Jul 11 15:42:53 2019 +0530 @@ -93,17 +93,18 @@ length:vertexCacheIndex * sizeof(J2DVertex) options:MTLResourceOptionCPUCacheModeDefault]; [encoder setVertexBuffer:vertexBuffer offset:0 atIndex:MeshVertexBuffer]; + [encoder setFragmentTexture:maskCacheTex atIndex: 0]; for (int i = 0; i < maskCacheIndex; i++) { J2dTraceLn1(J2D_TRACE_INFO, "MTLVertexCache_FlushVertexCache : draw texture at index %d", i); - [encoder setFragmentTexture:maskCacheTex atIndex: 0]; [encoder drawPrimitives:MTLPrimitiveTypeTriangle vertexStart:i*6 vertexCount:6]; } [encoder endEncoding]; + vertexBuffer = nil; } vertexCacheIndex = 0; maskCacheIndex = 0; - encoder = NULL; - maskCacheTex = NULL; + maskCacheTex = nil; + encoder = nil; } /** @@ -149,7 +150,10 @@ static jboolean MTLVertexCache_InitMaskCache(MTLContext *mtlc) { - J2dTraceLn(J2D_TRACE_INFO, "OGLVertexCache_InitMaskCache"); + J2dTraceLn(J2D_TRACE_INFO, "MTLVertexCache_InitMaskCache"); + // TODO : We are creating mask cache only of type MTLPixelFormatA8Unorm + // when we need more than 1 byte to store a pixel(LCD) we need to update + // below code. MTLTextureDescriptor *textureDescriptor = [MTLTextureDescriptor texture2DDescriptorWithPixelFormat:MTLPixelFormatA8Unorm width:MTLVC_MASK_CACHE_WIDTH_IN_TEXELS height:MTLVC_MASK_CACHE_HEIGHT_IN_TEXELS mipmapped:NO]; maskCacheTex = [mtlc.device newTextureWithDescriptor:textureDescriptor]; return JNI_TRUE;