Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8263159: Cleanup code based on review comments
  • Loading branch information
jayathirthrao committed Mar 8, 2021
1 parent d605bfb commit 6d34f21d679df160cfb794d1dc1894f63c41324c
@@ -70,15 +70,18 @@ public CGraphicsDevice(final int displayID) {
this.displayID = displayID;

if (MacOSFlags.isMetalEnabled()) {
// Try to create MTLGraphicsConfig, if it fails, try to create CGLGraphicsConfig as a fallback
// Try to create MTLGraphicsConfig, if it fails,
// try to create CGLGraphicsConfig as a fallback
this.config = MTLGraphicsConfig.getConfig(this, displayID);

if (this.config != null) {
metalPipelineEnabled = true;
} else {
// Try falling back to OpenGL pipeline
if (MacOSFlags.isMetalVerbose()) {
System.out.println("Metal rendering pipeline initialization failed. Using OpenGL rendering pipeline.");
System.out.println("Metal rendering pipeline" +
" initialization failed,using OpenGL" +
" rendering pipeline");
}

this.config = CGLGraphicsConfig.getConfig(this);
@@ -88,15 +91,18 @@ public CGraphicsDevice(final int displayID) {
}
}
} else {
// Try to create CGLGraphicsConfig, if it fails, try to create MTLGraphicsConfig as a fallback
// Try to create CGLGraphicsConfig, if it fails,
// try to create MTLGraphicsConfig as a fallback
this.config = CGLGraphicsConfig.getConfig(this);

if (this.config != null) {
oglPipelineEnabled = true;
} else {
// Try falling back to Metal pipeline
if (MacOSFlags.isOGLVerbose()) {
System.out.println("OpenGL rendering pipeline initialization failed. Using Metal rendering pipeline.");
System.out.println("OpenGL rendering pipeline" +
" initialization failed,using Metal" +
" rendering pipeline");
}

this.config = MTLGraphicsConfig.getConfig(this, displayID);
@@ -110,7 +116,8 @@ public CGraphicsDevice(final int displayID) {
if (!metalPipelineEnabled && !oglPipelineEnabled) {
// This indicates fallback to other rendering pipeline also failed.
// Should never reach here
throw new InternalError("Error - unable to initialize any rendering pipeline.");
throw new InternalError("Error - unable to initialize any" +
" rendering pipeline.");
}

if (metalPipelineEnabled && MacOSFlags.isMetalVerbose()) {
@@ -55,7 +55,7 @@ static void setScratchSurface(MTLGraphicsConfig gc) {
/**
* Makes the given GraphicsConfig's context current to its associated
* "scratch surface". Each GraphicsConfig maintains a native context
* (MTLDevice) as well as a native pbuffer
* (MTLDevice) as well as a native MTLTexture
* known as the "scratch surface". By making the context current to the
* scratch surface, we are assured that we have a current context for
* the relevant GraphicsConfig, and can therefore perform operations
@@ -22,6 +22,7 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package sun.java2d.metal;

import sun.java2d.InvalidPipeException;
@@ -192,7 +192,9 @@ public static MTLLayerSurfaceData createData(MTLLayer layer) {
* Creates a SurfaceData object representing an off-screen buffer
*/
public static MTLOffScreenSurfaceData createData(MTLGraphicsConfig gc,
int width, int height, ColorModel cm, Image image, int type) {
int width, int height,
ColorModel cm, Image image,
int type) {
return new MTLOffScreenSurfaceData(gc, width, height, image, cm,
type);
}
@@ -33,7 +33,6 @@
#include "MTLUtils.h"
#include "GraphicsPrimitiveMgr.h"

#include <stdlib.h> // malloc
#include <string.h> // memcpy
#include "IntArgbPre.h"

@@ -51,7 +51,6 @@
* and WGL) source files.
*/
extern void MTLGC_DestroyMTLGraphicsConfig(jlong pConfigInfo);
extern void MTLSD_SwapBuffers(JNIEnv *env, jlong window);

void MTLRenderQueue_CheckPreviousOp(jint op) {

@@ -695,15 +694,6 @@ void MTLRenderQueue_CheckPreviousOp(jint op) {
break;
}

// multibuffering ops
case sun_java2d_pipe_BufferedOpCodes_SWAP_BUFFERS:
{
CHECK_PREVIOUS_OP(MTL_OP_OTHER);
jlong window = NEXT_LONG(b);
MTLSD_SwapBuffers(env, window);
break;
}

// special no-op (mainly used for achieving 8-byte alignment)
case sun_java2d_pipe_BufferedOpCodes_NOOP:
break;
@@ -312,12 +312,6 @@ static jboolean MTLSurfaceData_initTexture(BMTLSDOps *bmtlsdo, jboolean isOpaque
return JNI_TRUE;
}

void
MTLSD_SwapBuffers(JNIEnv *env, jlong pPeerData)
{
J2dTraceLn(J2D_TRACE_ERROR, "MTLSD_SwapBuffers -- :TODO");
}

#pragma mark -
#pragma mark "--- MTLSurfaceData methods ---"

0 comments on commit 6d34f21

Please sign in to comment.