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

Commit 10f05d8f authored by Nader Jawad's avatar Nader Jawad
Browse files

Conditionally cache RenderEffect results

Added property to conditionally cache SkImage instances
with SkImageFilters applied. Some GL vendor implementations
invoke Fence::waitForver without signalling, leading
to ANRs throughout the system.

Bug: 193145089
Test: manual
Change-Id: I3e478b11b66205d96e9499a362f7412a1d6e952d
Merged-In: I3e478b11b66205d96e9499a362f7412a1d6e952d
parent 5837f7b4
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ bool Properties::showDirtyRegions = false;
bool Properties::skipEmptyFrames = true;
bool Properties::skipEmptyFrames = true;
bool Properties::useBufferAge = true;
bool Properties::useBufferAge = true;
bool Properties::enablePartialUpdates = true;
bool Properties::enablePartialUpdates = true;
bool Properties::enableRenderEffectCache = false;


DebugLevel Properties::debugLevel = kDebugDisabled;
DebugLevel Properties::debugLevel = kDebugDisabled;
OverdrawColorSet Properties::overdrawColorSet = OverdrawColorSet::Default;
OverdrawColorSet Properties::overdrawColorSet = OverdrawColorSet::Default;
+1 −0
Original line number Original line Diff line number Diff line
@@ -224,6 +224,7 @@ public:
    static bool skipEmptyFrames;
    static bool skipEmptyFrames;
    static bool useBufferAge;
    static bool useBufferAge;
    static bool enablePartialUpdates;
    static bool enablePartialUpdates;
    static bool enableRenderEffectCache;


    // TODO: Move somewhere else?
    // TODO: Move somewhere else?
    static constexpr float textGamma = 1.45f;
    static constexpr float textGamma = 1.45f;
+28 −8
Original line number Original line Diff line number Diff line
@@ -231,14 +231,34 @@ void RenderNodeDrawable::drawContent(SkCanvas* canvas) const {
            SkASSERT(properties.effectiveLayerType() == LayerType::RenderLayer);
            SkASSERT(properties.effectiveLayerType() == LayerType::RenderLayer);
            SkPaint paint;
            SkPaint paint;
            layerNeedsPaint(layerProperties, alphaMultiplier, &paint);
            layerNeedsPaint(layerProperties, alphaMultiplier, &paint);
            sk_sp<SkImage> snapshotImage;
            auto* imageFilter = layerProperties.getImageFilter();
            auto recordingContext = canvas->recordingContext();
            // On some GL vendor implementations, caching the result of
            // getLayerSurface->makeImageSnapshot() causes a call to
            // Fence::waitForever without a corresponding signal. This would
            // lead to ANRs throughout the system.
            // Instead only cache the SkImage created with the SkImageFilter
            // for supported devices. Otherwise just create a new SkImage with
            // the corresponding SkImageFilter each time.
            // See b/193145089 and b/197263715
            if (!Properties::enableRenderEffectCache) {
                if (imageFilter) {
                    auto subset = SkIRect::MakeWH(srcBounds.width(), srcBounds.height());
                    snapshotImage = snapshotImage->makeWithFilter(recordingContext, imageFilter,
                                                                  subset, clipBounds.roundOut(),
                                                                  &srcBounds, &offset);
                } else {
                    snapshotImage = renderNode->getLayerSurface()->makeImageSnapshot();
                }
            } else {
                const auto snapshotResult = renderNode->updateSnapshotIfRequired(
                const auto snapshotResult = renderNode->updateSnapshotIfRequired(
                canvas->recordingContext(),
                        recordingContext, layerProperties.getImageFilter(), clipBounds.roundOut());
                layerProperties.getImageFilter(),
                snapshotImage = snapshotResult->snapshot;
                clipBounds.roundOut()
            );
            sk_sp<SkImage> snapshotImage = snapshotResult->snapshot;
                srcBounds = snapshotResult->outSubset;
                srcBounds = snapshotResult->outSubset;
                offset = snapshotResult->outOffset;
                offset = snapshotResult->outOffset;
            }

            const auto dstBounds = SkIRect::MakeXYWH(offset.x(),
            const auto dstBounds = SkIRect::MakeXYWH(offset.x(),
                                                     offset.y(),
                                                     offset.y(),
                                                     srcBounds.width(),
                                                     srcBounds.width(),
+3 −0
Original line number Original line Diff line number Diff line
@@ -146,6 +146,9 @@ void EglManager::initialize() {
        LOG_ALWAYS_FATAL("Unsupported wide color space.");
        LOG_ALWAYS_FATAL("Unsupported wide color space.");
    }
    }
    mHasWideColorGamutSupport = EglExtensions.glColorSpace && hasWideColorSpaceExtension;
    mHasWideColorGamutSupport = EglExtensions.glColorSpace && hasWideColorSpaceExtension;

    auto* vendor = reinterpret_cast<const char*>(glGetString(GL_VENDOR));
    Properties::enableRenderEffectCache = (strcmp(vendor, "Qualcomm") != 0);
}
}


EGLConfig EglManager::load8BitsConfig(EGLDisplay display, EglManager::SwapBehavior swapBehavior) {
EGLConfig EglManager::load8BitsConfig(EGLDisplay display, EglManager::SwapBehavior swapBehavior) {