Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions src/java.desktop/macosx/classes/sun/java2d/metal/MTLLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
import sun.java2d.NullSurfaceData;
import sun.java2d.SurfaceData;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.CFRetainedResource;
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 CFRetainedResource {
public class MTLLayer extends CFLayer {

private native long nativeCreateLayer();
private static native void nativeSetScale(long layerPtr, double scale);
Expand All @@ -48,19 +48,13 @@ public class MTLLayer extends CFRetainedResource {
private LWWindowPeer peer;
private int scale = 1;

private SurfaceData surfaceData; // represents intermediate buffer (texture)

public MTLLayer(LWWindowPeer peer) {
super(0, true);

setPtr(nativeCreateLayer());
this.peer = peer;
}

public long getPointer() {
return ptr;
}

public Rectangle getBounds() {
return peer.getBounds();
}
Expand Down Expand Up @@ -103,10 +97,6 @@ public SurfaceData replaceSurfaceData() {
return surfaceData;
}

public SurfaceData getSurfaceData() {
return surfaceData;
}

public void validate(final MTLSurfaceData cglsd) {
MTLRenderQueue rq = MTLRenderQueue.getInstance();
rq.lock();
Expand Down
14 changes: 2 additions & 12 deletions src/java.desktop/macosx/classes/sun/java2d/opengl/CGLLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
import sun.java2d.NullSurfaceData;
import sun.java2d.SurfaceData;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.macosx.CFRetainedResource;
import sun.lwawt.macosx.CFLayer;

public class CGLLayer extends CFRetainedResource {
public class CGLLayer extends CFLayer {

private native long nativeCreateLayer();
private static native void nativeSetScale(long layerPtr, double scale);
Expand All @@ -45,19 +45,13 @@ public class CGLLayer extends CFRetainedResource {
private LWWindowPeer peer;
private int scale = 1;

private SurfaceData surfaceData; // represents intermediate buffer (texture)

public CGLLayer(LWWindowPeer peer) {
super(0, true);

setPtr(nativeCreateLayer());
this.peer = peer;
}

public long getPointer() {
return ptr;
}

public Rectangle getBounds() {
return peer.getBounds();
}
Expand Down Expand Up @@ -98,10 +92,6 @@ public SurfaceData replaceSurfaceData() {
return surfaceData;
}

public SurfaceData getSurfaceData() {
return surfaceData;
}

public void validate(final CGLSurfaceData cglsd) {
OGLRenderQueue rq = OGLRenderQueue.getInstance();
rq.lock();
Expand Down
55 changes: 55 additions & 0 deletions src/java.desktop/macosx/classes/sun/lwawt/macosx/CFLayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package sun.lwawt.macosx;

import sun.java2d.SurfaceData;
import sun.java2d.NullSurfaceData;

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

protected CFLayer(long ptr, boolean disposeOnAppKitThread) {
super(ptr, disposeOnAppKitThread);
}

public abstract SurfaceData replaceSurfaceData();

@Override
public void dispose() {
super.dispose();
}

public long getPointer() {
return ptr;
}

public SurfaceData getSurfaceData() {
return surfaceData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import sun.java2d.SurfaceData;
import sun.java2d.metal.MTLLayer;
import sun.java2d.opengl.CGLLayer;
import sun.lwawt.macosx.CFLayer;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformWindow;
import sun.lwawt.macosx.CFRetainedResource;
import sun.util.logging.PlatformLogger;


Expand All @@ -46,7 +46,7 @@ public class CPlatformEmbeddedFrame implements PlatformWindow {
private static final PlatformLogger focusLogger = PlatformLogger.getLogger(
"sun.lwawt.macosx.focus.CPlatformEmbeddedFrame");

private CFRetainedResource windowLayer;
private CFLayer windowLayer;
private LWWindowPeer peer;
private CEmbeddedFrame target;

Expand All @@ -71,20 +71,12 @@ public LWWindowPeer getPeer() {

@Override
public long getLayerPtr() {
if (CGraphicsDevice.usingMetalPipeline()) {
return ((MTLLayer)windowLayer).getPointer();
} else {
return ((CGLLayer)windowLayer).getPointer();
}
return windowLayer.getPointer();
}

@Override
public void dispose() {
if (CGraphicsDevice.usingMetalPipeline()) {
((MTLLayer)windowLayer).dispose();
} else {
((CGLLayer)windowLayer).dispose();
}
windowLayer.dispose();
}

@Override
Expand Down Expand Up @@ -115,20 +107,12 @@ public FontMetrics getFontMetrics(Font f) {

@Override
public SurfaceData getScreenSurface() {
if ( CGraphicsDevice.usingMetalPipeline()) {
return ((MTLLayer)windowLayer).getSurfaceData();
} else {
return ((CGLLayer)windowLayer).getSurfaceData();
}
return windowLayer.getSurfaceData();
}

@Override
public SurfaceData replaceSurfaceData() {
if (CGraphicsDevice.usingMetalPipeline()) {
return ((MTLLayer)windowLayer).replaceSurfaceData();
} else {
return ((CGLLayer)windowLayer).replaceSurfaceData();
}
return windowLayer.replaceSurfaceData();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

import sun.java2d.SurfaceData;
import sun.java2d.opengl.CGLLayer;
import sun.lwawt.macosx.CFLayer;

public class CPlatformView extends CFRetainedResource {
private native long nativeCreateView(int x, int y, int width, int height, long windowLayerPtr);
Expand All @@ -51,7 +52,7 @@ public class CPlatformView extends CFRetainedResource {

private LWWindowPeer peer;
private SurfaceData surfaceData;
private CFRetainedResource windowLayer;
private CFLayer windowLayer;
private CPlatformResponder responder;

public CPlatformView() {
Expand Down Expand Up @@ -104,10 +105,7 @@ public void setToolTip(String msg) {
// PAINTING METHODS
// ----------------------------------------------------------------------
public SurfaceData replaceSurfaceData() {
surfaceData = (CGraphicsDevice.usingMetalPipeline()) ?
((MTLLayer)windowLayer).replaceSurfaceData() :
((CGLLayer)windowLayer).replaceSurfaceData()
;
surfaceData = windowLayer.replaceSurfaceData();
return surfaceData;
}

Expand All @@ -122,9 +120,7 @@ public void dispose() {
}

public long getWindowLayerPtr() {
return CGraphicsDevice.usingMetalPipeline() ?
((MTLLayer)windowLayer).getPointer() :
((CGLLayer)windowLayer).getPointer();
return windowLayer.getPointer();
}

public void setAutoResizable(boolean toResize) {
Expand Down