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

Commit 4f16b050 authored by Robin Lee's avatar Robin Lee Committed by Android (Google) Code Review
Browse files

Merge "Add a sysprop to switch between blur algorithms" into main

parents 2b18d629 7338bd98
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -49,6 +49,11 @@
 */
#define PROPERTY_DEBUG_RENDERENGINE_CAPTURE_FILENAME "debug.renderengine.capture_filename"

/**
 * Switches the cross-window background blur algorithm.
 */
#define PROPERTY_DEBUG_RENDERENGINE_BLUR_ALGORITHM "debug.renderengine.blur_algorithm"

/**
 * Allows recording of Skia drawing commands with systrace.
 */
@@ -107,6 +112,12 @@ public:
        GRAPHITE,
    };

    enum class BlurAlgorithm {
        NONE,
        GAUSSIAN,
        KAWASE,
    };

    static std::unique_ptr<RenderEngine> create(const RenderEngineCreationArgs& args);

    static bool canSupport(GraphicsApi);
@@ -258,7 +269,7 @@ struct RenderEngineCreationArgs {
    bool useColorManagement;
    bool enableProtectedContext;
    bool precacheToneMapperShaderOnly;
    bool supportsBackgroundBlur;
    RenderEngine::BlurAlgorithm blurAlgorithm;
    RenderEngine::ContextPriority contextPriority;
    RenderEngine::Threaded threaded;
    RenderEngine::GraphicsApi graphicsApi;
@@ -270,7 +281,7 @@ private:
    // must be created by Builder via constructor with full argument list
    RenderEngineCreationArgs(int _pixelFormat, uint32_t _imageCacheSize,
                             bool _enableProtectedContext, bool _precacheToneMapperShaderOnly,
                             bool _supportsBackgroundBlur,
                             RenderEngine::BlurAlgorithm _blurAlgorithm,
                             RenderEngine::ContextPriority _contextPriority,
                             RenderEngine::Threaded _threaded,
                             RenderEngine::GraphicsApi _graphicsApi,
@@ -279,7 +290,7 @@ private:
            imageCacheSize(_imageCacheSize),
            enableProtectedContext(_enableProtectedContext),
            precacheToneMapperShaderOnly(_precacheToneMapperShaderOnly),
            supportsBackgroundBlur(_supportsBackgroundBlur),
            blurAlgorithm(_blurAlgorithm),
            contextPriority(_contextPriority),
            threaded(_threaded),
            graphicsApi(_graphicsApi),
@@ -306,8 +317,8 @@ struct RenderEngineCreationArgs::Builder {
        this->precacheToneMapperShaderOnly = precacheToneMapperShaderOnly;
        return *this;
    }
    Builder& setSupportsBackgroundBlur(bool supportsBackgroundBlur) {
        this->supportsBackgroundBlur = supportsBackgroundBlur;
    Builder& setBlurAlgorithm(RenderEngine::BlurAlgorithm blurAlgorithm) {
        this->blurAlgorithm = blurAlgorithm;
        return *this;
    }
    Builder& setContextPriority(RenderEngine::ContextPriority contextPriority) {
@@ -328,7 +339,7 @@ struct RenderEngineCreationArgs::Builder {
    }
    RenderEngineCreationArgs build() const {
        return RenderEngineCreationArgs(pixelFormat, imageCacheSize, enableProtectedContext,
                                        precacheToneMapperShaderOnly, supportsBackgroundBlur,
                                        precacheToneMapperShaderOnly, blurAlgorithm,
                                        contextPriority, threaded, graphicsApi, skiaBackend);
    }

@@ -338,7 +349,7 @@ private:
    uint32_t imageCacheSize = 0;
    bool enableProtectedContext = false;
    bool precacheToneMapperShaderOnly = false;
    bool supportsBackgroundBlur = false;
    RenderEngine::BlurAlgorithm blurAlgorithm = RenderEngine::BlurAlgorithm::NONE;
    RenderEngine::ContextPriority contextPriority = RenderEngine::ContextPriority::MEDIUM;
    RenderEngine::Threaded threaded = RenderEngine::Threaded::YES;
    RenderEngine::GraphicsApi graphicsApi = RenderEngine::GraphicsApi::GL;
+1 −1
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ SkiaGLRenderEngine::SkiaGLRenderEngine(const RenderEngineCreationArgs& args, EGL
                                       EGLContext ctxt, EGLSurface placeholder,
                                       EGLContext protectedContext, EGLSurface protectedPlaceholder)
      : SkiaRenderEngine(args.threaded, static_cast<PixelFormat>(args.pixelFormat),
                         args.supportsBackgroundBlur),
                         args.blurAlgorithm),
        mEGLDisplay(display),
        mEGLContext(ctxt),
        mPlaceholderSurface(placeholder),
+17 −4
Original line number Diff line number Diff line
@@ -273,12 +273,25 @@ void SkiaRenderEngine::setEnableTracing(bool tracingEnabled) {
}

SkiaRenderEngine::SkiaRenderEngine(Threaded threaded, PixelFormat pixelFormat,
                                   bool supportsBackgroundBlur)
                                   BlurAlgorithm blurAlgorithm)
      : RenderEngine(threaded), mDefaultPixelFormat(pixelFormat) {
    if (supportsBackgroundBlur) {
        ALOGD("Background Blurs Enabled");
    switch (blurAlgorithm) {
        case BlurAlgorithm::GAUSSIAN: {
            ALOGD("Background Blurs Enabled (Gaussian algorithm)");
            mBlurFilter = new GaussianBlurFilter();
            break;
        }
        case BlurAlgorithm::KAWASE: {
            ALOGD("Background Blurs Enabled (Kawase algorithm)");
            mBlurFilter = new KawaseBlurFilter();
            break;
        }
        default: {
            mBlurFilter = nullptr;
            break;
        }
    }

    mCapture = std::make_unique<SkiaCapture>();
}

+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ class BlurFilter;
class SkiaRenderEngine : public RenderEngine {
public:
    static std::unique_ptr<SkiaRenderEngine> create(const RenderEngineCreationArgs& args);
    SkiaRenderEngine(Threaded, PixelFormat pixelFormat, bool supportsBackgroundBlur);
    SkiaRenderEngine(Threaded, PixelFormat pixelFormat, BlurAlgorithm);
    ~SkiaRenderEngine() override;

    std::future<void> primeCache(bool shouldPrimeUltraHDR) override final;
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ using base::StringAppendF;

SkiaVkRenderEngine::SkiaVkRenderEngine(const RenderEngineCreationArgs& args)
      : SkiaRenderEngine(args.threaded, static_cast<PixelFormat>(args.pixelFormat),
                         args.supportsBackgroundBlur) {}
                         args.blurAlgorithm) {}

SkiaVkRenderEngine::~SkiaVkRenderEngine() {
    finishRenderingAndAbandonContext();
Loading