summaryrefslogtreecommitdiff
path: root/drmdisplaycomposition.cpp
diff options
context:
space:
mode:
authorSean Paul <seanpaul@chromium.org>2016-05-11 16:29:45 -0400
committerSean Paul <seanpaul@chromium.org>2016-05-12 14:20:39 -0400
commitca699be0bcc162c8748abb63cd4f7158733b1466 (patch)
tree5de723fa59113e26fa8b4c3741fa24abcbec32ad /drmdisplaycomposition.cpp
parent39b3784628eb4169b46e71b30c98daf83c93bb8e (diff)
downloaddrm_hwcomposer-ca699be0bcc162c8748abb63cd4f7158733b1466.tar.gz
drm_hwcomposer-ca699be0bcc162c8748abb63cd4f7158733b1466.tar.xz
drm_hwcomposer: Use a vector for composition source_layers
Instead of a 1:1 mapping of layer:plane, use a vector to store source layers for a composition plane. This will allow us to represent squash compositions more easily by adding all source layers to the vector. This should also facilitate hardware which allows multiple fbs per plane. BUG=b/28117135 TEST=Tested on ryu Signed-off-by: Sean Paul <seanpaul@chromium.org> Change-Id: I5d4bfc6e9da022eaab047f948cc874d6a8a25746
Diffstat (limited to 'drmdisplaycomposition.cpp')
-rw-r--r--drmdisplaycomposition.cpp72
1 files changed, 40 insertions, 32 deletions
diff --git a/drmdisplaycomposition.cpp b/drmdisplaycomposition.cpp
index 2089157..2af9d5a 100644
--- a/drmdisplaycomposition.cpp
+++ b/drmdisplaycomposition.cpp
@@ -113,11 +113,8 @@ int DrmDisplayComposition::SetDisplayMode(const DrmMode &display_mode) {
}
int DrmDisplayComposition::AddPlaneDisable(DrmPlane *plane) {
- composition_planes_.emplace_back(
- DrmCompositionPlane{.plane = plane,
- .crtc = crtc_,
- .type = DrmCompositionPlaneType::kDisable,
- .source_layer = -1});
+ composition_planes_.emplace_back(DrmCompositionPlaneType::kDisable, plane,
+ crtc_);
return 0;
}
@@ -153,8 +150,7 @@ static DrmPlane *TakePlane(DrmCrtc *crtc,
}
void DrmDisplayComposition::EmplaceCompositionPlane(
- DrmCompositionPlaneType type, int source_layer,
- std::vector<DrmPlane *> *primary_planes,
+ DrmCompositionPlaneType type, std::vector<DrmPlane *> *primary_planes,
std::vector<DrmPlane *> *overlay_planes) {
DrmPlane *plane = TakePlane(crtc_, primary_planes, overlay_planes);
if (plane == NULL) {
@@ -163,11 +159,21 @@ void DrmDisplayComposition::EmplaceCompositionPlane(
"remaining");
return;
}
- composition_planes_.emplace_back(
- DrmCompositionPlane{.plane = plane,
- .crtc = crtc_,
- .type = type,
- .source_layer = source_layer});
+ composition_planes_.emplace_back(type, plane, crtc_);
+}
+
+void DrmDisplayComposition::EmplaceCompositionPlane(
+ size_t source_layer, std::vector<DrmPlane *> *primary_planes,
+ std::vector<DrmPlane *> *overlay_planes) {
+ DrmPlane *plane = TakePlane(crtc_, primary_planes, overlay_planes);
+ if (plane == NULL) {
+ ALOGE(
+ "Failed to add composition plane because there are no planes "
+ "remaining");
+ return;
+ }
+ composition_planes_.emplace_back(DrmCompositionPlaneType::kLayer, plane,
+ crtc_, source_layer);
}
static std::vector<size_t> SetBitsToVector(uint64_t in, size_t *index_map) {
@@ -275,10 +281,12 @@ int DrmDisplayComposition::CreateAndAssignReleaseFences() {
}
for (const DrmCompositionPlane &plane : composition_planes_) {
- if (plane.type == DrmCompositionPlaneType::kLayer) {
- DrmHwcLayer *source_layer = &layers_[plane.source_layer];
- comp_layers.emplace(source_layer);
- pre_comp_layers.erase(source_layer);
+ if (plane.type() == DrmCompositionPlaneType::kLayer) {
+ for (auto i : plane.source_layers()) {
+ DrmHwcLayer *source_layer = &layers_[i];
+ comp_layers.emplace(source_layer);
+ pre_comp_layers.erase(source_layer);
+ }
}
}
@@ -393,8 +401,7 @@ int DrmDisplayComposition::Plan(SquashState *squash,
if (planes_can_use == 0 && layers_remaining.size() > 0) {
for (auto i : protected_layers)
- EmplaceCompositionPlane(DrmCompositionPlaneType::kLayer, i,
- primary_planes, overlay_planes);
+ EmplaceCompositionPlane(i, primary_planes, overlay_planes);
ALOGE("Protected layers consumed all hardware planes");
return CreateAndAssignReleaseFences();
@@ -430,15 +437,13 @@ int DrmDisplayComposition::Plan(SquashState *squash,
// that again.
if (protected_idx < protected_layers.size() &&
idx > protected_layers[protected_idx]) {
- EmplaceCompositionPlane(DrmCompositionPlaneType::kLayer,
- protected_layers[protected_idx], primary_planes,
+ EmplaceCompositionPlane(protected_layers[protected_idx], primary_planes,
overlay_planes);
protected_idx++;
continue;
}
- EmplaceCompositionPlane(DrmCompositionPlaneType::kLayer,
- layers_remaining[last_hw_comp_layer],
+ EmplaceCompositionPlane(layers_remaining[last_hw_comp_layer],
primary_planes, overlay_planes);
last_hw_comp_layer++;
planes_can_use--;
@@ -449,14 +454,13 @@ int DrmDisplayComposition::Plan(SquashState *squash,
// Enqueue the rest of the protected layers (if any) between the hw composited
// overlay layers and the squash/precomp layers.
- for (int i = protected_idx; i < protected_layers.size(); ++i)
- EmplaceCompositionPlane(DrmCompositionPlaneType::kLayer,
- protected_layers[i], primary_planes,
+ for (size_t i = protected_idx; i < protected_layers.size(); ++i)
+ EmplaceCompositionPlane(protected_layers[i], primary_planes,
overlay_planes);
if (layers_remaining.size() > 0) {
- EmplaceCompositionPlane(DrmCompositionPlaneType::kPrecomp, -1,
- primary_planes, overlay_planes);
+ EmplaceCompositionPlane(DrmCompositionPlaneType::kPrecomp, primary_planes,
+ overlay_planes);
SeparateLayers(layers_.data(), layers_remaining.data(),
layers_remaining.size(), protected_layers.data(),
protected_layers.size(), exclude_rects.data(),
@@ -464,8 +468,8 @@ int DrmDisplayComposition::Plan(SquashState *squash,
}
if (use_squash_framebuffer) {
- EmplaceCompositionPlane(DrmCompositionPlaneType::kSquash, -1,
- primary_planes, overlay_planes);
+ EmplaceCompositionPlane(DrmCompositionPlaneType::kSquash, primary_planes,
+ overlay_planes);
}
return CreateAndAssignReleaseFences();
@@ -631,9 +635,9 @@ void DrmDisplayComposition::Dump(std::ostringstream *out) const {
for (size_t i = 0; i < composition_planes_.size(); i++) {
const DrmCompositionPlane &comp_plane = composition_planes_[i];
*out << " [" << i << "]"
- << " plane=" << (comp_plane.plane ? comp_plane.plane->id() : -1)
+ << " plane=" << (comp_plane.plane() ? comp_plane.plane()->id() : -1)
<< " type=";
- switch (comp_plane.type) {
+ switch (comp_plane.type()) {
case DrmCompositionPlaneType::kDisable:
*out << "DISABLE";
break;
@@ -651,7 +655,11 @@ void DrmDisplayComposition::Dump(std::ostringstream *out) const {
break;
}
- *out << " source_layer=" << comp_plane.source_layer << "\n";
+ *out << " source_layer=";
+ for (auto i : comp_plane.source_layers()) {
+ *out << i << " ";
+ }
+ *out << "\n";
}
*out << " Squash Regions: count=" << squash_regions_.size() << "\n";