Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7df184f authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Only flush after all layers are drawn instead of after each layer.

This approach avoids paying for any extra overhead in flushing
commands from Skia to the GPU.

Test: LauncherJankTests#testOpenAllAppsContainer
Change-Id: Ie4be3592d1b032a06d848c994b8be435638d24c8
parent dc168546
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -83,7 +83,8 @@ void SkiaPipeline::renderLayers(const FrameBuilder::LightGeometry& lightGeometry

void SkiaPipeline::renderLayersImpl(const LayerUpdateQueue& layers,
        bool opaque, bool wideColorGamut) {
    // TODO: Handle wide color gamut
    sk_sp<GrContext> cachedContext;

    // Render all layers that need to be updated, in order.
    for (size_t i = 0; i < layers.entries().size(); i++) {
        RenderNode* layerNode = layers.entries()[i].renderNode.get();
@@ -126,12 +127,25 @@ void SkiaPipeline::renderLayersImpl(const LayerUpdateQueue& layers,
            RenderNodeDrawable root(layerNode, layerCanvas, false);
            root.forceDraw(layerCanvas);
            layerCanvas->restoreToCount(saveCount);
            layerCanvas->flush();
            mLightCenter = savedLightCenter;

            // cache the current context so that we can defer flushing it until
            // either all the layers have been rendered or the context changes
            GrContext* currentContext = layerCanvas->getGrContext();
            if (cachedContext.get() != currentContext) {
                if (cachedContext.get()) {
                    cachedContext->flush();
                }
                cachedContext.reset(SkSafeRef(currentContext));
            }
        }
    }

    if (cachedContext.get()) {
        cachedContext->flush();
    }
}

bool SkiaPipeline::createOrUpdateLayer(RenderNode* node,
        const DamageAccumulator& damageAccumulator, bool wideColorGamut) {
    SkSurface* layer = node->getLayerSurface();