Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4903)

Unified Diff: chrome/browser/android/vr_shell/vr_shell_gl.h

Issue 2584343002: WIP: working copy-no-compositor path
Patch Set: StatTracker destructor, delete old magic numbers, mojo export Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/vr_shell_gl.h
diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.h b/chrome/browser/android/vr_shell/vr_shell_gl.h
index ae908cb49593e539f93579e4bcf47c5060e4c851..a63b26a0fbcb8374dc1fa66e974b117f366dfa8d 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.h
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.h
@@ -5,6 +5,9 @@
#ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
#define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_GL_H_
+#include <deque>
+#include <iomanip>
+#include <list>
#include <memory>
#include "base/cancelable_callback.h"
@@ -13,6 +16,7 @@
#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "device/vr/android/gvr/gvr_delegate.h"
+#include "gpu/ipc/common/surface_handle.h"
#include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/gvr.h"
#include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/gvr_types.h"
#include "ui/gfx/native_widget_types.h"
@@ -62,7 +66,7 @@ class VrShellGl {
bool Initialize();
- void DrawFrame();
+ void DrawFrame(uint32_t pose_index);
void OnTriggerEvent();
void OnPause();
@@ -75,11 +79,14 @@ class VrShellGl {
void UIPhysicalBoundsChanged(int width, int height);
base::WeakPtr<VrShellGl> GetWeakPtr();
- void UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds,
+ void UpdateWebVRTextureBounds(uint32_t for_pose_index,
+ const gvr::Rectf& left_bounds,
const gvr::Rectf& right_bounds);
+ void SubmitWebVRFrame(int32_t surface_handle, const device::mojom::VRPosePtr& pose);
gvr::GvrApi* gvr_api();
- void SetGvrPoseForWebVr(const gvr::Mat4f& pose, uint32_t pose_num);
- gvr::Sizei GetWebVRCompositorSurfaceSize();
+ void SetWebVRGvrPose(const gvr::Mat4f& pose, uint32_t pose_index,
+ int64_t pose_time_nanos);
+ void GetWebVRSurfaceHandle(int width, int height, const device::mojom::VRDisplay::GetSurfaceHandleCallback& callback);
void UpdateScene(std::unique_ptr<base::ListValue> commands);
@@ -94,7 +101,7 @@ class VrShellGl {
void DrawElements(const gvr::Mat4f& render_matrix,
const std::vector<const ContentRectangle*>& elements);
void DrawCursor(const gvr::Mat4f& render_matrix);
- void DrawWebVr();
+ void DrawWebVr(uint32_t pose_index);
bool WebVrPoseByteIsValid(int pose_index_byte);
void UpdateController(const gvr::Vec3f& forward_vector);
@@ -105,6 +112,8 @@ class VrShellGl {
void OnUIFrameAvailable();
void OnContentFrameAvailable();
+ void OnWebVrFrameAvailable();
+ void SetWebVrSurface();
void UpdateVSyncParameters(const base::TimeTicks timebase,
const base::TimeDelta interval);
@@ -116,6 +125,8 @@ class VrShellGl {
int ui_texture_id_ = 0;
// samplerExternalOES texture data for main content image.
int content_texture_id_ = 0;
+ // samplerExternalOES texture data for WebVR image.
+ int webvr_texture_id_ = 0;
std::unique_ptr<UiScene> scene_;
@@ -123,9 +134,11 @@ class VrShellGl {
scoped_refptr<gl::GLContext> context_;
scoped_refptr<gl::SurfaceTexture> ui_surface_texture_;
scoped_refptr<gl::SurfaceTexture> content_surface_texture_;
+ scoped_refptr<gl::SurfaceTexture> webvr_surface_texture_;
std::unique_ptr<gl::ScopedJavaSurface> ui_surface_;
std::unique_ptr<gl::ScopedJavaSurface> content_surface_;
+ std::unique_ptr<gl::ScopedJavaSurface> webvr_surface_;
std::unique_ptr<gvr::GvrApi> gvr_api_;
std::unique_ptr<gvr::BufferViewportList> buffer_viewport_list_;
@@ -140,6 +153,10 @@ class VrShellGl {
gvr::Sizei render_size_primary_;
gvr::Sizei render_size_headlocked_;
+ // Expected sizes for the primary render buffer by mode.
+ gvr::Sizei render_size_primary_vrshell_;
+ gvr::Sizei render_size_primary_webvr_;
+
std::unique_ptr<VrShellRenderer> vr_shell_renderer_;
bool touch_pending_ = false;
@@ -160,9 +177,21 @@ class VrShellGl {
// current backlog of poses which is 2-3 frames.
static constexpr int kPoseRingBufferSize = 8;
std::vector<gvr::Mat4f> webvr_head_pose_;
- std::vector<bool> webvr_head_pose_valid_;
- int webvr_texture_id_ = 0;
+ std::vector<double> webvr_time_frame_start_;
+ std::vector<double> webvr_time_service_start_;
+ std::vector<double> webvr_time_get_pose_;
+ std::vector<double> webvr_time_got_pose_;
+ std::vector<double> webvr_time_submit_;
+ std::vector<double> webvr_time_surfaced_;
+ std::vector<double> webvr_time_acquired_;
bool web_vr_mode_;
+ gpu::SurfaceHandle webvr_surface_handle_ = 0;
+ uint32_t webvr_last_submitted_ = 0;
+ std::list<uint32_t> webvr_texture_bounds_need_update_at_;
+ std::list<gvr::Rectf> webvr_texture_bounds_left_;
+ std::list<gvr::Rectf> webvr_texture_bounds_right_;
+ std::deque<uint32_t> webvr_pending_poses_;
+ int webvr_already_available_frames_ = 0;
std::unique_ptr<VrController> controller_;

Powered by Google App Engine
This is Rietveld 408576698