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

Commit

Permalink
8245256: Cleanup OpenGL references in Metal documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jayathirthrao committed Jan 7, 2021
1 parent d1919ac commit 5a0ccbd
Show file tree
Hide file tree
Showing 26 changed files with 89 additions and 697 deletions.
Expand Up @@ -44,7 +44,7 @@ public class MacosxSurfaceManagerFactory extends SurfaceManagerFactory {
* as a way for the caller to pass pipeline-specific context data to
* the VolatileSurfaceManager (such as a backbuffer handle, for example).
*
* For Mac OS X, this method returns either an CGL-specific
* For Mac OS X, this method returns either an CGL/MTL-specific
* VolatileSurfaceManager based on the GraphicsConfiguration
* under which the SunVolatileImage was created.
*/
Expand Down
34 changes: 17 additions & 17 deletions src/java.desktop/macosx/classes/sun/java2d/metal/MTLBlitLoops.java
Expand Up @@ -273,14 +273,14 @@ static void Blit(SurfaceData srcData, SurfaceData dstData,
// disposed while the operation is processed on the QFT
rq.addReference(srcData);

MTLSurfaceData oglDst = (MTLSurfaceData)dstData;
MTLSurfaceData mtlDst = (MTLSurfaceData)dstData;
if (texture) {
// make sure we have a current context before uploading
// the sysmem data to the texture object
MTLGraphicsConfig gc = oglDst.getMTLGraphicsConfig();
MTLGraphicsConfig gc = mtlDst.getMTLGraphicsConfig();
MTLContext.setScratchSurface(gc);
} else {
MTLContext.validateContext(oglDst, oglDst,
MTLContext.validateContext(mtlDst, mtlDst,
clip, comp, xform, null, null,
ctxflags);
}
Expand Down Expand Up @@ -325,35 +325,35 @@ static void IsoBlit(SurfaceData srcData, SurfaceData dstData,
MTLRenderQueue rq = MTLRenderQueue.getInstance();
rq.lock();
try {
MTLSurfaceData oglSrc = (MTLSurfaceData)srcData;
MTLSurfaceData oglDst = (MTLSurfaceData)dstData;
int srctype = oglSrc.getType();
MTLSurfaceData mtlSrc = (MTLSurfaceData)srcData;
MTLSurfaceData mtlDst = (MTLSurfaceData)dstData;
int srctype = mtlSrc.getType();
boolean rtt;
MTLSurfaceData srcCtxData;
if (srctype == MTLSurfaceData.TEXTURE) {
// the source is a regular texture object; we substitute
// the destination surface for the purposes of making a
// context current
rtt = false;
srcCtxData = oglDst;
srcCtxData = mtlDst;
} else {
// the source is a pbuffer, backbuffer, or render-to-texture
// surface; we set rtt to true to differentiate this kind
// of surface from a regular texture object
rtt = true;
if (srctype == AccelSurface.RT_TEXTURE) {
srcCtxData = oglDst;
srcCtxData = mtlDst;
} else {
srcCtxData = oglSrc;
srcCtxData = mtlSrc;
}
}

MTLContext.validateContext(srcCtxData, oglDst,
MTLContext.validateContext(srcCtxData, mtlDst,
clip, comp, xform, null, null,
ctxflags);

if (biop != null) {
MTLBufImgOps.enableBufImgOp(rq, oglSrc, srcImg, biop);
MTLBufImgOps.enableBufImgOp(rq, mtlSrc, srcImg, biop);
}

int packedParams = createPackedParams(true, texture,
Expand All @@ -368,7 +368,7 @@ static void IsoBlit(SurfaceData srcData, SurfaceData dstData,
MTLBufImgOps.disableBufImgOp(rq, biop);
}

if (rtt && oglDst.isOnScreen()) {
if (rtt && mtlDst.isOnScreen()) {
// we only have to flush immediately when copying from a
// (non-texture) surface to the screen; otherwise Swing apps
// might appear unresponsive until the auto-flush completes
Expand Down Expand Up @@ -793,7 +793,7 @@ public void Transform(SurfaceData src, SurfaceData dst,
* This general Blit implementation converts any source surface to an
* intermediate IntArgbPre surface, and then uses the more specific
* IntArgbPre->MTLSurface/Texture loop to get the intermediate
* (premultiplied) surface down to OpenGL using simple blit.
* (premultiplied) surface down to Metal using simple blit.
*/
class MTLGeneralBlit extends Blit {

Expand Down Expand Up @@ -827,7 +827,7 @@ public synchronized void Blit(SurfaceData src, SurfaceData dst,
src = convertFrom(convertsrc, src, sx, sy, w, h,
cachedSrc, BufferedImage.TYPE_INT_ARGB_PRE);

// copy IntArgbPre intermediate surface to OpenGL surface
// copy IntArgbPre intermediate surface to Metal surface
performop.Blit(src, dst, comp, clip,
0, 0, dx, dy, w, h);

Expand All @@ -842,7 +842,7 @@ public synchronized void Blit(SurfaceData src, SurfaceData dst,
* This general TransformedBlit implementation converts any source surface to an
* intermediate IntArgbPre surface, and then uses the more specific
* IntArgbPre->MTLSurface/Texture loop to get the intermediate
* (premultiplied) surface down to OpenGL using simple transformBlit.
* (premultiplied) surface down to Metal using simple transformBlit.
*/
final class MTLGeneralTransformedBlit extends TransformBlit {

Expand Down Expand Up @@ -870,7 +870,7 @@ public synchronized void Transform(SurfaceData src, SurfaceData dst,
src = convertFrom(convertsrc, src, srcx, srcy, width, height, cachedSrc,
BufferedImage.TYPE_INT_ARGB_PRE);

// transform IntArgbPre intermediate surface to OpenGL surface
// transform IntArgbPre intermediate surface to Metal surface
performop.Transform(src, dst, comp, clip, at, hint, 0, 0, dstx, dsty,
width, height);

Expand All @@ -885,7 +885,7 @@ public synchronized void Transform(SurfaceData src, SurfaceData dst,
* This general MTLAnyCompositeBlit implementation can convert any source/target
* surface to an intermediate surface using convertsrc/convertdst loops, applies
* necessary composite operation, and then uses convertresult loop to get the
* intermediate surface down to OpenGL.
* intermediate surface down to Metal.
*/
final class MTLAnyCompositeBlit extends Blit {

Expand Down
Expand Up @@ -60,7 +60,7 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
{
//private static final int kOpenGLSwapInterval =
// RuntimeOptions.getCurrentOptions().OpenGLSwapInterval;
private static final int kOpenGLSwapInterval = 0; // TODO
private static final int kMetalSwapInterval = 0; // TODO
private static boolean mtlAvailable;
private static ImageCapabilities imageCaps = new MTLImageCaps();

Expand All @@ -82,10 +82,8 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
private static native long getMTLConfigInfo(int displayID, String mtlShadersLib);

/**
* Returns GL_MAX_TEXTURE_SIZE from the shared opengl context. Must be
* called under OGLRQ lock, because this method change current context.
*
* @return GL_MAX_TEXTURE_SIZE
* Returns maximum texture size supported by Metal. Must be
* called under MTLRQ lock.
*/
private static native int nativeGetMaxTextureSize();

Expand Down Expand Up @@ -134,7 +132,7 @@ public static MTLGraphicsConfig getConfig(CGraphicsDevice device,
MTLRenderQueue rq = MTLRenderQueue.getInstance();
rq.lock();
try {
// getCGLConfigInfo() creates and destroys temporary
// getMTLConfigInfo() creates and destroys temporary
// surfaces/contexts, so we should first invalidate the current
// Java-level context and flush the queue...
MTLContext.invalidateCurrentContext();
Expand Down
Expand Up @@ -83,7 +83,7 @@ public SurfaceData replaceSurfaceData() {
}

// the layer redirects all painting to the buffer's graphics
// and blits the buffer to the layer surface (in drawInCGLContext callback)
// and blits the buffer to the layer surface (in display callback)
MTLGraphicsConfig gc = (MTLGraphicsConfig)getGraphicsConfiguration();
surfaceData = gc.createSurfaceData(this);
setScale(gc.getDevice().getScaleFactor());
Expand Down
Expand Up @@ -64,8 +64,8 @@ private MTLMaskBlit(SurfaceType srcType,
protected void validateContext(SurfaceData dstData,
Composite comp, Region clip)
{
MTLSurfaceData oglDst = (MTLSurfaceData)dstData;
MTLContext.validateContext(oglDst, oglDst,
MTLSurfaceData mtlDst = (MTLSurfaceData)dstData;
MTLContext.validateContext(mtlDst, mtlDst,
clip, comp, null, null, null,
MTLContext.NO_CONTEXT_FLAGS);
}
Expand Down
11 changes: 5 additions & 6 deletions src/java.desktop/macosx/classes/sun/java2d/metal/MTLPaints.java
Expand Up @@ -97,9 +97,8 @@ private Texture() {}
* Returns true if the given TexturePaint instance can be used by the
* accelerated MTLPaints.Texture implementation. A TexturePaint is
* considered valid if the following conditions are met:
* - the texture image dimensions are power-of-two (or the
* GL_ARB_texture_non_power_of_two extension is present)
* - the texture image can be (or is already) cached in an OpenGL
* - the texture image dimensions are power-of-two
* - the texture image can be (or is already) cached in an Metal
* texture object
*/
@Override
Expand All @@ -115,7 +114,7 @@ boolean isPaintValid(SunGraphics2D sg2d) {
if (!(srcData instanceof MTLSurfaceData)) {
// REMIND: this is a hack that attempts to cache the system
// memory image from the TexturePaint instance into an
// OpenGL texture...
// Metal texture...
srcData =
dstData.getSourceSurfaceData(bi,
SunGraphics2D.TRANSFORM_ISIDENT,
Expand All @@ -126,8 +125,8 @@ boolean isPaintValid(SunGraphics2D sg2d) {
}

// verify that the source surface is actually a texture
MTLSurfaceData oglData = (MTLSurfaceData)srcData;
if (oglData.getType() != MTLSurfaceData.TEXTURE) {
MTLSurfaceData mtlData = (MTLSurfaceData)srcData;
if (mtlData.getType() != MTLSurfaceData.TEXTURE) {
return false;
}

Expand Down
Expand Up @@ -36,7 +36,7 @@
import static sun.java2d.pipe.BufferedOpCodes.SYNC;

/**
* OGL-specific implementation of RenderQueue. This class provides a
* MTL-specific implementation of RenderQueue. This class provides a
* single (daemon) thread that is responsible for periodically flushing
* the queue, thus ensuring that only one thread communicates with the native
* OpenGL libraries for the entire process.
Expand Down Expand Up @@ -70,10 +70,10 @@ public static synchronized MTLRenderQueue getInstance() {
* Flushes the single MTLRenderQueue instance synchronously. If an
* MTLRenderQueue has not yet been instantiated, this method is a no-op.
* This method is useful in the case of Toolkit.sync(), in which we want
* to flush the OGL pipeline, but only if the OGL pipeline is currently
* to flush the MTL pipeline, but only if the MTL pipeline is currently
* enabled. Since this class has few external dependencies, callers need
* not be concerned that calling this method will trigger initialization
* of the OGL pipeline and related classes.
* of the MTL pipeline and related classes.
*/
public static void sync() {
if (theInstance != null) {
Expand Down Expand Up @@ -113,7 +113,7 @@ public static void disposeGraphicsConfig(long pConfigInfo) {
}

/**
* Returns true if the current thread is the OGL QueueFlusher thread.
* Returns true if the current thread is the MTL QueueFlusher thread.
*/
public static boolean isQueueFlusherThread() {
return (Thread.currentThread() == getInstance().flusher.thread);
Expand Down
Expand Up @@ -157,11 +157,11 @@ public abstract class MTLSurfaceData extends SurfaceData
private int nativeHeight;

/**
* Returns the appropriate SurfaceType corresponding to the given OpenGL
* Returns the appropriate SurfaceType corresponding to the given Metal
* surface type constant (e.g. TEXTURE -> MTLTexture).
*/
private static SurfaceType getCustomSurfaceType(int oglType) {
switch (oglType) {
private static SurfaceType getCustomSurfaceType(int mtlType) {
switch (mtlType) {
case TEXTURE:
return MTLTexture;
case RT_TEXTURE:
Expand Down Expand Up @@ -296,7 +296,7 @@ private void initSurfaceNow(int width, int height) {
}

/**
* Initializes the appropriate OpenGL offscreen surface based on the value
* Initializes the appropriate Metal offscreen surface based on the value
* of the type parameter. If the surface creation fails for any reason,
* an OutOfMemoryError will be thrown.
*/
Expand Down Expand Up @@ -353,7 +353,7 @@ public final int getType() {
* - blending is SrcOverNoEa or disabled
* - and the destination is opaque
*
* Eventually, we could enhance the native OGL text rendering code
* Eventually, we could enhance the native MTL text rendering code
* and remove the above restrictions, but that would require significantly
* more code just to support a few uncommon cases.
*/
Expand Down Expand Up @@ -476,7 +476,7 @@ public void validatePipe(SunGraphics2D sg2d) {
// install the text pipe based on our earlier decision
sg2d.textpipe = textpipe;

// always override the image pipe with the specialized OGL pipe
// always override the image pipe with the specialized MTL pipe
sg2d.imagepipe = mtlImagePipe;
}

Expand Down
Expand Up @@ -33,7 +33,7 @@

/**
* The proxy class contains the logic for when to replace a
* SurfaceData with a cached OGL Texture and the code to create
* SurfaceData with a cached MTL Texture and the code to create
* the accelerated surfaces.
*/
public class MTLSurfaceDataProxy extends SurfaceDataProxy {
Expand Down
Expand Up @@ -49,8 +49,8 @@ protected native void drawGlyphList(int numGlyphs, boolean usePositions,
@Override
protected void validateContext(SunGraphics2D sg2d, Composite comp) {
// assert rq.lock.isHeldByCurrentThread();
MTLSurfaceData oglDst = (MTLSurfaceData)sg2d.surfaceData;
MTLContext.validateContext(oglDst, oglDst,
MTLSurfaceData mtlDst = (MTLSurfaceData)sg2d.surfaceData;
MTLContext.validateContext(mtlDst, mtlDst,
sg2d.getCompClip(), comp,
null, sg2d.paint, sg2d,
MTLContext.NO_CONTEXT_FLAGS);
Expand Down
Expand Up @@ -40,7 +40,7 @@
class MTLUtilities {

/**
* These OGL-specific surface type constants are the same as those
* These MTL-specific surface type constants are the same as those
* defined in the MTLSurfaceData class and are duplicated here so that
* clients of this API can access them more easily via reflection.
*/
Expand All @@ -54,7 +54,7 @@ private MTLUtilities() {
}

/**
* Returns true if the current thread is the OGL QueueFlusher thread.
* Returns true if the current thread is the MTL QueueFlusher thread.
*/
public static boolean isQueueFlusherThread() {
return MTLRenderQueue.isQueueFlusherThread();
Expand Down Expand Up @@ -117,7 +117,7 @@ public static boolean invokeWithMTLContextCurrent(Graphics g, Runnable r) {
* used when the Runnable needs a current context to complete its
* operation, but does not require that the context be made current to
* a particular surface. For example, an application may call this
* method so that the given Runnable can query the OpenGL capabilities
* method so that the given Runnable can query the Metal capabilities
* of the given GraphicsConfiguration, without making a context current
* to a dummy surface (or similar hacky techniques).
*
Expand Down Expand Up @@ -199,7 +199,7 @@ public static Rectangle getMTLViewport(Graphics g,

// this is the lower-left origin of the region to be painted,
// relative to the lower-left origin of the surface
// (in OpenGL coordinates)
// (in Metal coordinates)
Rectangle surfaceBounds = sData.getBounds();
int x1 = x0;
int y1 = surfaceBounds.height - (y0 + componentHeight);
Expand Down Expand Up @@ -249,7 +249,7 @@ public static Rectangle getOGLScissorBox(Graphics g) {
int h = r.getHeight();

// this is the lower-left origin of the scissor box relative to the
// lower-left origin of the surface (in OpenGL coordinates)
// lower-left origin of the surface (in Metal coordinates)
Rectangle surfaceBounds = sData.getBounds();
int x1 = x0;
int y1 = surfaceBounds.height - (y0 + h);
Expand Down
Expand Up @@ -502,7 +502,7 @@ public Insets getScreenInsets(final GraphicsConfiguration gc) {

@Override
public void sync() {
// flush the OGL pipeline (this is a no-op if OGL is not enabled)
// flush the OGL/MTL pipeline (this is a no-op if OGL/MTL is not enabled)
if (MacOSFlags.isMetalEnabled()) {
MTLRenderQueue.sync();
} else {
Expand Down

0 comments on commit 5a0ccbd

Please sign in to comment.