scenes/opengl: Avoid blending for entirely opaque SurfaceItems

Blending is quite expensive especially with software rendering.
In the case of Firefox on Wayland, it uses a ARGB8888 buffer but marks the
entire surface as opaque, so the alpha channel can be ignored.

CCBUG: 440386
This commit is contained in:
Fabian Vogt 2021-08-06 11:01:18 +02:00
parent 1041ef8275
commit 11c7e7a64d

View file

@ -983,12 +983,14 @@ void OpenGLWindow::createRenderNode(Item *item, RenderContext *context)
if (!quads.isEmpty()) {
SurfacePixmap *pixmap = surfaceItem->pixmap();
if (pixmap) {
// Don't bother with blending if the entire surface is opaque
bool hasAlpha = pixmap->hasAlphaChannel() && !surfaceItem->shape().subtracted(surfaceItem->opaque()).isEmpty();
context->renderNodes.append(RenderNode{
.texture = bindSurfaceTexture(surfaceItem),
.quads = quads,
.transformMatrix = transformation(item, context),
.opacity = context->paintData.opacity(),
.hasAlpha = pixmap->hasAlphaChannel(),
.hasAlpha = hasAlpha,
.coordinateType = UnnormalizedCoordinates,
});
}