Skip to content

feat: accelerated paint - #3

Merged
trethore merged 5 commits into
masterfrom
dev
Mar 21, 2026
Merged

trethore merged 5 commits into
masterfrom
dev

Conversation

@trethore

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for accelerated (GPU/shared-texture) windowless rendering and external begin-frame driving, extending both the native CEF callbacks and the Java-facing JCEF API surface to carry platform-specific GPU resource information.

Changes:

  • Implement CefRenderHandler::OnAcceleratedPaint native-to-Java bridging with new Java CefAcceleratedPaintInfo* data structures.
  • Add CefBrowser#sendExternalBeginFrame() and plumb new CefBrowserSettings flags (shared_texture_enabled, external_begin_frame_enabled) into native browser creation.
  • Introduce a public CefBrowserWindowless base class and update OSR messaging/tooling (.gitignore, clone script, README formatting).

Reviewed changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
native/render_handler.h Declares native OnAcceleratedPaint override.
native/render_handler.cpp Implements accelerated paint JNI bridging and Linux dmabuf plane mapping.
native/jni_util.h Declares SetJNIFieldLong helper.
native/jni_util.cpp Implements SetJNIFieldLong.
native/CefBrowser_N.h Declares JNI export for N_SendExternalBeginFrame.
native/CefBrowser_N.cpp Plumbs OSR parent handle derivation and new windowless flags; adds native begin-frame call.
java/org/cef/handler/CefRenderHandlerAdapter.java Adds no-op accelerated paint + listener hooks to adapter.
java/org/cef/handler/CefRenderHandler.java Adds accelerated paint callback + listener method defaults.
java/org/cef/handler/CefAcceleratedPaintInfo.java Adds base accelerated paint info DTO.
java/org/cef/handler/CefAcceleratedPaintInfoWin.java Windows-specific shared texture handle DTO.
java/org/cef/handler/CefAcceleratedPaintInfoMac.java macOS-specific IOSurface handle DTO.
java/org/cef/handler/CefAcceleratedPaintInfoLinux.java Linux dmabuf plane metadata DTO.
java/org/cef/browser/CefBrowser_N.java Adds Java wrapper for sendExternalBeginFrame() native call.
java/org/cef/browser/CefBrowserWr.java Throws unsupported for begin-frame on windowed browsers.
java/org/cef/browser/CefBrowserWindowless.java New public base class for custom windowless browser implementations.
java/org/cef/browser/CefBrowserFactory.java Updates OSR error message to guide users to CefBrowserWindowless.
java/org/cef/browser/CefBrowser.java Adds sendExternalBeginFrame() API to the interface.
java/org/cef/browser/CefAcceleratedPaintEvent.java Adds event wrapper for accelerated paint callbacks.
java/org/cef/CefClient.java Forwards onAcceleratedPaint to the real render handler.
java/org/cef/CefBrowserSettings.java Adds and clones new OSR flags.
clone_cef.sh Adds helper script to clone upstream CEF into /cef.
README.md Markdown list formatting cleanup.
.gitignore Ignores /cef directory created by clone script.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread native/render_handler.cpp Outdated
Comment on lines +314 to +316
SetJNIFieldInt(env, cls, jpaintInfo, "format", info.format);
SetJNIFieldInt(env, cls, jpaintInfo, "width", viewRect.width);
SetJNIFieldInt(env, cls, jpaintInfo, "height", viewRect.height);

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnAcceleratedPaint sets the Java paint info width/height from GetViewRect() (viewRect.width/height). This will be incorrect for PET_POPUP (and may diverge from the actual shared-texture dimensions). Consider populating width/height based on the painted element (e.g., popup size when type==PET_POPUP) or using dimensions provided by the accelerated paint info if available, so Java consumers (e.g., CefAcceleratedPaintEvent#getWidth/Height) receive accurate values.

Copilot uses AI. Check for mistakes.
Comment thread native/render_handler.cpp Outdated
Comment on lines +337 to +340
jfieldID fdsField = env->GetFieldID(cls, "plane_fds", "[I");
jfieldID stridesField = env->GetFieldID(cls, "plane_strides", "[I");
jfieldID offsetsField = env->GetFieldID(cls, "plane_offsets", "[J");
jfieldID sizesField = env->GetFieldID(cls, "plane_sizes", "[J");

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JNIEnv::GetFieldID will raise a pending Java exception (NoSuchFieldError) when a field is missing. Here the results are checked, but any pending exception is not cleared/handled before continuing, which can cause the later JNI_CALL_VOID_METHOD to fail silently. Please clear the exception and return early (or use a helper that clears exceptions) when any GetFieldID call fails.

Suggested change
jfieldID fdsField = env->GetFieldID(cls, "plane_fds", "[I");
jfieldID stridesField = env->GetFieldID(cls, "plane_strides", "[I");
jfieldID offsetsField = env->GetFieldID(cls, "plane_offsets", "[J");
jfieldID sizesField = env->GetFieldID(cls, "plane_sizes", "[J");
jfieldID fdsField = env->GetFieldID(cls, "plane_fds", "[I");
if (!fdsField && env->ExceptionCheck())
env->ExceptionClear();
jfieldID stridesField = env->GetFieldID(cls, "plane_strides", "[I");
if (!stridesField && env->ExceptionCheck())
env->ExceptionClear();
jfieldID offsetsField = env->GetFieldID(cls, "plane_offsets", "[J");
if (!offsetsField && env->ExceptionCheck())
env->ExceptionClear();
jfieldID sizesField = env->GetFieldID(cls, "plane_sizes", "[J");
if (!sizesField && env->ExceptionCheck())
env->ExceptionClear();

Copilot uses AI. Check for mistakes.
Comment thread native/render_handler.cpp Outdated
jlongArray offsetsArray = env->NewLongArray(plane_count);
jlongArray sizesArray = env->NewLongArray(plane_count);

if (fdsArray && stridesArray && offsetsArray && sizesArray) {

Copilot AI Mar 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NewIntArray/NewLongArray calls can throw (e.g., OOME) and leave a pending JNI exception. The code currently just checks for null and continues, which will keep the exception pending and break subsequent JNI calls. Consider checking env->ExceptionCheck() (or clearing and returning) if any array allocation fails.

Suggested change
if (fdsArray && stridesArray && offsetsArray && sizesArray) {
// NewIntArray/NewLongArray may throw (e.g., OOME) and leave a pending
// exception. Clear any such exception and only proceed when no
// exception is pending and all arrays were allocated successfully.
if (env->ExceptionCheck()) {
env->ExceptionClear();
} else if (fdsArray && stridesArray && offsetsArray && sizesArray) {

Copilot uses AI. Check for mistakes.
@trethore
trethore merged commit a1d834e into master Mar 21, 2026
@trethore
trethore deleted the dev branch March 21, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants