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 "modules/vr/VRDisplay.h" | 5 #include "modules/vr/VRDisplay.h" |
6 | 6 |
7 #include "core/dom/DOMException.h" | 7 #include "core/dom/DOMException.h" |
8 #include "core/dom/Fullscreen.h" | 8 #include "core/dom/Fullscreen.h" |
9 #include "core/frame/UseCounter.h" | 9 #include "core/frame/UseCounter.h" |
10 #include "core/inspector/ConsoleMessage.h" | 10 #include "core/inspector/ConsoleMessage.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 CanvasRenderingContext* renderingContext = m_layer.source()->renderingContex
t(); | 205 CanvasRenderingContext* renderingContext = m_layer.source()->renderingContex
t(); |
206 | 206 |
207 if (!renderingContext || !renderingContext->is3d()) { | 207 if (!renderingContext || !renderingContext->is3d()) { |
208 forceExitPresent(); | 208 forceExitPresent(); |
209 DOMException* exception = DOMException::create(InvalidStateError, "Layer
source must have a WebGLRenderingContext"); | 209 DOMException* exception = DOMException::create(InvalidStateError, "Layer
source must have a WebGLRenderingContext"); |
210 resolver->reject(exception); | 210 resolver->reject(exception); |
211 return promise; | 211 return promise; |
212 } | 212 } |
213 | 213 |
| 214 if ((m_layer.leftBounds().size() != 0 && m_layer.leftBounds().size() != 4) |
| 215 || (m_layer.rightBounds().size() != 0 && m_layer.rightBounds().size() !=
4)) { |
| 216 forceExitPresent(); |
| 217 DOMException* exception = DOMException::create(InvalidStateError, "Layer
bounds must either be an empty array or have 4 values"); |
| 218 resolver->reject(exception); |
| 219 return promise; |
| 220 } |
| 221 |
214 if (!m_capabilities->hasExternalDisplay()) { | 222 if (!m_capabilities->hasExternalDisplay()) { |
215 // TODO: Need a proper VR compositor, but for the moment on mobile | 223 // TODO: Need a proper VR compositor, but for the moment on mobile |
216 // we'll just make the canvas fullscreen so that VrShell can pick it | 224 // we'll just make the canvas fullscreen so that VrShell can pick it |
217 // up through the standard (high latency) compositing path. | 225 // up through the standard (high latency) compositing path. |
218 Fullscreen::requestFullscreen(*m_layer.source(), Fullscreen::UnprefixedR
equest); | 226 Fullscreen::requestFullscreen(*m_layer.source(), Fullscreen::UnprefixedR
equest); |
219 | 227 |
220 // Check to see if the canvas is still the current fullscreen | 228 // Check to see if the canvas is still the current fullscreen |
221 // element once per second. | 229 // element once per second. |
222 m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); | 230 m_fullscreenCheckTimer.startRepeating(1.0, BLINK_FROM_HERE); |
223 } | 231 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 296 |
289 m_isPresenting = false; | 297 m_isPresenting = false; |
290 } | 298 } |
291 | 299 |
292 void VRDisplay::updateLayerBounds() | 300 void VRDisplay::updateLayerBounds() |
293 { | 301 { |
294 // Set up the texture bounds for the provided layer | 302 // Set up the texture bounds for the provided layer |
295 device::blink::VRLayerBoundsPtr leftBounds = device::blink::VRLayerBounds::N
ew(); | 303 device::blink::VRLayerBoundsPtr leftBounds = device::blink::VRLayerBounds::N
ew(); |
296 device::blink::VRLayerBoundsPtr rightBounds = device::blink::VRLayerBounds::
New(); | 304 device::blink::VRLayerBoundsPtr rightBounds = device::blink::VRLayerBounds::
New(); |
297 | 305 |
298 if (m_layer.hasLeftBounds()) { | 306 if (m_layer.leftBounds().size() == 4) { |
299 leftBounds->left = m_layer.leftBounds()[0]; | 307 leftBounds->left = m_layer.leftBounds()[0]; |
300 leftBounds->top = m_layer.leftBounds()[1]; | 308 leftBounds->top = m_layer.leftBounds()[1]; |
301 leftBounds->width = m_layer.leftBounds()[2]; | 309 leftBounds->width = m_layer.leftBounds()[2]; |
302 leftBounds->height = m_layer.leftBounds()[3]; | 310 leftBounds->height = m_layer.leftBounds()[3]; |
303 } else { | 311 } else { |
304 // Left eye defaults | 312 // Left eye defaults |
305 leftBounds->left = 0.0f; | 313 leftBounds->left = 0.0f; |
306 leftBounds->top = 0.0f; | 314 leftBounds->top = 0.0f; |
307 leftBounds->width = 0.5f; | 315 leftBounds->width = 0.5f; |
308 leftBounds->height = 1.0f; | 316 leftBounds->height = 1.0f; |
309 } | 317 } |
310 | 318 |
311 if (m_layer.hasRightBounds()) { | 319 if (m_layer.rightBounds().size() == 4) { |
312 rightBounds->left = m_layer.rightBounds()[0]; | 320 rightBounds->left = m_layer.rightBounds()[0]; |
313 rightBounds->top = m_layer.rightBounds()[1]; | 321 rightBounds->top = m_layer.rightBounds()[1]; |
314 rightBounds->width = m_layer.rightBounds()[2]; | 322 rightBounds->width = m_layer.rightBounds()[2]; |
315 rightBounds->height = m_layer.rightBounds()[3]; | 323 rightBounds->height = m_layer.rightBounds()[3]; |
316 } else { | 324 } else { |
317 // Right eye defaults | 325 // Right eye defaults |
318 rightBounds->left = 0.5f; | 326 rightBounds->left = 0.5f; |
319 rightBounds->top = 0.0f; | 327 rightBounds->top = 0.0f; |
320 rightBounds->width = 0.5f; | 328 rightBounds->width = 0.5f; |
321 rightBounds->height = 1.0f; | 329 rightBounds->height = 1.0f; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 { | 368 { |
361 visitor->trace(m_navigatorVR); | 369 visitor->trace(m_navigatorVR); |
362 visitor->trace(m_capabilities); | 370 visitor->trace(m_capabilities); |
363 visitor->trace(m_stageParameters); | 371 visitor->trace(m_stageParameters); |
364 visitor->trace(m_eyeParametersLeft); | 372 visitor->trace(m_eyeParametersLeft); |
365 visitor->trace(m_eyeParametersRight); | 373 visitor->trace(m_eyeParametersRight); |
366 visitor->trace(m_layer); | 374 visitor->trace(m_layer); |
367 } | 375 } |
368 | 376 |
369 } // namespace blink | 377 } // namespace blink |
OLD | NEW |