|
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; |
@@ -360,6 +364,31 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t |
360 | 364 | return; |
361 | 365 | } |
362 | 366 |
|
| 367 | +#if !defined(_WIN32) && !defined(__APPLE__) |
| 368 | + if (info.plane_count == 0) |
| 369 | + return; |
| 370 | + |
| 371 | + struct obs_cef_video_format format = obs_cef_format_from_cef_type(info.format); |
| 372 | + |
| 373 | + if (format.gs_format == GS_UNKNOWN) |
| 374 | + return; |
| 375 | + |
| 376 | + uint32_t *strides = (uint32_t *)alloca(info.plane_count * sizeof(uint32_t)); |
| 377 | + uint32_t *offsets = (uint32_t *)alloca(info.plane_count * sizeof(uint32_t)); |
| 378 | + uint64_t *modifiers = (uint64_t *)alloca(info.plane_count * sizeof(uint64_t)); |
| 379 | + int *fds = (int *)alloca(info.plane_count * sizeof(int)); |
| 380 | + |
| 381 | + for (size_t i = 0; i < kAcceleratedPaintMaxPlanes; i++) { |
| 382 | + auto *plane = &info.planes[i]; |
| 383 | + |
| 384 | + strides[i] = plane->stride; |
| 385 | + offsets[i] = plane->offset; |
| 386 | + fds[i] = plane->fd; |
| 387 | + |
| 388 | + modifiers[i] = info.modifier; |
| 389 | + } |
| 390 | +#endif |
| 391 | + |
363 | 392 | #if !defined(_WIN32) && CHROME_VERSION_BUILD < 6367 |
364 | 393 | if (shared_handle == bs->last_handle) |
365 | 394 | return; |
@@ -389,17 +418,21 @@ void BrowserClient::OnAcceleratedPaint(CefRefPtr<CefBrowser>, PaintElementType t |
389 | 418 | //if (bs->texture) |
390 | 419 | // gs_texture_acquire_sync(bs->texture, 1, INFINITE); |
391 | 420 |
|
392 | | -#else |
| 421 | +#elif defined(_WIN32) |
393 | 422 | bs->texture = gs_texture_open_shared((uint32_t)(uintptr_t)shared_handle); |
| 423 | +#else |
| 424 | + bs->texture = gs_texture_create_from_dmabuf(bs->width, bs->height, format.drm_format, format.gs_format, |
| 425 | + info.plane_count, fds, strides, offsets, |
| 426 | + info.modifier != DRM_FORMAT_MOD_INVALID ? modifiers : NULL); |
394 | 427 | #endif |
395 | 428 | UpdateExtraTexture(); |
396 | 429 | obs_leave_graphics(); |
397 | 430 |
|
398 | 431 | #if defined(__APPLE__) && CHROME_VERSION_BUILD >= 6367 |
399 | 432 | bs->last_handle = info.shared_texture_io_surface; |
400 | | -#elif CHROME_VERSION_BUILD >= 6367 |
| 433 | +#elif defined(_WIN32) && CHROME_VERSION_BUILD >= 6367 |
401 | 434 | bs->last_handle = info.shared_texture_handle; |
402 | | -#else |
| 435 | +#elif defined(__APPLE__) || defined(_WIN32) |
403 | 436 | bs->last_handle = shared_handle; |
404 | 437 | #endif |
405 | 438 | } |
|
0 commit comments