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

Commit 32802849 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes I712083df,I800e6050

* changes:
  Fixup 2D app patch, forgot to remove unused variable
  Call releaseFrame on the IVrComposerView interface
parents f89046d4 479f872d
Loading
Loading
Loading
Loading
+1 −2
Original line number Original line Diff line number Diff line
@@ -79,7 +79,6 @@ Return<void> HwcCallback::onNewFrame(
  }
  }


  std::lock_guard<std::mutex> guard(mutex_);
  std::lock_guard<std::mutex> guard(mutex_);
  if (client_)
  client_->OnFrame(std::make_unique<Frame>(std::move(hwc_frame)));
  client_->OnFrame(std::make_unique<Frame>(std::move(hwc_frame)));


  return Void();
  return Void();
+29 −24
Original line number Original line Diff line number Diff line
@@ -311,12 +311,7 @@ void ShellView::VrMode(bool mode) {
                 : MainThreadTask::ExitingVrMode);
                 : MainThreadTask::ExitingVrMode);
}
}


void ShellView::OnDrawFrame() {
void ShellView::AdvanceFrame() {
  textures_.clear();
  has_ime_ = false;

  {
    std::unique_lock<std::mutex> l(pending_frame_mutex_);
  if (!pending_frames_.empty()) {
  if (!pending_frames_.empty()) {
    // Check if we should advance the frame.
    // Check if we should advance the frame.
    auto& frame = pending_frames_.front();
    auto& frame = pending_frames_.front();
@@ -324,8 +319,21 @@ void ShellView::OnDrawFrame() {
        frame.frame->Finish() == HwcCallback::FrameStatus::kFinished) {
        frame.frame->Finish() == HwcCallback::FrameStatus::kFinished) {
      current_frame_ = std::move(frame);
      current_frame_ = std::move(frame);
      pending_frames_.pop_front();
      pending_frames_.pop_front();

      for(int i = 0; i < skipped_frame_count_ + 1; i++)
        surface_flinger_view_->ReleaseFrame();
      skipped_frame_count_ = 0;
    }
  }
  }
}
}

void ShellView::OnDrawFrame() {
  textures_.clear();
  has_ime_ = false;

  {
    std::unique_lock<std::mutex> l(pending_frame_mutex_);
    AdvanceFrame();
  }
  }


  bool visible = current_frame_.visibility != ViewMode::Hidden;
  bool visible = current_frame_.visibility != ViewMode::Hidden;
@@ -334,14 +342,14 @@ void ShellView::OnDrawFrame() {
    SetVisibility(current_frame_.visibility != ViewMode::Hidden);
    SetVisibility(current_frame_.visibility != ViewMode::Hidden);
  }
  }


  if (!visible)
  if (!debug_mode_ && !visible)
    return;
    return;


  ime_texture_ = TextureLayer();
  ime_texture_ = TextureLayer();


  surface_flinger_view_->GetTextures(*current_frame_.frame.get(), &textures_,
  surface_flinger_view_->GetTextures(*current_frame_.frame.get(), &textures_,
                                     &ime_texture_, debug_mode_,
                                     &ime_texture_, debug_mode_,
                                     view_mode_ == ViewMode::VR);
                                     current_frame_.visibility == ViewMode::VR);
  has_ime_ = ime_texture_.texture != nullptr;
  has_ime_ = ime_texture_.texture != nullptr;
}
}


@@ -385,9 +393,6 @@ bool ShellView::OnClick(bool down) {
}
}


void ShellView::OnFrame(std::unique_ptr<HwcCallback::Frame> frame) {
void ShellView::OnFrame(std::unique_ptr<HwcCallback::Frame> frame) {
  if (!frame || frame->layers().empty())
    return;

  ViewMode visibility =
  ViewMode visibility =
      CalculateVisibilityFromLayerConfig(*frame.get(), current_vr_app_);
      CalculateVisibilityFromLayerConfig(*frame.get(), current_vr_app_);


@@ -395,21 +400,21 @@ void ShellView::OnFrame(std::unique_ptr<HwcCallback::Frame> frame) {
    visibility = ViewMode::VR;
    visibility = ViewMode::VR;
  current_vr_app_ = frame->layers().front().appid;
  current_vr_app_ = frame->layers().front().appid;


  // If we are not showing the frame there's no need to keep anything around.
  if (visibility == ViewMode::Hidden) {
    // Hidden, no change so drop it completely
    if (current_frame_.visibility == ViewMode::Hidden)
      return;

    frame.reset(nullptr);
  }

  std::unique_lock<std::mutex> l(pending_frame_mutex_);
  std::unique_lock<std::mutex> l(pending_frame_mutex_);


  pending_frames_.emplace_back(std::move(frame), visibility);
  pending_frames_.emplace_back(std::move(frame), visibility);


  if (pending_frames_.size() > kMaximumPendingFrames)
  if (pending_frames_.size() > kMaximumPendingFrames) {
    skipped_frame_count_++;
    pending_frames_.pop_front();
    pending_frames_.pop_front();
  }

  if (visibility == ViewMode::Hidden &&
      current_frame_.visibility == ViewMode::Hidden) {
    // Consume all frames while hidden.
    while (!pending_frames_.empty())
      AdvanceFrame();
  }


  // If we are showing ourselves the main thread is not processing anything,
  // If we are showing ourselves the main thread is not processing anything,
  // so give it a kick.
  // so give it a kick.
+4 −1
Original line number Original line Diff line number Diff line
@@ -63,6 +63,8 @@ class ShellView : public Application, public HwcCallback::Client {


  bool OnClick(bool down);
  bool OnClick(bool down);


  void AdvanceFrame();

  // HwcCallback::Client:
  // HwcCallback::Client:
  void OnFrame(std::unique_ptr<HwcCallback::Frame> frame) override;
  void OnFrame(std::unique_ptr<HwcCallback::Frame> frame) override;


@@ -70,7 +72,8 @@ class ShellView : public Application, public HwcCallback::Client {
  std::unique_ptr<ShaderProgram> overlay_program_;
  std::unique_ptr<ShaderProgram> overlay_program_;
  std::unique_ptr<ShaderProgram> controller_program_;
  std::unique_ptr<ShaderProgram> controller_program_;


  ViewMode view_mode_ = ViewMode::Hidden;
  // This starts at -1 so we don't call ReleaseFrame for the first frame.
  int skipped_frame_count_ = -1;


  uint32_t current_vr_app_;
  uint32_t current_vr_app_;


+4 −0
Original line number Original line Diff line number Diff line
@@ -75,5 +75,9 @@ bool SurfaceFlingerView::GetTextures(const HwcCallback::Frame& frame,
  return true;
  return true;
}
}


void SurfaceFlingerView::ReleaseFrame() {
  composer_service_->releaseFrame();
}

}  // namespace dvr
}  // namespace dvr
}  // namespace android
}  // namespace android
+2 −0
Original line number Original line Diff line number Diff line
@@ -36,6 +36,8 @@ class SurfaceFlingerView {
                   TextureLayer* ime_layer, bool debug,
                   TextureLayer* ime_layer, bool debug,
                   bool skip_first_layer) const;
                   bool skip_first_layer) const;


  void ReleaseFrame();

 private:
 private:
  sp<IVrComposerView> composer_service_;
  sp<IVrComposerView> composer_service_;
  std::unique_ptr<HwcCallback> composer_observer_;
  std::unique_ptr<HwcCallback> composer_observer_;