feat: initial video wallpaper implementation
This commit is contained in:
@@ -53,6 +53,11 @@ WallpaperSurface::WallpaperSurface(
|
||||
}
|
||||
|
||||
WallpaperSurface::~WallpaperSurface() {
|
||||
if (m_frameCallback) {
|
||||
wl_callback_destroy(m_frameCallback);
|
||||
m_frameCallback = nullptr;
|
||||
}
|
||||
|
||||
if (m_eglSurface != EGL_NO_SURFACE)
|
||||
eglDestroySurface(m_service->m_eglDisplay, m_eglSurface);
|
||||
|
||||
@@ -68,8 +73,45 @@ WallpaperSurface::~WallpaperSurface() {
|
||||
if (m_surface) wl_surface_destroy(m_surface);
|
||||
}
|
||||
|
||||
void WallpaperSurface::redraw() {
|
||||
m_service->queue(this);
|
||||
void WallpaperSurface::markDirty() {
|
||||
m_dirty.store(true, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
bool WallpaperSurface::needsDraw() const {
|
||||
return m_dirty.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
bool WallpaperSurface::frameReady() const {
|
||||
return m_frameReady.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void WallpaperSurface::requestFrame() {
|
||||
if (!m_surface || m_frameCallback) return;
|
||||
|
||||
m_frameCallback = wl_surface_frame(m_surface);
|
||||
|
||||
static const struct wl_callback_listener listener = {
|
||||
[](void* data, struct wl_callback*, uint32_t) {
|
||||
static_cast<WallpaperSurface*>(data)->onFrameDone();
|
||||
},
|
||||
};
|
||||
|
||||
wl_callback_add_listener(m_frameCallback, &listener, this);
|
||||
}
|
||||
|
||||
void WallpaperSurface::onFrameDone() {
|
||||
if (m_frameCallback) {
|
||||
wl_callback_destroy(m_frameCallback);
|
||||
m_frameCallback = nullptr;
|
||||
}
|
||||
|
||||
m_frameReady.store(true, std::memory_order_relaxed);
|
||||
m_service->wake();
|
||||
}
|
||||
|
||||
void WallpaperSurface::endDraw() {
|
||||
m_dirty.store(false, std::memory_order_relaxed);
|
||||
m_frameReady.store(false, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void WallpaperSurface::zwlr_layer_surface_v1_configure(
|
||||
@@ -141,6 +183,7 @@ void WallpaperSurface::updateBuffer() {
|
||||
if (QtWayland::wp_viewport::isInitialized())
|
||||
set_destination(m_size.width(), m_size.height());
|
||||
|
||||
requestFrame();
|
||||
m_service->queue(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user