FTL: Pull Flags into namespace
Bug: 185536303
Test: Build
Change-Id: Ia9aafc78565414815dfc14732ce85b06fa96e17b
diff --git a/include/ftl/Flags.h b/include/ftl/flags.h
similarity index 89%
rename from include/ftl/Flags.h
rename to include/ftl/flags.h
index db3d9ea..70aaa0e 100644
--- a/include/ftl/Flags.h
+++ b/include/ftl/flags.h
@@ -25,9 +25,9 @@
#include <string>
#include <type_traits>
-// TODO(b/185536303): Align with FTL style and namespace.
+// TODO(b/185536303): Align with FTL style.
-namespace android {
+namespace android::ftl {
/* A class for handling flags defined by an enum or enum class in a type-safe way. */
template <typename F>
@@ -48,10 +48,10 @@
// should force them to be explicitly constructed from their underlying types to make full use
// of the type checker.
template <typename T = U>
- constexpr Flags(T t, std::enable_if_t<!ftl::is_scoped_enum_v<F>, T>* = nullptr) : mFlags(t) {}
+ constexpr Flags(T t, std::enable_if_t<!is_scoped_enum_v<F>, T>* = nullptr) : mFlags(t) {}
template <typename T = U>
- explicit constexpr Flags(T t, std::enable_if_t<ftl::is_scoped_enum_v<F>, T>* = nullptr)
+ explicit constexpr Flags(T t, std::enable_if_t<is_scoped_enum_v<F>, T>* = nullptr)
: mFlags(t) {}
class Iterator {
@@ -175,7 +175,7 @@
bool first = true;
U unstringified = 0;
for (const F f : *this) {
- if (const auto flagName = ftl::flag_name(f)) {
+ if (const auto flagName = flag_name(f)) {
appendFlag(result, flagName.value(), first);
} else {
unstringified |= static_cast<U>(f);
@@ -183,8 +183,8 @@
}
if (unstringified != 0) {
- constexpr auto radix = sizeof(U) == 1 ? ftl::Radix::kBin : ftl::Radix::kHex;
- appendFlag(result, ftl::to_string(unstringified, radix), first);
+ constexpr auto radix = sizeof(U) == 1 ? Radix::kBin : Radix::kHex;
+ appendFlag(result, to_string(unstringified, radix), first);
}
if (first) {
@@ -211,15 +211,15 @@
// as flags. In order to use these, add them via a `using namespace` declaration.
namespace flag_operators {
-template <typename F, typename = std::enable_if_t<ftl::is_scoped_enum_v<F>>>
+template <typename F, typename = std::enable_if_t<is_scoped_enum_v<F>>>
inline Flags<F> operator~(F f) {
- return static_cast<F>(~ftl::to_underlying(f));
+ return static_cast<F>(~to_underlying(f));
}
-template <typename F, typename = std::enable_if_t<ftl::is_scoped_enum_v<F>>>
+template <typename F, typename = std::enable_if_t<is_scoped_enum_v<F>>>
Flags<F> operator|(F lhs, F rhs) {
- return static_cast<F>(ftl::to_underlying(lhs) | ftl::to_underlying(rhs));
+ return static_cast<F>(to_underlying(lhs) | to_underlying(rhs));
}
} // namespace flag_operators
-} // namespace android
+} // namespace android::ftl
diff --git a/libs/ftl/Android.bp b/libs/ftl/Android.bp
index ef20196..c010a2e 100644
--- a/libs/ftl/Android.bp
+++ b/libs/ftl/Android.bp
@@ -14,11 +14,11 @@
address: true,
},
srcs: [
- "Flags_test.cpp",
"cast_test.cpp",
"concat_test.cpp",
"enum_test.cpp",
"fake_guard_test.cpp",
+ "flags_test.cpp",
"future_test.cpp",
"small_map_test.cpp",
"small_vector_test.cpp",
diff --git a/libs/ftl/Flags_test.cpp b/libs/ftl/flags_test.cpp
similarity index 98%
rename from libs/ftl/Flags_test.cpp
rename to libs/ftl/flags_test.cpp
index d241fa2..eea052b 100644
--- a/libs/ftl/Flags_test.cpp
+++ b/libs/ftl/flags_test.cpp
@@ -14,14 +14,15 @@
* limitations under the License.
*/
+#include <ftl/flags.h>
#include <gtest/gtest.h>
-#include <ftl/Flags.h>
#include <type_traits>
namespace android::test {
-using namespace android::flag_operators;
+using ftl::Flags;
+using namespace ftl::flag_operators;
enum class TestFlags : uint8_t { ONE = 0x1, TWO = 0x2, THREE = 0x4 };
diff --git a/libs/gui/LayerState.cpp b/libs/gui/LayerState.cpp
index 34db5b1..53c7f5a 100644
--- a/libs/gui/LayerState.cpp
+++ b/libs/gui/LayerState.cpp
@@ -815,7 +815,7 @@
status_t BufferData::readFromParcel(const Parcel* input) {
int32_t tmpInt32;
SAFE_PARCEL(input->readInt32, &tmpInt32);
- flags = Flags<BufferDataChange>(tmpInt32);
+ flags = ftl::Flags<BufferDataChange>(tmpInt32);
bool tmpBool = false;
SAFE_PARCEL(input->readBool, &tmpBool);
diff --git a/libs/gui/WindowInfo.cpp b/libs/gui/WindowInfo.cpp
index 2312a8c..804ce4f 100644
--- a/libs/gui/WindowInfo.cpp
+++ b/libs/gui/WindowInfo.cpp
@@ -14,10 +14,11 @@
* limitations under the License.
*/
-#include <type_traits>
#define LOG_TAG "WindowInfo"
#define LOG_NDEBUG 0
+#include <type_traits>
+
#include <binder/Parcel.h>
#include <gui/WindowInfo.h>
@@ -25,8 +26,7 @@
namespace android::gui {
-// --- WindowInfo ---
-void WindowInfo::setInputConfig(Flags<InputConfig> config, bool value) {
+void WindowInfo::setInputConfig(ftl::Flags<InputConfig> config, bool value) {
if (value) {
inputConfig |= config;
return;
@@ -182,18 +182,16 @@
return status;
}
- layoutParamsFlags = Flags<Flag>(lpFlags);
+ layoutParamsFlags = ftl::Flags<Flag>(lpFlags);
layoutParamsType = static_cast<Type>(lpType);
transform.set({dsdx, dtdx, tx, dtdy, dsdy, ty, 0, 0, 1});
touchOcclusionMode = static_cast<TouchOcclusionMode>(touchOcclusionModeInt);
- inputConfig = Flags<InputConfig>(inputConfigInt);
+ inputConfig = ftl::Flags<InputConfig>(inputConfigInt);
touchableRegionCropHandle = touchableRegionCropHandleSp;
return OK;
}
-// --- WindowInfoHandle ---
-
WindowInfoHandle::WindowInfoHandle() {}
WindowInfoHandle::~WindowInfoHandle() {}
diff --git a/libs/gui/include/gui/ISurfaceComposer.h b/libs/gui/include/gui/ISurfaceComposer.h
index 0a3cc19..b11e674 100644
--- a/libs/gui/include/gui/ISurfaceComposer.h
+++ b/libs/gui/include/gui/ISurfaceComposer.h
@@ -27,7 +27,7 @@
#include <android/gui/IWindowInfosListener.h>
#include <binder/IBinder.h>
#include <binder/IInterface.h>
-#include <ftl/Flags.h>
+#include <ftl/flags.h>
#include <gui/FrameTimelineInfo.h>
#include <gui/ITransactionCompletedListener.h>
#include <gui/SpHash.h>
@@ -126,7 +126,7 @@
frameRateOverride = 1 << 1,
};
- using EventRegistrationFlags = Flags<EventRegistration>;
+ using EventRegistrationFlags = ftl::Flags<EventRegistration>;
/*
* Create a connection with SurfaceFlinger.
diff --git a/libs/gui/include/gui/LayerState.h b/libs/gui/include/gui/LayerState.h
index 0f37dab..b33d4c0 100644
--- a/libs/gui/include/gui/LayerState.h
+++ b/libs/gui/include/gui/LayerState.h
@@ -29,6 +29,7 @@
#include <android/gui/DropInputMode.h>
#include <android/gui/FocusRequest.h>
+#include <ftl/flags.h>
#include <gui/DisplayCaptureArgs.h>
#include <gui/ISurfaceComposer.h>
#include <gui/LayerCaptureArgs.h>
@@ -102,7 +103,7 @@
// was called with.
sp<IBinder> releaseBufferEndpoint;
- Flags<BufferDataChange> flags;
+ ftl::Flags<BufferDataChange> flags;
client_cache_t cachedBuffer;
diff --git a/libs/gui/include/gui/WindowInfo.h b/libs/gui/include/gui/WindowInfo.h
index ef0b98b..0e1d258 100644
--- a/libs/gui/include/gui/WindowInfo.h
+++ b/libs/gui/include/gui/WindowInfo.h
@@ -20,7 +20,7 @@
#include <android/os/InputConfig.h>
#include <binder/Parcel.h>
#include <binder/Parcelable.h>
-#include <ftl/Flags.h>
+#include <ftl/flags.h>
#include <gui/constants.h>
#include <ui/Rect.h>
#include <ui/Region.h>
@@ -224,7 +224,7 @@
int32_t ownerPid = -1;
int32_t ownerUid = -1;
std::string packageName;
- Flags<InputConfig> inputConfig;
+ ftl::Flags<InputConfig> inputConfig;
int32_t displayId = ADISPLAY_ID_NONE;
InputApplicationInfo applicationInfo;
bool replaceTouchableRegionWithCrop = false;
@@ -232,9 +232,9 @@
// The window's layout params flags and type set by WM.
Type layoutParamsType = Type::UNKNOWN;
- Flags<Flag> layoutParamsFlags;
+ ftl::Flags<Flag> layoutParamsFlags;
- void setInputConfig(Flags<InputConfig> config, bool value);
+ void setInputConfig(ftl::Flags<InputConfig> config, bool value);
void addTouchableRegion(const Rect& region);
diff --git a/services/inputflinger/reader/EventHub.cpp b/services/inputflinger/reader/EventHub.cpp
index 8bd3899..d6a6bd2 100644
--- a/services/inputflinger/reader/EventHub.cpp
+++ b/services/inputflinger/reader/EventHub.cpp
@@ -60,10 +60,11 @@
#define INDENT3 " "
using android::base::StringPrintf;
-using namespace android::flag_operators;
namespace android {
+using namespace ftl::flag_operators;
+
static const char* DEVICE_INPUT_PATH = "/dev/input";
// v4l2 devices go directly into /dev
static const char* DEVICE_PATH = "/dev";
@@ -302,7 +303,8 @@
// --- Global Functions ---
-Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, Flags<InputDeviceClass> deviceClasses) {
+ftl::Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis,
+ ftl::Flags<InputDeviceClass> deviceClasses) {
// Touch devices get dibs on touch-related axes.
if (deviceClasses.test(InputDeviceClass::TOUCH)) {
switch (axis) {
@@ -765,10 +767,10 @@
return device != nullptr ? device->identifier : InputDeviceIdentifier();
}
-Flags<InputDeviceClass> EventHub::getDeviceClasses(int32_t deviceId) const {
+ftl::Flags<InputDeviceClass> EventHub::getDeviceClasses(int32_t deviceId) const {
std::scoped_lock _l(mLock);
Device* device = getDeviceLocked(deviceId);
- return device != nullptr ? device->classes : Flags<InputDeviceClass>(0);
+ return device != nullptr ? device->classes : ftl::Flags<InputDeviceClass>(0);
}
int32_t EventHub::getDeviceControllerNumber(int32_t deviceId) const {
@@ -1909,7 +1911,7 @@
}
void EventHub::reportDeviceAddedForStatisticsLocked(const InputDeviceIdentifier& identifier,
- Flags<InputDeviceClass> classes) {
+ ftl::Flags<InputDeviceClass> classes) {
SHA256_CTX ctx;
SHA256_Init(&ctx);
SHA256_Update(&ctx, reinterpret_cast<const uint8_t*>(identifier.uniqueId.c_str()),
@@ -2191,7 +2193,7 @@
}
// If the device isn't recognized as something we handle, don't monitor it.
- if (device->classes == Flags<InputDeviceClass>(0)) {
+ if (device->classes == ftl::Flags<InputDeviceClass>(0)) {
ALOGV("Dropping device: id=%d, path='%s', name='%s'", deviceId, devicePath.c_str(),
device->identifier.name.c_str());
return;
diff --git a/services/inputflinger/reader/InputDevice.cpp b/services/inputflinger/reader/InputDevice.cpp
index a050963..ba5083b 100644
--- a/services/inputflinger/reader/InputDevice.cpp
+++ b/services/inputflinger/reader/InputDevice.cpp
@@ -18,9 +18,10 @@
#include "InputDevice.h"
-#include <ftl/Flags.h>
#include <algorithm>
+#include <ftl/flags.h>
+
#include "CursorInputMapper.h"
#include "ExternalStylusInputMapper.h"
#include "InputReaderContext.h"
@@ -145,7 +146,7 @@
return;
}
std::unique_ptr<InputDeviceContext> contextPtr(new InputDeviceContext(*this, eventHubId));
- Flags<InputDeviceClass> classes = contextPtr->getDeviceClasses();
+ ftl::Flags<InputDeviceClass> classes = contextPtr->getDeviceClasses();
std::vector<std::unique_ptr<InputMapper>> mappers;
// Check if we should skip population
@@ -236,7 +237,7 @@
void InputDevice::configure(nsecs_t when, const InputReaderConfiguration* config,
uint32_t changes) {
mSources = 0;
- mClasses = Flags<InputDeviceClass>(0);
+ mClasses = ftl::Flags<InputDeviceClass>(0);
mControllerNumber = 0;
for_each_subdevice([this](InputDeviceContext& context) {
diff --git a/services/inputflinger/reader/include/EventHub.h b/services/inputflinger/reader/include/EventHub.h
index 18e912d..130c556 100644
--- a/services/inputflinger/reader/include/EventHub.h
+++ b/services/inputflinger/reader/include/EventHub.h
@@ -19,13 +19,12 @@
#include <bitset>
#include <climits>
+#include <filesystem>
#include <unordered_map>
#include <vector>
-#include <ftl/Flags.h>
-#include <filesystem>
-
#include <batteryservice/BatteryService.h>
+#include <ftl/flags.h>
#include <input/Input.h>
#include <input/InputDevice.h>
#include <input/KeyCharacterMap.h>
@@ -189,7 +188,7 @@
int32_t id;
std::string name;
std::optional<int32_t> maxBrightness;
- Flags<InputLightClass> flags;
+ ftl::Flags<InputLightClass> flags;
std::array<int32_t, COLOR_NUM> rgbIndex;
std::filesystem::path path;
};
@@ -198,7 +197,7 @@
struct RawBatteryInfo {
int32_t id;
std::string name;
- Flags<InputBatteryClass> flags;
+ ftl::Flags<InputBatteryClass> flags;
std::filesystem::path path;
};
@@ -206,7 +205,8 @@
* Gets the class that owns an axis, in cases where multiple classes might claim
* the same axis for different purposes.
*/
-extern Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis, Flags<InputDeviceClass> deviceClasses);
+extern ftl::Flags<InputDeviceClass> getAbsAxisUsage(int32_t axis,
+ ftl::Flags<InputDeviceClass> deviceClasses);
/*
* Grand Central Station for events.
@@ -239,7 +239,7 @@
FIRST_SYNTHETIC_EVENT = DEVICE_ADDED,
};
- virtual Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const = 0;
+ virtual ftl::Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const = 0;
virtual InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const = 0;
@@ -436,7 +436,7 @@
public:
EventHub();
- Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const override final;
+ ftl::Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const override final;
InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const override final;
@@ -559,7 +559,7 @@
std::unique_ptr<TouchVideoDevice> videoDevice;
- Flags<InputDeviceClass> classes;
+ ftl::Flags<InputDeviceClass> classes;
BitArray<KEY_MAX> keyBitmask;
BitArray<KEY_MAX> keyState;
@@ -662,7 +662,7 @@
int32_t getNextControllerNumberLocked(const std::string& name) REQUIRES(mLock);
void releaseControllerNumberLocked(int32_t num) REQUIRES(mLock);
void reportDeviceAddedForStatisticsLocked(const InputDeviceIdentifier& identifier,
- Flags<InputDeviceClass> classes) REQUIRES(mLock);
+ ftl::Flags<InputDeviceClass> classes) REQUIRES(mLock);
const std::unordered_map<int32_t, RawBatteryInfo>& getBatteryInfoLocked(int32_t deviceId) const
REQUIRES(mLock);
@@ -725,6 +725,6 @@
bool mPendingINotify;
};
-}; // namespace android
+} // namespace android
#endif // _RUNTIME_EVENT_HUB_H
diff --git a/services/inputflinger/reader/include/InputDevice.h b/services/inputflinger/reader/include/InputDevice.h
index 694daa9..728020e 100644
--- a/services/inputflinger/reader/include/InputDevice.h
+++ b/services/inputflinger/reader/include/InputDevice.h
@@ -17,12 +17,12 @@
#ifndef _UI_INPUTREADER_INPUT_DEVICE_H
#define _UI_INPUTREADER_INPUT_DEVICE_H
-#include <ftl/Flags.h>
+#include <ftl/flags.h>
#include <input/DisplayViewport.h>
#include <input/InputDevice.h>
#include <input/PropertyMap.h>
-#include <stdint.h>
+#include <cstdint>
#include <optional>
#include <unordered_map>
#include <vector>
@@ -53,7 +53,7 @@
inline int32_t getGeneration() const { return mGeneration; }
inline const std::string getName() const { return mIdentifier.name; }
inline const std::string getDescriptor() { return mIdentifier.descriptor; }
- inline Flags<InputDeviceClass> getClasses() const { return mClasses; }
+ inline ftl::Flags<InputDeviceClass> getClasses() const { return mClasses; }
inline uint32_t getSources() const { return mSources; }
inline bool hasEventHubDevices() const { return !mDevices.empty(); }
@@ -160,7 +160,7 @@
int32_t mControllerNumber;
InputDeviceIdentifier mIdentifier;
std::string mAlias;
- Flags<InputDeviceClass> mClasses;
+ ftl::Flags<InputDeviceClass> mClasses;
// map from eventHubId to device context and mappers
using MapperVector = std::vector<std::unique_ptr<InputMapper>>;
@@ -250,7 +250,7 @@
inline int32_t getId() { return mDeviceId; }
inline int32_t getEventHubId() { return mId; }
- inline Flags<InputDeviceClass> getDeviceClasses() const {
+ inline ftl::Flags<InputDeviceClass> getDeviceClasses() const {
return mEventHub->getDeviceClasses(mId);
}
inline InputDeviceIdentifier getDeviceIdentifier() const {
diff --git a/services/inputflinger/tests/InputDispatcher_test.cpp b/services/inputflinger/tests/InputDispatcher_test.cpp
index bf58705..8641287 100644
--- a/services/inputflinger/tests/InputDispatcher_test.cpp
+++ b/services/inputflinger/tests/InputDispatcher_test.cpp
@@ -39,10 +39,11 @@
using android::gui::WindowInfoHandle;
using android::os::InputEventInjectionResult;
using android::os::InputEventInjectionSync;
-using namespace android::flag_operators;
namespace android::inputdispatcher {
+using namespace ftl::flag_operators;
+
// An arbitrary time value.
static const nsecs_t ARBITRARY_TIME = 1234;
diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp
index 9f33d23..8ba501c 100644
--- a/services/inputflinger/tests/InputReader_test.cpp
+++ b/services/inputflinger/tests/InputReader_test.cpp
@@ -14,6 +14,9 @@
* limitations under the License.
*/
+#include <cinttypes>
+#include <memory>
+
#include <CursorInputMapper.h>
#include <InputDevice.h>
#include <InputMapper.h>
@@ -34,18 +37,15 @@
#include <android-base/thread_annotations.h>
#include <gtest/gtest.h>
#include <gui/constants.h>
-#include <inttypes.h>
-#include <math.h>
-#include <memory>
-#include <regex>
#include "input/DisplayViewport.h"
#include "input/Input.h"
namespace android {
+using namespace ftl::flag_operators;
+
using std::chrono_literals::operator""ms;
-using namespace android::flag_operators;
// Timeout for waiting for an expected event
static constexpr std::chrono::duration WAIT_TIMEOUT = 100ms;
@@ -429,7 +429,7 @@
struct Device {
InputDeviceIdentifier identifier;
- Flags<InputDeviceClass> classes;
+ ftl::Flags<InputDeviceClass> classes;
PropertyMap configuration;
KeyedVector<int, RawAbsoluteAxisInfo> absoluteAxes;
KeyedVector<int, bool> relativeAxes;
@@ -457,7 +457,7 @@
return OK;
}
- explicit Device(Flags<InputDeviceClass> classes) : classes(classes), enabled(true) {}
+ explicit Device(ftl::Flags<InputDeviceClass> classes) : classes(classes), enabled(true) {}
};
std::mutex mLock;
@@ -484,7 +484,8 @@
FakeEventHub() { }
- void addDevice(int32_t deviceId, const std::string& name, Flags<InputDeviceClass> classes) {
+ void addDevice(int32_t deviceId, const std::string& name,
+ ftl::Flags<InputDeviceClass> classes) {
Device* device = new Device(classes);
device->identifier.name = name;
mDevices.add(deviceId, device);
@@ -695,9 +696,9 @@
return index >= 0 ? mDevices.valueAt(index) : nullptr;
}
- Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const override {
+ ftl::Flags<InputDeviceClass> getDeviceClasses(int32_t deviceId) const override {
Device* device = getDevice(deviceId);
- return device ? device->classes : Flags<InputDeviceClass>(0);
+ return device ? device->classes : ftl::Flags<InputDeviceClass>(0);
}
InputDeviceIdentifier getDeviceIdentifier(int32_t deviceId) const override {
@@ -1572,8 +1573,8 @@
mFakePolicy.clear();
}
- void addDevice(int32_t eventHubId, const std::string& name, Flags<InputDeviceClass> classes,
- const PropertyMap* configuration) {
+ void addDevice(int32_t eventHubId, const std::string& name,
+ ftl::Flags<InputDeviceClass> classes, const PropertyMap* configuration) {
mFakeEventHub->addDevice(eventHubId, name, classes);
if (configuration) {
@@ -1598,7 +1599,8 @@
FakeInputMapper& addDeviceWithFakeInputMapper(int32_t deviceId, int32_t eventHubId,
const std::string& name,
- Flags<InputDeviceClass> classes, uint32_t sources,
+ ftl::Flags<InputDeviceClass> classes,
+ uint32_t sources,
const PropertyMap* configuration) {
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, name);
FakeInputMapper& mapper = device->addMapper<FakeInputMapper>(eventHubId, sources);
@@ -1610,7 +1612,7 @@
TEST_F(InputReaderTest, PolicyGetInputDevices) {
ASSERT_NO_FATAL_FAILURE(addDevice(1, "keyboard", InputDeviceClass::KEYBOARD, nullptr));
- ASSERT_NO_FATAL_FAILURE(addDevice(2, "ignored", Flags<InputDeviceClass>(0),
+ ASSERT_NO_FATAL_FAILURE(addDevice(2, "ignored", ftl::Flags<InputDeviceClass>(0),
nullptr)); // no classes so device will be ignored
// Should also have received a notification describing the new input devices.
@@ -1672,7 +1674,7 @@
TEST_F(InputReaderTest, WhenEnabledChanges_SendsDeviceResetNotification) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass(InputDeviceClass::KEYBOARD);
+ constexpr ftl::Flags<InputDeviceClass> deviceClass(InputDeviceClass::KEYBOARD);
constexpr int32_t eventHubId = 1;
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake");
// Must add at least one mapper or the device will be ignored!
@@ -1709,7 +1711,7 @@
TEST_F(InputReaderTest, GetKeyCodeState_ForwardsRequestsToMappers) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubId = 1;
FakeInputMapper& mapper =
addDeviceWithFakeInputMapper(deviceId, eventHubId, "fake", deviceClass,
@@ -1773,7 +1775,7 @@
TEST_F(InputReaderTest, GetScanCodeState_ForwardsRequestsToMappers) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubId = 1;
FakeInputMapper& mapper =
addDeviceWithFakeInputMapper(deviceId, eventHubId, "fake", deviceClass,
@@ -1806,7 +1808,7 @@
TEST_F(InputReaderTest, GetSwitchState_ForwardsRequestsToMappers) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubId = 1;
FakeInputMapper& mapper =
addDeviceWithFakeInputMapper(deviceId, eventHubId, "fake", deviceClass,
@@ -1839,7 +1841,7 @@
TEST_F(InputReaderTest, MarkSupportedKeyCodes_ForwardsRequestsToMappers) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubId = 1;
FakeInputMapper& mapper =
addDeviceWithFakeInputMapper(deviceId, eventHubId, "fake", deviceClass,
@@ -1891,7 +1893,7 @@
TEST_F(InputReaderTest, LoopOnce_ForwardsRawEventsToMappers) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr nsecs_t when = 0;
constexpr int32_t eventHubId = 1;
constexpr nsecs_t readTime = 2;
@@ -1915,7 +1917,7 @@
TEST_F(InputReaderTest, DeviceReset_RandomId) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubId = 1;
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake");
// Must add at least one mapper or the device will be ignored!
@@ -1948,7 +1950,7 @@
TEST_F(InputReaderTest, DeviceReset_GenerateIdWithInputReaderSource) {
constexpr int32_t deviceId = 1;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubId = 1;
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake");
// Must add at least one mapper or the device will be ignored!
@@ -1963,7 +1965,7 @@
TEST_F(InputReaderTest, Device_CanDispatchToDisplay) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubId = 1;
const char* DEVICE_LOCATION = "USB1";
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake", DEVICE_LOCATION);
@@ -2008,7 +2010,7 @@
TEST_F(InputReaderTest, WhenEnabledChanges_AllSubdevicesAreUpdated) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubIds[2] = {END_RESERVED_ID, END_RESERVED_ID + 1};
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake");
// Must add at least one mapper or the device will be ignored!
@@ -2049,7 +2051,7 @@
TEST_F(InputReaderTest, GetKeyCodeState_ForwardsRequestsToSubdeviceMappers) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- constexpr Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
+ constexpr ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD;
constexpr int32_t eventHubIds[2] = {END_RESERVED_ID, END_RESERVED_ID + 1};
// Add two subdevices to device
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake");
@@ -2106,7 +2108,8 @@
TEST_F(InputReaderTest, VibratorGetVibratorIds) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD | InputDeviceClass::VIBRATOR;
+ ftl::Flags<InputDeviceClass> deviceClass =
+ InputDeviceClass::KEYBOARD | InputDeviceClass::VIBRATOR;
constexpr int32_t eventHubId = 1;
const char* DEVICE_LOCATION = "BLUETOOTH";
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake", DEVICE_LOCATION);
@@ -2166,7 +2169,8 @@
TEST_F(InputReaderTest, BatteryGetCapacity) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD | InputDeviceClass::BATTERY;
+ ftl::Flags<InputDeviceClass> deviceClass =
+ InputDeviceClass::KEYBOARD | InputDeviceClass::BATTERY;
constexpr int32_t eventHubId = 1;
const char* DEVICE_LOCATION = "BLUETOOTH";
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake", DEVICE_LOCATION);
@@ -2182,7 +2186,8 @@
TEST_F(InputReaderTest, BatteryGetStatus) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD | InputDeviceClass::BATTERY;
+ ftl::Flags<InputDeviceClass> deviceClass =
+ InputDeviceClass::KEYBOARD | InputDeviceClass::BATTERY;
constexpr int32_t eventHubId = 1;
const char* DEVICE_LOCATION = "BLUETOOTH";
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake", DEVICE_LOCATION);
@@ -2198,7 +2203,7 @@
TEST_F(InputReaderTest, LightGetColor) {
constexpr int32_t deviceId = END_RESERVED_ID + 1000;
- Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD | InputDeviceClass::LIGHT;
+ ftl::Flags<InputDeviceClass> deviceClass = InputDeviceClass::KEYBOARD | InputDeviceClass::LIGHT;
constexpr int32_t eventHubId = 1;
const char* DEVICE_LOCATION = "BLUETOOTH";
std::shared_ptr<InputDevice> device = mReader->newDevice(deviceId, "fake", DEVICE_LOCATION);
@@ -2625,7 +2630,7 @@
static const int32_t DEVICE_ID;
static const int32_t DEVICE_GENERATION;
static const int32_t DEVICE_CONTROLLER_NUMBER;
- static const Flags<InputDeviceClass> DEVICE_CLASSES;
+ static const ftl::Flags<InputDeviceClass> DEVICE_CLASSES;
static const int32_t EVENTHUB_ID;
std::shared_ptr<FakeEventHub> mFakeEventHub;
@@ -2646,7 +2651,7 @@
mDevice = std::make_shared<InputDevice>(mReader->getContext(), DEVICE_ID, DEVICE_GENERATION,
identifier);
mReader->pushNextDevice(mDevice);
- mFakeEventHub->addDevice(EVENTHUB_ID, DEVICE_NAME, Flags<InputDeviceClass>(0));
+ mFakeEventHub->addDevice(EVENTHUB_ID, DEVICE_NAME, ftl::Flags<InputDeviceClass>(0));
mReader->loopOnce();
}
@@ -2661,14 +2666,14 @@
const int32_t InputDeviceTest::DEVICE_ID = END_RESERVED_ID + 1000;
const int32_t InputDeviceTest::DEVICE_GENERATION = 2;
const int32_t InputDeviceTest::DEVICE_CONTROLLER_NUMBER = 0;
-const Flags<InputDeviceClass> InputDeviceTest::DEVICE_CLASSES =
+const ftl::Flags<InputDeviceClass> InputDeviceTest::DEVICE_CLASSES =
InputDeviceClass::KEYBOARD | InputDeviceClass::TOUCH | InputDeviceClass::JOYSTICK;
const int32_t InputDeviceTest::EVENTHUB_ID = 1;
TEST_F(InputDeviceTest, ImmutableProperties) {
ASSERT_EQ(DEVICE_ID, mDevice->getId());
ASSERT_STREQ(DEVICE_NAME, mDevice->getName().c_str());
- ASSERT_EQ(Flags<InputDeviceClass>(0), mDevice->getClasses());
+ ASSERT_EQ(ftl::Flags<InputDeviceClass>(0), mDevice->getClasses());
}
TEST_F(InputDeviceTest, WhenDeviceCreated_EnabledIsFalse) {
@@ -2912,7 +2917,7 @@
static const int32_t DEVICE_ID;
static const int32_t DEVICE_GENERATION;
static const int32_t DEVICE_CONTROLLER_NUMBER;
- static const Flags<InputDeviceClass> DEVICE_CLASSES;
+ static const ftl::Flags<InputDeviceClass> DEVICE_CLASSES;
static const int32_t EVENTHUB_ID;
std::shared_ptr<FakeEventHub> mFakeEventHub;
@@ -2921,7 +2926,7 @@
std::unique_ptr<InstrumentedInputReader> mReader;
std::shared_ptr<InputDevice> mDevice;
- virtual void SetUp(Flags<InputDeviceClass> classes) {
+ virtual void SetUp(ftl::Flags<InputDeviceClass> classes) {
mFakeEventHub = std::make_unique<FakeEventHub>();
mFakePolicy = new FakeInputReaderPolicy();
mFakeListener = std::make_unique<TestInputListener>();
@@ -2953,7 +2958,7 @@
std::shared_ptr<InputDevice> newDevice(int32_t deviceId, const std::string& name,
const std::string& location, int32_t eventHubId,
- Flags<InputDeviceClass> classes) {
+ ftl::Flags<InputDeviceClass> classes) {
InputDeviceIdentifier identifier;
identifier.name = name;
identifier.location = location;
@@ -3045,8 +3050,8 @@
const int32_t InputMapperTest::DEVICE_ID = END_RESERVED_ID + 1000;
const int32_t InputMapperTest::DEVICE_GENERATION = 2;
const int32_t InputMapperTest::DEVICE_CONTROLLER_NUMBER = 0;
-const Flags<InputDeviceClass> InputMapperTest::DEVICE_CLASSES =
- Flags<InputDeviceClass>(0); // not needed for current tests
+const ftl::Flags<InputDeviceClass> InputMapperTest::DEVICE_CLASSES =
+ ftl::Flags<InputDeviceClass>(0); // not needed for current tests
const int32_t InputMapperTest::EVENTHUB_ID = 1;
// --- SwitchInputMapperTest ---
@@ -3842,7 +3847,7 @@
constexpr int32_t SECOND_EVENTHUB_ID = EVENTHUB_ID + 1;
std::shared_ptr<InputDevice> device2 =
newDevice(SECOND_DEVICE_ID, DEVICE_NAME2, USB2, SECOND_EVENTHUB_ID,
- Flags<InputDeviceClass>(0));
+ ftl::Flags<InputDeviceClass>(0));
mFakeEventHub->addKey(SECOND_EVENTHUB_ID, KEY_UP, 0, AKEYCODE_DPAD_UP, 0);
mFakeEventHub->addKey(SECOND_EVENTHUB_ID, KEY_RIGHT, 0, AKEYCODE_DPAD_RIGHT, 0);
@@ -3954,7 +3959,7 @@
constexpr int32_t SECOND_EVENTHUB_ID = EVENTHUB_ID + 1;
std::shared_ptr<InputDevice> device2 =
newDevice(SECOND_DEVICE_ID, DEVICE_NAME2, USB2, SECOND_EVENTHUB_ID,
- Flags<InputDeviceClass>(0));
+ ftl::Flags<InputDeviceClass>(0));
mFakeEventHub->addLed(SECOND_EVENTHUB_ID, LED_CAPSL, true /*initially on*/);
mFakeEventHub->addLed(SECOND_EVENTHUB_ID, LED_NUML, false /*initially off*/);
mFakeEventHub->addLed(SECOND_EVENTHUB_ID, LED_SCROLLL, false /*initially off*/);
@@ -8409,7 +8414,7 @@
constexpr int32_t SECOND_EVENTHUB_ID = EVENTHUB_ID + 1;
std::shared_ptr<InputDevice> device2 =
newDevice(SECOND_DEVICE_ID, DEVICE_NAME2, USB2, SECOND_EVENTHUB_ID,
- Flags<InputDeviceClass>(0));
+ ftl::Flags<InputDeviceClass>(0));
mFakeEventHub->addAbsoluteAxis(SECOND_EVENTHUB_ID, ABS_MT_POSITION_X, RAW_X_MIN, RAW_X_MAX,
0 /*flat*/, 0 /*fuzz*/);
@@ -9350,7 +9355,7 @@
static const int32_t DEVICE_ID;
static const int32_t DEVICE_GENERATION;
static const int32_t DEVICE_CONTROLLER_NUMBER;
- static const Flags<InputDeviceClass> DEVICE_CLASSES;
+ static const ftl::Flags<InputDeviceClass> DEVICE_CLASSES;
static const int32_t EVENTHUB_ID;
std::shared_ptr<FakeEventHub> mFakeEventHub;
@@ -9359,7 +9364,7 @@
std::unique_ptr<InstrumentedInputReader> mReader;
std::shared_ptr<InputDevice> mDevice;
- virtual void SetUp(Flags<InputDeviceClass> classes) {
+ virtual void SetUp(ftl::Flags<InputDeviceClass> classes) {
mFakeEventHub = std::make_unique<FakeEventHub>();
mFakePolicy = new FakeInputReaderPolicy();
mFakeListener = std::make_unique<TestInputListener>();
@@ -9385,7 +9390,7 @@
std::shared_ptr<InputDevice> newDevice(int32_t deviceId, const std::string& name,
const std::string& location, int32_t eventHubId,
- Flags<InputDeviceClass> classes) {
+ ftl::Flags<InputDeviceClass> classes) {
InputDeviceIdentifier identifier;
identifier.name = name;
identifier.location = location;
@@ -9411,8 +9416,8 @@
const int32_t PeripheralControllerTest::DEVICE_ID = END_RESERVED_ID + 1000;
const int32_t PeripheralControllerTest::DEVICE_GENERATION = 2;
const int32_t PeripheralControllerTest::DEVICE_CONTROLLER_NUMBER = 0;
-const Flags<InputDeviceClass> PeripheralControllerTest::DEVICE_CLASSES =
- Flags<InputDeviceClass>(0); // not needed for current tests
+const ftl::Flags<InputDeviceClass> PeripheralControllerTest::DEVICE_CLASSES =
+ ftl::Flags<InputDeviceClass>(0); // not needed for current tests
const int32_t PeripheralControllerTest::EVENTHUB_ID = 1;
// --- BatteryControllerTest ---
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
index cb00e71..29d3366 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/LayerState.h
@@ -16,20 +16,20 @@
#pragma once
+#include <string>
+
+#include <aidl/android/hardware/graphics/common/BufferUsage.h>
+#include <aidl/android/hardware/graphics/composer3/Composition.h>
#include <android-base/strings.h>
+#include <ftl/flags.h>
+#include <math/HashCombine.h>
+
#include <compositionengine/LayerFE.h>
#include <compositionengine/LayerFECompositionState.h>
#include <compositionengine/OutputLayer.h>
#include <compositionengine/impl/OutputLayerCompositionState.h>
-#include <ftl/Flags.h>
-
-#include <string>
#include "DisplayHardware/Hal.h"
-#include "math/HashCombine.h"
-
-#include <aidl/android/hardware/graphics/common/BufferUsage.h>
-#include <aidl/android/hardware/graphics/composer3/Composition.h>
namespace std {
template <typename T>
@@ -84,13 +84,13 @@
public:
virtual ~StateInterface() = default;
- virtual Flags<LayerStateField> update(const compositionengine::OutputLayer* layer) = 0;
+ virtual ftl::Flags<LayerStateField> update(const compositionengine::OutputLayer* layer) = 0;
virtual size_t getHash() const = 0;
virtual LayerStateField getField() const = 0;
- virtual Flags<LayerStateField> getFieldIfDifferent(const StateInterface* other) const = 0;
+ virtual ftl::Flags<LayerStateField> getFieldIfDifferent(const StateInterface* other) const = 0;
virtual bool equals(const StateInterface* other) const = 0;
@@ -152,12 +152,12 @@
~OutputLayerState() override = default;
// Returns this member's field flag if it was changed
- Flags<LayerStateField> update(const compositionengine::OutputLayer* layer) override {
+ ftl::Flags<LayerStateField> update(const compositionengine::OutputLayer* layer) override {
T newValue = mReader(layer);
return update(newValue);
}
- Flags<LayerStateField> update(const T& newValue) {
+ ftl::Flags<LayerStateField> update(const T& newValue) {
if (!mEquals(mValue, newValue)) {
mValue = newValue;
mHash = {};
@@ -176,14 +176,14 @@
return *mHash;
}
- Flags<LayerStateField> getFieldIfDifferent(const StateInterface* other) const override {
+ ftl::Flags<LayerStateField> getFieldIfDifferent(const StateInterface* other) const override {
if (other->getField() != FIELD) {
return {};
}
// The early return ensures that this downcast is sound
const OutputLayerState* otherState = static_cast<const OutputLayerState*>(other);
- return *this != *otherState ? FIELD : Flags<LayerStateField>{};
+ return *this != *otherState ? FIELD : ftl::Flags<LayerStateField>{};
}
bool equals(const StateInterface* other) const override {
@@ -215,7 +215,7 @@
LayerState(compositionengine::OutputLayer* layer);
// Returns which fields were updated
- Flags<LayerStateField> update(compositionengine::OutputLayer*);
+ ftl::Flags<LayerStateField> update(compositionengine::OutputLayer*);
// Computes a hash for this LayerState.
// The hash is only computed from NonUniqueFields, and excludes GraphicBuffers since they are
@@ -224,7 +224,7 @@
// Returns the bit-set of differing fields between this LayerState and another LayerState.
// This bit-set is based on NonUniqueFields only, and excludes GraphicBuffers.
- Flags<LayerStateField> getDifferingFields(const LayerState& other) const;
+ ftl::Flags<LayerStateField> getDifferingFields(const LayerState& other) const;
compositionengine::OutputLayer* getOutputLayer() const { return mOutputLayer; }
int32_t getId() const { return mId.get(); }
diff --git a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Predictor.h b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Predictor.h
index ef1560e..6be6735 100644
--- a/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Predictor.h
+++ b/services/surfaceflinger/CompositionEngine/include/compositionengine/impl/planner/Predictor.h
@@ -16,6 +16,8 @@
#pragma once
+#include <ftl/flags.h>
+
#include <compositionengine/impl/planner/LayerState.h>
namespace android::compositionengine::impl::planner {
@@ -35,7 +37,7 @@
// This implies that only one layer is allowed to differ in an approximate match.
size_t differingIndex;
// Set of fields that differ for the differing layer in the approximate match.
- Flags<LayerStateField> differingFields;
+ ftl::Flags<LayerStateField> differingFields;
};
// Returns an approximate match when comparing this layer stack with the provided list of
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/LayerState.cpp b/services/surfaceflinger/CompositionEngine/src/planner/LayerState.cpp
index c79ca0d..f439caf 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/LayerState.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/LayerState.cpp
@@ -41,7 +41,7 @@
update(layer);
}
-Flags<LayerStateField> LayerState::update(compositionengine::OutputLayer* layer) {
+ftl::Flags<LayerStateField> LayerState::update(compositionengine::OutputLayer* layer) {
ALOGE_IF(mOutputLayer != layer && layer->getLayerFE().getSequence() != mId.get(),
"[%s] Expected mOutputLayer ID to never change: %d, %d", __func__,
layer->getLayerFE().getSequence(), mId.get());
@@ -50,7 +50,7 @@
// same, i.e., the LayerFE is the same. An example use-case is screen rotation.
mOutputLayer = layer;
- Flags<LayerStateField> differences;
+ ftl::Flags<LayerStateField> differences;
// Update the unique fields as well, since we have to set them at least
// once from the OutputLayer
@@ -76,8 +76,8 @@
return hash;
}
-Flags<LayerStateField> LayerState::getDifferingFields(const LayerState& other) const {
- Flags<LayerStateField> differences;
+ftl::Flags<LayerStateField> LayerState::getDifferingFields(const LayerState& other) const {
+ ftl::Flags<LayerStateField> differences;
auto myFields = getNonUniqueFields();
auto otherFields = other.getNonUniqueFields();
for (size_t i = 0; i < myFields.size(); ++i) {
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/Planner.cpp b/services/surfaceflinger/CompositionEngine/src/planner/Planner.cpp
index 74d2701..c8413eb 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/Planner.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/Planner.cpp
@@ -97,7 +97,7 @@
if (const auto layerEntry = mPreviousLayers.find(id); layerEntry != mPreviousLayers.end()) {
// Track changes from previous info
LayerState& state = layerEntry->second;
- Flags<LayerStateField> differences = state.update(layer);
+ ftl::Flags<LayerStateField> differences = state.update(layer);
if (differences.get() == 0) {
state.incrementFramesSinceBufferUpdate();
} else {
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/Predictor.cpp b/services/surfaceflinger/CompositionEngine/src/planner/Predictor.cpp
index 2d53583..2fc029f 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/Predictor.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/Predictor.cpp
@@ -57,7 +57,7 @@
return std::nullopt;
}
- Flags<LayerStateField> differingFields = mLayers[i].getDifferingFields(*other[i]);
+ ftl::Flags<LayerStateField> differingFields = mLayers[i].getDifferingFields(*other[i]);
// If we don't find an approximate match on this layer, then the LayerStacks differ
// by too much, so return nothing
diff --git a/services/surfaceflinger/CompositionEngine/tests/planner/LayerStateTest.cpp b/services/surfaceflinger/CompositionEngine/tests/planner/LayerStateTest.cpp
index bd4ff13..5c6e8da 100644
--- a/services/surfaceflinger/CompositionEngine/tests/planner/LayerStateTest.cpp
+++ b/services/surfaceflinger/CompositionEngine/tests/planner/LayerStateTest.cpp
@@ -97,12 +97,12 @@
void verifyUniqueDifferingFields(const LayerState& lhs, const LayerState& rhs) {
EXPECT_EQ(lhs.getHash(), rhs.getHash());
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::None), lhs.getDifferingFields(rhs));
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::None), rhs.getDifferingFields(lhs));
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::None), lhs.getDifferingFields(rhs));
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::None), rhs.getDifferingFields(lhs));
}
void verifyNonUniqueDifferingFields(const LayerState& lhs, const LayerState& rhs,
- Flags<LayerStateField> fields) {
+ ftl::Flags<LayerStateField> fields) {
EXPECT_NE(lhs.getHash(), rhs.getHash());
EXPECT_EQ(fields, lhs.getDifferingFields(rhs));
@@ -159,9 +159,9 @@
sp<mock::LayerFE> newLayerFE = sp<mock::LayerFE>::make();
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionState, sSequenceIdTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
EXPECT_EQ(sSequenceIdTwo, mLayerState->getId());
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Id), updates);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::Id), updates);
}
TEST_F(LayerStateTest, compareId) {
@@ -204,9 +204,9 @@
sp<mock::LayerFE> newLayerFE = sp<mock::LayerFE>::make();
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionState, sSequenceId, sDebugNameTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
EXPECT_EQ(sDebugNameTwo, mLayerState->getName());
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Name), updates);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::Name), updates);
}
TEST_F(LayerStateTest, compareName) {
@@ -253,9 +253,9 @@
outputLayerCompositionStateTwo.displayFrame = sRectTwo;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionStateTwo,
layerFECompositionState);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
EXPECT_EQ(sRectTwo, mLayerState->getDisplayFrame());
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::DisplayFrame), updates);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::DisplayFrame), updates);
}
TEST_F(LayerStateTest, compareDisplayFrame) {
@@ -315,9 +315,9 @@
layerFECompositionStateTwo.compositionType = Composition::SOLID_COLOR;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
EXPECT_EQ(Composition::SOLID_COLOR, mLayerState->getCompositionType());
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::CompositionType), updates);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::CompositionType), updates);
}
TEST_F(LayerStateTest, compareCompositionType) {
@@ -357,8 +357,8 @@
layerFECompositionStateTwo.buffer = new GraphicBuffer();
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Buffer), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::Buffer), updates);
}
TEST_F(LayerStateTest, updateBufferSingleBufferedLegacy) {
@@ -380,8 +380,8 @@
layerFECompositionStateTwo.frameNumber = i;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Buffer), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::Buffer), updates);
}
}
@@ -404,8 +404,8 @@
for (uint64_t i = 0; i < 10; i++) {
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Buffer), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::Buffer), updates);
}
}
@@ -446,8 +446,8 @@
outputLayerCompositionStateTwo.sourceCrop = sFloatRectTwo;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionStateTwo,
layerFECompositionState);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::SourceCrop), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::SourceCrop), updates);
}
TEST_F(LayerStateTest, compareSourceCrop) {
@@ -485,8 +485,8 @@
outputLayerCompositionStateTwo.bufferTransform = Hwc2::Transform::FLIP_V;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionStateTwo,
layerFECompositionState);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::BufferTransform), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::BufferTransform), updates);
}
TEST_F(LayerStateTest, compareBufferTransform) {
@@ -525,8 +525,8 @@
layerFECompositionStateTwo.blendMode = hal::BlendMode::PREMULTIPLIED;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::BlendMode), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::BlendMode), updates);
}
TEST_F(LayerStateTest, compareBlendMode) {
@@ -564,8 +564,8 @@
layerFECompositionStateTwo.alpha = sAlphaTwo;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Alpha), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::Alpha), updates);
}
TEST_F(LayerStateTest, compareAlpha) {
@@ -603,8 +603,8 @@
layerFECompositionStateTwo.metadata[sMetadataKeyTwo] = sMetadataValueTwo;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::LayerMetadata), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::LayerMetadata), updates);
}
TEST_F(LayerStateTest, compareLayerMetadata) {
@@ -652,8 +652,8 @@
outputLayerCompositionStateTwo.visibleRegion = sRegionTwo;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionStateTwo,
layerFECompositionState);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::VisibleRegion), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::VisibleRegion), updates);
}
TEST_F(LayerStateTest, compareVisibleRegion) {
@@ -691,8 +691,8 @@
outputLayerCompositionStateTwo.dataspace = ui::Dataspace::DISPLAY_P3;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionStateTwo,
layerFECompositionState);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Dataspace), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::Dataspace), updates);
}
TEST_F(LayerStateTest, compareDataspace) {
@@ -738,9 +738,9 @@
"buffer2");
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::Buffer) |
- Flags<LayerStateField>(LayerStateField::PixelFormat),
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::Buffer) |
+ ftl::Flags<LayerStateField>(LayerStateField::PixelFormat),
updates);
}
@@ -768,7 +768,7 @@
auto otherLayerState = std::make_unique<LayerState>(&newOutputLayer);
verifyNonUniqueDifferingFields(*mLayerState, *otherLayerState,
- Flags<LayerStateField>(LayerStateField::PixelFormat));
+ ftl::Flags<LayerStateField>(LayerStateField::PixelFormat));
EXPECT_TRUE(mLayerState->compare(*otherLayerState));
EXPECT_TRUE(otherLayerState->compare(*mLayerState));
@@ -790,8 +790,8 @@
layerFECompositionStateTwo.colorTransform = sMat4One;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::ColorTransform), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::ColorTransform), updates);
}
TEST_F(LayerStateTest, compareColorTransform) {
@@ -831,8 +831,8 @@
layerFECompositionStateTwo.sidebandStream = NativeHandle::create(sFakeSidebandStreamTwo, false);
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::SidebandStream), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::SidebandStream), updates);
}
TEST_F(LayerStateTest, compareSidebandStream) {
@@ -870,8 +870,8 @@
layerFECompositionStateTwo.color = sHalf4Two;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::SolidColor), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::SolidColor), updates);
}
TEST_F(LayerStateTest, compareSolidColor) {
@@ -909,8 +909,8 @@
layerFECompositionStateTwo.backgroundBlurRadius = sBgBlurRadiusTwo;
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::BackgroundBlurRadius), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::BackgroundBlurRadius), updates);
}
TEST_F(LayerStateTest, compareBackgroundBlur) {
@@ -949,8 +949,8 @@
layerFECompositionStateTwo.blurRegions.push_back(sBlurRegionTwo);
setupMocksForLayer(newOutputLayer, *newLayerFE, outputLayerCompositionState,
layerFECompositionStateTwo);
- Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
- EXPECT_EQ(Flags<LayerStateField>(LayerStateField::BlurRegions), updates);
+ ftl::Flags<LayerStateField> updates = mLayerState->update(&newOutputLayer);
+ EXPECT_EQ(ftl::Flags<LayerStateField>(LayerStateField::BlurRegions), updates);
}
TEST_F(LayerStateTest, compareBlurRegions) {
diff --git a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
index b4fb51f..3803a78 100644
--- a/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
+++ b/services/surfaceflinger/DisplayHardware/VirtualDisplaySurface.cpp
@@ -19,20 +19,20 @@
#pragma clang diagnostic ignored "-Wconversion"
// #define LOG_NDEBUG 0
-#include "VirtualDisplaySurface.h"
#include <cinttypes>
-#include "HWComposer.h"
-#include "SurfaceFlinger.h"
-
-#include <ftl/Flags.h>
#include <ftl/enum.h>
+#include <ftl/flags.h>
#include <gui/BufferItem.h>
#include <gui/BufferQueue.h>
#include <gui/IProducerListener.h>
#include <system/window.h>
+#include "HWComposer.h"
+#include "SurfaceFlinger.h"
+#include "VirtualDisplaySurface.h"
+
#define VDS_LOGE(msg, ...) ALOGE("[%s] " msg, \
mDisplayName.c_str(), ##__VA_ARGS__)
#define VDS_LOGW_IF(cond, msg, ...) ALOGW_IF(cond, "[%s] " msg, \
@@ -657,7 +657,7 @@
std::string VirtualDisplaySurface::toString(CompositionType type) {
using namespace std::literals;
- return type == CompositionType::Unknown ? "Unknown"s : Flags(type).string();
+ return type == CompositionType::Unknown ? "Unknown"s : ftl::Flags(type).string();
}
} // namespace android
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 894fb8d..41e0487 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -82,11 +82,13 @@
constexpr int kDumpTableRowLength = 159;
} // namespace
+using namespace ftl::flag_operators;
+
using base::StringAppendF;
-using namespace android::flag_operators;
-using PresentState = frametimeline::SurfaceFrame::PresentState;
using gui::WindowInfo;
+using PresentState = frametimeline::SurfaceFrame::PresentState;
+
std::atomic<int32_t> Layer::sSequence{1};
Layer::Layer(const LayerCreationArgs& args)
diff --git a/services/surfaceflinger/Scheduler/include/scheduler/Features.h b/services/surfaceflinger/Scheduler/include/scheduler/Features.h
index 0e96678..b3a6a60 100644
--- a/services/surfaceflinger/Scheduler/include/scheduler/Features.h
+++ b/services/surfaceflinger/Scheduler/include/scheduler/Features.h
@@ -16,10 +16,10 @@
#pragma once
-#include <ftl/Flags.h>
-
#include <cstdint>
+#include <ftl/flags.h>
+
namespace android::scheduler {
enum class Feature : std::uint8_t {
@@ -29,6 +29,6 @@
kTracePredictedVsync = 0b1000,
};
-using FeatureFlags = Flags<Feature>;
+using FeatureFlags = ftl::Flags<Feature>;
} // namespace android::scheduler
diff --git a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
index d249b60..a73eccf 100644
--- a/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
+++ b/services/surfaceflinger/Tracing/TransactionProtoParser.cpp
@@ -429,7 +429,7 @@
bufferProto.height(), bufferProto.pixel_format(),
bufferProto.usage()));
layer.bufferData->frameNumber = bufferProto.frame_number();
- layer.bufferData->flags = Flags<BufferData::BufferDataChange>(bufferProto.flags());
+ layer.bufferData->flags = ftl::Flags<BufferData::BufferDataChange>(bufferProto.flags());
layer.bufferData->cachedBuffer.id = bufferProto.cached_buffer_id();
layer.bufferData->acquireFence = Fence::NO_FENCE;
}
diff --git a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
index 14d8f98..fa36d9c 100644
--- a/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
+++ b/services/surfaceflinger/tests/unittests/EventThreadTest.cpp
@@ -34,12 +34,13 @@
using namespace std::chrono_literals;
using namespace std::placeholders;
-using namespace android::flag_operators;
using testing::_;
using testing::Invoke;
namespace android {
+using namespace ftl::flag_operators;
+
namespace {
constexpr PhysicalDisplayId INTERNAL_DISPLAY_ID = PhysicalDisplayId::fromPort(111u);