Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8226384: Implement a better logic to switch between OpenGL and Metal pipeline #3851

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -29,11 +29,8 @@
import sun.java2d.SurfaceData;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.CFLayer;

import java.awt.GraphicsConfiguration;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Transparency;

public class MTLLayer extends CFLayer {

@@ -45,7 +42,6 @@
private static native void validate(long layerPtr, MTLSurfaceData mtlsd);
private static native void blitTexture(long layerPtr);

private LWWindowPeer peer;
private int scale = 1;

public MTLLayer(LWWindowPeer peer) {
@@ -55,26 +51,6 @@ public MTLLayer(LWWindowPeer peer) {
this.peer = peer;
}

public Rectangle getBounds() {
return peer.getBounds();
}

public GraphicsConfiguration getGraphicsConfiguration() {
return peer.getGraphicsConfiguration();
}

public boolean isOpaque() {
return !peer.isTranslucent();
}

public int getTransparency() {
return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
}

public Object getDestination() {
return peer.getTarget();
}

public SurfaceData replaceSurfaceData() {
if (getBounds().isEmpty()) {
surfaceData = NullSurfaceData.theInstance;
@@ -26,13 +26,10 @@
package sun.java2d.opengl;

import java.awt.GraphicsConfiguration;
import java.awt.Rectangle;
import java.awt.Transparency;

import sun.awt.CGraphicsConfig;
import sun.java2d.NullSurfaceData;
import sun.java2d.SurfaceData;
import sun.lwawt.LWWindowPeer;
import sun.java2d.SurfaceData;
import sun.lwawt.macosx.CFLayer;

public class CGLLayer extends CFLayer {
@@ -42,7 +39,6 @@
private static native void validate(long layerPtr, CGLSurfaceData cglsd);
private static native void blitTexture(long layerPtr);

private LWWindowPeer peer;
private int scale = 1;

public CGLLayer(LWWindowPeer peer) {
@@ -52,26 +48,6 @@ public CGLLayer(LWWindowPeer peer) {
this.peer = peer;
}

public Rectangle getBounds() {
return peer.getBounds();
}

public GraphicsConfiguration getGraphicsConfiguration() {
return peer.getGraphicsConfiguration();
}

public boolean isOpaque() {
return !peer.isTranslucent();
}

public int getTransparency() {
return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
}

public Object getDestination() {
return peer.getTarget();
}

public SurfaceData replaceSurfaceData() {
if (getBounds().isEmpty()) {
surfaceData = NullSurfaceData.theInstance;
@@ -27,12 +27,17 @@

import sun.java2d.SurfaceData;
import sun.java2d.NullSurfaceData;
import java.awt.GraphicsConfiguration;
import java.awt.Rectangle;
import java.awt.Transparency;
import sun.lwawt.LWWindowPeer;

/**
* Common layer class between OpenGl and Metal.
*/
public abstract class CFLayer extends CFRetainedResource {
protected SurfaceData surfaceData; // represents intermediate buffer (texture)
protected LWWindowPeer peer;

protected CFLayer(long ptr, boolean disposeOnAppKitThread) {
super(ptr, disposeOnAppKitThread);
@@ -52,4 +57,24 @@ public long getPointer() {
public SurfaceData getSurfaceData() {
return surfaceData;
}

public Rectangle getBounds() {
return peer.getBounds();
}

public GraphicsConfiguration getGraphicsConfiguration() {
return peer.getGraphicsConfiguration();
}

public boolean isOpaque() {
return !peer.isTranslucent();
}

public int getTransparency() {
return isOpaque() ? Transparency.OPAQUE : Transparency.TRANSLUCENT;
}

public Object getDestination() {
return peer.getTarget();
}
}