drm_hwcomposer: Remove HWC2 usage for Present
Add HwcDisplay::PresentStagedComposition to commit the changes that have
been previously validated through ValidateStagedComposition.
Drop usage of legacy HWC2 api in ComposerClient.cpp for DisplayCommand
present commands.
Change-Id: I0b7fcd4b664bf707f468cd40b1fefdfdd963f7f7
Signed-off-by: Drew Davenport <ddavenport@google.com>
diff --git a/hwc2_device/HwcDisplay.cpp b/hwc2_device/HwcDisplay.cpp
index 9fbd6b9..c0fc3c5 100644
--- a/hwc2_device/HwcDisplay.cpp
+++ b/hwc2_device/HwcDisplay.cpp
@@ -401,6 +401,29 @@
return changed_layers;
}
+auto HwcDisplay::AcceptValidatedComposition() -> void {
+ for (std::pair<const hwc2_layer_t, HwcLayer> &l : layers_) {
+ l.second.AcceptTypeChange();
+ }
+}
+
+auto HwcDisplay::PresentStagedComposition(
+ int32_t *out_present_fence, std::vector<ReleaseFence> *out_release_fences)
+ -> HWC2::Error {
+ auto error = PresentDisplay(out_present_fence);
+ if (error != HWC2::Error::None || *out_present_fence == -1) {
+ return error;
+ }
+
+ for (auto &l : layers_) {
+ if (!l.second.GetPriorBufferScanOutFlag() || !present_fence_) {
+ continue;
+ }
+ out_release_fences->emplace_back(l.first, DupFd(present_fence_));
+ }
+ return error;
+}
+
void HwcDisplay::SetPipeline(std::shared_ptr<DrmDisplayPipeline> pipeline) {
Deinit();
diff --git a/hwc2_device/HwcDisplay.h b/hwc2_device/HwcDisplay.h
index 9c113fd..8dc059c 100644
--- a/hwc2_device/HwcDisplay.h
+++ b/hwc2_device/HwcDisplay.h
@@ -95,6 +95,17 @@
using ChangedLayer = std::pair<hwc2_layer_t, HWC2::Composition>;
auto ValidateStagedComposition() -> std::vector<ChangedLayer>;
+ // Mark previously validated properties as ready to present.
+ auto AcceptValidatedComposition() -> void;
+
+ // Present previously staged properties, and return fences to indicate when
+ // the new content has been presented, and when the previous buffers have
+ // been released.
+ using ReleaseFence = std::pair<hwc2_layer_t, int32_t>;
+ auto PresentStagedComposition(int32_t *out_present_fence,
+ std::vector<ReleaseFence> *out_release_fences)
+ -> HWC2::Error;
+
// HWC2 Hooks - these should not be used outside of the hwc2 device.
HWC2::Error AcceptDisplayChanges();
HWC2::Error CreateLayer(hwc2_layer_t *layer);