Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

8245256: Cleanup OpenGL references in Metal documentation

  • Loading branch information
jayathirthrao committed Jan 7, 2021
1 parent d1919ac commit 5a0ccbd732f17dc79ee2358e51ad7ddf2d262ffa
Showing with 89 additions and 697 deletions.
  1. +1 −1 src/java.desktop/macosx/classes/sun/java2d/MacosxSurfaceManagerFactory.java
  2. +17 −17 src/java.desktop/macosx/classes/sun/java2d/metal/MTLBlitLoops.java
  3. +4 −6 src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java
  4. +1 −1 src/java.desktop/macosx/classes/sun/java2d/metal/MTLLayer.java
  5. +2 −2 src/java.desktop/macosx/classes/sun/java2d/metal/MTLMaskBlit.java
  6. +5 −6 src/java.desktop/macosx/classes/sun/java2d/metal/MTLPaints.java
  7. +4 −4 src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderQueue.java
  8. +6 −6 src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceData.java
  9. +1 −1 src/java.desktop/macosx/classes/sun/java2d/metal/MTLSurfaceDataProxy.java
  10. +2 −2 src/java.desktop/macosx/classes/sun/java2d/metal/MTLTextRenderer.java
  11. +5 −5 src/java.desktop/macosx/classes/sun/java2d/metal/MTLUtilities.java
  12. +1 −1 src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
  13. +5 −37 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLContext.h
  14. +2 −17 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLContext.m
  15. +3 −28 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.h
  16. +5 −5 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m
  17. +1 −1 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLLayer.h
  18. +2 −42 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLMaskFill.m
  19. +0 −367 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLPaints.m
  20. +3 −8 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLRenderer.m
  21. +1 −1 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLSurfaceData.h
  22. +9 −10 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLSurfaceData.m
  23. +6 −75 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLSurfaceDataBase.h
  24. +2 −3 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLTextRenderer.m
  25. +0 −1 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.h
  26. +1 −50 src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLVertexCache.m
@@ -44,7 +44,7 @@
* 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.
*/
@@ -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);
}
@@ -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,
@@ -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
@@ -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 {

@@ -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);

@@ -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 {

@@ -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);

@@ -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 {

@@ -60,7 +60,7 @@
{
//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();

@@ -82,10 +82,8 @@
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();

@@ -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();
@@ -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());
@@ -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);
}
@@ -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
@@ -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,
@@ -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;
}

@@ -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.
@@ -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) {
@@ -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);
@@ -157,11 +157,11 @@
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:
@@ -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.
*/
@@ -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.
*/
@@ -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;
}

@@ -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 {
@@ -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);
@@ -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.
*/
@@ -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();
@@ -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).
*
@@ -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);
@@ -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);
@@ -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 {

0 comments on commit 5a0ccbd

Please sign in to comment.