return BufferConsumer::Import(std::move(status));
}
+bool DisplayClient::IsVrAppRunning() {
+ auto status = InvokeRemoteMethod<DisplayRPC::IsVrAppRunning>();
+ if (!status)
+ return 0;
+ return static_cast<bool>(status.get());
+}
} // namespace dvr
} // namespace android
std::unique_ptr<BufferConsumer> GetPoseBuffer();
+ // Temporary query for current VR status. Will be removed later.
+ bool IsVrAppRunning();
+
private:
friend BASE;
kOpVideoMeshSurfaceCreateProducerQueue,
kOpSetViewerParams,
kOpGetPoseBuffer,
+ kOpIsVrAppRunning,
};
// Aliases.
void(const ViewerParams& viewer_params));
PDX_REMOTE_METHOD(GetPoseBuffer, kOpGetPoseBuffer,
LocalChannelHandle(Void));
+ PDX_REMOTE_METHOD(IsVrAppRunning, kOpIsVrAppRunning, int(Void));
};
struct DisplayManagerRPC {
*this, &DisplayService::OnGetPoseBuffer, message);
return 0;
+ case DisplayRPC::IsVrAppRunning::Opcode:
+ DispatchRemoteMethod<DisplayRPC::IsVrAppRunning>(
+ *this, &DisplayService::IsVrAppRunning, message);
+ return 0;
+
// Direct the surface specific messages to the surface instance.
case DisplayRPC::CreateBufferQueue::Opcode:
case DisplayRPC::SetAttributes::Opcode:
update_notifier_();
}
+int DisplayService::IsVrAppRunning(pdx::Message& message) {
+ bool visible = true;
+ ForEachDisplaySurface([&visible](const std::shared_ptr<DisplaySurface>& surface) {
+ if (surface->client_z_order() == 0 && !surface->IsVisible())
+ visible = false;
+ });
+
+ REPLY_SUCCESS_RETURN(message, visible, 0);
+}
+
} // namespace dvr
} // namespace android
const ViewerParams& view_params);
pdx::LocalChannelHandle OnGetPoseBuffer(pdx::Message& message);
+ // Temporary query for current VR status. Will be removed later.
+ int IsVrAppRunning(pdx::Message& message);
+
// Called by DisplaySurface to signal that a surface property has changed and
// the display manager should be notified.
void NotifyDisplayConfigurationUpdate();
void Application::DeallocateResources() {
if (graphics_context_)
dvrGraphicsContextDestroy(graphics_context_);
+ graphics_context_ = nullptr;
if (pose_client_)
dvrPoseDestroy(pose_client_);
constexpr float kLayerScaleFactor = 3.0f;
constexpr unsigned int kMaximumPendingFrames = 8;
+constexpr uint32_t kSystemId = 1000;
// clang-format off
const GLfloat kVertices[] = {
// Determine if ths frame should be shown or hidden.
ViewMode CalculateVisibilityFromLayerConfig(const HwcCallback::Frame& frame,
- uint32_t *appid) {
+ uint32_t* appid) {
auto& layers = frame.layers();
- // TODO(achaulk): Figure out how to identify the current VR app for 2D app
- // detection.
-
size_t index;
// Skip all layers that we don't know about.
for (index = 0; index < layers.size(); index++) {
return ViewMode::Hidden;
}
- if(layers[index].appid != *appid) {
+ if (layers[index].appid != *appid) {
*appid = layers[index].appid;
return ViewMode::App;
}
}
base::unique_fd DisplayView::OnFrame(std::unique_ptr<HwcCallback::Frame> frame,
- bool debug_mode, bool* showing) {
+ bool debug_mode, bool is_vr_active,
+ bool* showing) {
uint32_t app = current_vr_app_;
ViewMode visibility = CalculateVisibilityFromLayerConfig(*frame.get(), &app);
} else if (visibility == ViewMode::App) {
// This is either a VR app switch or a 2D app launching.
// If we can have VR apps, update if it's 0.
- if (!always_2d_ && (current_vr_app_ == 0 || !use_2dmode_)) {
+ if (!always_2d_ && is_vr_active && !use_2dmode_ && app != kSystemId) {
visibility = ViewMode::Hidden;
current_vr_app_ = app;
}
// Calls to these 3 functions must be synchronized.
base::unique_fd OnFrame(std::unique_ptr<HwcCallback::Frame> frame,
- bool debug_mode, bool* showing);
+ bool debug_mode, bool is_vr_active, bool* showing);
void AdvanceFrame();
void UpdateReleaseFence();
#include <GLES3/gl3.h>
#include <android/input.h>
#include <binder/IServiceManager.h>
+#include <dvr/graphics.h>
#include <hardware/hwcomposer2.h>
#include <inttypes.h>
#include <log/log.h>
if (!surface_flinger_view_->Initialize(this))
return 1;
+ // This is a temporary fix for now. These APIs will be changed when everything
+ // is moved into vrcore.
+ display_client_ = DisplayClient::Create();
+
return 0;
}
bool showing = false;
- base::unique_fd fd(display->OnFrame(std::move(frame), debug_mode_, &showing));
+ // TODO(achaulk): change when moved into vrcore.
+ bool vr_running = display_client_->IsVrAppRunning();
+
+ base::unique_fd fd(
+ display->OnFrame(std::move(frame), debug_mode_, vr_running, &showing));
if (showing)
QueueTask(MainThreadTask::Show);
#define VR_WINDOW_MANAGER_SHELL_VIEW_H_
#include <dvr/virtual_touchpad_client.h>
+#include <private/dvr/display_client.h>
#include <private/dvr/graphics/mesh.h>
#include <private/dvr/graphics/shader_program.h>
std::unique_ptr<SurfaceFlingerView> surface_flinger_view_;
std::unique_ptr<Reticle> reticle_;
+ std::unique_ptr<DisplayClient> display_client_;
+
struct DvrVirtualTouchpadDeleter {
void operator()(DvrVirtualTouchpad* p) {
dvrVirtualTouchpadDetach(p);