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

Commit b2c76246 authored by Chia-I Wu's avatar Chia-I Wu
Browse files

surfaceflinger: manage RenderEngine with unique_ptr

Test: SurfaceFlinger_test
Change-Id: I603a399b88963acdcd154f721fe64bf59d9032fd
parent 761f8b4a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -60,9 +60,9 @@ class GLES20RenderEngine : public RenderEngine {

public:
    GLES20RenderEngine(uint32_t featureFlags); // See RenderEngine::FeatureFlag
    virtual ~GLES20RenderEngine();

protected:
    virtual ~GLES20RenderEngine();

    virtual void dump(String8& result);
    virtual void setViewportAndProjection(size_t vpw, size_t vph,
+4 −3
Original line number Diff line number Diff line
@@ -47,7 +47,8 @@ static bool findExtension(const char* exts, const char* name) {
    return false;
}

RenderEngine* RenderEngine::create(EGLDisplay display, int hwcFormat, uint32_t featureFlags) {
std::unique_ptr<RenderEngine> RenderEngine::create(EGLDisplay display,
        int hwcFormat, uint32_t featureFlags) {
    // EGL_ANDROIDX_no_config_context is an experimental extension with no
    // written specification. It will be replaced by something more formal.
    // SurfaceFlinger is using it to allow a single EGLContext to render to
@@ -127,7 +128,7 @@ RenderEngine* RenderEngine::create(EGLDisplay display, int hwcFormat, uint32_t f

    // initialize the renderer while GL is current

    RenderEngine* engine = NULL;
    std::unique_ptr<RenderEngine> engine;
    switch (version) {
    case GLES_VERSION_1_0:
    case GLES_VERSION_1_1:
@@ -135,7 +136,7 @@ RenderEngine* RenderEngine::create(EGLDisplay display, int hwcFormat, uint32_t f
        break;
    case GLES_VERSION_2_0:
    case GLES_VERSION_3_0:
        engine = new GLES20RenderEngine(featureFlags);
        engine = std::make_unique<GLES20RenderEngine>(featureFlags);
        break;
    }
    engine->setEGLHandles(config, ctxt);
+6 −2
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#ifndef SF_RENDERENGINE_H_
#define SF_RENDERENGINE_H_

#include <memory>

#include <stdint.h>
#include <sys/types.h>

@@ -57,13 +59,15 @@ class RenderEngine {

protected:
    RenderEngine();
    virtual ~RenderEngine() = 0;

public:
    virtual ~RenderEngine() = 0;

    enum FeatureFlag {
        WIDE_COLOR_SUPPORT = 1 << 0 // Platform has a wide color display
    };
    static RenderEngine* create(EGLDisplay display, int hwcFormat, uint32_t featureFlags);
    static std::unique_ptr<RenderEngine> create(EGLDisplay display,
            int hwcFormat, uint32_t featureFlags);

    static EGLConfig chooseEglConfig(EGLDisplay display, int format, bool logConfig);

+1 −1
Original line number Diff line number Diff line
@@ -659,7 +659,7 @@ private:
    const std::string mHwcServiceName; // "default" for real use, something else for testing.

    // constant members (no synchronization needed for access)
    RenderEngine* mRenderEngine;
    std::unique_ptr<RenderEngine> mRenderEngine;
    nsecs_t mBootTime;
    bool mGpuToCpuSupported;
    sp<EventThread> mEventThread;