|
30 | 30 | #include <IOSurface/IOSurface.h> |
31 | 31 | #endif |
32 | 32 |
|
| 33 | +#if !defined(_WIN32) && !defined(__APPLE__) |
| 34 | +#include "drm-format.hpp" |
| 35 | +#endif |
| 36 | + |
33 | 37 | inline bool BrowserClient::valid() const |
34 | 38 | { |
35 | 39 | return !!bs && !bs->destroying; |
@@ -369,6 +373,31 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t |
369 | 373 | return; |
370 | 374 | } |
371 | 375 |
|
| 376 | +#if !defined(_WIN32) && !defined(__APPLE__) |
| 377 | + if (info.plane_count == 0) |
| 378 | + return; |
| 379 | + |
| 380 | + struct obs_cef_video_format format = obs_cef_format_from_cef_type(info.format); |
| 381 | + |
| 382 | + if (format.gs_format == GS_UNKNOWN) |
| 383 | + return; |
| 384 | + |
| 385 | + uint32_t *strides = (uint32_t *)alloca(info.plane_count * sizeof(uint32_t)); |
| 386 | + uint32_t *offsets = (uint32_t *)alloca(info.plane_count * sizeof(uint32_t)); |
| 387 | + uint64_t *modifiers = (uint64_t *)alloca(info.plane_count * sizeof(uint64_t)); |
| 388 | + int *fds = (int *)alloca(info.plane_count * sizeof(int)); |
| 389 | + |
| 390 | + for (size_t i = 0; i < kAcceleratedPaintMaxPlanes; i++) { |
| 391 | + auto *plane = &info.planes[i]; |
| 392 | + |
| 393 | + strides[i] = plane->stride; |
| 394 | + offsets[i] = plane->offset; |
| 395 | + fds[i] = plane->fd; |
| 396 | + |
| 397 | + modifiers[i] = info.modifier; |
| 398 | + } |
| 399 | +#endif |
| 400 | + |
372 | 401 | #if !defined(_WIN32) && CHROME_VERSION_BUILD < 6367 |
373 | 402 | if (shared_handle == bs->last_handle) |
374 | 403 | return; |
@@ -398,17 +427,21 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t |
398 | 427 | //if (bs->texture) |
399 | 428 | // gs_texture_acquire_sync(bs->texture, 1, INFINITE); |
400 | 429 |
|
401 | | -#else |
| 430 | +#elif defined(_WIN32) |
402 | 431 | bs->texture = gs_texture_open_shared((uint32_t)(uintptr_t)shared_handle); |
| 432 | +#else |
| 433 | + bs->texture = gs_texture_create_from_dmabuf(bs->width, bs->height, format.drm_format, format.gs_format, |
| 434 | + info.plane_count, fds, strides, offsets, |
| 435 | + info.modifier != DRM_FORMAT_MOD_INVALID ? modifiers : NULL); |
403 | 436 | #endif |
404 | 437 | UpdateExtraTexture(); |
405 | 438 | obs_leave_graphics(); |
406 | 439 |
|
407 | 440 | #if defined(__APPLE__) && CHROME_VERSION_BUILD >= 6367 |
408 | 441 | bs->last_handle = info.shared_texture_io_surface; |
409 | | -#elif CHROME_VERSION_BUILD >= 6367 |
| 442 | +#elif defined(_WIN32) && CHROME_VERSION_BUILD >= 6367 |
410 | 443 | bs->last_handle = info.shared_texture_handle; |
411 | | -#else |
| 444 | +#elif defined(__APPLE__) || defined(_WIN32) |
412 | 445 | bs->last_handle = shared_handle; |
413 | 446 | #endif |
414 | 447 | } |
|
0 commit comments