<AWT Dev> RFR: 8226384: Implement a better logic to switch between OpenGL and Metal pipeline [v2]

Jayathirth D V jdv at openjdk.java.net
Mon May 10 10:18:31 UTC 2021

On Fri, 7 May 2021 19:44:31 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

>> In dispose() we call validate which internally calls corresponding RenderQueue's of OpenGL/Metal, thats why it is not moved to CFLayer.
>> For other getters since initialization of peer was happening in individual subclasses(which in turn calls OpenGL/Metal native initialization) i had kept getters also in subclasses, but we can move getters to CFLayer. I have updated the PR.
> You can add a new abstract method to the parent class: getRenderQueue(), and override it in subclasses to call MTLRenderQueue/OGL.getInstance(); In this way, you can push to the parent more methods by calling just this new getRenderQueue().
> I think the only methods which cannot be pushe dto the parent is replaceSurfaceData() due to insets usage.

I tried making this change.
Moved all methods except replaceSurfaceData() to CFLayer.java. Moved the jni native declaration also to CFlayer.java.
For this to link i need to change native JNI signatures also to map to CFLayer. But this will result in duplicate JNI symbols. If i change name of these native JNI calls to something like nativeMTL/CGLSetScale, i again have to use if/else check to verify which signature to call. Introducing a common native interface between MTLLayer.m and CGLLayer.m would not help because their implementation is different(Also it is out of scope of this PR).

I am not finding ways to move methods accessing native JNI calls to common CFLayer.


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

More information about the awt-dev mailing list