diff options
Diffstat (limited to 'src/core/ozone/surface_factory_qt.cpp')
-rw-r--r-- | src/core/ozone/surface_factory_qt.cpp | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/src/core/ozone/surface_factory_qt.cpp b/src/core/ozone/surface_factory_qt.cpp index 374f870e2..1bfa49c60 100644 --- a/src/core/ozone/surface_factory_qt.cpp +++ b/src/core/ozone/surface_factory_qt.cpp @@ -9,15 +9,16 @@ #include "ozone/gl_ozone_egl_qt.h" #include "media/gpu/buildflags.h" +#include "ui/base/ozone_buildflags.h" #include "ui/gfx/linux/drm_util_linux.h" #include "ui/gfx/linux/gbm_buffer.h" #include "ui/gfx/linux/native_pixmap_dmabuf.h" #include "ui/gl/egl_util.h" -#include "ui/ozone/buildflags.h" #include <QDebug> +#include <QtGui/qtgui-config.h> -#if BUILDFLAG(OZONE_PLATFORM_X11) +#if BUILDFLAG(IS_OZONE_X11) #include "ozone/gl_ozone_glx_qt.h" #include "ui/gfx/linux/gpu_memory_buffer_support_x11.h" @@ -31,7 +32,7 @@ namespace QtWebEngineCore { SurfaceFactoryQt::SurfaceFactoryQt() { -#if BUILDFLAG(OZONE_PLATFORM_X11) +#if BUILDFLAG(IS_OZONE_X11) if (GLContextHelper::getGlxPlatformInterface()) { m_impl = { gl::GLImplementationParts(gl::kGLImplementationDesktopGL), gl::GLImplementationParts(gl::kGLImplementationDisabled) }; @@ -72,7 +73,7 @@ SurfaceFactoryQt::CreateVulkanImplementation(bool /*allow_protected_memory*/, bool SurfaceFactoryQt::CanCreateNativePixmapForFormat(gfx::BufferFormat format) { -#if BUILDFLAG(OZONE_PLATFORM_X11) +#if BUILDFLAG(IS_OZONE_X11) if (GLContextHelper::getGlxPlatformInterface()) return ui::GpuMemoryBufferSupportX11::GetInstance()->CanCreateNativePixmapForFormat(format); #endif @@ -91,13 +92,16 @@ 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; gfx::NativePixmapHandle handle; -#if BUILDFLAG(OZONE_PLATFORM_X11) +#if BUILDFLAG(IS_OZONE_X11) if (GLContextHelper::getGlxPlatformInterface()) { auto gbmBuffer = ui::GpuMemoryBufferSupportX11::GetInstance()->CreateBuffer(format, size, usage); @@ -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,10 +159,13 @@ 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) +#if BUILDFLAG(IS_OZONE_X11) if (GLContextHelper::getGlxPlatformInterface()) { auto gbmBuffer = ui::GpuMemoryBufferSupportX11::GetInstance()->CreateBufferFromHandle( size, format, std::move(handle)); @@ -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 BUILDFLAG(OZONE_PLATFORM_X11) +#if QT_CONFIG(opengl) +#if BUILDFLAG(IS_OZONE_X11) if (GLContextHelper::getGlxPlatformInterface()) return ui::GpuMemoryBufferSupportX11::GetInstance()->has_gbm_device(); -#endif +#endif // BUILDFLAG(IS_OZONE_X11) if (GLContextHelper::getEglPlatformInterface()) return EGLHelper::instance()->isDmaBufSupported(); +#endif // QT_CONFIG(opengl) return false; } |