diff options
Diffstat (limited to 'src/core/ozone/surface_factory_qt.cpp')
-rw-r--r-- | src/core/ozone/surface_factory_qt.cpp | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp index 374f870e2..2d311a02a 100644 --- a/src/core/ozone/surface_factory_qt.cpp +++ b/src/core/ozone/surface_factory_qt.cpp @@ -16,6 +16,7 @@ #include "ui/ozone/buildflags.h" #include <QDebug> +#include <QtGui/qtgui-config.h> #if BUILDFLAG(OZONE_PLATFORM_X11) #include "ozone/gl_ozone_glx_qt.h" @@ -91,7 +92,10 @@ scoped_refptr<gfx::NativePixmap> SurfaceFactoryQt::CreateNativePixmap( gfx::BufferUsage usage, absl::optional<gfx::Size> framebuffer_size) { - Q_ASSERT(SupportsNativePixmaps()); + if (!SupportsNativePixmaps()) + return nullptr; + +#if QT_CONFIG(opengl) if (framebuffer_size && !gfx::Rect(size).Contains(gfx::Rect(*framebuffer_size))) return nullptr; @@ -125,6 +129,9 @@ scoped_refptr<gfx::NativePixmap> SurfaceFactoryQt::CreateNativePixmap( } return base::MakeRefCounted<gfx::NativePixmapDmaBuf>(size, format, std::move(handle)); +#else + return nullptr; +#endif // QT_CONFIG(opengl) } void SurfaceFactoryQt::CreateNativePixmapAsync( @@ -135,7 +142,11 @@ void SurfaceFactoryQt::CreateNativePixmapAsync( gfx::BufferUsage usage, NativePixmapCallback callback) { - Q_ASSERT(SupportsNativePixmaps()); + if (!SupportsNativePixmaps()) { + std::move(callback).Run(nullptr); + return; + } + // CreateNativePixmap is non-blocking operation. Thus, it is safe to call it // and return the result with the provided callback. std::move(callback).Run(CreateNativePixmap(widget, device_queue, size, format, usage)); @@ -148,7 +159,10 @@ SurfaceFactoryQt::CreateNativePixmapFromHandle( gfx::BufferFormat format, gfx::NativePixmapHandle handle) { - Q_ASSERT(SupportsNativePixmaps()); + if (!SupportsNativePixmaps()) + return nullptr; + +#if QT_CONFIG(opengl) gfx::NativePixmapHandle bufferHandle; #if BUILDFLAG(OZONE_PLATFORM_X11) @@ -212,7 +226,7 @@ SurfaceFactoryQt::CreateNativePixmapFromHandle( int fd = fds[i]; int stride = strides[i]; int offset = offsets[i]; - int size = handle.planes[i].size; + int planeSize = handle.planes[i].size; if (fd == -1) { fd = fds[0]; @@ -220,7 +234,7 @@ SurfaceFactoryQt::CreateNativePixmapFromHandle( offset = handle.planes[i].offset; } - gfx::NativePixmapPlane plane(stride, offset, size, base::ScopedFD(::dup(fd))); + gfx::NativePixmapPlane plane(stride, offset, planeSize, base::ScopedFD(::dup(fd))); bufferHandle.planes.push_back(std::move(plane)); } @@ -228,17 +242,22 @@ SurfaceFactoryQt::CreateNativePixmapFromHandle( } return base::MakeRefCounted<gfx::NativePixmapDmaBuf>(size, format, std::move(bufferHandle)); +#else + return nullptr; +#endif // QT_CONFIG(opengl) } -bool SurfaceFactoryQt::SupportsNativePixmaps() const +bool SurfaceFactoryQt::SupportsNativePixmaps() { +#if QT_CONFIG(opengl) #if BUILDFLAG(OZONE_PLATFORM_X11) if (GLContextHelper::getGlxPlatformInterface()) return ui::GpuMemoryBufferSupportX11::GetInstance()->has_gbm_device(); -#endif +#endif // BUILDFLAG(OZONE_PLATFORM_X11) if (GLContextHelper::getEglPlatformInterface()) return EGLHelper::instance()->isDmaBufSupported(); +#endif // QT_CONFIG(opengl) return false; } |