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

Commit 6b049fff authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

ui: Pull DisplayMap.h from SF

...so it can be used in more places, e.g. libscheduler headers.

Clean up the verbose type for the frontend::DisplayInfo map by aliasing
it as frontend::DisplayInfos.

Bug: 241285475
Fixes: 256881188
Test: Build
Change-Id: Idf36e20ca304190e43618a6cfd7c67e8f62e9d40
parent c183eed0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
#include <ftl/small_map.h>
#include <ftl/small_vector.h>

namespace android::display {
namespace android::ui {

// The static capacities were chosen to exceed a typical number of physical and/or virtual displays.

@@ -32,4 +32,4 @@ using PhysicalDisplayMap = ftl::SmallMap<Key, Value, 3>;
template <typename T>
using PhysicalDisplayVector = ftl::SmallVector<T, 3>;

} // namespace android::display
} // namespace android::ui
+2 −2
Original line number Diff line number Diff line
@@ -21,9 +21,9 @@

#include <binder/IBinder.h>
#include <ui/DisplayId.h>
#include <ui/DisplayMap.h>
#include <utils/StrongPointer.h>

#include "DisplayMap.h"
#include "DisplaySnapshot.h"

namespace android::display {
@@ -66,7 +66,7 @@ private:
    DisplaySnapshot mSnapshot;
};

using PhysicalDisplays = PhysicalDisplayMap<PhysicalDisplayId, PhysicalDisplay>;
using PhysicalDisplays = ui::PhysicalDisplayMap<PhysicalDisplayId, PhysicalDisplay>;

// Combinator for ftl::Optional<PhysicalDisplayId>::and_then.
constexpr auto getPhysicalDisplay(const PhysicalDisplays& displays) {
+5 −4
Original line number Diff line number Diff line
@@ -17,8 +17,9 @@
#pragma once

#include "ComposerHal.h"

#include <ftl/shared_mutex.h>
#include <ftl/small_map.h>
#include <ui/DisplayMap.h>

#include <functional>
#include <optional>
@@ -272,9 +273,9 @@ private:
    // Invalid displayId used as a key to mReaders when mSingleReader is true.
    static constexpr int64_t kSingleReaderKey = 0;

    // TODO (b/256881188): Use display::PhysicalDisplayMap instead of hard-coded `3`
    ftl::SmallMap<Display, ComposerClientWriter, 3> mWriters GUARDED_BY(mMutex);
    ftl::SmallMap<Display, ComposerClientReader, 3> mReaders GUARDED_BY(mMutex);
    ui::PhysicalDisplayMap<Display, ComposerClientWriter> mWriters GUARDED_BY(mMutex);
    ui::PhysicalDisplayMap<Display, ComposerClientReader> mReaders GUARDED_BY(mMutex);

    // Protect access to mWriters and mReaders with a shared_mutex. Adding and
    // removing a display require exclusive access, since the iterator or the
    // writer/reader may be invalidated. Other calls need shared access while
+5 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@
#include <sstream>

#include <gui/DisplayInfo.h>
#include <ui/DisplayMap.h>
#include <ui/LayerStack.h>
#include <ui/Transform.h>

namespace android::surfaceflinger::frontend {

@@ -44,4 +47,6 @@ struct DisplayInfo {
    }
};

using DisplayInfos = ui::DisplayMap<ui::LayerStack, DisplayInfo>;

} // namespace android::surfaceflinger::frontend
+6 −9
Original line number Diff line number Diff line
@@ -19,28 +19,26 @@
#undef LOG_TAG
#define LOG_TAG "LayerSnapshotBuilder"

#include "LayerSnapshotBuilder.h"
#include <gui/TraceUtils.h>
#include <ui/FloatRect.h>

#include <numeric>
#include <optional>

#include <ftl/small_map.h>
#include <gui/TraceUtils.h>
#include <ui/FloatRect.h>

#include "DisplayHardware/HWC2.h"
#include "DisplayHardware/Hal.h"
#include "LayerLog.h"
#include "LayerSnapshotBuilder.h"
#include "TimeStats/TimeStats.h"
#include "ftl/small_map.h"

namespace android::surfaceflinger::frontend {

using namespace ftl::flag_operators;

namespace {
FloatRect getMaxDisplayBounds(
        const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displays) {

FloatRect getMaxDisplayBounds(const DisplayInfos& displays) {
    const ui::Size maxSize = [&displays] {
        if (displays.empty()) return ui::Size{5000, 5000};

@@ -667,8 +665,7 @@ void LayerSnapshotBuilder::resetRelativeState(LayerSnapshot& snapshot) {
    snapshot.relativeLayerMetadata.mMap.clear();
}

uint32_t getPrimaryDisplayRotationFlags(
        const display::DisplayMap<ui::LayerStack, frontend::DisplayInfo>& displays) {
uint32_t getPrimaryDisplayRotationFlags(const DisplayInfos& displays) {
    for (auto& [_, display] : displays) {
        if (display.isPrimary) {
            return display.rotationFlags;
Loading