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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell_gl.cc

Issue 2683953007: Support rendering Android Native Pages in VR Shell. (Closed)
Patch Set: rebase Created 3 years, 10 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/vr_shell/vr_shell_gl.h" 5 #include "chrome/browser/android/vr_shell/vr_shell_gl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 ForceExitVr(); 235 ForceExitVr();
236 return; 236 return;
237 } 237 }
238 238
239 unsigned int textures[2]; 239 unsigned int textures[2];
240 glGenTextures(2, textures); 240 glGenTextures(2, textures);
241 ui_texture_id_ = textures[0]; 241 ui_texture_id_ = textures[0];
242 content_texture_id_ = textures[1]; 242 content_texture_id_ = textures[1];
243 ui_surface_texture_ = gl::SurfaceTexture::Create(ui_texture_id_); 243 ui_surface_texture_ = gl::SurfaceTexture::Create(ui_texture_id_);
244 content_surface_texture_ = gl::SurfaceTexture::Create(content_texture_id_); 244 content_surface_texture_ = gl::SurfaceTexture::Create(content_texture_id_);
245 ui_surface_.reset(new gl::ScopedJavaSurface(ui_surface_texture_.get())); 245 CreateUiSurface();
246 content_surface_.reset(new gl::ScopedJavaSurface( 246 CreateContentSurface();
247 content_surface_texture_.get()));
248 ui_surface_texture_->SetFrameAvailableCallback(base::Bind( 247 ui_surface_texture_->SetFrameAvailableCallback(base::Bind(
249 &VrShellGl::OnUIFrameAvailable, weak_ptr_factory_.GetWeakPtr())); 248 &VrShellGl::OnUIFrameAvailable, weak_ptr_factory_.GetWeakPtr()));
250 content_surface_texture_->SetFrameAvailableCallback(base::Bind( 249 content_surface_texture_->SetFrameAvailableCallback(base::Bind(
251 &VrShellGl::OnContentFrameAvailable, weak_ptr_factory_.GetWeakPtr())); 250 &VrShellGl::OnContentFrameAvailable, weak_ptr_factory_.GetWeakPtr()));
252
253 content_surface_texture_->SetDefaultBufferSize( 251 content_surface_texture_->SetDefaultBufferSize(
254 content_tex_physical_size_.width, content_tex_physical_size_.height); 252 content_tex_physical_size_.width, content_tex_physical_size_.height);
255 ui_surface_texture_->SetDefaultBufferSize(ui_tex_physical_size_.width, 253 ui_surface_texture_->SetDefaultBufferSize(ui_tex_physical_size_.width,
256 ui_tex_physical_size_.height); 254 ui_tex_physical_size_.height);
257
258 main_thread_task_runner_->PostTask(FROM_HERE, base::Bind(
259 &VrShell::SurfacesChanged, weak_vr_shell_,
260 content_surface_->j_surface().obj(),
261 ui_surface_->j_surface().obj()));
262
263 InitializeRenderer(); 255 InitializeRenderer();
264 256
265 vsync_task_.Reset(base::Bind(&VrShellGl::OnVSync, base::Unretained(this))); 257 vsync_task_.Reset(base::Bind(&VrShellGl::OnVSync, base::Unretained(this)));
266 OnVSync(); 258 OnVSync();
267 259
268 ready_to_draw_ = true; 260 ready_to_draw_ = true;
269 } 261 }
270 262
263 void VrShellGl::CreateContentSurface() {
264 content_surface_ =
265 base::MakeUnique<gl::ScopedJavaSurface>(content_surface_texture_.get());
266 main_thread_task_runner_->PostTask(
267 FROM_HERE, base::Bind(&VrShell::ContentSurfaceChanged, weak_vr_shell_,
268 content_surface_->j_surface().obj()));
269 }
270
271 void VrShellGl::CreateUiSurface() {
272 ui_surface_ =
273 base::MakeUnique<gl::ScopedJavaSurface>(ui_surface_texture_.get());
274 main_thread_task_runner_->PostTask(
275 FROM_HERE, base::Bind(&VrShell::UiSurfaceChanged, weak_vr_shell_,
276 ui_surface_->j_surface().obj()));
277 }
278
271 void VrShellGl::OnUIFrameAvailable() { 279 void VrShellGl::OnUIFrameAvailable() {
272 ui_surface_texture_->UpdateTexImage(); 280 ui_surface_texture_->UpdateTexImage();
273 } 281 }
274 282
275 void VrShellGl::OnContentFrameAvailable() { 283 void VrShellGl::OnContentFrameAvailable() {
276 content_surface_texture_->UpdateTexImage(); 284 content_surface_texture_->UpdateTexImage();
277 received_frame_ = true; 285 received_frame_ = true;
278 } 286 }
279 287
280 bool VrShellGl::GetPixelEncodedFrameIndex(uint16_t* frame_index) { 288 bool VrShellGl::GetPixelEncodedFrameIndex(uint16_t* frame_index) {
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, 1092 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback,
1085 uint32_t device_id) { 1093 uint32_t device_id) {
1086 device::mojom::VRDisplayInfoPtr info = VrShell::CreateVRDisplayInfo( 1094 device::mojom::VRDisplayInfoPtr info = VrShell::CreateVRDisplayInfo(
1087 gvr_api_.get(), content_tex_physical_size_, device_id); 1095 gvr_api_.get(), content_tex_physical_size_, device_id);
1088 main_thread_task_runner_->PostTask( 1096 main_thread_task_runner_->PostTask(
1089 FROM_HERE, 1097 FROM_HERE,
1090 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); 1098 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info)));
1091 } 1099 }
1092 1100
1093 } // namespace vr_shell 1101 } // namespace vr_shell
OLDNEW
« 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