Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 57d3f2d9 authored by Albert Chaulk's avatar Albert Chaulk
Browse files

vrwm: Fix startup flickering

Sometimes starting an app appears similar to a 2D app or a VR app +
window. This changes the logic to avoid that.

If a dim or extra layer appears after the 2D app layers then consider
it to be hidden

Bug: 35915107
Test: start permissionsgen several times
Change-Id: If66d1b06cc6c688c26b856e9b5aeee9d1b8940f7
parent ca6625b9
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -51,6 +51,18 @@ class HwcCallback : public VrComposerView::Callback {
      }
    }

    // This is a layer that provides some other functionality, eg dim layer.
    // We use this to determine the point at which layers are "on top".
    bool is_extra_layer() const {
      switch(type) {
      case kSurfaceFlingerLayer:
      case kUndefinedWindow:
        return true;
      default:
        return false;
      }
    }

    sp<Fence> fence;
    sp<GraphicBuffer> buffer;
    Rectf crop;
+9 −4
Original line number Diff line number Diff line
@@ -195,7 +195,8 @@ ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame,
                                            uint32_t vr_app) {
  auto& layers = frame.layers();

  // We assume the first two layers are the VR app.
  // We assume the first two layers are the VR app. In the case of a 2D app,
  // there will be the app + at least one system layer so this is still safe.
  if (layers.size() < kVRAppLayerCount)
    return ViewMode::Hidden;

@@ -203,19 +204,23 @@ ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame,
      layers[1].appid != layers[0].appid) {
    if (layers[1].appid != layers[0].appid && layers[0].appid) {
      // This might be a 2D app.
      // If a dim layer exists afterwards it is much more likely that this is
      // actually an app launch artifact.
      for (size_t i = 2; i < layers.size(); i++) {
        if (layers[i].is_extra_layer())
          return ViewMode::Hidden;
      }
      return ViewMode::App;
    }
    return ViewMode::Hidden;
  }

  // If a non-VR-app, non-skipped layer appears, show.
  size_t index = kVRAppLayerCount;
  // Now, find a dim layer if it exists.
  // If it does, ignore any layers behind it for visibility determination.
  for (size_t i = index; i < layers.size(); i++) {
    if (layers[i].appid == 0) {
    if (layers[i].appid == HwcCallback::HwcLayer::kSurfaceFlingerLayer) {
      index = i + 1;
      break;
    }
  }