| 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/css/StylePropertySet.h" | 7 #include "core/css/StylePropertySet.h" |
| 8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 9 #include "core/dom/FrameRequestCallback.h" | 9 #include "core/dom/FrameRequestCallback.h" |
| 10 #include "core/dom/ScriptedAnimationController.h" | 10 #include "core/dom/ScriptedAnimationController.h" |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 (layer_.rightBounds().size() != 0 && layer_.rightBounds().size() != 4)) { | 374 (layer_.rightBounds().size() != 0 && layer_.rightBounds().size() != 4)) { |
| 375 ForceExitPresent(); | 375 ForceExitPresent(); |
| 376 DOMException* exception = DOMException::Create( | 376 DOMException* exception = DOMException::Create( |
| 377 kInvalidStateError, | 377 kInvalidStateError, |
| 378 "Layer bounds must either be an empty array or have 4 values"); | 378 "Layer bounds must either be an empty array or have 4 values"); |
| 379 resolver->Reject(exception); | 379 resolver->Reject(exception); |
| 380 ReportPresentationResult(PresentationResult::kInvalidLayerBounds); | 380 ReportPresentationResult(PresentationResult::kInvalidLayerBounds); |
| 381 return promise; | 381 return promise; |
| 382 } | 382 } |
| 383 | 383 |
| 384 for (float value : layer_.leftBounds()) { |
| 385 if (std::isnan(value)) { |
| 386 ForceExitPresent(); |
| 387 DOMException* exception = DOMException::Create( |
| 388 kInvalidStateError, "Layer bounds must not contain NAN values"); |
| 389 resolver->Reject(exception); |
| 390 ReportPresentationResult(PresentationResult::kInvalidLayerBounds); |
| 391 return promise; |
| 392 } |
| 393 } |
| 394 |
| 395 for (float value : layer_.rightBounds()) { |
| 396 if (std::isnan(value)) { |
| 397 ForceExitPresent(); |
| 398 DOMException* exception = DOMException::Create( |
| 399 kInvalidStateError, "Layer bounds must not contain NAN values"); |
| 400 resolver->Reject(exception); |
| 401 ReportPresentationResult(PresentationResult::kInvalidLayerBounds); |
| 402 return promise; |
| 403 } |
| 404 } |
| 405 |
| 384 if (!pending_present_resolvers_.IsEmpty()) { | 406 if (!pending_present_resolvers_.IsEmpty()) { |
| 385 // If we are waiting on the results of a previous requestPresent call don't | 407 // If we are waiting on the results of a previous requestPresent call don't |
| 386 // fire a new request, just cache the resolver and resolve it when the | 408 // fire a new request, just cache the resolver and resolve it when the |
| 387 // original request returns. | 409 // original request returns. |
| 388 pending_present_resolvers_.push_back(resolver); | 410 pending_present_resolvers_.push_back(resolver); |
| 389 } else if (first_present) { | 411 } else if (first_present) { |
| 390 bool secure_context = | 412 bool secure_context = |
| 391 ExecutionContext::From(script_state)->IsSecureContext(); | 413 ExecutionContext::From(script_state)->IsSecureContext(); |
| 392 if (!display_) { | 414 if (!display_) { |
| 393 ForceExitPresent(); | 415 ForceExitPresent(); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 | 725 |
| 704 pending_previous_frame_render_ = true; | 726 pending_previous_frame_render_ = true; |
| 705 pending_submit_frame_ = true; | 727 pending_submit_frame_ = true; |
| 706 | 728 |
| 707 TRACE_EVENT_BEGIN0("gpu", "VRDisplay::SubmitFrame"); | 729 TRACE_EVENT_BEGIN0("gpu", "VRDisplay::SubmitFrame"); |
| 708 vr_presentation_provider_->SubmitFrame( | 730 vr_presentation_provider_->SubmitFrame( |
| 709 vr_frame_id_, gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D)); | 731 vr_frame_id_, gpu::MailboxHolder(mailbox, sync_token, GL_TEXTURE_2D)); |
| 710 TRACE_EVENT_END0("gpu", "VRDisplay::SubmitFrame"); | 732 TRACE_EVENT_END0("gpu", "VRDisplay::SubmitFrame"); |
| 711 | 733 |
| 712 did_submit_this_frame_ = true; | 734 did_submit_this_frame_ = true; |
| 735 // Reset our frame id, since anything we'd want to do (resizing/etc) can |
| 736 // no-longer happen to this frame. |
| 737 vr_frame_id_ = -1; |
| 713 // If we were deferring a rAF-triggered vsync request, do this now. | 738 // If we were deferring a rAF-triggered vsync request, do this now. |
| 714 RequestVSync(); | 739 RequestVSync(); |
| 715 | 740 |
| 716 // If preserveDrawingBuffer is false, must clear now. Normally this | 741 // If preserveDrawingBuffer is false, must clear now. Normally this |
| 717 // happens as part of compositing, but that's not active while | 742 // happens as part of compositing, but that's not active while |
| 718 // presenting, so run the responsible code directly. | 743 // presenting, so run the responsible code directly. |
| 719 rendering_context_->MarkCompositedAndClearBackbufferIfNeeded(); | 744 rendering_context_->MarkCompositedAndClearBackbufferIfNeeded(); |
| 720 } | 745 } |
| 721 | 746 |
| 722 void VRDisplay::OnSubmitFrameTransferred() { | 747 void VRDisplay::OnSubmitFrameTransferred() { |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 visitor->Trace(stage_parameters_); | 1019 visitor->Trace(stage_parameters_); |
| 995 visitor->Trace(eye_parameters_left_); | 1020 visitor->Trace(eye_parameters_left_); |
| 996 visitor->Trace(eye_parameters_right_); | 1021 visitor->Trace(eye_parameters_right_); |
| 997 visitor->Trace(layer_); | 1022 visitor->Trace(layer_); |
| 998 visitor->Trace(rendering_context_); | 1023 visitor->Trace(rendering_context_); |
| 999 visitor->Trace(scripted_animation_controller_); | 1024 visitor->Trace(scripted_animation_controller_); |
| 1000 visitor->Trace(pending_present_resolvers_); | 1025 visitor->Trace(pending_present_resolvers_); |
| 1001 } | 1026 } |
| 1002 | 1027 |
| 1003 } // namespace blink | 1028 } // namespace blink |
| OLD | NEW |