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

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: 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
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 <utility> 7 #include <utility>
8 8
9 #include "base/android/jni_android.h" 9 #include "base/android/jni_android.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 ForceExitVr(); 234 ForceExitVr();
235 return; 235 return;
236 } 236 }
237 237
238 unsigned int textures[2]; 238 unsigned int textures[2];
239 glGenTextures(2, textures); 239 glGenTextures(2, textures);
240 ui_texture_id_ = textures[0]; 240 ui_texture_id_ = textures[0];
241 content_texture_id_ = textures[1]; 241 content_texture_id_ = textures[1];
242 ui_surface_texture_ = gl::SurfaceTexture::Create(ui_texture_id_); 242 ui_surface_texture_ = gl::SurfaceTexture::Create(ui_texture_id_);
243 content_surface_texture_ = gl::SurfaceTexture::Create(content_texture_id_); 243 content_surface_texture_ = gl::SurfaceTexture::Create(content_texture_id_);
244 ui_surface_.reset(new gl::ScopedJavaSurface(ui_surface_texture_.get())); 244 CreateUiSurface();
245 content_surface_.reset(new gl::ScopedJavaSurface( 245 CreateContentSurface();
246 content_surface_texture_.get()));
247 ui_surface_texture_->SetFrameAvailableCallback(base::Bind( 246 ui_surface_texture_->SetFrameAvailableCallback(base::Bind(
248 &VrShellGl::OnUIFrameAvailable, weak_ptr_factory_.GetWeakPtr())); 247 &VrShellGl::OnUIFrameAvailable, weak_ptr_factory_.GetWeakPtr()));
249 content_surface_texture_->SetFrameAvailableCallback(base::Bind( 248 content_surface_texture_->SetFrameAvailableCallback(base::Bind(
250 &VrShellGl::OnContentFrameAvailable, weak_ptr_factory_.GetWeakPtr())); 249 &VrShellGl::OnContentFrameAvailable, weak_ptr_factory_.GetWeakPtr()));
251
252 content_surface_texture_->SetDefaultBufferSize( 250 content_surface_texture_->SetDefaultBufferSize(
253 content_tex_physical_size_.width, content_tex_physical_size_.height); 251 content_tex_physical_size_.width, content_tex_physical_size_.height);
254 ui_surface_texture_->SetDefaultBufferSize(ui_tex_physical_size_.width, 252 ui_surface_texture_->SetDefaultBufferSize(ui_tex_physical_size_.width,
255 ui_tex_physical_size_.height); 253 ui_tex_physical_size_.height);
256
257 main_thread_task_runner_->PostTask(FROM_HERE, base::Bind(
258 &VrShell::SurfacesChanged, weak_vr_shell_,
259 content_surface_->j_surface().obj(),
260 ui_surface_->j_surface().obj()));
261
262 InitializeRenderer(); 254 InitializeRenderer();
263 255
264 vsync_task_.Reset(base::Bind(&VrShellGl::OnVSync, base::Unretained(this))); 256 vsync_task_.Reset(base::Bind(&VrShellGl::OnVSync, base::Unretained(this)));
265 OnVSync(); 257 OnVSync();
266 258
267 ready_to_draw_ = true; 259 ready_to_draw_ = true;
268 } 260 }
269 261
262 void VrShellGl::CreateContentSurface() {
263 content_surface_ =
264 base::MakeUnique<gl::ScopedJavaSurface>(content_surface_texture_.get());
265 main_thread_task_runner_->PostTask(
266 FROM_HERE, base::Bind(&VrShell::ContentSurfaceChanged, weak_vr_shell_,
267 content_surface_->j_surface().obj()));
268 }
269
270 void VrShellGl::CreateUiSurface() {
271 ui_surface_ =
272 base::MakeUnique<gl::ScopedJavaSurface>(ui_surface_texture_.get());
273 main_thread_task_runner_->PostTask(
274 FROM_HERE, base::Bind(&VrShell::UiSurfaceChanged, weak_vr_shell_,
275 ui_surface_->j_surface().obj()));
276 }
277
270 void VrShellGl::OnUIFrameAvailable() { 278 void VrShellGl::OnUIFrameAvailable() {
271 ui_surface_texture_->UpdateTexImage(); 279 ui_surface_texture_->UpdateTexImage();
272 } 280 }
273 281
274 void VrShellGl::OnContentFrameAvailable() { 282 void VrShellGl::OnContentFrameAvailable() {
275 content_surface_texture_->UpdateTexImage(); 283 content_surface_texture_->UpdateTexImage();
276 received_frame_ = true; 284 received_frame_ = true;
277 } 285 }
278 286
279 bool VrShellGl::GetPixelEncodedFrameIndex(uint16_t* frame_index) { 287 bool VrShellGl::GetPixelEncodedFrameIndex(uint16_t* frame_index) {
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback, 1091 const base::Callback<void(device::mojom::VRDisplayInfoPtr)>& callback,
1084 uint32_t device_id) { 1092 uint32_t device_id) {
1085 device::mojom::VRDisplayInfoPtr info = VrShell::CreateVRDisplayInfo( 1093 device::mojom::VRDisplayInfoPtr info = VrShell::CreateVRDisplayInfo(
1086 gvr_api_.get(), content_tex_physical_size_, device_id); 1094 gvr_api_.get(), content_tex_physical_size_, device_id);
1087 main_thread_task_runner_->PostTask( 1095 main_thread_task_runner_->PostTask(
1088 FROM_HERE, 1096 FROM_HERE,
1089 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info))); 1097 base::Bind(&RunVRDisplayInfoCallback, callback, base::Passed(&info)));
1090 } 1098 }
1091 1099
1092 } // namespace vr_shell 1100 } // namespace vr_shell
OLDNEW
« chrome/browser/android/vr_shell/vr_shell.cc ('K') | « 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