summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--services/vr/hardware_composer/impl/vr_hwc.cpp28
-rw-r--r--services/vr/hardware_composer/impl/vr_hwc.h2
2 files changed, 16 insertions, 14 deletions
diff --git a/services/vr/hardware_composer/impl/vr_hwc.cpp b/services/vr/hardware_composer/impl/vr_hwc.cpp
index 11ffc3f2fe..4af47d2a35 100644
--- a/services/vr/hardware_composer/impl/vr_hwc.cpp
+++ b/services/vr/hardware_composer/impl/vr_hwc.cpp
@@ -251,20 +251,22 @@ VrHwc::~VrHwc() {}
bool VrHwc::hasCapability(hwc2_capability_t /* capability */) { return false; }
void VrHwc::registerEventCallback(EventCallback* callback) {
- event_callback_ = callback;
-
- if (client_ != nullptr) {
- {
- int32_t width, height;
- GetPrimaryDisplaySize(&width, &height);
- std::lock_guard<std::mutex> guard(mutex_);
- // Create the primary display late to avoid initialization issues between
- // VR HWC and SurfaceFlinger.
- displays_[kDefaultDisplayId].reset(new HwcDisplay(width, height));
- }
- event_callback_->onHotplug(kDefaultDisplayId,
- IComposerCallback::Connection::CONNECTED);
+ {
+ std::lock_guard<std::mutex> guard(mutex_);
+ event_callback_ = callback;
+ int32_t width, height;
+ GetPrimaryDisplaySize(&width, &height);
+ // Create the primary display late to avoid initialization issues between
+ // VR HWC and SurfaceFlinger.
+ displays_[kDefaultDisplayId].reset(new HwcDisplay(width, height));
}
+ event_callback_->onHotplug(kDefaultDisplayId,
+ IComposerCallback::Connection::CONNECTED);
+}
+
+void VrHwc::unregisterEventCallback() {
+ std::lock_guard<std::mutex> guard(mutex_);
+ event_callback_ = nullptr;
}
uint32_t VrHwc::getMaxVirtualDisplayCount() { return 1; }
diff --git a/services/vr/hardware_composer/impl/vr_hwc.h b/services/vr/hardware_composer/impl/vr_hwc.h
index d5d5f55e2e..85e587abbe 100644
--- a/services/vr/hardware_composer/impl/vr_hwc.h
+++ b/services/vr/hardware_composer/impl/vr_hwc.h
@@ -213,7 +213,7 @@ class VrHwc : public IComposer, public ComposerHal, public ComposerView {
std::string dumpDebugInfo() override { return {}; }
void registerEventCallback(EventCallback* callback) override;
- void unregisterEventCallback() override {}
+ void unregisterEventCallback() override;
uint32_t getMaxVirtualDisplayCount() override;
Error createVirtualDisplay(uint32_t width, uint32_t height,