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

Commit 04c12a09 authored by Daniel Nicoara's avatar Daniel Nicoara
Browse files

VR: Move VR HWC initialization in SurfaceFlingerView

Initialize the VR HWC at first use since it is also needed to register
the frame observer VR WM uses to display SurfaceFlinger output.

Note, need the real implementation, rather than the passthrough
interface received via IComposer::getService().

Bug: b/35403318
Test: Compiled
Change-Id: I7569136edcef57f545e3d1c3daf644f48fd6b907
parent 52978075
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -14,16 +14,29 @@ SurfaceFlingerView::SurfaceFlingerView() {}
SurfaceFlingerView::~SurfaceFlingerView() {}

bool SurfaceFlingerView::Initialize(HwcCallback::Client *client) {
  sp<IComposer> vr_hwcomposer = IComposer::getService("vr_hwcomposer");
  if (!vr_hwcomposer.get()) {
    ALOGE("vr_hwcomposer not registered as service");
  const char vr_hwcomposer_name[] = "vr_hwcomposer";
  vr_hwcomposer_ = HIDL_FETCH_IComposer(vr_hwcomposer_name);
  if (!vr_hwcomposer_.get()) {
    ALOGE("Failed to get vr_hwcomposer");
    return false;
  }

  if (vr_hwcomposer_->isRemote()) {
    ALOGE("vr_hwcomposer service is remote");
    return false;
  }

  const android::status_t vr_hwcomposer_status =
      vr_hwcomposer_->registerAsService(vr_hwcomposer_name);
  if (vr_hwcomposer_status != OK) {
    ALOGE("Failed to register vr_hwcomposer service");
    return false;
  }

  vr_composer_view_ =
      std::make_unique<VrComposerView>(std::make_unique<HwcCallback>(client));
  vr_composer_view_->Initialize(GetComposerViewFromIComposer(
      vr_hwcomposer.get()));
      vr_hwcomposer_.get()));

  // TODO(dnicoara): Query this from the composer service.
  width_ = 1920;
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ class SurfaceFlingerView {
  void ReleaseFrame();

 private:
  sp<IComposer> vr_hwcomposer_;
  std::unique_ptr<VrComposerView> vr_composer_view_;
  int width_ = 0;
  int height_ = 0;
+0 −12
Original line number Diff line number Diff line
@@ -14,18 +14,6 @@ using namespace android::dvr;
int main(int /* argc */, char** /* argv */) {
  android::ProcessState::self()->startThreadPool();

  // Create vr_hwcomposer.
  const char vr_hwcomposer_name[] = "vr_hwcomposer";
  sp<IComposer> vr_hwcomposer = HIDL_FETCH_IComposer(vr_hwcomposer_name);
  LOG_ALWAYS_FATAL_IF(!vr_hwcomposer.get(), "Failed to get vr_hwcomposer");
  LOG_ALWAYS_FATAL_IF(vr_hwcomposer->isRemote(),
                      "vr_hwcomposer service is remote");

  const android::status_t vr_hwcomposer_status =
      vr_hwcomposer->registerAsService(vr_hwcomposer_name);
  LOG_ALWAYS_FATAL_IF(vr_hwcomposer_status != ::android::OK,
                      "Failed to register vr_hwcomposer service");

  // ShellView needs to be created after vr_hwcomposer.
  android::dvr::ShellView app;
  const int app_status = app.Initialize();