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

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

Issue 2775513002: WebVR: match GVR renderbuffer resolution to canvas resolution (Closed)
Patch Set: Rebase, fix Target Ref Created 3 years, 9 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/vr_shell/vr_shell_gl.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.cc b/chrome/browser/android/vr_shell/vr_shell_gl.cc
index ae068e4e7b93bc407e1298cacfd1f800272a4653..b7d91a51b93a88f756fd1bbe3cf557e6b6334253 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
@@ -359,6 +359,7 @@ void VrShellGl::InitializeRenderer() {
// For kFramePrimaryBuffer (primary VrShell and WebVR content)
specs.push_back(gvr_api_->CreateBufferSpec());
render_size_primary_ = specs[kFramePrimaryBuffer].GetSize();
+ render_size_primary_vrshell_ = render_size_primary_;
// For kFrameHeadlockedBuffer (for WebVR insecure content warning).
// Set this up at fixed resolution, the (smaller) FOV gets set below.
@@ -638,6 +639,27 @@ void VrShellGl::DrawFrame() {
// DrawVrShell if needed.
buffer_viewport_list_->SetToRecommendedBufferViewports();
+ // Resize render buffers to match desired resolution when switching
+ // modes between WebVR and VrShell mode.
+ if (web_vr_mode_) {
+ // If needed, resize the primary buffer for use with WebVR so that
+ // it matches the canvas size used for WebGL rendering.
+ if (render_size_primary_ != render_size_primary_webvr_) {
+ if (!render_size_primary_webvr_.width) {
+ DVLOG(2) << "WebVR rendering size not known yet, dropping frame";
+ return;
+ }
+ render_size_primary_ = render_size_primary_webvr_;
+ swap_chain_->ResizeBuffer(kFramePrimaryBuffer, render_size_primary_);
+ }
+ } else {
+ // Restore high resolution for VrShell mode.
+ if (render_size_primary_ != render_size_primary_vrshell_) {
+ render_size_primary_ = render_size_primary_vrshell_;
+ swap_chain_->ResizeBuffer(kFramePrimaryBuffer, render_size_primary_);
+ }
+ }
+
gvr::Frame frame = swap_chain_->AcquireFrame();
if (!frame.is_valid()) {
return;
@@ -1049,6 +1071,8 @@ void VrShellGl::ContentPhysicalBoundsChanged(int width, int height) {
content_surface_texture_->SetDefaultBufferSize(width, height);
content_tex_physical_size_.width = width;
content_tex_physical_size_.height = height;
+ render_size_primary_webvr_.width = width;
+ render_size_primary_webvr_.height = height;
}
void VrShellGl::UIBoundsChanged(int width, int height) {
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698