Drop isCompletelyOpaque optimisation

With the floating geometry this becomes a non-trivial check, at some
point this will cost more than the gl blend itself.
This commit is contained in:
David Edmundson 2022-11-01 16:39:45 +00:00
parent bcd9f1e958
commit dadfd7aec8

View file

@ -386,24 +386,12 @@ void SceneOpenGL::createRenderNode(Item *item, RenderContext *context)
SurfacePixmap *pixmap = surfaceItem->pixmap(); SurfacePixmap *pixmap = surfaceItem->pixmap();
if (pixmap) { if (pixmap) {
if (!geometry.isEmpty()) { if (!geometry.isEmpty()) {
bool hasAlpha = pixmap->hasAlphaChannel();
bool isCompletelyOpaque = true;
// Don't bother with blending if the entire surface is opaque
const QVector<QRectF> shape = surfaceItem->shape();
for (const QRectF &shapePart : shape) {
if (!item->opaque().contains(shapePart.toRect())) {
isCompletelyOpaque = false;
break;
}
}
hasAlpha &= !isCompletelyOpaque;
context->renderNodes.append(RenderNode{ context->renderNodes.append(RenderNode{
.texture = bindSurfaceTexture(surfaceItem), .texture = bindSurfaceTexture(surfaceItem),
.geometry = geometry, .geometry = geometry,
.transformMatrix = context->transformStack.top(), .transformMatrix = context->transformStack.top(),
.opacity = context->opacityStack.top(), .opacity = context->opacityStack.top(),
.hasAlpha = hasAlpha, .hasAlpha = pixmap->hasAlphaChannel(),
.coordinateType = NormalizedCoordinates, .coordinateType = NormalizedCoordinates,
.scale = scale, .scale = scale,
}); });