зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1711214 - Use ShmBuffer for NativeLayerRootWayland surface, r=gfx-reviewers,aosmond
We currently use an EGLSurface from the shared GL context, which is both not very clean and also likely uses more resources. Use our just refactored and generalized `WaylandShmBuffer` instead. Depends on D115083 Differential Revision: https://phabricator.services.mozilla.com/D115139
This commit is contained in:
Родитель
5f9ec00358
Коммит
dc3ad30a3e
|
@ -40,41 +40,17 @@ NativeLayerRootWayland::NativeLayerRootWayland(MozContainer* aContainer)
|
|||
void NativeLayerRootWayland::EnsureSurfaceInitialized() {
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
if (mInitialized) {
|
||||
if (mShmBuffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
mEGLWindow = moz_container_wayland_get_egl_window(mContainer, 1);
|
||||
if (!mEGLWindow) {
|
||||
return;
|
||||
}
|
||||
mShmBuffer = widget::WaylandShmBuffer::Create(widget::WaylandDisplayGet(),
|
||||
LayoutDeviceIntSize(1, 1));
|
||||
mShmBuffer->Clear();
|
||||
|
||||
moz_container_wayland_egl_window_set_size(mContainer, 1, 1);
|
||||
wp_viewport* viewporter = moz_container_wayland_get_viewport(mContainer);
|
||||
wp_viewport_set_source(viewporter, wl_fixed_from_int(0), wl_fixed_from_int(0),
|
||||
wl_fixed_from_int(1), wl_fixed_from_int(1));
|
||||
wp_viewport_set_destination(viewporter, 1, 1);
|
||||
|
||||
// TODO: use shm-buffer instead of GL
|
||||
GLContextEGL* gl = GLContextEGL::Cast(wr::RenderThread::Get()->SingletonGL());
|
||||
auto egl = gl->mEgl;
|
||||
|
||||
mEGLSurface = egl->fCreateWindowSurface(gl->mConfig, mEGLWindow, nullptr);
|
||||
MOZ_ASSERT(mEGLSurface != EGL_NO_SURFACE);
|
||||
|
||||
gl->SetEGLSurfaceOverride(mEGLSurface);
|
||||
gl->MakeCurrent();
|
||||
|
||||
gl->fClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
gl->fClear(LOCAL_GL_COLOR_BUFFER_BIT);
|
||||
|
||||
egl->fSwapInterval(0);
|
||||
egl->fSwapBuffers(mEGLSurface);
|
||||
|
||||
gl->SetEGLSurfaceOverride(nullptr);
|
||||
gl->MakeCurrent();
|
||||
|
||||
mInitialized = true;
|
||||
wl_surface* wlSurface = moz_container_wayland_surface_lock(mContainer);
|
||||
mShmBuffer->AttachAndCommit(wlSurface);
|
||||
moz_container_wayland_surface_unlock(mContainer, &wlSurface);
|
||||
}
|
||||
|
||||
already_AddRefed<NativeLayer> NativeLayerRootWayland::CreateLayer(
|
||||
|
@ -320,9 +296,7 @@ bool NativeLayerRootWayland::CommitToScreen() {
|
|||
}
|
||||
}
|
||||
|
||||
if (mInitialized) {
|
||||
wl_surface_commit(wlSurface);
|
||||
}
|
||||
wl_surface_commit(wlSurface);
|
||||
moz_container_wayland_surface_unlock(mContainer, &wlSurface);
|
||||
}
|
||||
|
||||
|
@ -337,12 +311,7 @@ void NativeLayerRootWayland::PauseCompositor() {
|
|||
UnmapLayer(layer);
|
||||
}
|
||||
|
||||
GLContextEGL* gl = GLContextEGL::Cast(wr::RenderThread::Get()->SingletonGL());
|
||||
auto egl = gl->mEgl;
|
||||
egl->fDestroySurface(mEGLSurface);
|
||||
mEGLSurface = nullptr;
|
||||
mEGLWindow = nullptr;
|
||||
mInitialized = false;
|
||||
mShmBuffer = nullptr;
|
||||
}
|
||||
|
||||
bool NativeLayerRootWayland::ResumeCompositor() { return true; }
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/layers/NativeLayer.h"
|
||||
#include "mozilla/layers/SurfacePoolWayland.h"
|
||||
#include "mozilla/widget/MozContainerWayland.h"
|
||||
#include "mozilla/widget/WaylandShmBuffer.h"
|
||||
#include "nsRegion.h"
|
||||
#include "nsISupportsImpl.h"
|
||||
|
||||
|
@ -67,10 +68,7 @@ class NativeLayerRootWayland : public NativeLayerRoot {
|
|||
nsTArray<RefPtr<NativeLayerWayland>> mSublayers;
|
||||
float mBackingScale = 1.0f;
|
||||
MozContainer* mContainer = nullptr;
|
||||
bool mInitialized = false;
|
||||
wl_egl_window* mEGLWindow = nullptr;
|
||||
EGLSurface mEGLSurface = nullptr;
|
||||
struct wp_viewport* mViewport = nullptr;
|
||||
RefPtr<widget::WaylandShmBuffer> mShmBuffer;
|
||||
};
|
||||
|
||||
class NativeLayerWayland : public NativeLayer {
|
||||
|
|
|
@ -95,6 +95,7 @@ if CONFIG["MOZ_WAYLAND"]:
|
|||
"DMABufSurface.h",
|
||||
"MozContainerWayland.h",
|
||||
"nsWaylandDisplay.h",
|
||||
"WaylandShmBuffer.h",
|
||||
]
|
||||
|
||||
if CONFIG["MOZ_X11"]:
|
||||
|
|
Загрузка…
Ссылка в новой задаче