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

Commit 77ff8af7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Creating a threaded version of the Render Engine."

parents 737a18a2 9bc9dc69
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -64,6 +64,13 @@ filegroup {
    ],
}

filegroup {
    name: "librenderengine_threaded_sources",
    srcs: [
        "threaded/RenderEngineThreaded.cpp",
    ],
}

cc_library_static {
    name: "librenderengine",
    defaults: ["librenderengine_defaults"],
@@ -80,6 +87,7 @@ cc_library_static {
    srcs: [
        ":librenderengine_sources",
        ":librenderengine_gl_sources",
        ":librenderengine_threaded_sources",
    ],
    lto: {
        thin: true,
+19 −5
Original line number Diff line number Diff line
@@ -20,20 +20,34 @@
#include <log/log.h>
#include <private/gui/SyncFeatures.h>
#include "gl/GLESRenderEngine.h"
#include "threaded/RenderEngineThreaded.h"

namespace android {
namespace renderengine {

std::unique_ptr<impl::RenderEngine> RenderEngine::create(const RenderEngineCreationArgs& args) {
    RenderEngineType renderEngineType = args.renderEngineType;

    // Keep the ability to override by PROPERTIES:
    char prop[PROPERTY_VALUE_MAX];
    property_get(PROPERTY_DEBUG_RENDERENGINE_BACKEND, prop, "gles");
    property_get(PROPERTY_DEBUG_RENDERENGINE_BACKEND, prop, "");
    if (strcmp(prop, "gles") == 0) {
        ALOGD("RenderEngine GLES Backend");
        return renderengine::gl::GLESRenderEngine::create(args);
        renderEngineType = RenderEngineType::GLES;
    }
    if (strcmp(prop, "threaded") == 0) {
        renderEngineType = RenderEngineType::THREADED;
    }
    ALOGE("UNKNOWN BackendType: %s, create GLES RenderEngine.", prop);

    switch (renderEngineType) {
        case RenderEngineType::THREADED:
            ALOGD("Threaded RenderEngine with GLES Backend");
            return renderengine::threaded::RenderEngineThreaded::create(args);
        case RenderEngineType::GLES:
        default:
            ALOGD("RenderEngine with GLES Backend");
            return renderengine::gl::GLESRenderEngine::create(args);
    }
}

RenderEngine::~RenderEngine() = default;

+30 −16
Original line number Diff line number Diff line
@@ -50,6 +50,10 @@ class Mesh;
class Texture;
struct RenderEngineCreationArgs;

namespace threaded {
class RenderEngineThreaded;
}

namespace impl {
class RenderEngine;
}
@@ -67,6 +71,11 @@ public:
        HIGH = 3,
    };

    enum class RenderEngineType {
        GLES = 1,
        THREADED = 2,
    };

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

    virtual ~RenderEngine() = 0;
@@ -174,6 +183,7 @@ protected:
    // live longer than RenderEngine.
    virtual Framebuffer* getFramebufferForDrawing() = 0;
    friend class BindNativeBufferAsFramebuffer;
    friend class threaded::RenderEngineThreaded;
};

struct RenderEngineCreationArgs {
@@ -184,26 +194,25 @@ struct RenderEngineCreationArgs {
    bool precacheToneMapperShaderOnly;
    bool supportsBackgroundBlur;
    RenderEngine::ContextPriority contextPriority;
    RenderEngine::RenderEngineType renderEngineType;

    struct Builder;

private:
    // must be created by Builder via constructor with full argument list
    RenderEngineCreationArgs(
            int _pixelFormat,
            uint32_t _imageCacheSize,
            bool _useColorManagement,
            bool _enableProtectedContext,
            bool _precacheToneMapperShaderOnly,
    RenderEngineCreationArgs(int _pixelFormat, uint32_t _imageCacheSize, bool _useColorManagement,
                             bool _enableProtectedContext, bool _precacheToneMapperShaderOnly,
                             bool _supportsBackgroundBlur,
            RenderEngine::ContextPriority _contextPriority)
        : pixelFormat(_pixelFormat)
        , imageCacheSize(_imageCacheSize)
        , useColorManagement(_useColorManagement)
        , enableProtectedContext(_enableProtectedContext)
        , precacheToneMapperShaderOnly(_precacheToneMapperShaderOnly)
        , supportsBackgroundBlur(_supportsBackgroundBlur)
        , contextPriority(_contextPriority) {}
                             RenderEngine::ContextPriority _contextPriority,
                             RenderEngine::RenderEngineType _renderEngineType)
          : pixelFormat(_pixelFormat),
            imageCacheSize(_imageCacheSize),
            useColorManagement(_useColorManagement),
            enableProtectedContext(_enableProtectedContext),
            precacheToneMapperShaderOnly(_precacheToneMapperShaderOnly),
            supportsBackgroundBlur(_supportsBackgroundBlur),
            contextPriority(_contextPriority),
            renderEngineType(_renderEngineType) {}
    RenderEngineCreationArgs() = delete;
};

@@ -238,10 +247,14 @@ struct RenderEngineCreationArgs::Builder {
        this->contextPriority = contextPriority;
        return *this;
    }
    Builder& setRenderEngineType(RenderEngine::RenderEngineType renderEngineType) {
        this->renderEngineType = renderEngineType;
        return *this;
    }
    RenderEngineCreationArgs build() const {
        return RenderEngineCreationArgs(pixelFormat, imageCacheSize, useColorManagement,
                                        enableProtectedContext, precacheToneMapperShaderOnly,
                                        supportsBackgroundBlur, contextPriority);
                                        supportsBackgroundBlur, contextPriority, renderEngineType);
    }

private:
@@ -253,6 +266,7 @@ private:
    bool precacheToneMapperShaderOnly = false;
    bool supportsBackgroundBlur = false;
    RenderEngine::ContextPriority contextPriority = RenderEngine::ContextPriority::MEDIUM;
    RenderEngine::RenderEngineType renderEngineType = RenderEngine::RenderEngineType::GLES;
};

class BindNativeBufferAsFramebuffer {
+2 −0
Original line number Diff line number Diff line
@@ -18,10 +18,12 @@ cc_test {
    test_suites: ["device-tests"],
    srcs: [
        "RenderEngineTest.cpp",
        "RenderEngineThreadedTest.cpp",
    ],
    static_libs: [
        "libgmock",
        "librenderengine",
        "librenderengine_mocks",
    ],
    shared_libs: [
        "libbase",
+11 −9
Original line number Diff line number Diff line
@@ -22,12 +22,13 @@
#include <condition_variable>
#include <fstream>

#include <gtest/gtest.h>
#include <cutils/properties.h>
#include <gtest/gtest.h>
#include <renderengine/RenderEngine.h>
#include <sync/sync.h>
#include <ui/PixelFormat.h>
#include "../gl/GLESRenderEngine.h"
#include "../threaded/RenderEngineThreaded.h"

constexpr int DEFAULT_DISPLAY_WIDTH = 128;
constexpr int DEFAULT_DISPLAY_HEIGHT = 256;
@@ -47,6 +48,7 @@ struct RenderEngineTest : public ::testing::Test {
                        .setPrecacheToneMapperShaderOnly(false)
                        .setSupportsBackgroundBlur(true)
                        .setContextPriority(renderengine::RenderEngine::ContextPriority::MEDIUM)
                        .setRenderEngineType(renderengine::RenderEngine::RenderEngineType::GLES)
                        .build());
    }

Loading