Merge "VR: Move VR HWC initialization in SurfaceFlingerView"
diff --git a/services/vr/vr_window_manager/surface_flinger_view.cpp b/services/vr/vr_window_manager/surface_flinger_view.cpp
index 7b17420..d42d3ff 100644
--- a/services/vr/vr_window_manager/surface_flinger_view.cpp
+++ b/services/vr/vr_window_manager/surface_flinger_view.cpp
@@ -14,16 +14,29 @@
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;
diff --git a/services/vr/vr_window_manager/surface_flinger_view.h b/services/vr/vr_window_manager/surface_flinger_view.h
index 8d9b44e..9c16192 100644
--- a/services/vr/vr_window_manager/surface_flinger_view.h
+++ b/services/vr/vr_window_manager/surface_flinger_view.h
@@ -39,6 +39,7 @@
void ReleaseFrame();
private:
+ sp<IComposer> vr_hwcomposer_;
std::unique_ptr<VrComposerView> vr_composer_view_;
int width_ = 0;
int height_ = 0;
diff --git a/services/vr/vr_window_manager/vr_window_manager.cpp b/services/vr/vr_window_manager/vr_window_manager.cpp
index 5e9215c..6636dc5 100644
--- a/services/vr/vr_window_manager/vr_window_manager.cpp
+++ b/services/vr/vr_window_manager/vr_window_manager.cpp
@@ -14,18 +14,6 @@
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();