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

Commit feb73d79 authored by Lloyd Pique's avatar Lloyd Pique
Browse files

SF: Setup CompositionEngine::Layer

Add a Layer class to CompositionEngine, and modify ColorLayer and
BufferLayer to create them.

Also sets up CompositionEngine::LayerFE as an interface to be
implemented by the SF Layer class.

Test: atest libsurfaceflinger_unittest libcompositionengine_test
Bug: 121291683
Change-Id: I2ed83355e81f36954b034ec60dd1a24c631f4874
parent 3b7f2022
Loading
Loading
Loading
Loading
+23 −17
Original line number Original line Diff line number Diff line
@@ -19,40 +19,42 @@
#define LOG_TAG "BufferLayer"
#define LOG_TAG "BufferLayer"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
#define ATRACE_TAG ATRACE_TAG_GRAPHICS


#include "BufferLayer.h"
#include <cmath>
#include "Colorizer.h"
#include <cstdlib>
#include "DisplayDevice.h"
#include <mutex>
#include "LayerRejecter.h"

#include "TimeStats/TimeStats.h"

#include <renderengine/RenderEngine.h>


#include <compositionengine/CompositionEngine.h>
#include <compositionengine/Layer.h>
#include <compositionengine/LayerCreationArgs.h>
#include <cutils/compiler.h>
#include <cutils/native_handle.h>
#include <cutils/properties.h>
#include <gui/BufferItem.h>
#include <gui/BufferItem.h>
#include <gui/BufferQueue.h>
#include <gui/BufferQueue.h>
#include <gui/LayerDebugInfo.h>
#include <gui/LayerDebugInfo.h>
#include <gui/Surface.h>
#include <gui/Surface.h>

#include <renderengine/RenderEngine.h>
#include <ui/DebugUtils.h>
#include <ui/DebugUtils.h>

#include <utils/Errors.h>
#include <utils/Errors.h>
#include <utils/Log.h>
#include <utils/Log.h>
#include <utils/NativeHandle.h>
#include <utils/NativeHandle.h>
#include <utils/StopWatch.h>
#include <utils/StopWatch.h>
#include <utils/Trace.h>
#include <utils/Trace.h>


#include <cutils/compiler.h>
#include "BufferLayer.h"
#include <cutils/native_handle.h>
#include "Colorizer.h"
#include <cutils/properties.h>
#include "DisplayDevice.h"
#include "LayerRejecter.h"


#include <math.h>
#include "TimeStats/TimeStats.h"
#include <stdlib.h>
#include <mutex>


namespace android {
namespace android {


BufferLayer::BufferLayer(const LayerCreationArgs& args)
BufferLayer::BufferLayer(const LayerCreationArgs& args)
      : Layer(args), mTextureName(args.flinger->getNewTexture()) {
      : Layer(args),
        mTextureName(args.flinger->getNewTexture()),
        mCompositionLayer{mFlinger->getCompositionEngine().createLayer(
                compositionengine::LayerCreationArgs{this})} {
    ALOGV("Creating Layer %s", args.name.string());
    ALOGV("Creating Layer %s", args.name.string());


    mPremultipliedAlpha = !(args.flags & ISurfaceComposerClient::eNonPremultiplied);
    mPremultipliedAlpha = !(args.flags & ISurfaceComposerClient::eNonPremultiplied);
@@ -649,6 +651,10 @@ Rect BufferLayer::getBufferSize(const State& s) const {
    return Rect(bufWidth, bufHeight);
    return Rect(bufWidth, bufHeight);
}
}


std::shared_ptr<compositionengine::Layer> BufferLayer::getCompositionLayer() const {
    return mCompositionLayer;
}

} // namespace android
} // namespace android


#if defined(__gl_h_)
#if defined(__gl_h_)
+17 −15
Original line number Original line Diff line number Diff line
@@ -16,35 +16,33 @@


#pragma once
#pragma once


#include "BufferLayerConsumer.h"
#include <sys/types.h>
#include "Client.h"
#include <cstdint>
#include "Layer.h"
#include <list>
#include "DisplayHardware/HWComposer.h"
#include "DisplayHardware/HWComposerBufferCache.h"
#include "FrameTracker.h"
#include "LayerVector.h"
#include "MonitoredProducer.h"
#include "SurfaceFlinger.h"


#include <gui/ISurfaceComposerClient.h>
#include <gui/ISurfaceComposerClient.h>
#include <gui/LayerState.h>
#include <gui/LayerState.h>
#include <renderengine/Image.h>
#include <renderengine/Image.h>
#include <renderengine/Mesh.h>
#include <renderengine/Mesh.h>
#include <renderengine/Texture.h>
#include <renderengine/Texture.h>
#include <system/window.h> // For NATIVE_WINDOW_SCALING_MODE_FREEZE
#include <ui/FrameStats.h>
#include <ui/FrameStats.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
#include <ui/PixelFormat.h>
#include <ui/PixelFormat.h>
#include <ui/Region.h>
#include <ui/Region.h>

#include <utils/RefBase.h>
#include <utils/RefBase.h>
#include <utils/String8.h>
#include <utils/String8.h>
#include <utils/Timers.h>
#include <utils/Timers.h>


#include <system/window.h> // For NATIVE_WINDOW_SCALING_MODE_FREEZE
#include "BufferLayerConsumer.h"

#include "Client.h"
#include <stdint.h>
#include "DisplayHardware/HWComposer.h"
#include <sys/types.h>
#include "DisplayHardware/HWComposerBufferCache.h"
#include <list>
#include "FrameTracker.h"
#include "Layer.h"
#include "LayerVector.h"
#include "MonitoredProducer.h"
#include "SurfaceFlinger.h"


namespace android {
namespace android {


@@ -57,6 +55,8 @@ public:
    // Overriden from Layer
    // Overriden from Layer
    // -----------------------------------------------------------------------
    // -----------------------------------------------------------------------
public:
public:
    std::shared_ptr<compositionengine::Layer> getCompositionLayer() const override;

