Bug 1938033 [Wayland] Pass DRMFormat to WaylandBufferDMABUF::CreateRGBA() created by SurfacePoolWayland r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D234910
This commit is contained in:
stransky
2025-02-19 13:54:16 +00:00
parent 2c2168d6eb
commit 8262e23b12
2 changed files with 33 additions and 14 deletions

View File

@@ -8,6 +8,19 @@
#include "GLBlitHelper.h" #include "GLBlitHelper.h"
#include "mozilla/gfx/DataSurfaceHelpers.h" #include "mozilla/gfx/DataSurfaceHelpers.h"
#ifdef MOZ_LOGGING
# undef LOG
# include "mozilla/Logging.h"
# include "nsTArray.h"
# include "Units.h"
extern mozilla::LazyLogModule gWidgetCompositorLog;
# define LOG(str, ...) \
MOZ_LOG(gWidgetCompositorLog, mozilla::LogLevel::Debug, \
(str, ##__VA_ARGS__))
#else
# define LOG(args)
#endif /* MOZ_LOGGING */
namespace mozilla::layers { namespace mozilla::layers {
using gfx::IntSize; using gfx::IntSize;
@@ -66,7 +79,7 @@ bool SurfacePoolWayland::CanRecycleSurfaceForRequest(
} }
RefPtr<WaylandBuffer> SurfacePoolWayland::ObtainBufferFromPool( RefPtr<WaylandBuffer> SurfacePoolWayland::ObtainBufferFromPool(
const IntSize& aSize, GLContext* aGL) { const IntSize& aSize, GLContext* aGL, RefPtr<widget::DRMFormat> aFormat) {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
auto iterToRecycle = std::find_if( auto iterToRecycle = std::find_if(
@@ -83,10 +96,8 @@ RefPtr<WaylandBuffer> SurfacePoolWayland::ObtainBufferFromPool(
RefPtr<WaylandBuffer> buffer; RefPtr<WaylandBuffer> buffer;
if (aGL) { if (aGL) {
#if 0 buffer = widget::WaylandBufferDMABUF::CreateRGBA(
buffer = widget::WaylandBufferDMABUF::Create( LayoutDeviceIntSize::FromUnknownSize(aSize), aGL, aFormat);
LayoutDeviceIntSize::FromUnknownSize(aSize), aGL);
#endif
} else { } else {
buffer = widget::WaylandBufferSHM::Create( buffer = widget::WaylandBufferSHM::Create(
LayoutDeviceIntSize::FromUnknownSize(aSize)); LayoutDeviceIntSize::FromUnknownSize(aSize));
@@ -123,10 +134,16 @@ void SurfacePoolWayland::EnforcePoolSizeLimit() {
mAvailableEntries.RemoveElementAt(0); mAvailableEntries.RemoveElementAt(0);
} }
NS_WARNING_ASSERTION(mPendingEntries.Length() < mPoolSizeLimit * 2, if (mPendingEntries.Length() > mPoolSizeLimit * 2) {
"Are we leaking pending entries?"); LOG("SurfacePoolWayland() mPendingEntries num %d mPoolSizeLimit %d Are we "
NS_WARNING_ASSERTION(mInUseEntries.size() < mPoolSizeLimit * 2, "leaking pending entries?",
"Are we leaking in-use entries?"); (int)mPendingEntries.Length(), (int)mPoolSizeLimit);
}
if (mInUseEntries.size() > mPoolSizeLimit * 2) {
LOG("SurfacePoolWayland() mInUseEntries num %d mPoolSizeLimit %d Are we "
"leaking in-use entries?",
(int)mInUseEntries.size(), (int)mPoolSizeLimit);
}
} }
void SurfacePoolWayland::CollectPendingSurfaces() { void SurfacePoolWayland::CollectPendingSurfaces() {
@@ -231,8 +248,8 @@ void SurfacePoolHandleWayland::OnBeginFrame() {
void SurfacePoolHandleWayland::OnEndFrame() { mPool->EnforcePoolSizeLimit(); } void SurfacePoolHandleWayland::OnEndFrame() { mPool->EnforcePoolSizeLimit(); }
RefPtr<WaylandBuffer> SurfacePoolHandleWayland::ObtainBufferFromPool( RefPtr<WaylandBuffer> SurfacePoolHandleWayland::ObtainBufferFromPool(
const IntSize& aSize) { const IntSize& aSize, RefPtr<widget::DRMFormat> aFormat) {
return mPool->ObtainBufferFromPool(aSize, mGL); return mPool->ObtainBufferFromPool(aSize, mGL, aFormat);
} }
void SurfacePoolHandleWayland::ReturnBufferToPool( void SurfacePoolHandleWayland::ReturnBufferToPool(

View File

@@ -31,8 +31,9 @@ class SurfacePoolWayland final : public SurfacePool {
explicit SurfacePoolWayland(size_t aPoolSizeLimit); explicit SurfacePoolWayland(size_t aPoolSizeLimit);
RefPtr<widget::WaylandBuffer> ObtainBufferFromPool(const gfx::IntSize& aSize, RefPtr<widget::WaylandBuffer> ObtainBufferFromPool(
gl::GLContext* aGL); const gfx::IntSize& aSize, gl::GLContext* aGL,
RefPtr<widget::DRMFormat> aFormat);
void ReturnBufferToPool(const RefPtr<widget::WaylandBuffer>& aBuffer); void ReturnBufferToPool(const RefPtr<widget::WaylandBuffer>& aBuffer);
void EnforcePoolSizeLimit(); void EnforcePoolSizeLimit();
void CollectPendingSurfaces(); void CollectPendingSurfaces();
@@ -103,7 +104,8 @@ class SurfacePoolHandleWayland final : public SurfacePoolHandle {
return this; return this;
} }
RefPtr<widget::WaylandBuffer> ObtainBufferFromPool(const gfx::IntSize& aSize); RefPtr<widget::WaylandBuffer> ObtainBufferFromPool(
const gfx::IntSize& aSize, RefPtr<widget::DRMFormat> aFormat);
void ReturnBufferToPool(const RefPtr<widget::WaylandBuffer>& aBuffer); void ReturnBufferToPool(const RefPtr<widget::WaylandBuffer>& aBuffer);
Maybe<GLuint> GetFramebufferForBuffer( Maybe<GLuint> GetFramebufferForBuffer(
const RefPtr<widget::WaylandBuffer>& aBuffer, bool aNeedsDepthBuffer); const RefPtr<widget::WaylandBuffer>& aBuffer, bool aNeedsDepthBuffer);