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

Commit 63f9dbf9 authored by Lloyd Pique's avatar Lloyd Pique
Browse files

[SurfaceFlinger] Hide SyncFeatures behind RenderEngine

This allows a future test that uses BufferLayerConsumer as-is and does
not actually set up a GL context to work by adding call expectations to
RenderEngine for what sync configuration should be used.

SyncFeatures is a singleton, and makes a bunch of GL queries when first
constructed to determine what is supported by the GL driver. It made
most sense to me to hide this inside the RenderEngine for that reason.

Test: Builds
Bug: None

Change-Id: Ic62bfb689a84fd9e509139c7f189223cf215277e
parent b1a4e00a
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@
#include <gui/SurfaceComposerClient.h>

#include <private/gui/ComposerService.h>
#include <private/gui/SyncFeatures.h>

#include <utils/Log.h>
#include <utils/String8.h>
@@ -206,7 +205,7 @@ status_t BufferLayerConsumer::updateTexImage(BufferRejecter* rejecter, const Dis
        return err;
    }

    if (!SyncFeatures::getInstance().useNativeFenceSync()) {
    if (mRE.useNativeFenceSync()) {
        // Bind the new buffer to the GL texture.
        //
        // Older devices require the "implicit" synchronization provided
@@ -374,7 +373,7 @@ status_t BufferLayerConsumer::syncForReleaseLocked() {
    BLC_LOGV("syncForReleaseLocked");

    if (mCurrentTexture != BufferQueue::INVALID_BUFFER_SLOT) {
        if (SyncFeatures::getInstance().useNativeFenceSync()) {
        if (mRE.useNativeFenceSync()) {
            base::unique_fd fenceFd = mRE.flush();
            if (fenceFd == -1) {
                BLC_LOGE("syncForReleaseLocked: failed to flush RenderEngine");
@@ -512,7 +511,7 @@ status_t BufferLayerConsumer::doFenceWaitLocked() const {
    }

    if (mCurrentFence->isValid()) {
        if (SyncFeatures::getInstance().useWaitSync()) {
        if (mRE.useWaitSync()) {
            base::unique_fd fenceFd(mCurrentFence->dup());
            if (fenceFd == -1) {
                BLC_LOGE("doFenceWait: error dup'ing fence fd: %d", errno);
+9 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@

#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
#include <configstore/Utils.h>
#include <private/gui/SyncFeatures.h>

using namespace android::hardware::configstore;
using namespace android::hardware::configstore::V1_0;
@@ -175,6 +176,14 @@ EGLConfig RenderEngine::getEGLConfig() const {
    return mEGLConfig;
}

bool RenderEngine::useNativeFenceSync() const {
    return SyncFeatures::getInstance().useNativeFenceSync();
}

bool RenderEngine::useWaitSync() const {
    return SyncFeatures::getInstance().useWaitSync();
}

bool RenderEngine::isCurrent() const {
    return mEGLDisplay == eglGetCurrentDisplay() && mEGLContext == eglGetCurrentContext();
}
+6 −0
Original line number Diff line number Diff line
@@ -69,6 +69,9 @@ public:
    // dump the extension strings. always call the base class.
    virtual void dump(String8& result) = 0;

    virtual bool useNativeFenceSync() const = 0;
    virtual bool useWaitSync() const = 0;

    virtual bool isCurrent() const = 0;
    virtual bool setCurrentSurface(const RE::Surface& surface) = 0;
    virtual void resetCurrentSurface() = 0;
@@ -190,6 +193,9 @@ public:
    // dump the extension strings. always call the base class.
    void dump(String8& result) override;

    bool useNativeFenceSync() const override;
    bool useWaitSync() const override;

    bool isCurrent() const;
    bool setCurrentSurface(const RE::Surface& surface) override;
    void resetCurrentSurface() override;
+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ public:
    MOCK_METHOD0(createImage, std::unique_ptr<RE::Image>());
    MOCK_CONST_METHOD0(primeCache, void());
    MOCK_METHOD1(dump, void(String8&));
    MOCK_CONST_METHOD0(useNativeFenceSync, bool());
    MOCK_CONST_METHOD0(useWaitSync, bool());
    MOCK_CONST_METHOD0(isCurrent, bool());
    MOCK_METHOD1(setCurrentSurface, bool(const RE::Surface&));
    MOCK_METHOD0(resetCurrentSurface, void());