drm_hwcomposer: Move CompositionType out of HwcLayer struct
Moving this paves the way for reducing dependency on HwcLayer from the Backend class Change-Id: I62f057a0efcb7afc3c9a04cff3bd53b5c56c5ad9
This commit is contained in:
parent
3a403db8d3
commit
a5fb437d37
9 changed files with 41 additions and 46 deletions
|
|
@ -31,7 +31,7 @@ HwcLayer *GetCursorLayer(const std::vector<HwcLayer *> &layers) {
|
|||
auto it = std::find_if(layers.begin(), layers.end(),
|
||||
[&](auto *layer) -> bool {
|
||||
return layer->GetSfType() ==
|
||||
HwcLayer::CompositionType::kCursor;
|
||||
CompositionType::kCursor;
|
||||
});
|
||||
if (it == layers.end()) {
|
||||
return nullptr;
|
||||
|
|
@ -148,9 +148,9 @@ bool Backend::IsClientLayer(HwcDisplay *display, HwcLayer *layer) {
|
|||
display->GetHwc()->GetResMan().ForcedScalingWithGpu());
|
||||
}
|
||||
|
||||
bool Backend::HardwareSupportsLayerType(HwcLayer::CompositionType comp_type) {
|
||||
return comp_type == HwcLayer::CompositionType::kDevice ||
|
||||
comp_type == HwcLayer::CompositionType::kCursor;
|
||||
bool Backend::HardwareSupportsLayerType(CompositionType comp_type) {
|
||||
return comp_type == CompositionType::kDevice ||
|
||||
comp_type == CompositionType::kCursor;
|
||||
}
|
||||
|
||||
uint32_t Backend::CalcPixOps(const std::vector<HwcLayer *> &layers,
|
||||
|
|
@ -179,12 +179,12 @@ void Backend::MarkValidated(std::vector<HwcLayer *> &layers,
|
|||
bool use_cursor_plane) {
|
||||
for (size_t z_order = 0; z_order < layers.size(); ++z_order) {
|
||||
if (z_order >= client_first_z && z_order < client_first_z + client_size) {
|
||||
layers[z_order]->SetValidatedType(HwcLayer::CompositionType::kClient);
|
||||
} else if (use_cursor_plane && layers[z_order]->GetSfType() ==
|
||||
HwcLayer::CompositionType::kCursor) {
|
||||
layers[z_order]->SetValidatedType(HwcLayer::CompositionType::kCursor);
|
||||
layers[z_order]->SetValidatedType(CompositionType::kClient);
|
||||
} else if (use_cursor_plane &&
|
||||
layers[z_order]->GetSfType() == CompositionType::kCursor) {
|
||||
layers[z_order]->SetValidatedType(CompositionType::kCursor);
|
||||
} else {
|
||||
layers[z_order]->SetValidatedType(HwcLayer::CompositionType::kDevice);
|
||||
layers[z_order]->SetValidatedType(CompositionType::kDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -198,8 +198,8 @@ std::tuple<int, int> Backend::GetExtraClientRange(
|
|||
// Cursor plane is not counted among |avail_planes|, so the cursor layer
|
||||
// shouldn't be counted in |layers_size|.
|
||||
if (use_cursor_plane) {
|
||||
ALOGE_IF(layers.empty() || layers.back()->GetSfType() !=
|
||||
HwcLayer::CompositionType::kCursor,
|
||||
ALOGE_IF(layers.empty() ||
|
||||
layers.back()->GetSfType() != CompositionType::kCursor,
|
||||
"Cursor layer was not found at highest z-order");
|
||||
--layers_size;
|
||||
}
|
||||
|
|
@ -213,7 +213,7 @@ std::tuple<int, int> Backend::GetExtraClientRange(
|
|||
// If the cursor plane isn't being used, reserve a plane for the cursor to be
|
||||
// device composited.
|
||||
if (!use_cursor_plane && avail_planes > 0 && layers_size > 0 &&
|
||||
layers.back()->GetSfType() == HwcLayer::CompositionType::kCursor) {
|
||||
layers.back()->GetSfType() == CompositionType::kCursor) {
|
||||
avail_planes--;
|
||||
layers_size--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class Backend {
|
|||
virtual bool IsClientLayer(HwcDisplay *display, HwcLayer *layer);
|
||||
|
||||
protected:
|
||||
static bool HardwareSupportsLayerType(HwcLayer::CompositionType comp_type);
|
||||
static bool HardwareSupportsLayerType(CompositionType comp_type);
|
||||
static uint32_t CalcPixOps(const std::vector<HwcLayer *> &layers,
|
||||
size_t first_z, size_t size,
|
||||
std::pair<uint32_t, uint32_t> display_size);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace android {
|
|||
|
||||
void BackendClient::ValidateDisplay(HwcDisplay *display) {
|
||||
for (auto &[layer_handle, layer] : display->layers()) {
|
||||
layer.SetValidatedType(HwcLayer::CompositionType::kClient);
|
||||
layer.SetValidatedType(CompositionType::kClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ class DrmFbIdHandle;
|
|||
|
||||
using ILayerId = int64_t;
|
||||
|
||||
enum class CompositionType { kInvalid, kClient, kDevice, kSolidColor, kCursor };
|
||||
|
||||
/* Rotation is defined in the clockwise direction */
|
||||
/* The flip is done before rotation */
|
||||
struct LayerTransform {
|
||||
|
|
|
|||
|
|
@ -304,11 +304,11 @@ auto HwcDisplay::ValidateStagedComposition() -> std::vector<ChangedLayer> {
|
|||
*/
|
||||
for (auto &l : layers_) {
|
||||
l.second.SetPriorBufferScanOutFlag(l.second.GetValidatedType() !=
|
||||
HwcLayer::CompositionType::kClient);
|
||||
CompositionType::kClient);
|
||||
|
||||
/* Populate layer data for layers that might be mapped to a drm plane. */
|
||||
if (l.second.GetSfType() == HwcLayer::CompositionType::kDevice ||
|
||||
l.second.GetSfType() == HwcLayer::CompositionType::kCursor) {
|
||||
if (l.second.GetSfType() == CompositionType::kDevice ||
|
||||
l.second.GetSfType() == CompositionType::kCursor) {
|
||||
l.second.PopulateLayerData();
|
||||
}
|
||||
}
|
||||
|
|
@ -798,10 +798,10 @@ bool HwcDisplay::CreateComposition(AtomicCommitArgs &a_args) {
|
|||
std::optional<LayerData> cursor_layer = std::nullopt;
|
||||
for (auto &[_, layer] : layers_) {
|
||||
switch (layer.GetValidatedType()) {
|
||||
case HwcLayer::CompositionType::kDevice:
|
||||
case CompositionType::kDevice:
|
||||
z_map.emplace(layer.GetZOrder(), &layer);
|
||||
break;
|
||||
case HwcLayer::CompositionType::kCursor:
|
||||
case CompositionType::kCursor:
|
||||
if (!cursor_layer.has_value()) {
|
||||
cursor_layer = layer.GetLayerData();
|
||||
} else {
|
||||
|
|
@ -809,14 +809,14 @@ bool HwcDisplay::CreateComposition(AtomicCommitArgs &a_args) {
|
|||
z_map.emplace(layer.GetZOrder(), &layer);
|
||||
}
|
||||
break;
|
||||
case HwcLayer::CompositionType::kClient:
|
||||
case CompositionType::kClient:
|
||||
// Place it at the z_order of the lowest client layer
|
||||
use_client_layer = true;
|
||||
client_layer_count++;
|
||||
client_z_order = std::min(client_z_order, layer.GetZOrder());
|
||||
break;
|
||||
case HwcLayer::CompositionType::kSolidColor:
|
||||
case HwcLayer::CompositionType::kInvalid:
|
||||
case CompositionType::kSolidColor:
|
||||
case CompositionType::kInvalid:
|
||||
ALOGE("Invalid layer type: %d",
|
||||
static_cast<int>(layer.GetValidatedType()));
|
||||
continue;
|
||||
|
|
@ -979,9 +979,9 @@ std::vector<HwcLayer *> HwcDisplay::GetOrderLayersByZPos() {
|
|||
std::sort(std::begin(ordered_layers), std::end(ordered_layers),
|
||||
[](const HwcLayer *lhs, const HwcLayer *rhs) {
|
||||
// Cursor layers should always have highest zpos.
|
||||
if ((lhs->GetSfType() == HwcLayer::CompositionType::kCursor) !=
|
||||
(rhs->GetSfType() == HwcLayer::CompositionType::kCursor)) {
|
||||
return rhs->GetSfType() == HwcLayer::CompositionType::kCursor;
|
||||
if ((lhs->GetSfType() == CompositionType::kCursor) !=
|
||||
(rhs->GetSfType() == CompositionType::kCursor)) {
|
||||
return rhs->GetSfType() == CompositionType::kCursor;
|
||||
}
|
||||
|
||||
return lhs->GetZOrder() < rhs->GetZOrder();
|
||||
|
|
@ -1055,8 +1055,8 @@ void HwcDisplay::set_backend(std::unique_ptr<Backend> backend) {
|
|||
bool HwcDisplay::NeedsClientLayerUpdate() const {
|
||||
return std::any_of(layers_.begin(), layers_.end(), [](const auto &pair) {
|
||||
const auto &layer = pair.second;
|
||||
return layer.GetSfType() == HwcLayer::CompositionType::kClient ||
|
||||
layer.GetValidatedType() == HwcLayer::CompositionType::kClient;
|
||||
return layer.GetSfType() == CompositionType::kClient ||
|
||||
layer.GetValidatedType() == CompositionType::kClient;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ class HwcDisplay {
|
|||
// To be called after SetDisplayProperties. Returns an empty vector if the
|
||||
// requested layers have been validated, otherwise the vector describes
|
||||
// the requested composition type changes.
|
||||
using ChangedLayer = std::pair<ILayerId, HwcLayer::CompositionType>;
|
||||
using ChangedLayer = std::pair<ILayerId, CompositionType>;
|
||||
auto ValidateStagedComposition() -> std::vector<ChangedLayer>;
|
||||
|
||||
// Mark previously validated properties as ready to present.
|
||||
|
|
|
|||
|
|
@ -42,13 +42,6 @@ class HwcLayer {
|
|||
int32_t slot_id;
|
||||
SharedFd fence;
|
||||
};
|
||||
enum class CompositionType {
|
||||
kInvalid,
|
||||
kClient,
|
||||
kDevice,
|
||||
kSolidColor,
|
||||
kCursor
|
||||
};
|
||||
// A set of properties to be validated.
|
||||
struct LayerProperties {
|
||||
std::optional<Buffer> slot_buffer;
|
||||
|
|
|
|||
|
|
@ -1190,17 +1190,16 @@ static int32_t SetLayerCompositionType(hwc2_device_t *device,
|
|||
HwcLayer::LayerProperties layer_properties;
|
||||
switch (static_cast<HWC2::Composition>(type)) {
|
||||
case HWC2::Composition::Client:
|
||||
layer_properties.composition_type = HwcLayer::CompositionType::kClient;
|
||||
layer_properties.composition_type = CompositionType::kClient;
|
||||
break;
|
||||
case HWC2::Composition::Device:
|
||||
layer_properties.composition_type = HwcLayer::CompositionType::kDevice;
|
||||
layer_properties.composition_type = CompositionType::kDevice;
|
||||
break;
|
||||
case HWC2::Composition::SolidColor:
|
||||
layer_properties
|
||||
.composition_type = HwcLayer::CompositionType::kSolidColor;
|
||||
layer_properties.composition_type = CompositionType::kSolidColor;
|
||||
break;
|
||||
case HWC2::Composition::Cursor:
|
||||
layer_properties.composition_type = HwcLayer::CompositionType::kCursor;
|
||||
layer_properties.composition_type = CompositionType::kCursor;
|
||||
break;
|
||||
default:
|
||||
ALOGE("Unsupported composition type t=%d", type);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@
|
|||
|
||||
using ::android::CompositionStatsAtomReporter;
|
||||
using ::android::CompositionStatsPoller;
|
||||
using ::android::CompositionType;
|
||||
using ::android::DamageInfo;
|
||||
using ::android::DisplayHandle;
|
||||
using ::android::DstRectInfo;
|
||||
|
|
@ -216,7 +217,7 @@ std::optional<std::array<float, kCtmSize>> AidlToColorTransformMatrix(
|
|||
return color_transform_matrix;
|
||||
}
|
||||
|
||||
std::optional<HwcLayer::CompositionType> AidlToCompositionType(
|
||||
std::optional<CompositionType> AidlToCompositionType(
|
||||
const std::optional<ParcelableComposition> composition) {
|
||||
if (!composition) {
|
||||
return std::nullopt;
|
||||
|
|
@ -224,15 +225,15 @@ std::optional<HwcLayer::CompositionType> AidlToCompositionType(
|
|||
|
||||
switch (composition->composition) {
|
||||
case Composition::INVALID:
|
||||
return HwcLayer::CompositionType::kInvalid;
|
||||
return CompositionType::kInvalid;
|
||||
case Composition::CLIENT:
|
||||
return HwcLayer::CompositionType::kClient;
|
||||
return CompositionType::kClient;
|
||||
case Composition::DEVICE:
|
||||
return HwcLayer::CompositionType::kDevice;
|
||||
return CompositionType::kDevice;
|
||||
case Composition::SOLID_COLOR:
|
||||
return HwcLayer::CompositionType::kSolidColor;
|
||||
return CompositionType::kSolidColor;
|
||||
case Composition::CURSOR:
|
||||
return HwcLayer::CompositionType::kCursor;
|
||||
return CompositionType::kCursor;
|
||||
|
||||
// Unsupported composition types.
|
||||
case Composition::DISPLAY_DECORATION:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue