Chromium Code Reviews| OLD | NEW |
|---|---|
| 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.h" | 5 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "chrome/browser/android/vr_shell/ui_elements.h" | 8 #include "chrome/browser/android/vr_shell/ui_elements.h" |
| 9 #include "chrome/browser/android/vr_shell/ui_interface.h" | 9 #include "chrome/browser/android/vr_shell/ui_interface.h" |
| 10 #include "chrome/browser/android/vr_shell/ui_scene.h" | 10 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 mouse_event.x = x; | 134 mouse_event.x = x; |
| 135 mouse_event.y = y; | 135 mouse_event.y = y; |
| 136 mouse_event.windowX = x; | 136 mouse_event.windowX = x; |
| 137 mouse_event.windowY = y; | 137 mouse_event.windowY = y; |
| 138 mouse_event.timeStampSeconds = timestamp; | 138 mouse_event.timeStampSeconds = timestamp; |
| 139 mouse_event.clickCount = 1; | 139 mouse_event.clickCount = 1; |
| 140 mouse_event.modifiers = 0; | 140 mouse_event.modifiers = 0; |
| 141 | 141 |
| 142 return mouse_event; | 142 return mouse_event; |
| 143 } | 143 } |
| 144 | |
| 145 } // namespace | 144 } // namespace |
| 146 | 145 |
| 147 namespace vr_shell { | 146 namespace vr_shell { |
| 148 | 147 |
| 149 VrShell::VrShell(JNIEnv* env, | 148 VrShell::VrShell(JNIEnv* env, |
| 150 jobject obj, | 149 jobject obj, |
| 151 content::WebContents* main_contents, | 150 content::WebContents* main_contents, |
| 152 ui::WindowAndroid* content_window, | 151 ui::WindowAndroid* content_window, |
| 153 content::WebContents* ui_contents, | 152 content::WebContents* ui_contents, |
| 154 ui::WindowAndroid* ui_window, | 153 ui::WindowAndroid* ui_window, |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 } | 206 } |
| 208 g_instance = nullptr; | 207 g_instance = nullptr; |
| 209 gl::init::ClearGLBindings(); | 208 gl::init::ClearGLBindings(); |
| 210 } | 209 } |
| 211 | 210 |
| 212 void VrShell::SetDelegate(JNIEnv* env, | 211 void VrShell::SetDelegate(JNIEnv* env, |
| 213 const base::android::JavaParamRef<jobject>& obj, | 212 const base::android::JavaParamRef<jobject>& obj, |
| 214 const base::android::JavaParamRef<jobject>& delegate) { | 213 const base::android::JavaParamRef<jobject>& delegate) { |
| 215 base::AutoLock lock(gvr_init_lock_); | 214 base::AutoLock lock(gvr_init_lock_); |
| 216 delegate_ = VrShellDelegate::GetNativeDelegate(env, delegate); | 215 delegate_ = VrShellDelegate::GetNativeDelegate(env, delegate); |
| 217 if (gvr_api_) { | 216 if (swap_chain_.get()) { |
| 218 main_thread_task_runner_->PostTask( | 217 main_thread_task_runner_->PostTask( |
| 219 FROM_HERE, base::Bind(&device::GvrDeviceProvider::OnGvrDelegateReady, | 218 FROM_HERE, base::Bind(&device::GvrDeviceProvider::OnGvrDelegateReady, |
| 220 delegate_->GetDeviceProvider(), | 219 delegate_->GetDeviceProvider(), |
| 221 weak_ptr_factory_.GetWeakPtr())); | 220 weak_ptr_factory_.GetWeakPtr())); |
| 222 } | 221 } |
| 223 } | 222 } |
| 224 | 223 |
| 225 enum class ViewerType { | 224 enum class ViewerType { |
| 226 UNKNOWN_TYPE = 0, | 225 UNKNOWN_TYPE = 0, |
| 227 CARDBOARD = 1, | 226 CARDBOARD = 1, |
| 228 DAYDREAM = 2, | 227 DAYDREAM = 2, |
| 229 VIEWER_TYPE_MAX, | 228 VIEWER_TYPE_MAX, |
| 230 }; | 229 }; |
| 231 | 230 |
| 232 void VrShell::GvrInit(JNIEnv* env, | 231 void VrShell::GvrInit(JNIEnv* env, |
| 233 const JavaParamRef<jobject>& obj, | 232 const JavaParamRef<jobject>& obj, |
| 234 jlong native_gvr_api) { | 233 jlong native_gvr_api) { |
| 235 base::AutoLock lock(gvr_init_lock_); | |
| 236 | |
| 237 // set the initial webvr state | 234 // set the initial webvr state |
| 238 metrics_helper_->SetVRActive(true); | 235 metrics_helper_->SetVRActive(true); |
| 239 | 236 |
| 240 gvr_api_ = | 237 gvr_api_ = |
| 241 gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(native_gvr_api)); | 238 gvr::GvrApi::WrapNonOwned(reinterpret_cast<gvr_context*>(native_gvr_api)); |
| 242 // TODO(klausw,crbug.com/655722): should report OnGvrDelegateReady here once | 239 // TODO(klausw,crbug.com/655722): should report OnGvrDelegateReady here once |
| 243 // we switch to using a WebVR render surface. We currently need to wait for | 240 // we switch to using a WebVR render surface. We currently need to wait for |
| 244 // the compositor window's size to be known first. See also | 241 // the compositor window's size to be known first. See also |
| 245 // ContentSurfaceChanged. | 242 // ContentSurfaceChanged. |
| 246 controller_.reset( | 243 controller_.reset( |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 262 break; | 259 break; |
| 263 } | 260 } |
| 264 UMA_HISTOGRAM_ENUMERATION("VRViewerType", static_cast<int>(viewerType), | 261 UMA_HISTOGRAM_ENUMERATION("VRViewerType", static_cast<int>(viewerType), |
| 265 static_cast<int>(ViewerType::VIEWER_TYPE_MAX)); | 262 static_cast<int>(ViewerType::VIEWER_TYPE_MAX)); |
| 266 } | 263 } |
| 267 | 264 |
| 268 void VrShell::InitializeGl(JNIEnv* env, | 265 void VrShell::InitializeGl(JNIEnv* env, |
| 269 const JavaParamRef<jobject>& obj, | 266 const JavaParamRef<jobject>& obj, |
| 270 jint content_texture_handle, | 267 jint content_texture_handle, |
| 271 jint ui_texture_handle) { | 268 jint ui_texture_handle) { |
| 269 base::AutoLock lock(gvr_init_lock_); | |
| 272 CHECK(gl::GetGLImplementation() != gl::kGLImplementationNone || | 270 CHECK(gl::GetGLImplementation() != gl::kGLImplementationNone || |
| 273 gl::init::InitializeGLOneOff()); | 271 gl::init::InitializeGLOneOff()); |
| 274 | 272 |
| 275 content_texture_id_ = content_texture_handle; | 273 content_texture_id_ = content_texture_handle; |
| 276 ui_texture_id_ = ui_texture_handle; | 274 ui_texture_id_ = ui_texture_handle; |
| 277 | 275 |
| 278 // While WebVR is going through the compositor path, it shares | 276 // While WebVR is going through the compositor path, it shares |
| 279 // the same texture ID. This will change once it gets its own | 277 // the same texture ID. This will change once it gets its own |
| 280 // surface, but store it separately to avoid future confusion. | 278 // surface, but store it separately to avoid future confusion. |
| 281 // TODO(klausw,crbug.com/655722): remove this. | 279 // TODO(klausw,crbug.com/655722): remove this. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 337 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); | 335 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); |
| 338 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE, | 336 buffer_viewport_list_->GetBufferViewport(GVR_LEFT_EYE, |
| 339 webvr_left_viewport_.get()); | 337 webvr_left_viewport_.get()); |
| 340 webvr_left_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); | 338 webvr_left_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); |
| 341 | 339 |
| 342 webvr_right_viewport_.reset( | 340 webvr_right_viewport_.reset( |
| 343 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); | 341 new gvr::BufferViewport(gvr_api_->CreateBufferViewport())); |
| 344 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, | 342 buffer_viewport_list_->GetBufferViewport(GVR_RIGHT_EYE, |
| 345 webvr_right_viewport_.get()); | 343 webvr_right_viewport_.get()); |
| 346 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); | 344 webvr_right_viewport_->SetSourceBufferIndex(kFramePrimaryBuffer); |
| 345 | |
| 346 if (delegate_) { | |
| 347 main_thread_task_runner_->PostTask( | |
| 348 FROM_HERE, base::Bind(&device::GvrDeviceProvider::OnGvrDelegateReady, | |
| 349 delegate_->GetDeviceProvider(), | |
| 350 weak_ptr_factory_.GetWeakPtr())); | |
| 351 } | |
| 347 } | 352 } |
| 348 | 353 |
| 349 void VrShell::UpdateController(const gvr::Vec3f& forward_vector) { | 354 void VrShell::UpdateController(const gvr::Vec3f& forward_vector) { |
| 350 controller_->UpdateState(); | 355 controller_->UpdateState(); |
| 351 | 356 |
| 352 #if defined(ENABLE_VR_SHELL) | 357 #if defined(ENABLE_VR_SHELL) |
| 353 // Note that button up/down state is transient, so IsButtonUp only returns | 358 // Note that button up/down state is transient, so IsButtonUp only returns |
| 354 // true for a single frame (and we're guaranteed not to miss it). | 359 // true for a single frame (and we're guaranteed not to miss it). |
| 355 if (controller_->IsButtonUp( | 360 if (controller_->IsButtonUp( |
| 356 gvr::ControllerButton::GVR_CONTROLLER_BUTTON_APP)) { | 361 gvr::ControllerButton::GVR_CONTROLLER_BUTTON_APP)) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 if (distance_to_plane > 0 && distance_to_plane < closest_element_distance) { | 460 if (distance_to_plane > 0 && distance_to_plane < closest_element_distance) { |
| 456 float x = rect_2d_point.x + 0.5f; | 461 float x = rect_2d_point.x + 0.5f; |
| 457 float y = 0.5f - rect_2d_point.y; | 462 float y = 0.5f - rect_2d_point.y; |
| 458 bool is_inside = x >= 0.0f && x < 1.0f && y >= 0.0f && y < 1.0f; | 463 bool is_inside = x >= 0.0f && x < 1.0f && y >= 0.0f && y < 1.0f; |
| 459 if (!is_inside) | 464 if (!is_inside) |
| 460 continue; | 465 continue; |
| 461 | 466 |
| 462 closest_element_distance = distance_to_plane; | 467 closest_element_distance = distance_to_plane; |
| 463 Rectf pixel_rect; | 468 Rectf pixel_rect; |
| 464 if (plane->content_quad) { | 469 if (plane->content_quad) { |
| 465 pixel_rect = {0, 0, content_tex_width_, content_tex_height_}; | 470 pixel_rect = {0, 0, content_tex_css_width_, content_tex_css_height_}; |
| 466 } else { | 471 } else { |
| 467 pixel_rect = {plane->copy_rect.x, plane->copy_rect.y, | 472 pixel_rect = {plane->copy_rect.x, plane->copy_rect.y, |
| 468 plane->copy_rect.width, plane->copy_rect.height}; | 473 plane->copy_rect.width, plane->copy_rect.height}; |
| 469 } | 474 } |
| 470 pixel_x = pixel_rect.width * x + pixel_rect.x; | 475 pixel_x = pixel_rect.width * x + pixel_rect.x; |
| 471 pixel_y = pixel_rect.height * y + pixel_rect.y; | 476 pixel_y = pixel_rect.height * y + pixel_rect.y; |
| 472 | 477 |
| 473 target_point_ = plane_intersection_point; | 478 target_point_ = plane_intersection_point; |
| 474 target_element_ = plane.get(); | 479 target_element_ = plane.get(); |
| 475 input_target = plane->content_quad ? content_input_manager_.get() | 480 input_target = plane->content_quad ? content_input_manager_.get() |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 render_size_primary_webvr_.width = width; | 698 render_size_primary_webvr_.width = width; |
| 694 render_size_primary_webvr_.height = height; | 699 render_size_primary_webvr_.height = height; |
| 695 // TODO(klausw,crbug.com/655722): set the WebVR render surface size here once | 700 // TODO(klausw,crbug.com/655722): set the WebVR render surface size here once |
| 696 // we have that. | 701 // we have that. |
| 697 } | 702 } |
| 698 | 703 |
| 699 gvr::Sizei VrShell::GetWebVRCompositorSurfaceSize() { | 704 gvr::Sizei VrShell::GetWebVRCompositorSurfaceSize() { |
| 700 // This is a stopgap while we're using the WebVR compositor rendering path. | 705 // This is a stopgap while we're using the WebVR compositor rendering path. |
| 701 // TODO(klausw,crbug.com/655722): Remove this method and member once we're | 706 // TODO(klausw,crbug.com/655722): Remove this method and member once we're |
| 702 // using a separate WebVR render surface. | 707 // using a separate WebVR render surface. |
| 703 return content_tex_pixels_for_webvr_; | 708 return content_tex_physical_size_; |
| 704 } | 709 } |
| 705 | 710 |
| 706 | 711 |
| 707 void VrShell::DrawUiView(const gvr::Mat4f* head_pose, | 712 void VrShell::DrawUiView(const gvr::Mat4f* head_pose, |
| 708 const std::vector<const ContentRectangle*>& elements, | 713 const std::vector<const ContentRectangle*>& elements, |
| 709 const gvr::Sizei& render_size, int viewport_offset) { | 714 const gvr::Sizei& render_size, int viewport_offset) { |
| 710 TRACE_EVENT0("gpu", "VrShell::DrawUiView"); | 715 TRACE_EVENT0("gpu", "VrShell::DrawUiView"); |
| 711 for (auto eye : {GVR_LEFT_EYE, GVR_RIGHT_EYE}) { | 716 for (auto eye : {GVR_LEFT_EYE, GVR_RIGHT_EYE}) { |
| 712 buffer_viewport_list_->GetBufferViewport( | 717 buffer_viewport_list_->GetBufferViewport( |
| 713 eye + viewport_offset, buffer_viewport_.get()); | 718 eye + viewport_offset, buffer_viewport_.get()); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 739 void VrShell::DrawElements( | 744 void VrShell::DrawElements( |
| 740 const gvr::Mat4f& render_matrix, | 745 const gvr::Mat4f& render_matrix, |
| 741 const std::vector<const ContentRectangle*>& elements) { | 746 const std::vector<const ContentRectangle*>& elements) { |
| 742 for (const auto& rect : elements) { | 747 for (const auto& rect : elements) { |
| 743 Rectf copy_rect; | 748 Rectf copy_rect; |
| 744 jint texture_handle; | 749 jint texture_handle; |
| 745 if (rect->content_quad) { | 750 if (rect->content_quad) { |
| 746 copy_rect = {0, 0, 1, 1}; | 751 copy_rect = {0, 0, 1, 1}; |
| 747 texture_handle = content_texture_id_; | 752 texture_handle = content_texture_id_; |
| 748 } else { | 753 } else { |
| 749 copy_rect.x = static_cast<float>(rect->copy_rect.x) / ui_tex_width_; | 754 copy_rect.x = static_cast<float>(rect->copy_rect.x) / ui_tex_css_width_; |
| 750 copy_rect.y = static_cast<float>(rect->copy_rect.y) / ui_tex_height_; | 755 copy_rect.y = static_cast<float>(rect->copy_rect.y) / ui_tex_css_height_; |
| 751 copy_rect.width = static_cast<float>(rect->copy_rect.width) / | 756 copy_rect.width = static_cast<float>(rect->copy_rect.width) / |
| 752 ui_tex_width_; | 757 ui_tex_css_width_; |
| 753 copy_rect.height = static_cast<float>(rect->copy_rect.height) / | 758 copy_rect.height = static_cast<float>(rect->copy_rect.height) / |
| 754 ui_tex_height_; | 759 ui_tex_css_height_; |
| 755 texture_handle = ui_texture_id_; | 760 texture_handle = ui_texture_id_; |
| 756 } | 761 } |
| 757 gvr::Mat4f transform = MatrixMul(render_matrix, rect->transform.to_world); | 762 gvr::Mat4f transform = MatrixMul(render_matrix, rect->transform.to_world); |
| 758 vr_shell_renderer_->GetTexturedQuadRenderer()->Draw( | 763 vr_shell_renderer_->GetTexturedQuadRenderer()->Draw( |
| 759 texture_handle, transform, copy_rect); | 764 texture_handle, transform, copy_rect); |
| 760 } | 765 } |
| 761 } | 766 } |
| 762 | 767 |
| 763 void VrShell::DrawCursor(const gvr::Mat4f& render_matrix) { | 768 void VrShell::DrawCursor(const gvr::Mat4f& render_matrix) { |
| 764 gvr::Mat4f mat; | 769 gvr::Mat4f mat; |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 915 void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, | 920 void VrShell::UpdateWebVRTextureBounds(const gvr::Rectf& left_bounds, |
| 916 const gvr::Rectf& right_bounds) { | 921 const gvr::Rectf& right_bounds) { |
| 917 webvr_left_viewport_->SetSourceUv(left_bounds); | 922 webvr_left_viewport_->SetSourceUv(left_bounds); |
| 918 webvr_right_viewport_->SetSourceUv(right_bounds); | 923 webvr_right_viewport_->SetSourceUv(right_bounds); |
| 919 } | 924 } |
| 920 | 925 |
| 921 gvr::GvrApi* VrShell::gvr_api() { | 926 gvr::GvrApi* VrShell::gvr_api() { |
| 922 return gvr_api_.get(); | 927 return gvr_api_.get(); |
| 923 } | 928 } |
| 924 | 929 |
| 925 void VrShell::ContentSurfaceChanged(JNIEnv* env, | 930 void VrShell::SurfacesChanged(JNIEnv* env, |
| 926 const JavaParamRef<jobject>& object, | 931 const JavaParamRef<jobject>& object, |
| 927 jint width, | 932 const JavaParamRef<jobject>& content_surface, |
| 928 jint height, | 933 const JavaParamRef<jobject>& ui_surface) { |
| 929 const JavaParamRef<jobject>& surface) { | 934 content_compositor_->SurfaceChanged(content_surface); |
| 930 TRACE_EVENT0("gpu", "VrShell::ContentSurfaceChanged"); | 935 ui_compositor_->SurfaceChanged(ui_surface); |
| 931 // If we have a delegate, must trigger "ready" callback one time only. | |
| 932 // Do so the first time we got a nonzero size. (This assumes it doesn't | |
| 933 // change, but once we get resize ability we'll no longer need this hack.) | |
| 934 // TODO(klausw,crbug.com/655722): remove when we have surface support. | |
| 935 bool delegate_not_ready = delegate_ && !content_tex_pixels_for_webvr_.width; | |
| 936 | |
| 937 content_compositor_->SurfaceChanged((int)width, (int)height, surface); | |
| 938 content_tex_pixels_for_webvr_.width = width; | |
| 939 content_tex_pixels_for_webvr_.height = height; | |
| 940 float scale_factor = display::Screen::GetScreen() | |
| 941 ->GetPrimaryDisplay().device_scale_factor(); | |
| 942 content_tex_width_ = width / scale_factor; | |
| 943 content_tex_height_ = height / scale_factor; | |
| 944 | |
| 945 // TODO(klausw,crbug.com/655722): move this back to GvrInit once we have | |
| 946 // our own WebVR surface. | |
| 947 if (delegate_ && delegate_not_ready) { | |
| 948 main_thread_task_runner_->PostTask( | |
| 949 FROM_HERE, base::Bind(&device::GvrDeviceProvider::OnGvrDelegateReady, | |
| 950 delegate_->GetDeviceProvider(), | |
| 951 weak_ptr_factory_.GetWeakPtr())); | |
| 952 } | |
| 953 } | 936 } |
| 954 | 937 |
| 955 void VrShell::UiSurfaceChanged(JNIEnv* env, | 938 void VrShell::ContentBoundsChanged(JNIEnv* env, |
| 956 const JavaParamRef<jobject>& object, | 939 const JavaParamRef<jobject>& object, |
| 957 jint width, | 940 jint width, jint height, jfloat dpr) { |
| 958 jint height, | 941 TRACE_EVENT0("gpu", "VrShell::ContentBoundsChanged"); |
| 959 const JavaParamRef<jobject>& surface) { | 942 content_tex_physical_size_.width = width; |
| 960 ui_compositor_->SurfaceChanged((int)width, (int)height, surface); | 943 content_tex_physical_size_.height = height; |
| 961 float scale_factor = display::Screen::GetScreen() | 944 content_tex_css_width_ = width / dpr; |
| 962 ->GetPrimaryDisplay().device_scale_factor(); | 945 content_tex_css_height_ = height / dpr; |
| 963 ui_tex_width_ = width / scale_factor; | 946 |
| 964 ui_tex_height_ = height / scale_factor; | 947 content_compositor_->SetWindowBounds(width, height); |
| 948 main_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost() | |
| 949 ->WasResized(); | |
| 950 } | |
| 951 | |
| 952 void VrShell::UIBoundsChanged(JNIEnv* env, | |
| 953 const JavaParamRef<jobject>& object, | |
| 954 jint width, jint height, jfloat dpr) { | |
| 955 // TODO(mthiesse): Synchronize these values changing with the renderer | |
| 956 // actually sending us a texture with the updated size somehow. | |
|
bshe
2016/11/30 23:00:46
This TODO is confusing. Do you mean you want to sy
mthiesse
2016/11/30 23:25:05
Moved into MainFrameWasResized, and updated the co
| |
| 957 ui_tex_css_width_ = width / dpr; | |
| 958 ui_tex_css_height_ = height / dpr; | |
| 959 | |
| 960 ui_compositor_->SetWindowBounds(width, height); | |
| 961 ui_contents_->GetRenderWidgetHostView()->GetRenderWidgetHost()->WasResized(); | |
| 965 } | 962 } |
| 966 | 963 |
| 967 UiScene* VrShell::GetScene() { | 964 UiScene* VrShell::GetScene() { |
| 968 return scene_.get(); | 965 return scene_.get(); |
| 969 } | 966 } |
| 970 | 967 |
| 971 UiInterface* VrShell::GetUiInterface() { | 968 UiInterface* VrShell::GetUiInterface() { |
| 972 return html_interface_.get(); | 969 return html_interface_.get(); |
| 973 } | 970 } |
| 974 | 971 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1021 default: | 1018 default: |
| 1022 NOTREACHED(); | 1019 NOTREACHED(); |
| 1023 } | 1020 } |
| 1024 } | 1021 } |
| 1025 | 1022 |
| 1026 void VrShell::RenderViewHostChanged(content::RenderViewHost* old_host, | 1023 void VrShell::RenderViewHostChanged(content::RenderViewHost* old_host, |
| 1027 content::RenderViewHost* new_host) { | 1024 content::RenderViewHost* new_host) { |
| 1028 new_host->GetWidget()->GetView()->SetBackgroundColor(SK_ColorTRANSPARENT); | 1025 new_host->GetWidget()->GetView()->SetBackgroundColor(SK_ColorTRANSPARENT); |
| 1029 } | 1026 } |
| 1030 | 1027 |
| 1028 void VrShell::SetContentCssSize(float width, float height, float dpr) { | |
| 1029 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 1030 Java_VrShellImpl_setContentCssSize(env, j_vr_shell_.obj(), width, height, | |
| 1031 dpr); | |
| 1032 } | |
| 1033 | |
| 1034 void VrShell::SetUiCssSize(float width, float height, float dpr) { | |
| 1035 JNIEnv* env = base::android::AttachCurrentThread(); | |
| 1036 Java_VrShellImpl_setUiCssSize(env, j_vr_shell_.obj(), width, height, dpr); | |
| 1037 } | |
| 1038 | |
| 1031 // ---------------------------------------------------------------------------- | 1039 // ---------------------------------------------------------------------------- |
| 1032 // Native JNI methods | 1040 // Native JNI methods |
| 1033 // ---------------------------------------------------------------------------- | 1041 // ---------------------------------------------------------------------------- |
| 1034 | 1042 |
| 1035 jlong Init(JNIEnv* env, | 1043 jlong Init(JNIEnv* env, |
| 1036 const JavaParamRef<jobject>& obj, | 1044 const JavaParamRef<jobject>& obj, |
| 1037 const JavaParamRef<jobject>& content_web_contents, | 1045 const JavaParamRef<jobject>& content_web_contents, |
| 1038 jlong content_window_android, | 1046 jlong content_window_android, |
| 1039 const JavaParamRef<jobject>& ui_web_contents, | 1047 const JavaParamRef<jobject>& ui_web_contents, |
| 1040 jlong ui_window_android, | 1048 jlong ui_window_android, |
| 1041 jboolean for_web_vr) { | 1049 jboolean for_web_vr) { |
| 1042 return reinterpret_cast<intptr_t>(new VrShell( | 1050 return reinterpret_cast<intptr_t>(new VrShell( |
| 1043 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), | 1051 env, obj, content::WebContents::FromJavaWebContents(content_web_contents), |
| 1044 reinterpret_cast<ui::WindowAndroid*>(content_window_android), | 1052 reinterpret_cast<ui::WindowAndroid*>(content_window_android), |
| 1045 content::WebContents::FromJavaWebContents(ui_web_contents), | 1053 content::WebContents::FromJavaWebContents(ui_web_contents), |
| 1046 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), | 1054 reinterpret_cast<ui::WindowAndroid*>(ui_window_android), |
| 1047 for_web_vr)); | 1055 for_web_vr)); |
| 1048 } | 1056 } |
| 1049 | 1057 |
| 1050 } // namespace vr_shell | 1058 } // namespace vr_shell |
| OLD | NEW |