    // If we have received a new buffer this frame, we will pass its surface
    // If we have received a new buffer this frame, we will pass its surface
    // damage down to hardware composer. Otherwise, we must send a region with
    // damage down to hardware composer. Otherwise, we must send a region with
    // one empty rect.
    // one empty rect.
@@ -187,6 +187,8 @@ private:
    bool mBufferLatched{false}; // TODO: Use mActiveBuffer?
    bool mBufferLatched{false}; // TODO: Use mActiveBuffer?


    Rect getBufferSize(const State& s) const override;
    Rect getBufferSize(const State& s) const override;

    std::shared_ptr<compositionengine::Layer> mCompositionLayer;
};
};


} // namespace android
} // namespace android
+11 −1
Original line number Original line Diff line number Diff line
@@ -22,6 +22,9 @@
#include <stdlib.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/types.h>


#include <compositionengine/CompositionEngine.h>
#include <compositionengine/Layer.h>
#include <compositionengine/LayerCreationArgs.h>
#include <renderengine/RenderEngine.h>
#include <renderengine/RenderEngine.h>
#include <ui/GraphicBuffer.h>
#include <ui/GraphicBuffer.h>
#include <utils/Errors.h>
#include <utils/Errors.h>
@@ -34,7 +37,10 @@
namespace android {
namespace android {
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


ColorLayer::ColorLayer(const LayerCreationArgs& args) : Layer(args) {}
ColorLayer::ColorLayer(const LayerCreationArgs& args)
      : Layer(args),
        mCompositionLayer{mFlinger->getCompositionEngine().createLayer(
                compositionengine::LayerCreationArgs{this})} {}


ColorLayer::~ColorLayer() = default;
ColorLayer::~ColorLayer() = default;


@@ -113,6 +119,10 @@ void ColorLayer::setPerFrameData(DisplayId displayId, const ui::Transform& trans
    getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion;
    getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion;
}
}


std::shared_ptr<compositionengine::Layer> ColorLayer::getCompositionLayer() const {
    return mCompositionLayer;
}

// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------


}; // namespace android
}; // namespace android
+5 −0
Original line number Original line Diff line number Diff line
@@ -28,6 +28,8 @@ public:
    explicit ColorLayer(const LayerCreationArgs&);
    explicit ColorLayer(const LayerCreationArgs&);
    ~ColorLayer() override;
    ~ColorLayer() override;


    std::shared_ptr<compositionengine::Layer> getCompositionLayer() const override;

    virtual const char* getTypeId() const { return "ColorLayer"; }
    virtual const char* getTypeId() const { return "ColorLayer"; }
    bool isVisible() const override;
    bool isVisible() const override;


@@ -41,6 +43,9 @@ protected:
    virtual bool prepareClientLayer(const RenderArea& renderArea, const Region& clip,
    virtual bool prepareClientLayer(const RenderArea& renderArea, const Region& clip,
                                    bool useIdentityTransform, Region& clearRegion,
                                    bool useIdentityTransform, Region& clearRegion,
                                    renderengine::LayerSettings& layer);
                                    renderengine::LayerSettings& layer);

private:
    std::shared_ptr<compositionengine::Layer> mCompositionLayer;
};
};


} // namespace android
} // namespace android
+4 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ cc_library {
        "src/DisplayColorProfile.cpp",
        "src/DisplayColorProfile.cpp",
        "src/DisplaySurface.cpp",
        "src/DisplaySurface.cpp",
        "src/DumpHelpers.cpp",
        "src/DumpHelpers.cpp",
        "src/Layer.cpp",
        "src/Output.cpp",
        "src/Output.cpp",
        "src/OutputCompositionState.cpp",
        "src/OutputCompositionState.cpp",
        "src/RenderSurface.cpp",
        "src/RenderSurface.cpp",
@@ -57,6 +58,8 @@ cc_library {
        "mock/Display.cpp",
        "mock/Display.cpp",
        "mock/DisplayColorProfile.cpp",
        "mock/DisplayColorProfile.cpp",
        "mock/DisplaySurface.cpp",
        "mock/DisplaySurface.cpp",
        "mock/Layer.cpp",
        "mock/LayerFE.cpp",
        "mock/Output.cpp",
        "mock/Output.cpp",
        "mock/RenderSurface.cpp",
        "mock/RenderSurface.cpp",
    ],
    ],
@@ -77,6 +80,7 @@ cc_test {
        "tests/CompositionEngineTest.cpp",
        "tests/CompositionEngineTest.cpp",
        "tests/DisplayColorProfileTest.cpp",
        "tests/DisplayColorProfileTest.cpp",
        "tests/DisplayTest.cpp",
        "tests/DisplayTest.cpp",
        "tests/LayerTest.cpp",
        "tests/MockHWComposer.cpp",
        "tests/MockHWComposer.cpp",
        "tests/OutputTest.cpp",
        "tests/OutputTest.cpp",
        "tests/RenderSurfaceTest.cpp",
        "tests/RenderSurfaceTest.cpp",
Loading