Switch from HIDL Composition type to AIDL
In preparation for adding a new Composition type which is only in AIDL.
This change is almost completely mechanical, and should have no impact
on behavior.
Bug: 193170859
Test: existing tests
Change-Id: I1f923fcc8d8e6dff388493a76e31d435638b5255
diff --git a/services/surfaceflinger/CompositionEngine/src/Display.cpp b/services/surfaceflinger/CompositionEngine/src/Display.cpp
index 4603e6b..3571319 100644
--- a/services/surfaceflinger/CompositionEngine/src/Display.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/Display.cpp
@@ -282,7 +282,8 @@
if (auto it = changedTypes.find(hwcLayer); it != changedTypes.end()) {
layer->applyDeviceCompositionTypeChange(
- static_cast<Hwc2::IComposerClient::Composition>(it->second));
+ static_cast<aidl::android::hardware::graphics::composer3::Composition>(
+ it->second));
}
}
}
diff --git a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
index b010d9f..e6bcec8 100644
--- a/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/OutputLayer.cpp
@@ -37,6 +37,8 @@
// TODO(b/129481165): remove the #pragma below and fix conversion issues
#pragma clang diagnostic pop // ignored "-Wconversion"
+using aidl::android::hardware::graphics::composer3::Composition;
+
namespace android::compositionengine {
OutputLayer::~OutputLayer() = default;
@@ -358,8 +360,8 @@
auto requestedCompositionType = outputIndependentState->compositionType;
- if (requestedCompositionType == hal::Composition::SOLID_COLOR && state.overrideInfo.buffer) {
- requestedCompositionType = hal::Composition::DEVICE;
+ if (requestedCompositionType == Composition::SOLID_COLOR && state.overrideInfo.buffer) {
+ requestedCompositionType = Composition::DEVICE;
}
// TODO(b/181172795): We now update geometry for all flattened layers. We should update it
@@ -380,7 +382,7 @@
writeCompositionTypeToHWC(hwcLayer.get(), requestedCompositionType, isPeekingThrough,
skipLayer);
- if (requestedCompositionType == hal::Composition::SOLID_COLOR) {
+ if (requestedCompositionType == Composition::SOLID_COLOR) {
writeSolidColorStateToHWC(hwcLayer.get(), *outputIndependentState);
}
@@ -389,7 +391,7 @@
}
void OutputLayer::writeOutputDependentGeometryStateToHWC(HWC2::Layer* hwcLayer,
- hal::Composition requestedCompositionType,
+ Composition requestedCompositionType,
uint32_t z) {
const auto& outputDependentState = getState();
@@ -423,7 +425,7 @@
}
// Solid-color layers and overridden buffers should always use an identity transform.
- const auto bufferTransform = (requestedCompositionType != hal::Composition::SOLID_COLOR &&
+ const auto bufferTransform = (requestedCompositionType != Composition::SOLID_COLOR &&
getState().overrideInfo.buffer == nullptr)
? outputDependentState.bufferTransform
: static_cast<hal::Transform>(0);
@@ -504,7 +506,7 @@
void OutputLayer::writeOutputIndependentPerFrameStateToHWC(
HWC2::Layer* hwcLayer, const LayerFECompositionState& outputIndependentState,
- hal::Composition compositionType, bool skipLayer) {
+ Composition compositionType, bool skipLayer) {
switch (auto error = hwcLayer->setColorTransform(outputIndependentState.colorTransform)) {
case hal::Error::NONE:
break;
@@ -529,18 +531,18 @@
// Content-specific per-frame state
switch (compositionType) {
- case hal::Composition::SOLID_COLOR:
+ case Composition::SOLID_COLOR:
// For compatibility, should be written AFTER the composition type.
break;
- case hal::Composition::SIDEBAND:
+ case Composition::SIDEBAND:
writeSidebandStateToHWC(hwcLayer, outputIndependentState);
break;
- case hal::Composition::CURSOR:
- case hal::Composition::DEVICE:
+ case Composition::CURSOR:
+ case Composition::DEVICE:
writeBufferStateToHWC(hwcLayer, outputIndependentState, skipLayer);
break;
- case hal::Composition::INVALID:
- case hal::Composition::CLIENT:
+ case Composition::INVALID:
+ case Composition::CLIENT:
// Ignored
break;
}
@@ -606,13 +608,13 @@
}
void OutputLayer::writeCompositionTypeToHWC(HWC2::Layer* hwcLayer,
- hal::Composition requestedCompositionType,
+ Composition requestedCompositionType,
bool isPeekingThrough, bool skipLayer) {
auto& outputDependentState = editState();
if (isClientCompositionForced(isPeekingThrough)) {
// If we are forcing client composition, we need to tell the HWC
- requestedCompositionType = hal::Composition::CLIENT;
+ requestedCompositionType = Composition::CLIENT;
}
// Set the requested composition type with the HWC whenever it changes
@@ -625,7 +627,7 @@
if (auto error = hwcLayer->setCompositionType(requestedCompositionType);
error != hal::Error::NONE) {
ALOGE("[%s] Failed to set composition type %s: %s (%d)", getLayerFE().getDebugName(),
- toString(requestedCompositionType).c_str(), to_string(error).c_str(),
+ to_string(requestedCompositionType).c_str(), to_string(error).c_str(),
static_cast<int32_t>(error));
}
}
@@ -664,38 +666,37 @@
bool OutputLayer::requiresClientComposition() const {
const auto& state = getState();
- return !state.hwc || state.hwc->hwcCompositionType == hal::Composition::CLIENT;
+ return !state.hwc || state.hwc->hwcCompositionType == Composition::CLIENT;
}
bool OutputLayer::isHardwareCursor() const {
const auto& state = getState();
- return state.hwc && state.hwc->hwcCompositionType == hal::Composition::CURSOR;
+ return state.hwc && state.hwc->hwcCompositionType == Composition::CURSOR;
}
-void OutputLayer::detectDisallowedCompositionTypeChange(hal::Composition from,
- hal::Composition to) const {
+void OutputLayer::detectDisallowedCompositionTypeChange(Composition from, Composition to) const {
bool result = false;
switch (from) {
- case hal::Composition::INVALID:
- case hal::Composition::CLIENT:
+ case Composition::INVALID:
+ case Composition::CLIENT:
result = false;
break;
- case hal::Composition::DEVICE:
- case hal::Composition::SOLID_COLOR:
- result = (to == hal::Composition::CLIENT);
+ case Composition::DEVICE:
+ case Composition::SOLID_COLOR:
+ result = (to == Composition::CLIENT);
break;
- case hal::Composition::CURSOR:
- case hal::Composition::SIDEBAND:
- result = (to == hal::Composition::CLIENT || to == hal::Composition::DEVICE);
+ case Composition::CURSOR:
+ case Composition::SIDEBAND:
+ result = (to == Composition::CLIENT || to == Composition::DEVICE);
break;
}
if (!result) {
ALOGE("[%s] Invalid device requested composition type change: %s (%d) --> %s (%d)",
- getLayerFE().getDebugName(), toString(from).c_str(), static_cast<int>(from),
- toString(to).c_str(), static_cast<int>(to));
+ getLayerFE().getDebugName(), to_string(from).c_str(), static_cast<int>(from),
+ to_string(to).c_str(), static_cast<int>(to));
}
}
@@ -704,7 +705,7 @@
(!isPeekingThrough && getLayerFE().hasRoundedCorners());
}
-void OutputLayer::applyDeviceCompositionTypeChange(hal::Composition compositionType) {
+void OutputLayer::applyDeviceCompositionTypeChange(Composition compositionType) {
auto& state = editState();
LOG_FATAL_IF(!state.hwc);
auto& hwcState = *state.hwc;
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp b/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
index c14effc..0918510 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/Flattener.cpp
@@ -211,7 +211,8 @@
displayCost += static_cast<size_t>(layer->getDisplayFrame().width() *
layer->getDisplayFrame().height());
- hasClientComposition |= layer->getCompositionType() == hal::Composition::CLIENT;
+ hasClientComposition |= layer->getCompositionType() ==
+ aidl::android::hardware::graphics::composer3::Composition::CLIENT;
}
if (hasClientComposition) {
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/LayerState.cpp b/services/surfaceflinger/CompositionEngine/src/planner/LayerState.cpp
index 2532e3d..c79ca0d 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/LayerState.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/LayerState.cpp
@@ -160,7 +160,8 @@
lhs.mColorTransform == rhs.mColorTransform &&
lhs.mCompositionType == rhs.mCompositionType &&
lhs.mSidebandStream == rhs.mSidebandStream && lhs.mBuffer == rhs.mBuffer &&
- (lhs.mCompositionType.get() != hal::Composition::SOLID_COLOR ||
+ (lhs.mCompositionType.get() !=
+ aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR ||
lhs.mSolidColor == rhs.mSolidColor);
}
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/Planner.cpp b/services/surfaceflinger/CompositionEngine/src/planner/Planner.cpp
index f5b1cee..74d2701 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/Planner.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/Planner.cpp
@@ -193,7 +193,7 @@
finalPlan.addLayerType(
forcedOrRequestedClient
- ? hardware::graphics::composer::hal::Composition::CLIENT
+ ? aidl::android::hardware::graphics::composer3::Composition::CLIENT
: layer->getLayerFE().getCompositionState()->compositionType);
}
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/Predictor.cpp b/services/surfaceflinger/CompositionEngine/src/planner/Predictor.cpp
index 8226ef7..074673e 100644
--- a/services/surfaceflinger/CompositionEngine/src/planner/Predictor.cpp
+++ b/services/surfaceflinger/CompositionEngine/src/planner/Predictor.cpp
@@ -39,8 +39,10 @@
// Skip layers where both are client-composited, since that doesn't change the
// composition plan
- if (mLayers[i].getCompositionType() == hal::Composition::CLIENT &&
- other[i]->getCompositionType() == hal::Composition::CLIENT) {
+ if (mLayers[i].getCompositionType() ==
+ aidl::android::hardware::graphics::composer3::Composition::CLIENT &&
+ other[i]->getCompositionType() ==
+ aidl::android::hardware::graphics::composer3::Composition::CLIENT) {
continue;
}
@@ -89,22 +91,28 @@
for (char c : string) {
switch (c) {
case 'C':
- plan.addLayerType(hal::Composition::CLIENT);
+ plan.addLayerType(
+ aidl::android::hardware::graphics::composer3::Composition::CLIENT);
continue;
case 'U':
- plan.addLayerType(hal::Composition::CURSOR);
+ plan.addLayerType(
+ aidl::android::hardware::graphics::composer3::Composition::CURSOR);
continue;
case 'D':
- plan.addLayerType(hal::Composition::DEVICE);
+ plan.addLayerType(
+ aidl::android::hardware::graphics::composer3::Composition::DEVICE);
continue;
case 'I':
- plan.addLayerType(hal::Composition::INVALID);
+ plan.addLayerType(
+ aidl::android::hardware::graphics::composer3::Composition::INVALID);
continue;
case 'B':
- plan.addLayerType(hal::Composition::SIDEBAND);
+ plan.addLayerType(
+ aidl::android::hardware::graphics::composer3::Composition::SIDEBAND);
continue;
case 'S':
- plan.addLayerType(hal::Composition::SOLID_COLOR);
+ plan.addLayerType(
+ aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR);
continue;
default:
return std::nullopt;
@@ -117,22 +125,22 @@
std::string result;
for (auto type : plan.mLayerTypes) {
switch (type) {
- case hal::Composition::CLIENT:
+ case aidl::android::hardware::graphics::composer3::Composition::CLIENT:
result.append("C");
break;
- case hal::Composition::CURSOR:
+ case aidl::android::hardware::graphics::composer3::Composition::CURSOR:
result.append("U");
break;
- case hal::Composition::DEVICE:
+ case aidl::android::hardware::graphics::composer3::Composition::DEVICE:
result.append("D");
break;
- case hal::Composition::INVALID:
+ case aidl::android::hardware::graphics::composer3::Composition::INVALID:
result.append("I");
break;
- case hal::Composition::SIDEBAND:
+ case aidl::android::hardware::graphics::composer3::Composition::SIDEBAND:
result.append("B");
break;
- case hal::Composition::SOLID_COLOR:
+ case aidl::android::hardware::graphics::composer3::Composition::SOLID_COLOR:
result.append("S");
break;
}