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
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue