Skip to content

Commit 6b078b3

Browse files
committed
feat: color format and plane count
1 parent dcf6dd6 commit 6b078b3

File tree

2 files changed

+38
-30
lines changed

2 files changed

+38
-30
lines changed

java/org/cef/handler/CefAcceleratedPaintInfo.java

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,36 @@
99
*/
1010
public class CefAcceleratedPaintInfo {
1111
/**
12-
* Shared texture handle. The meaning depends on the platform:
13-
* - Windows: HANDLE to a texture that can be opened with D3D11 OpenSharedResource
14-
* - macOS: IOSurface pointer that can be opened with Metal or OpenGL
15-
* - Linux: Contains several planes, each with an fd to the underlying system native buffer
12+
* Handle for the shared D3D11 texture (Windows).
1613
*/
1714
public long shared_texture_handle = 0;
18-
15+
16+
/**
17+
* Handle for the shared texture IOSurface (macOS, Linux).
18+
*/
19+
public long shared_texture_io_surface = 0;
20+
1921
/**
20-
* Format of the shared texture.
22+
* Color format of the shared texture.
2123
*/
2224
public int format = 0;
23-
25+
2426
/**
25-
* Size information for the shared texture.
27+
* Plane count on Linux
2628
*/
27-
public int width = 0;
28-
public int height = 0;
29-
29+
public int plane_count = 0;
30+
3031
public CefAcceleratedPaintInfo() {}
31-
32-
public CefAcceleratedPaintInfo(long shared_texture_handle, int format, int width, int height) {
32+
33+
public CefAcceleratedPaintInfo(long shared_texture_handle, long shared_texture_io_surface, int format, int plane_count) {
3334
this.shared_texture_handle = shared_texture_handle;
35+
this.shared_texture_io_surface = shared_texture_io_surface;
3436
this.format = format;
35-
this.width = width;
36-
this.height = height;
37+
this.plane_count = plane_count;
3738
}
38-
39+
3940
@Override
4041
public CefAcceleratedPaintInfo clone() {
41-
return new CefAcceleratedPaintInfo(shared_texture_handle, format, width, height);
42+
return new CefAcceleratedPaintInfo(shared_texture_handle, shared_texture_io_surface, format, plane_count);
4243
}
4344
}

native/render_handler.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -290,20 +290,27 @@ void RenderHandler::OnAcceleratedPaint(CefRefPtr<CefBrowser> browser,
290290
if (!jpaintInfo)
291291
return;
292292

293-
// Get view rect to determine width and height
294-
CefRect viewRect;
295-
GetViewRect(browser, viewRect);
296-
// Set the fields of the paint info object
297-
#if defined(OS_WIN)
298-
SetJNIFieldLong(env, cls, jpaintInfo, "shared_texture_handle",
299-
reinterpret_cast<jlong>(info.shared_texture_handle));
300-
#else
301-
// On non-Windows platforms, shared_texture_handle is not available
302-
SetJNIFieldLong(env, cls, jpaintInfo, "shared_texture_handle", 0);
303-
#endif
293+
#if defined(OS_WIN)
294+
SetJNIFieldLong(env, cls, jpaintInfo, "shared_texture_handle",
295+
reinterpret_cast<jlong>(info.shared_texture_handle));
296+
#else
297+
SetJNIFieldLong(env, cls, jpaintInfo, "shared_texture_handle", 0);
298+
#endif
299+
300+
#if defined(OS_MAC) || defined(OS_LINUX)
301+
SetJNIFieldLong(env, cls, jpaintInfo, "shared_texture_io_surface",
302+
reinterpret_cast<jlong>(info.shared_texture_io_surface));
303+
#else
304+
SetJNIFieldLong(env, cls, jpaintInfo, "shared_texture_io_surface", 0);
305+
#endif
306+
304307
SetJNIFieldInt(env, cls, jpaintInfo, "format", info.format);
305-
SetJNIFieldInt(env, cls, jpaintInfo, "width", viewRect.width);
306-
SetJNIFieldInt(env, cls, jpaintInfo, "height", viewRect.height);
308+
309+
#if defined(OS_LINUX)
310+
SetJNIFieldInt(env, cls, jpaintInfo, "plane_count", info.plane_count);
311+
#else
312+
SetJNIFieldInt(env, cls, jpaintInfo, "plane_count", 0);
313+
#endif
307314

308315
JNI_CALL_VOID_METHOD(env, handle_, "onAcceleratedPaint",
309316
"(Lorg/cef/browser/CefBrowser;Z[Ljava/awt/"

0 commit comments

Comments
 (0)