On Thu, 4 Feb 2021 10:35:02 GMT, Ajit Ghaisas <aghai...@openjdk.org> wrote:

> **Description :**
> This is the implementation of [JEP 382 : New macOS Rendering 
> Pipeline](https://bugs.openjdk.java.net/browse/JDK-8238361)
> It implements a Java 2D internal rendering pipeline for macOS using the Apple 
> Metal API.
> The entire work on this was done under [OpenJDK Project - 
> Lanai](http://openjdk.java.net/projects/lanai/)
> 
> We iterated through several Early Access (EA) builds and have reached a stage 
> where it is ready to be integrated to openjdk/jdk. The latest EA build is 
> available at - https://jdk.java.net/lanai/
> 
> A new option -Dsun.java2d.metal=true | True needs to be used to use this 
> pipeline.
> 
> **Testing :**
> This implementation has been tested with the tests present at - [Test Plan 
> for JEP 382: New macOS Rendering 
> Pipeline](https://bugs.openjdk.java.net/browse/JDK-8251396)
> 
> **Note to reviewers :**
> 1) Default rendering pipeline on macOS has not been changed by this PR. 
> OpenGL still stays as the default rendering pipeline and Metal rendering 
> pipeline is optional to choose.
> 
> 2) To apply and test this PR - 
> To enable the metal pipeline you must specify on command line 
> -Dsun.java2d.metal=true (No message will be printed in this case) or 
> -Dsun.java2d.metal=True (A message indicating Metal rendering pipeline is 
> enabled gets printed)

Here is my initial set of mostly minor comments and a couple questions.

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLLayer.h line 33:

> 31: #import "common.h"
> 32: 
> 33: #import <JavaNativeFoundation/JavaNativeFoundation.h>

JNF has been removed from the jdk, so this must be removed or it will no longer 
compile. It has already been fixed in the lanai repo by 
[JDK-8261234](https://bugs.openjdk.java.net/browse/JDK-8261234).

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m 
line 38:

> 36: #import <string.h>
> 37: #import <ApplicationServices/ApplicationServices.h>
> 38: #import <JavaNativeFoundation/JavaNativeFoundation.h>

JNF has been removed from the jdk, so this must be removed or it will no longer 
compile. It has already been fixed in the lanai repo by 
[JDK-8261234](https://bugs.openjdk.java.net/browse/JDK-8261234).

make/modules/java.desktop/lib/Awt2dLibraries.gmk line 894:

> 892:   SHADERS_SUPPORT_DIR := 
> $(SUPPORT_OUTPUTDIR)/native/java.desktop/libosxui
> 893:   SHADERS_AIR := $(SHADERS_SUPPORT_DIR)/shaders.air
> 894:   SHADERS_LIB := $(INSTALL_LIBRARIES_HERE)/shaders.metallib

Q: Should 2d (or awt) be in the name of this file, or is a generic name OK?

src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java line 2:

> 1: /*
> 2:  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.

Should be `2019, 2021,` (I missed this file when I fixed up the copyright 
notices and years).

src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java line 81:

> 79:             (PrivilegedAction<String>) () ->
> 80:                     System.getProperty("java.home", "") + File.separator +
> 81:                             "lib" + File.separator + "shaders.metallib");

Same question as in the makefile about the name of the shader library file.

src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java line 
155:

> 153:             if (cfginfo != 0L) {
> 154:                 textureSize = nativeGetMaxTextureSize();
> 155:                 // 7160609: GL still fails to create a square texture of 
> this

This refers to GL. Is this relevant to metal?

src/java.desktop/macosx/classes/sun/java2d/metal/MTLRenderQueue.java line 78:

> 76:      * of the MTL pipeline and related classes.
> 77:      */
> 78:     public static void sync() {

Should this be synchronized?

src/java.desktop/macosx/classes/sun/java2d/opengl/CGLGraphicsConfig.java line 
142:

> 140:                 // TODO : This clamping code is same as in OpenGL.
> 141:                 // Whether we need such clamping or not in case of Metal
> 142:                 // will be pursued under 8260644

This change seems wrong. The comment suggests it belong in a metal class or 
method, not here where we are using OpenGL.

src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformView.java line 193:

> 191:             responder.handleScrollEvent(x, y, absX, absY, 
> event.getModifierFlags(),
> 192:                     event.getScrollDeltaX(), event.getScrollDeltaY(),
> 193:                     event.getScrollPhase());

Minor: This part of the file is otherwise unchanged. Maybe revert this 
whitespace-only change? Same applies to the last two changes in this file.

src/java.desktop/macosx/classes/sun/lwawt/macosx/CWarningWindow.java line 227:

> 225:                             CWrapper.NSWindow.orderWindow(ptr,
> 226:                                     CWrapper.NSWindow.NSWindowAbove,
> 227:                                     ownerPtr);

Minor: This part of the file is otherwise unchanged. Maybe revert this 
whitespace-only change? Same applies futher down in a couple places.

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/EncoderManager.h line 
47:

> 45:  *  2. Updates 'mutable' properties encoder: pipelineState (with 
> corresponding buffers), clip, transform, e.t.c. To avoid
> 46:  *  unnecessary calls of [encoder setXXX] this manager compares requested 
> state with cached one.
> 47:  * */

Minor: `* */` --> `*/`

src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/EncoderManager.m line 
204:

> 202: {
> 203:     if (clip.stencilMaskGenerationInProgress == JNI_TRUE) {
> 204:         // don't set setScissorOrStencil when generateion in progress

Minor: typo in comment, should be `generation`.

-------------

PR: https://git.openjdk.java.net/jdk/pull/2403

Reply via email to