Skip to content
Closed
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
9 changes: 4 additions & 5 deletions .github/workflows/build-jcef.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ on:
workflow_dispatch:

jobs:

java-cef-linux:
runs-on: [ubuntu-20.04]
runs-on: [ubuntu-22.04]
strategy:
matrix:
platform: [amd64, arm64]
Expand Down Expand Up @@ -56,7 +57,6 @@ jobs:
tar -czf windows_${{ matrix.platform }}.tar.gz windows_${{ matrix.platform }} .hash
Get-FileHash -Algorithm SHA256 -Path "windows_${{ matrix.platform }}.tar.gz" | Out-File "windows_${{ matrix.platform }}.tar.gz.sha256"
- uses: actions/upload-artifact@v4
if: ${{ github.ref == 'refs/heads/master' }}
with:
name: 'windows_${{ matrix.platform }}'
path: |
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
jcef_build/macos_${{ matrix.platform }}.tar.gz.sha256
if-no-files-found: error
check-secret:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/master'
steps:
- name: Check secret
Expand All @@ -108,10 +108,9 @@ jobs:
exit 1
fi
echo "API_TOKEN is set. Upload can proceed."

upload-to-api:
needs: [java-cef-linux, java-cef-windows, java-cef-macos, check-secret]
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
if: github.ref == 'refs/heads/master'
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON)

# Specify the CEF distribution version.
if(NOT DEFINED CEF_VERSION)
set(CEF_VERSION "122.1.10+gc902316+chromium-122.0.6261.112")
set(CEF_VERSION "130.1.9+gfc42567+chromium-130.0.6723.70")
endif()

# Determine the platform.
Expand Down
34 changes: 34 additions & 0 deletions java/org/cef/CefBrowserSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

package org.cef;

import org.cef.handler.CefOsrRendererSettings;

/**
* Browser initialization settings. Specify NULL or 0 to get the recommended
* default values. The consequences of using custom values may not be well
Expand All @@ -20,12 +22,44 @@ public class CefBrowserSettings {
*/
public int windowless_frame_rate = 0;

/**
* Set to true to enable shared texture rendering. When enabled, the browser
* will render to a shared texture that can be accessed by the host application
* for hardware-accelerated compositing. This is supported on Windows via D3D11,
* macOS via Metal/OpenGL, and Linux via native buffers.
*/
public boolean shared_texture_enabled = false;

/**
* Set to true to enable external begin frame scheduling. When enabled, the
* client must call CefBrowserHost::SendExternalBeginFrame to trigger frame
* rendering at the specified frame rate.
*/
public boolean external_begin_frame_enabled = false;

public CefBrowserSettings() {}

/**
* Apply OSR renderer settings to this browser settings object.
* This is a convenience method to configure off-screen rendering settings.
*
* @param osrSettings The OSR renderer settings to apply
*/
public void applyOsrSettings(CefOsrRendererSettings osrSettings) {
if (osrSettings != null) {
this.shared_texture_enabled = osrSettings.shared_texture_enabled;
this.external_begin_frame_enabled = osrSettings.external_begin_frame_enabled;
// Note: windowless_frame_rate can be set separately or via setWindowlessFrameRate()
// Note: background_color and other visual settings are typically handled in CefSettings
}
}

@Override
public CefBrowserSettings clone() {
CefBrowserSettings tmp = new CefBrowserSettings();
tmp.windowless_frame_rate = windowless_frame_rate;
tmp.shared_texture_enabled = shared_texture_enabled;
tmp.external_begin_frame_enabled = external_begin_frame_enabled;
return tmp;
}
}
34 changes: 24 additions & 10 deletions java/org/cef/CefClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,11 @@ public void removeDialogHandler() {

@Override
public boolean onFileDialog(CefBrowser browser, FileDialogMode mode, String title,
String defaultFilePath, Vector<String> acceptFilters, CefFileDialogCallback callback) {
String defaultFilePath, Vector<String> acceptFilters, Vector<String> acceptExtensions,
Vector<String> acceptDescriptions, CefFileDialogCallback callback) {
if (dialogHandler_ != null && browser != null) {
return dialogHandler_.onFileDialog(
browser, mode, title, defaultFilePath, acceptFilters, callback);
return dialogHandler_.onFileDialog(browser, mode, title, defaultFilePath, acceptFilters,
acceptExtensions, acceptDescriptions, callback);
}
return false;
}
Expand Down Expand Up @@ -244,9 +245,9 @@ public void onTitleChange(CefBrowser browser, String title) {
}

@Override
public void OnFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
public void onFullscreenModeChange(CefBrowser browser, boolean fullscreen) {
if (displayHandler_ != null && browser != null)
displayHandler_.OnFullscreenModeChange(browser, fullscreen);
displayHandler_.onFullscreenModeChange(browser, fullscreen);
}

@Override
Expand Down Expand Up @@ -303,10 +304,12 @@ public void removeDownloadHandler() {
}

@Override
public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
String suggestedName, CefBeforeDownloadCallback callback) {
public boolean onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem,
String suggestedName, CefBeforeDownloadCallback callback) {
if (downloadHandler_ != null && browser != null)
downloadHandler_.onBeforeDownload(browser, downloadItem, suggestedName, callback);
return downloadHandler_.onBeforeDownload(
browser, downloadItem, suggestedName, callback);
return false;
}

@Override
Expand Down Expand Up @@ -673,6 +676,15 @@ public void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects,
realHandler.onPaint(browser, popup, dirtyRects, buffer, width, height);
}

@Override
public void onAcceleratedPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects, CefAcceleratedPaintInfo info) {
if (browser == null) return;

CefRenderHandler realHandler = browser.getRenderHandler();
if (realHandler != null)
realHandler.onAcceleratedPaint(browser, popup, dirtyRects, info);
}

@Override
public void addOnPaintListener(Consumer<CefPaintEvent> listener) {}

Expand Down Expand Up @@ -757,8 +769,10 @@ public boolean onCertificateError(
}

@Override
public void onRenderProcessTerminated(CefBrowser browser, TerminationStatus status) {
if (requestHandler_ != null) requestHandler_.onRenderProcessTerminated(browser, status);
public void onRenderProcessTerminated(
CefBrowser browser, TerminationStatus status, int error_code, String error_string) {
if (requestHandler_ != null)
requestHandler_.onRenderProcessTerminated(browser, status, error_code, error_string);
}

// CefWindowHandler
Expand Down
10 changes: 0 additions & 10 deletions java/org/cef/CefSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,6 @@ public ColorType clone() {
*/
public String locales_dir_path = null;

/**
* Set to true to disable loading of pack files for resources and locales.
* A resource bundle handler must be provided for the browser and render
* processes via CefApp::GetResourceBundleHandler() if loading of pack files
* is disabled. Also configurable using the "disable-pack-loading" command-
* line switch.
*/
public boolean pack_loading_disabled = false;

/**
* Set to a value between 1024 and 65535 to enable remote debugging on the
* specified port. For example, if 8080 is specified the remote debugging URL
Expand Down Expand Up @@ -284,7 +275,6 @@ public CefSettings clone() {
tmp.javascript_flags = javascript_flags;
tmp.resources_dir_path = resources_dir_path;
tmp.locales_dir_path = locales_dir_path;
tmp.pack_loading_disabled = pack_loading_disabled;
tmp.remote_debugging_port = remote_debugging_port;
tmp.uncaught_exception_stack_size = uncaught_exception_stack_size;
if (background_color != null) tmp.background_color = background_color.clone();
Expand Down
24 changes: 18 additions & 6 deletions java/org/cef/browser/CefBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,18 +331,21 @@ public void runFileDialog(FileDialogMode mode, String title, String defaultFileP
public void stopFinding(boolean clearSelection);

/**
* Get an instance of the DevTools to be displayed in its own window or to be
* embedded within your UI. Only one instance per browser is available.
* Get an instance of the DevTools to be displayed in its own window.
*/
public CefBrowser getDevTools();
public void openDevTools();

/**
* Get an instance of the DevTools to be displayed in its own window or to be
* embedded within your UI. Only one instance per browser is available.
* Open an instance of the DevTools to be displayed in its own window.
*
* @param inspectAt a position in the UI which should be inspected.
*/
public CefBrowser getDevTools(Point inspectAt);
public void openDevTools(Point inspectAt);

/**
* Close the DevTools.
*/
public void closeDevTools();

/**
* Get an instance of a client that can be used to leverage the DevTools
Expand Down Expand Up @@ -396,6 +399,15 @@ public void runFileDialog(FileDialogMode mode, String title, String defaultFileP
*/
public void setWindowlessFrameRate(int frameRate);

/**
* Send an external begin frame to trigger frame rendering when external begin frame
* scheduling is enabled. This method should be called at the desired frame rate when
* CefBrowserSettings.external_begin_frame_enabled is set to true.
*
* @throws UnsupportedOperationException if not supported
*/
public void sendExternalBeginFrame();

/**
* Returns the maximum rate in frames per second (fps) that {@code CefRenderHandler::onPaint}
* will be called for a windowless browser. The actual fps may be lower if the browser cannot
Expand Down
5 changes: 5 additions & 0 deletions java/org/cef/browser/CefBrowserOsr.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.cef.CefBrowserSettings;
import org.cef.CefClient;
import org.cef.callback.CefDragData;
import org.cef.handler.CefAcceleratedPaintInfo;
import org.cef.handler.CefRenderHandler;
import org.cef.handler.CefScreenInfo;

Expand Down Expand Up @@ -107,6 +108,10 @@ public void removeOnPaintListener(Consumer<CefPaintEvent> listener) {
public void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects, ByteBuffer buffer, int width, int height) {
}

@Override
public void onAcceleratedPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects, CefAcceleratedPaintInfo info) {
}

@Override
public boolean onCursorChange(CefBrowser browser, final int cursorType) {
return true;
Expand Down
25 changes: 15 additions & 10 deletions java/org/cef/browser/CefBrowser_N.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public abstract class CefBrowser_N extends CefNativeAdapter implements CefBrowse
private final CefRequestContext request_context_;
private volatile CefBrowser_N parent_ = null;
private volatile Point inspectAt_ = null;
private volatile CefBrowser_N devTools_ = null;
private volatile CefDevToolsClient devToolsClient_ = null;
private boolean closeAllowed_ = false;
private volatile boolean isClosed_ = false;
Expand Down Expand Up @@ -112,7 +111,6 @@ public synchronized void onBeforeClose() {
if (request_context_ != null) request_context_.dispose();
if (parent_ != null) {
parent_.closeDevTools();
parent_.devTools_ = null;
parent_ = null;
}
if (devToolsClient_ != null) {
Expand All @@ -121,16 +119,13 @@ public synchronized void onBeforeClose() {
}

@Override
public CefBrowser getDevTools() {
return getDevTools(null);
public void openDevTools() {
openDevTools(null);
}

@Override
public synchronized CefBrowser getDevTools(Point inspectAt) {
if (devTools_ == null) {
devTools_ = createDevToolsBrowser(client_, url_, request_context_, this, inspectAt);
}
return devTools_;
public synchronized void openDevTools(Point inspectAt) {
createDevToolsBrowser(client_, url_, request_context_, this, inspectAt).createImmediately();
}

@Override
Expand Down Expand Up @@ -572,7 +567,8 @@ public void stopFinding(boolean clearSelection) {
}
}

protected final void closeDevTools() {
@Override
public void closeDevTools() {
try {
N_CloseDevTools();
} catch (UnsatisfiedLinkError ule) {
Expand Down Expand Up @@ -771,6 +767,14 @@ public void setWindowlessFrameRate(int frameRate) {
}
}

public void sendExternalBeginFrame() {
try {
N_SendExternalBeginFrame();
} catch (UnsatisfiedLinkError ule) {
ule.printStackTrace();
}
}

public CompletableFuture<Integer> getWindowlessFrameRate() {
final CompletableFuture<Integer> future = new CompletableFuture<>();
try {
Expand Down Expand Up @@ -854,5 +858,6 @@ private final native void N_DragTargetDragEnter(
private final native void N_SetParent(long windowHandle, Component canvas);
private final native void N_NotifyMoveOrResizeStarted();
private final native void N_SetWindowlessFrameRate(int frameRate);
private final native void N_SendExternalBeginFrame();
private final native void N_GetWindowlessFrameRate(IntCallback frameRateCallback);
}
43 changes: 43 additions & 0 deletions java/org/cef/handler/CefAcceleratedPaintInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2024 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.

package org.cef.handler;

/**
* Structure representing shared texture info for accelerated painting.
*/
public class CefAcceleratedPaintInfo {
/**
* Shared texture handle. The meaning depends on the platform:
* - Windows: HANDLE to a texture that can be opened with D3D11 OpenSharedResource
* - macOS: IOSurface pointer that can be opened with Metal or OpenGL
* - Linux: Contains several planes, each with an fd to the underlying system native buffer
*/
public long shared_texture_handle = 0;

/**
* Format of the shared texture.
*/
public int format = 0;

/**
* Size information for the shared texture.
*/
public int width = 0;
public int height = 0;

public CefAcceleratedPaintInfo() {}

public CefAcceleratedPaintInfo(long shared_texture_handle, int format, int width, int height) {
this.shared_texture_handle = shared_texture_handle;
this.format = format;
this.width = width;
this.height = height;
}

@Override
public CefAcceleratedPaintInfo clone() {
return new CefAcceleratedPaintInfo(shared_texture_handle, format, width, height);
}
}
10 changes: 6 additions & 4 deletions java/org/cef/handler/CefAppHandlerAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ public void onBeforeCommandLineProcessing(String process_type, CefCommandLine co
case 1: {
// Switches can optionally have a value specified using the '=' delimiter
// (e.g. "-switch=value").
String[] switchVals = arg.substring(switchCnt).split("=");
if (switchVals.length == 2) {
command_line.appendSwitchWithValue(switchVals[0], switchVals[1]);
String switchStr = arg.substring(switchCnt);
int index = switchStr.indexOf('=');
if (index > 0) {
command_line.appendSwitchWithValue(
switchStr.substring(0, index), switchStr.substring(index + 1));
} else {
command_line.appendSwitch(switchVals[0]);
command_line.appendSwitch(switchStr);
}
break;
}
Expand Down
Loading
Loading