drm_hwcomposer: Remove HWC2 CompositionType
Remove HWC2 CompositionType from midlayers. Define a new HwcLayer::CompositionType enum to capture all composition types supported by drm-hwcomposer. HWC2 and HWC3 frontends do the necessary conversion to/from HwcLayer::Composition type. Since the last HWC2 usage has been removed from HwcLayer, remove the hwc2 #include. Change-Id: I00d579d699599f0918d114b35080933348aa513b Signed-off-by: Drew Davenport <ddavenport@google.com>
This commit is contained in:
parent
3b62014b4a
commit
7e573a50c9
8 changed files with 64 additions and 38 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() ==
|
||||
HWC2::Composition::Cursor;
|
||||
HwcLayer::CompositionType::kCursor;
|
||||
});
|
||||
if (it == layers.end()) {
|
||||
return nullptr;
|
||||
|
|
@ -136,9 +136,9 @@ bool Backend::IsClientLayer(HwcDisplay *display, HwcLayer *layer) {
|
|||
display->GetHwc()->GetResMan().ForcedScalingWithGpu());
|
||||
}
|
||||
|
||||
bool Backend::HardwareSupportsLayerType(HWC2::Composition comp_type) {
|
||||
return comp_type == HWC2::Composition::Device ||
|
||||
comp_type == HWC2::Composition::Cursor;
|
||||
bool Backend::HardwareSupportsLayerType(HwcLayer::CompositionType comp_type) {
|
||||
return comp_type == HwcLayer::CompositionType::kDevice ||
|
||||
comp_type == HwcLayer::CompositionType::kCursor;
|
||||
}
|
||||
|
||||
uint32_t Backend::CalcPixOps(const std::vector<HwcLayer *> &layers,
|
||||
|
|
@ -161,12 +161,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(HWC2::Composition::Client);
|
||||
} else if (use_cursor_plane &&
|
||||
layers[z_order]->GetSfType() == HWC2::Composition::Cursor) {
|
||||
layers[z_order]->SetValidatedType(HWC2::Composition::Cursor);
|
||||
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);
|
||||
} else {
|
||||
layers[z_order]->SetValidatedType(HWC2::Composition::Device);
|
||||
layers[z_order]->SetValidatedType(HwcLayer::CompositionType::kDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Backend {
|
|||
virtual bool IsClientLayer(HwcDisplay *display, HwcLayer *layer);
|
||||
|
||||
protected:
|
||||
static bool HardwareSupportsLayerType(HWC2::Composition comp_type);
|
||||
static bool HardwareSupportsLayerType(HwcLayer::CompositionType comp_type);
|
||||
static uint32_t CalcPixOps(const std::vector<HwcLayer *> &layers,
|
||||
size_t first_z, size_t size);
|
||||
static void MarkValidated(std::vector<HwcLayer *> &layers,
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace android {
|
|||
|
||||
void BackendClient::ValidateDisplay(HwcDisplay *display) {
|
||||
for (auto &[layer_handle, layer] : display->layers()) {
|
||||
layer.SetValidatedType(HWC2::Composition::Client);
|
||||
layer.SetValidatedType(HwcLayer::CompositionType::kClient);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -286,11 +286,11 @@ auto HwcDisplay::ValidateStagedComposition() -> std::vector<ChangedLayer> {
|
|||
*/
|
||||
for (auto &l : layers_) {
|
||||
l.second.SetPriorBufferScanOutFlag(l.second.GetValidatedType() !=
|
||||
HWC2::Composition::Client);
|
||||
HwcLayer::CompositionType::kClient);
|
||||
|
||||
/* Populate layer data for layers that might be mapped to a drm plane. */
|
||||
if (l.second.GetSfType() == HWC2::Composition::Device ||
|
||||
l.second.GetSfType() == HWC2::Composition::Cursor) {
|
||||
if (l.second.GetSfType() == HwcLayer::CompositionType::kDevice ||
|
||||
l.second.GetSfType() == HwcLayer::CompositionType::kCursor) {
|
||||
l.second.PopulateLayerData();
|
||||
}
|
||||
}
|
||||
|
|
@ -777,10 +777,10 @@ HWC2::Error HwcDisplay::CreateComposition(AtomicCommitArgs &a_args) {
|
|||
std::optional<LayerData> cursor_layer = std::nullopt;
|
||||
for (auto &[_, layer] : layers_) {
|
||||
switch (layer.GetValidatedType()) {
|
||||
case HWC2::Composition::Device:
|
||||
case HwcLayer::CompositionType::kDevice:
|
||||
z_map.emplace(layer.GetZOrder(), &layer);
|
||||
break;
|
||||
case HWC2::Composition::Cursor:
|
||||
case HwcLayer::CompositionType::kCursor:
|
||||
if (!cursor_layer.has_value()) {
|
||||
cursor_layer = layer.GetLayerData();
|
||||
} else {
|
||||
|
|
@ -788,13 +788,16 @@ HWC2::Error HwcDisplay::CreateComposition(AtomicCommitArgs &a_args) {
|
|||
z_map.emplace(layer.GetZOrder(), &layer);
|
||||
}
|
||||
break;
|
||||
case HWC2::Composition::Client:
|
||||
case HwcLayer::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;
|
||||
default:
|
||||
case HwcLayer::CompositionType::kSolidColor:
|
||||
case HwcLayer::CompositionType::kInvalid:
|
||||
ALOGE("Invalid layer type: %d",
|
||||
static_cast<int>(layer.GetValidatedType()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
@ -1040,9 +1043,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() == HWC2::Composition::Cursor) !=
|
||||
(rhs->GetSfType() == HWC2::Composition::Cursor)) {
|
||||
return rhs->GetSfType() == HWC2::Composition::Cursor;
|
||||
if ((lhs->GetSfType() == HwcLayer::CompositionType::kCursor) !=
|
||||
(rhs->GetSfType() == HwcLayer::CompositionType::kCursor)) {
|
||||
return rhs->GetSfType() == HwcLayer::CompositionType::kCursor;
|
||||
}
|
||||
|
||||
return lhs->GetZOrder() < rhs->GetZOrder();
|
||||
|
|
@ -1151,8 +1154,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() == HWC2::Composition::Client ||
|
||||
layer.GetValidatedType() == HWC2::Composition::Client;
|
||||
return layer.GetSfType() == HwcLayer::CompositionType::kClient ||
|
||||
layer.GetValidatedType() == HwcLayer::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, HWC2::Composition>;
|
||||
using ChangedLayer = std::pair<ILayerId, HwcLayer::CompositionType>;
|
||||
auto ValidateStagedComposition() -> std::vector<ChangedLayer>;
|
||||
|
||||
// Mark previously validated properties as ready to present.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <aidl/android/hardware/graphics/common/Transform.h>
|
||||
#include <hardware/hwcomposer2.h>
|
||||
#include <memory>
|
||||
|
||||
#include "bufferinfo/BufferInfo.h"
|
||||
|
|
@ -44,6 +43,13 @@ 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;
|
||||
|
|
@ -51,7 +57,7 @@ class HwcLayer {
|
|||
std::optional<BufferBlendMode> blend_mode;
|
||||
std::optional<BufferColorSpace> color_space;
|
||||
std::optional<BufferSampleRange> sample_range;
|
||||
std::optional<HWC2::Composition> composition_type;
|
||||
std::optional<CompositionType> composition_type;
|
||||
std::optional<DstRectInfo> display_frame;
|
||||
std::optional<float> alpha;
|
||||
std::optional<SrcRectInfo> source_crop;
|
||||
|
|
@ -62,16 +68,16 @@ class HwcLayer {
|
|||
|
||||
explicit HwcLayer(HwcDisplay *parent_display) : parent_(parent_display){};
|
||||
|
||||
HWC2::Composition GetSfType() const {
|
||||
CompositionType GetSfType() const {
|
||||
return sf_type_;
|
||||
}
|
||||
HWC2::Composition GetValidatedType() const {
|
||||
CompositionType GetValidatedType() const {
|
||||
return validated_type_;
|
||||
}
|
||||
void AcceptTypeChange() {
|
||||
sf_type_ = validated_type_;
|
||||
}
|
||||
void SetValidatedType(HWC2::Composition type) {
|
||||
void SetValidatedType(CompositionType type) {
|
||||
validated_type_ = type;
|
||||
}
|
||||
bool IsTypeChanged() const {
|
||||
|
|
@ -107,8 +113,8 @@ class HwcLayer {
|
|||
private:
|
||||
// sf_type_ stores the initial type given to us by surfaceflinger,
|
||||
// validated_type_ stores the type after running ValidateDisplay
|
||||
HWC2::Composition sf_type_ = HWC2::Composition::Invalid;
|
||||
HWC2::Composition validated_type_ = HWC2::Composition::Invalid;
|
||||
CompositionType sf_type_ = CompositionType::kInvalid;
|
||||
CompositionType validated_type_ = CompositionType::kInvalid;
|
||||
|
||||
uint32_t z_order_ = 0;
|
||||
LayerData layer_data_;
|
||||
|
|
|
|||
|
|
@ -1005,7 +1005,24 @@ static int32_t SetLayerCompositionType(hwc2_device_t *device,
|
|||
GET_LAYER(layer);
|
||||
|
||||
HwcLayer::LayerProperties layer_properties;
|
||||
layer_properties.composition_type = static_cast<HWC2::Composition>(type);
|
||||
switch (static_cast<HWC2::Composition>(type)) {
|
||||
case HWC2::Composition::Client:
|
||||
layer_properties.composition_type = HwcLayer::CompositionType::kClient;
|
||||
break;
|
||||
case HWC2::Composition::Device:
|
||||
layer_properties.composition_type = HwcLayer::CompositionType::kDevice;
|
||||
break;
|
||||
case HWC2::Composition::SolidColor:
|
||||
layer_properties
|
||||
.composition_type = HwcLayer::CompositionType::kSolidColor;
|
||||
break;
|
||||
case HWC2::Composition::Cursor:
|
||||
layer_properties.composition_type = HwcLayer::CompositionType::kCursor;
|
||||
break;
|
||||
default:
|
||||
ALOGE("Unsupported composition type t=%d", type);
|
||||
break;
|
||||
}
|
||||
ilayer->SetLayerProperties(layer_properties);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ std::optional<std::array<float, kCtmSize>> AidlToColorTransformMatrix(
|
|||
return color_transform_matrix;
|
||||
}
|
||||
|
||||
std::optional<HWC2::Composition> AidlToCompositionType(
|
||||
std::optional<HwcLayer::CompositionType> AidlToCompositionType(
|
||||
const std::optional<ParcelableComposition> composition) {
|
||||
if (!composition) {
|
||||
return std::nullopt;
|
||||
|
|
@ -228,15 +228,15 @@ std::optional<HWC2::Composition> AidlToCompositionType(
|
|||
|
||||
switch (composition->composition) {
|
||||
case Composition::INVALID:
|
||||
return HWC2::Composition::Invalid;
|
||||
return HwcLayer::CompositionType::kInvalid;
|
||||
case Composition::CLIENT:
|
||||
return HWC2::Composition::Client;
|
||||
return HwcLayer::CompositionType::kClient;
|
||||
case Composition::DEVICE:
|
||||
return HWC2::Composition::Device;
|
||||
return HwcLayer::CompositionType::kDevice;
|
||||
case Composition::SOLID_COLOR:
|
||||
return HWC2::Composition::SolidColor;
|
||||
return HwcLayer::CompositionType::kSolidColor;
|
||||
case Composition::CURSOR:
|
||||
return HWC2::Composition::Cursor;
|
||||
return HwcLayer::CompositionType::kCursor;
|
||||
|
||||
// Unsupported composition types.
|
||||
case Composition::DISPLAY_DECORATION:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue