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

Side by Side Diff: third_party/WebKit/Source/modules/vr/VRController.cpp

Issue 2668003003: Provide WebVR pose data only to the focused frame. (Closed)
Patch Set: Update to correct copyright notice? 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/VRController.h" 5 #include "modules/vr/VRController.h"
6 6
7 #include "bindings/core/v8/ScriptPromiseResolver.h" 7 #include "bindings/core/v8/ScriptPromiseResolver.h"
8 #include "core/dom/DOMException.h" 8 #include "core/dom/DOMException.h"
9 #include "core/dom/Document.h" 9 #include "core/dom/Document.h"
10 #include "core/frame/LocalFrame.h" 10 #include "core/frame/LocalFrame.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // here. Upon calling SetClient in the constructor we should receive one call 57 // here. Upon calling SetClient in the constructor we should receive one call
58 // for each VRDisplay that was already connected at the time. 58 // for each VRDisplay that was already connected at the time.
59 void VRController::OnDisplayConnected( 59 void VRController::OnDisplayConnected(
60 device::mojom::blink::VRDisplayPtr display, 60 device::mojom::blink::VRDisplayPtr display,
61 device::mojom::blink::VRDisplayClientRequest request, 61 device::mojom::blink::VRDisplayClientRequest request,
62 device::mojom::blink::VRDisplayInfoPtr displayInfo) { 62 device::mojom::blink::VRDisplayInfoPtr displayInfo) {
63 VRDisplay* vrDisplay = 63 VRDisplay* vrDisplay =
64 new VRDisplay(m_navigatorVR, std::move(display), std::move(request)); 64 new VRDisplay(m_navigatorVR, std::move(display), std::move(request));
65 vrDisplay->update(displayInfo); 65 vrDisplay->update(displayInfo);
66 vrDisplay->onConnected(); 66 vrDisplay->onConnected();
67 vrDisplay->focusChanged(m_focused);
67 m_displays.push_back(vrDisplay); 68 m_displays.push_back(vrDisplay);
68 69
69 if (m_displays.size() == m_numberOfSyncedDisplays) { 70 if (m_displays.size() == m_numberOfSyncedDisplays) {
70 m_displaySynced = true; 71 m_displaySynced = true;
71 onGetDisplays(); 72 onGetDisplays();
72 } 73 }
73 } 74 }
74 75
76 void VRController::focusChanged(bool focused) {
77 m_focused = focused;
78 for (size_t i = 0; i < m_displays.size(); ++i)
jbroman 2017/02/02 16:07:20 super-nit: you could use a range-based loop here t
mthiesse 2017/02/02 17:52:18 Done.
79 m_displays[i]->focusChanged(focused);
80 }
81
75 // Called when the VRService has called OnDisplayConnected for all active 82 // Called when the VRService has called OnDisplayConnected for all active
76 // VRDisplays. 83 // VRDisplays.
77 void VRController::onDisplaysSynced(unsigned numberOfDisplays) { 84 void VRController::onDisplaysSynced(unsigned numberOfDisplays) {
78 m_numberOfSyncedDisplays = numberOfDisplays; 85 m_numberOfSyncedDisplays = numberOfDisplays;
79 if (m_numberOfSyncedDisplays == m_displays.size()) { 86 if (m_numberOfSyncedDisplays == m_displays.size()) {
80 m_displaySynced = true; 87 m_displaySynced = true;
81 onGetDisplays(); 88 onGetDisplays();
82 } 89 }
83 } 90 }
84 91
(...skipping 26 matching lines...) Expand all
111 } 118 }
112 119
113 DEFINE_TRACE(VRController) { 120 DEFINE_TRACE(VRController) {
114 visitor->trace(m_navigatorVR); 121 visitor->trace(m_navigatorVR);
115 visitor->trace(m_displays); 122 visitor->trace(m_displays);
116 123
117 ContextLifecycleObserver::trace(visitor); 124 ContextLifecycleObserver::trace(visitor);
118 } 125 }
119 126
120 } // namespace blink 127 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698