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

Commit 9ba36ca6 authored by Huihong Luo's avatar Huihong Luo
Browse files

Skip caching if any layer has protected contents

When a protected layer exists, it causes rendering issues with caching. They can be safely excluded as caching is usually not really useful with protected layers.
Bug: 191420183
Test: play a secure video with ExoPlayer, e.g., Secure->Clear->Secure
(cenc), check if flicking occurs

Change-Id: I31a01ee7da0e48f699f0fff7d2af410b648841e2
parent 49569edc
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -378,10 +378,14 @@ void CachedSet::dump(std::string& result) const {
    if (mLayers.size() == 1) {
        base::StringAppendF(&result, "    Layer [%s]\n", mLayers[0].getName().c_str());
        base::StringAppendF(&result, "    Buffer %p", mLayers[0].getBuffer().get());
        base::StringAppendF(&result, "    Protected [%s]",
                            mLayers[0].getState()->isProtected() ? "true" : "false");
    } else {
        result.append("    Cached set of:");
        for (const Layer& layer : mLayers) {
            base::StringAppendF(&result, "\n      Layer [%s]", layer.getName().c_str());
            base::StringAppendF(&result, "\n      Protected [%s]",
                                layer.getState()->isProtected() ? "true" : "false");
        }
    }

+9 −1
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ std::vector<Flattener::Run> Flattener::findCandidateRuns(time_point now) const {
        const bool layerIsInactive = now - currentSet->getLastUpdate() > mActiveLayerTimeout;
        const bool layerHasBlur = currentSet->hasBlurBehind();
        if (layerIsInactive && (firstLayer || runHasFirstLayer || !layerHasBlur) &&
            !currentSet->hasHdrLayers() && !currentSet->hasProtectedLayers()) {
            !currentSet->hasHdrLayers()) {
            if (isPartOfRun) {
                builder.append(currentSet->getLayerCount());
            } else {
@@ -491,6 +491,14 @@ void Flattener::buildCachedSets(time_point now) {
        return;
    }

    for (const CachedSet& layer : mLayers) {
        // TODO (b/191997217): make it less aggressive, and sync with findCandidateRuns
        if (layer.hasProtectedLayers()) {
            ATRACE_NAME("layer->hasProtectedLayers()");
            return;
        }
    }

    std::vector<Run> runs = findCandidateRuns(now);

    std::optional<Run> bestRun = findBestRun(runs);