summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2023-03-02 13:05:26 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2023-04-04 11:00:11 +0200
commit356f65b87c508c44bf31bc3134eaebfd6f39c6ec (patch)
tree3422b3aed75e4ab99294445e871563345f2b3338
parentcaf5f383ac53401dc2749f43ce46a208fe8738c9 (diff)
Adapt to painting cleanup
Pass through alphaChannel requirement correctly, instead of having a nonfunctional hasAlphaChannel(). Pick-to: 6.5 Change-Id: I99adb17aa38fd91ea8fd93b86a352bc476690837 Reviewed-by: Michal Klocek <michal.klocek@qt.io> Reviewed-by: Peter Varga <pvarga@inf.u-szeged.hu>
-rw-r--r--src/core/compositor/compositor.h8
-rw-r--r--src/core/compositor/display_overrides.cpp27
-rw-r--r--src/core/compositor/display_skia_output_device.cpp9
-rw-r--r--src/core/compositor/display_skia_output_device.h4
-rw-r--r--src/core/compositor/display_software_output_surface.cpp19
-rw-r--r--src/core/compositor/display_software_output_surface.h2
-rw-r--r--src/core/render_widget_host_view_qt_delegate_item.cpp8
7 files changed, 31 insertions, 46 deletions
diff --git a/src/core/compositor/compositor.h b/src/core/compositor/compositor.h
index 7c6590134..21263150b 100644
--- a/src/core/compositor/compositor.h
+++ b/src/core/compositor/compositor.h
@@ -124,13 +124,7 @@ public:
virtual QSize size() = 0;
// Whether frame needs an alpha channel.
- //
- // In software mode, the image format can be either
- // QImage::Format_ARGB32_Premultiplied or
- // QImage::Format_RGBA8888_Premultiplied
- //
- // In OpenGL mode, the texture format is either GL_RGBA or GL_RGB.
- virtual bool hasAlphaChannel() = 0;
+ virtual bool requiresAlphaChannel() = 0;
// (Software) QImage of the frame.
//
diff --git a/src/core/compositor/display_overrides.cpp b/src/core/compositor/display_overrides.cpp
index aa86861d2..3b33f5dcc 100644
--- a/src/core/compositor/display_overrides.cpp
+++ b/src/core/compositor/display_overrides.cpp
@@ -10,9 +10,9 @@
#include <qtgui-config.h>
std::unique_ptr<viz::OutputSurface>
-viz::OutputSurfaceProviderImpl::CreateSoftwareOutputSurface()
+viz::OutputSurfaceProviderImpl::CreateSoftwareOutputSurface(const RendererSettings &renderer_settings)
{
- return std::make_unique<QtWebEngineCore::DisplaySoftwareOutputSurface>();
+ return std::make_unique<QtWebEngineCore::DisplaySoftwareOutputSurface>(renderer_settings.requires_alpha_channel);
}
std::unique_ptr<viz::SkiaOutputDevice>
@@ -21,6 +21,7 @@ viz::SkiaOutputSurfaceImplOnGpu::CreateOutputDevice()
#if QT_CONFIG(opengl)
return std::make_unique<QtWebEngineCore::DisplaySkiaOutputDevice>(
context_state_,
+ renderer_settings_.requires_alpha_channel,
shared_gpu_deps_->memory_tracker(),
GetDidSwapBuffersCompleteCallback());
#else
@@ -28,25 +29,3 @@ viz::SkiaOutputSurfaceImplOnGpu::CreateOutputDevice()
#endif // QT_CONFIG(opengl)
}
-void gpu::InProcessCommandBuffer::GetTextureQt(
- unsigned int client_id,
- GetTextureCallback callback,
- const std::vector<SyncToken>& sync_token_fences)
-{
- ScheduleGpuTask(base::BindOnce(&InProcessCommandBuffer::GetTextureQtOnGpuThread,
- gpu_thread_weak_ptr_factory_.GetWeakPtr(),
- client_id,
- std::move(callback)),
- sync_token_fences);
-}
-
-void gpu::InProcessCommandBuffer::GetTextureQtOnGpuThread(
- unsigned int client_id, GetTextureCallback callback)
-{
- if (!MakeCurrent()) {
- LOG(ERROR) << "MakeCurrent failed for GetTextureQt";
- return;
- }
- gpu::TextureBase *texture = decoder_->GetTextureBase(client_id);
- std::move(callback).Run(texture ? texture->service_id() : 0, gl::GLFence::Create());
-}
diff --git a/src/core/compositor/display_skia_output_device.cpp b/src/core/compositor/display_skia_output_device.cpp
index 7f42d61de..d2cce14d0 100644
--- a/src/core/compositor/display_skia_output_device.cpp
+++ b/src/core/compositor/display_skia_output_device.cpp
@@ -255,12 +255,15 @@ private:
};
DisplaySkiaOutputDevice::DisplaySkiaOutputDevice(
- scoped_refptr<gpu::SharedContextState> contextState, gpu::MemoryTracker *memoryTracker,
+ scoped_refptr<gpu::SharedContextState> contextState,
+ bool requiresAlpha,
+ gpu::MemoryTracker *memoryTracker,
DidSwapBufferCompleteCallback didSwapBufferCompleteCallback)
: SkiaOutputDevice(contextState->gr_context(), memoryTracker, didSwapBufferCompleteCallback)
, Compositor(contextState->GrContextIsVulkan() ? Compositor::Type::Vulkan
: Compositor::Type::OpenGL)
, m_contextState(contextState)
+ , m_requiresAlpha(requiresAlpha)
{
capabilities_.uses_default_gl_framebuffer = false;
capabilities_.supports_surfaceless = true;
@@ -369,9 +372,9 @@ QSize DisplaySkiaOutputDevice::size()
return m_frontBuffer ? toQt(m_frontBuffer->shape().characterization.dimensions()) : QSize();
}
-bool DisplaySkiaOutputDevice::hasAlphaChannel()
+bool DisplaySkiaOutputDevice::requiresAlphaChannel()
{
- return true;
+ return m_requiresAlpha;
}
float DisplaySkiaOutputDevice::devicePixelRatio()
diff --git a/src/core/compositor/display_skia_output_device.h b/src/core/compositor/display_skia_output_device.h
index e2818d604..648784f52 100644
--- a/src/core/compositor/display_skia_output_device.h
+++ b/src/core/compositor/display_skia_output_device.h
@@ -23,6 +23,7 @@ class DisplaySkiaOutputDevice final : public viz::SkiaOutputDevice, public Compo
{
public:
DisplaySkiaOutputDevice(scoped_refptr<gpu::SharedContextState> contextState,
+ bool requiresAlpha,
gpu::MemoryTracker *memoryTracker,
DidSwapBufferCompleteCallback didSwapBufferCompleteCallback);
~DisplaySkiaOutputDevice() override;
@@ -45,7 +46,7 @@ public:
void waitForTexture() override;
int textureId() override;
QSize size() override;
- bool hasAlphaChannel() override;
+ bool requiresAlphaChannel() override;
float devicePixelRatio() override;
#if QT_CONFIG(webengine_vulkan)
VkImage vkImage(QQuickWindow *win) override;
@@ -81,6 +82,7 @@ private:
std::unique_ptr<Buffer> m_backBuffer;
viz::OutputSurfaceFrame m_frame;
bool m_readyToUpdate = false;
+ bool m_requiresAlpha;
scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
#if QT_CONFIG(webengine_vulkan)
diff --git a/src/core/compositor/display_software_output_surface.cpp b/src/core/compositor/display_software_output_surface.cpp
index 2277dfea3..10872da27 100644
--- a/src/core/compositor/display_software_output_surface.cpp
+++ b/src/core/compositor/display_software_output_surface.cpp
@@ -20,7 +20,7 @@ class DisplaySoftwareOutputSurface::Device final : public viz::SoftwareOutputDev
public Compositor
{
public:
- Device();
+ Device(bool requiresAlpha);
// Overridden from viz::SoftwareOutputDevice.
void Resize(const gfx::Size &sizeInPixels, float devicePixelRatio) override;
@@ -31,20 +31,23 @@ public:
QImage image() override;
float devicePixelRatio() override;
QSize size() override;
- bool hasAlphaChannel() override;
+ bool requiresAlphaChannel() override;
private:
mutable QMutex m_mutex;
float m_devicePixelRatio = 1.0;
+ bool m_requiresAlpha;
scoped_refptr<base::SingleThreadTaskRunner> m_taskRunner;
SwapBuffersCallback m_swapCompletionCallback;
QImage m_image;
float m_imageDevicePixelRatio = 1.0;
};
-DisplaySoftwareOutputSurface::Device::Device()
+DisplaySoftwareOutputSurface::Device::Device(bool requiresAlpha)
: Compositor(Type::Software)
-{}
+ , m_requiresAlpha(requiresAlpha)
+{
+}
void DisplaySoftwareOutputSurface::Device::Resize(const gfx::Size &sizeInPixels, float devicePixelRatio)
{
@@ -122,13 +125,13 @@ QSize DisplaySoftwareOutputSurface::Device::size()
return m_image.size();
}
-bool DisplaySoftwareOutputSurface::Device::hasAlphaChannel()
+bool DisplaySoftwareOutputSurface::Device::requiresAlphaChannel()
{
- return m_image.format() == QImage::Format_ARGB32_Premultiplied;
+ return m_requiresAlpha;
}
-DisplaySoftwareOutputSurface::DisplaySoftwareOutputSurface()
- : SoftwareOutputSurface(std::make_unique<Device>())
+DisplaySoftwareOutputSurface::DisplaySoftwareOutputSurface(bool requiresAlpha)
+ : SoftwareOutputSurface(std::make_unique<Device>(requiresAlpha))
{}
DisplaySoftwareOutputSurface::~DisplaySoftwareOutputSurface() {}
diff --git a/src/core/compositor/display_software_output_surface.h b/src/core/compositor/display_software_output_surface.h
index 5bb4e77c3..d23664d56 100644
--- a/src/core/compositor/display_software_output_surface.h
+++ b/src/core/compositor/display_software_output_surface.h
@@ -11,7 +11,7 @@ namespace QtWebEngineCore {
class DisplaySoftwareOutputSurface final : public viz::SoftwareOutputSurface
{
public:
- DisplaySoftwareOutputSurface();
+ DisplaySoftwareOutputSurface(bool requiresAlpha);
~DisplaySoftwareOutputSurface() override;
// Overridden from viz::OutputSurface.
diff --git a/src/core/render_widget_host_view_qt_delegate_item.cpp b/src/core/render_widget_host_view_qt_delegate_item.cpp
index 91f765c2d..2bade607e 100644
--- a/src/core/render_widget_host_view_qt_delegate_item.cpp
+++ b/src/core/render_widget_host_view_qt_delegate_item.cpp
@@ -370,8 +370,10 @@ QSGNode *RenderWidgetHostViewQtDelegateItem::updatePaintNode(QSGNode *oldNode, U
#if QT_CONFIG(opengl)
} else if (comp->type() == Compositor::Type::OpenGL) {
QQuickWindow::CreateTextureOptions texOpts;
- if (comp->hasAlphaChannel())
+ if (comp->requiresAlphaChannel() || m_clearColor.alpha() < 255)
texOpts.setFlag(QQuickWindow::TextureHasAlphaChannel);
+ else
+ texOpts.setFlag(QQuickWindow::TextureIsOpaque);
int texId = comp->textureId();
node->setTexture(QNativeInterface::QSGOpenGLTexture::fromNative(texId, win, texSize, texOpts));
node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
@@ -379,8 +381,10 @@ QSGNode *RenderWidgetHostViewQtDelegateItem::updatePaintNode(QSGNode *oldNode, U
#if QT_CONFIG(webengine_vulkan)
} else if (comp->type() == Compositor::Type::Vulkan) {
QQuickWindow::CreateTextureOptions texOpts;
- if (comp->hasAlphaChannel())
+ if (comp->requiresAlphaChannel() || m_clearColor.alpha() < 255)
texOpts.setFlag(QQuickWindow::TextureHasAlphaChannel);
+ else
+ texOpts.setFlag(QQuickWindow::TextureIsOpaque);
VkImage image = comp->vkImage(win);
VkImageLayout layout = comp->vkImageLayout();