diff mbox series

[EARLYREVIEW] drm_hwcomposer: Use client compositing if there is only one plane

Message ID 1517891585-25047-1-git-send-email-john.stultz@linaro.org
State New
Headers show
Series [EARLYREVIEW] drm_hwcomposer: Use client compositing if there is only one plane | expand

Commit Message

John Stultz Feb. 6, 2018, 4:33 a.m. UTC
Wanted to see if this was closer to what you were thinking on
this change. I probably need to split it into two patches
(the first changing the pre_compositor initialization, and
the second chosing the client compositing).

I suspect I'm still off, so let me know what you think.

thanks
-john


Originally based on work by Rob Herring, this patch changes
ValidateDisplay() so that if there is only one plane or we are
not using the hwcomposer GL compositor (defaulting to
surfaceflinger instead), we modify Device composited layers to
be Client composited.

Without this, on devices with just one plane, nothing gets
displayed on the screen.

Suggestions for alternative solutions here would be greatly
appreciated!

Change-Id: Ic963c356ab1ef241d92fde6c890936b560f52051
Signed-off-by: John Stultz <john.stultz@linaro.org>

---
v2:
* Rework Rob's change to check planes
v3:
* Integrate Rob's feedback to conditionalize
  on GL compositor usage as well
---
 drmdisplaycompositor.cpp | 40 +++++++++++++++++++++-------------------
 drmdisplaycompositor.h   |  3 +++
 drmhwctwo.cpp            |  7 +++++++
 3 files changed, 31 insertions(+), 19 deletions(-)

-- 
2.7.4
diff mbox series

Patch

diff --git a/drmdisplaycompositor.cpp b/drmdisplaycompositor.cpp
index 3a20b31..f401208 100644
--- a/drmdisplaycompositor.cpp
+++ b/drmdisplaycompositor.cpp
@@ -222,6 +222,13 @@  int DrmDisplayCompositor::Init(DrmResources *drm, int display) {
     return ret;
   }
 
+  pre_compositor_.reset(new GLWorkerCompositor());
+  ret = pre_compositor_->Init();
+  if (ret) {
+    ALOGE("Failed to initialize OpenGL compositor %d", ret);
+    pre_compositor_.reset();
+  }
+
   initialized_ = true;
   return 0;
 }
@@ -294,14 +301,16 @@  int DrmDisplayCompositor::ApplySquash(DrmDisplayComposition *display_comp) {
   }
 
   std::vector<DrmCompositionRegion> &regions = display_comp->squash_regions();
-  ret = pre_compositor_->Composite(display_comp->layers().data(),
+  if (pre_compositor_) {
+    ret = pre_compositor_->Composite(display_comp->layers().data(),
                                    regions.data(), regions.size(), fb.buffer(),
                                    display_comp->importer());
-  pre_compositor_->Finish();
+    pre_compositor_->Finish();
 
-  if (ret) {
-    ALOGE("Failed to squash layers");
-    return ret;
+    if (ret) {
+      ALOGE("Failed to squash layers");
+      return ret;
+    }
   }
 
   ret = display_comp->CreateNextTimelineFence();
@@ -328,14 +337,16 @@  int DrmDisplayCompositor::ApplyPreComposite(
   }
 
   std::vector<DrmCompositionRegion> &regions = display_comp->pre_comp_regions();
-  ret = pre_compositor_->Composite(display_comp->layers().data(),
+  if (pre_compositor_) {
+    ret = pre_compositor_->Composite(display_comp->layers().data(),
                                    regions.data(), regions.size(), fb.buffer(),
                                    display_comp->importer());
-  pre_compositor_->Finish();
+    pre_compositor_->Finish();
 
-  if (ret) {
-    ALOGE("Failed to pre-composite layers");
-    return ret;
+    if (ret) {
+      ALOGE("Failed to pre-composite layers");
+      return ret;
+    }
   }
 
   ret = display_comp->CreateNextTimelineFence();
@@ -395,15 +406,6 @@  int DrmDisplayCompositor::PrepareFrame(DrmDisplayComposition *display_comp) {
   std::vector<DrmCompositionRegion> &pre_comp_regions =
       display_comp->pre_comp_regions();
 
-  if (!pre_compositor_) {
-    pre_compositor_.reset(new GLWorkerCompositor());
-    int ret = pre_compositor_->Init();
-    if (ret) {
-      ALOGE("Failed to initialize OpenGL compositor %d", ret);
-      return ret;
-    }
-  }
-
   int squash_layer_index = -1;
   if (squash_regions.size() > 0) {
     squash_framebuffer_index_ = (squash_framebuffer_index_ + 1) % 2;
diff --git a/drmdisplaycompositor.h b/drmdisplaycompositor.h
index f1965fb..ed6c5f9 100644
--- a/drmdisplaycompositor.h
+++ b/drmdisplaycompositor.h
@@ -98,6 +98,9 @@  class DrmDisplayCompositor {
     return &squash_state_;
   }
 
+  bool uses_GL() {
+    return !!pre_compositor_;
+  }
  private:
   struct ModeState {
     bool needs_modeset = false;
diff --git a/drmhwctwo.cpp b/drmhwctwo.cpp
index dfca1a6..ed8793b 100644
--- a/drmhwctwo.cpp
+++ b/drmhwctwo.cpp
@@ -688,6 +688,7 @@  HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
   *num_requests = 0;
   for (std::pair<const hwc2_layer_t, DrmHwcTwo::HwcLayer> &l : layers_) {
     DrmHwcTwo::HwcLayer &layer = l.second;
+    int planes = primary_planes_.size() + overlay_planes_.size();
     switch (layer.sf_type()) {
       case HWC2::Composition::SolidColor:
       case HWC2::Composition::Cursor:
@@ -695,6 +696,12 @@  HWC2::Error DrmHwcTwo::HwcDisplay::ValidateDisplay(uint32_t *num_types,
         layer.set_validated_type(HWC2::Composition::Client);
         ++*num_types;
         break;
+      case HWC2::Composition::Device:
+        if (!compositor_.uses_GL() || planes == 1) {
+          layer.set_validated_type(HWC2::Composition::Client);
+          ++*num_types;
+          break;
+        }
       default:
         layer.set_validated_type(layer.sf_type());
         break;