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

Commit 76ed7030 authored by Lloyd Pique's avatar Lloyd Pique
Browse files

SF: Move HWComposerBufferCache in to CompositionEngine

This simply moves DisplayHardware/HWComposerBufferCache.* to
CompositionEngine/HwcBufferCache.*, adjusting the existing code to
reference the moved file and namespace.

This is a prelude to moving the layerBE state into CompositionEngine.

Test: atest libsurfaceflinger_unittest libcompositionengine_test
Bug: 121291683
Change-Id: Id1e907963d0453ec7beea285ab384a963c356f89
parent cc01a45a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -128,7 +128,6 @@ filegroup {
        "DisplayHardware/FramebufferSurface.cpp",
        "DisplayHardware/HWC2.cpp",
        "DisplayHardware/HWComposer.cpp",
        "DisplayHardware/HWComposerBufferCache.cpp",
        "DisplayHardware/PowerAdvisor.cpp",
        "DisplayHardware/VirtualDisplaySurface.cpp",
        "Effects/Daltonizer.cpp",
+0 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#include "BufferLayerConsumer.h"
#include "Client.h"
#include "DisplayHardware/HWComposer.h"
#include "DisplayHardware/HWComposerBufferCache.h"
#include "FrameTracker.h"
#include "Layer.h"
#include "LayerVector.h"
+2 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ cc_library {
        "src/DisplayColorProfile.cpp",
        "src/DisplaySurface.cpp",
        "src/DumpHelpers.cpp",
        "src/HwcBufferCache.cpp",
        "src/Layer.cpp",
        "src/Output.cpp",
        "src/OutputCompositionState.cpp",
@@ -82,6 +83,7 @@ cc_test {
        "tests/CompositionEngineTest.cpp",
        "tests/DisplayColorProfileTest.cpp",
        "tests/DisplayTest.cpp",
        "tests/HwcBufferCacheTest.cpp",
        "tests/LayerTest.cpp",
        "tests/MockHWComposer.cpp",
        "tests/OutputTest.cpp",
+11 −14
Original line number Diff line number Diff line
@@ -14,20 +14,19 @@
 * limitations under the License.
 */

#ifndef ANDROID_SF_HWCOMPOSERBUFFERCACHE_H
#define ANDROID_SF_HWCOMPOSERBUFFERCACHE_H
#pragma once

#include <stdint.h>
#include <cstdint>
#include <vector>

#include <utils/StrongPointer.h>

#include <vector>

namespace android {
// ---------------------------------------------------------------------------

class GraphicBuffer;

namespace compositionengine::impl {

// With HIDLized hwcomposer HAL, the HAL can maintain a buffer cache for each
// HWC display and layer.  When updating a display target or a layer buffer,
// we have the option to send the buffer handle over or to request the HAL to
@@ -37,17 +36,17 @@ class GraphicBuffer;
//
// To be able to find out whether a buffer is already in the HAL's cache, we
// use HWComposerBufferCache to mirror the cache in SF.
class HWComposerBufferCache {
class HwcBufferCache {
public:
    HWComposerBufferCache();
    HwcBufferCache();

    // Given a buffer queue slot and buffer, return the HWC cache slot and
    // buffer to be sent to HWC.
    //
    // outBuffer is set to buffer when buffer is not in the HWC cache;
    // otherwise, outBuffer is set to nullptr.
    void getHwcBuffer(int slot, const sp<GraphicBuffer>& buffer,
            uint32_t* outSlot, sp<GraphicBuffer>* outBuffer);
    void getHwcBuffer(int slot, const sp<GraphicBuffer>& buffer, uint32_t* outSlot,
                      sp<GraphicBuffer>* outBuffer);

private:
    // a vector as we expect "slot" to be in the range of [0, 63] (that is,
@@ -55,7 +54,5 @@ private:
    std::vector<sp<GraphicBuffer>> mBuffers;
};

// ---------------------------------------------------------------------------
}; // namespace android

#endif // ANDROID_SF_HWCOMPOSERBUFFERCACHE_H
} // namespace compositionengine::impl
} // namespace android
+7 −10
Original line number Diff line number Diff line
@@ -14,21 +14,18 @@
 * limitations under the License.
 */

#include "HWComposerBufferCache.h"

#include <compositionengine/impl/HwcBufferCache.h>
#include <gui/BufferQueue.h>
#include <ui/GraphicBuffer.h>

namespace android {
namespace android::compositionengine::impl {

HWComposerBufferCache::HWComposerBufferCache()
{
HwcBufferCache::HwcBufferCache() {
    mBuffers.reserve(BufferQueue::NUM_BUFFER_SLOTS);
}

void HWComposerBufferCache::getHwcBuffer(int slot,
        const sp<GraphicBuffer>& buffer,
        uint32_t* outSlot, sp<GraphicBuffer>* outBuffer)
{
void HwcBufferCache::getHwcBuffer(int slot, const sp<GraphicBuffer>& buffer, uint32_t* outSlot,
                                  sp<GraphicBuffer>* outBuffer) {
    if (slot == BufferQueue::INVALID_BUFFER_SLOT || slot < 0) {
        // default to slot 0
        slot = 0;
@@ -51,4 +48,4 @@ void HWComposerBufferCache::getHwcBuffer(int slot,
    }
}

} // namespace android
} // namespace android::compositionengine::impl
Loading