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

Commit ab448ac8 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Dither HDR content when compositing to an 8-bit target" into tm-dev am: a3eab26a

parents 107faf89 a3eab26a
Loading
Loading
Loading
Loading
+9 −2
Original line number Original line Diff line number Diff line
@@ -57,6 +57,7 @@
#include <gui/TraceUtils.h>
#include <gui/TraceUtils.h>
#include <sync/sync.h>
#include <sync/sync.h>
#include <ui/BlurRegion.h>
#include <ui/BlurRegion.h>
#include <ui/DataspaceUtils.h>
#include <ui/DebugUtils.h>
#include <ui/DebugUtils.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
#include <utils/Trace.h>
#include <utils/Trace.h>
@@ -1121,9 +1122,15 @@ void SkiaGLRenderEngine::drawLayersInternal(
                                                  .requiresLinearEffect = requiresLinearEffect,
                                                  .requiresLinearEffect = requiresLinearEffect,
                                                  .layerDimmingRatio = layerDimmingRatio}));
                                                  .layerDimmingRatio = layerDimmingRatio}));


            // Turn on dithering when dimming beyond this threshold.
            // Turn on dithering when dimming beyond this (arbitrary) threshold...
            static constexpr float kDimmingThreshold = 0.2f;
            static constexpr float kDimmingThreshold = 0.2f;
            if (layerDimmingRatio <= kDimmingThreshold) {
            // ...or we're rendering an HDR layer down to an 8-bit target
            // Most HDR standards require at least 10-bits of color depth for source content, so we
            // can just extract the transfer function rather than dig into precise gralloc layout.
            // Furthermore, we can assume that the only 8-bit target we support is RGBA8888.
            const bool requiresDownsample = isHdrDataspace(layer.sourceDataspace) &&
                    buffer->getPixelFormat() == PIXEL_FORMAT_RGBA_8888;
            if (layerDimmingRatio <= kDimmingThreshold || requiresDownsample) {
                paint.setDither(true);
                paint.setDither(true);
            }
            }
            paint.setAlphaf(layer.alpha);
            paint.setAlphaf(layer.alpha);