Bike-X  0.8
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Util_LatencyTest.h
Go to the documentation of this file.
1 /************************************************************************************
2 
3 PublicHeader: OVR.h
4 Filename : Util_LatencyTest.h
5 Content : Wraps the lower level LatencyTesterDevice and adds functionality.
6 Created : February 14, 2013
7 Authors : Lee Cooper
8 
9 Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10 
11 Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12 you may not use the Oculus VR Rift SDK except in compliance with the License,
13 which is provided at the time of installation or download, or which
14 otherwise accompanies this software in either electronic or hard copy form.
15 
16 You may obtain a copy of the License at
17 
18 http://www.oculusvr.com/licenses/LICENSE-3.1
19 
20 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21 distributed under the License is distributed on an "AS IS" BASIS,
22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23 See the License for the specific language governing permissions and
24 limitations under the License.
25 
26 *************************************************************************************/
27 
28 #ifndef OVR_Util_LatencyTest_h
29 #define OVR_Util_LatencyTest_h
30 
31 #include "../OVR_Device.h"
32 
33 #include "../Kernel/OVR_String.h"
34 #include "../Kernel/OVR_List.h"
35 
36 namespace OVR { namespace Util {
37 
38 
39 //-------------------------------------------------------------------------------------
40 // ***** LatencyTest
41 //
42 // LatencyTest utility class wraps the low level LatencyTestDevice and manages the scheduling
43 // of a latency test. A single test is composed of a series of individual latency measurements
44 // which are used to derive min, max, and an average latency value.
45 //
46 // Developers are required to call the following methods:
47 // SetDevice - Sets the LatencyTestDevice to be used for the tests.
48 // ProcessInputs - This should be called at the same place in the code where the game engine
49 // reads the headset orientation from LibOVR (typically done by calling
50 // 'GetOrientation' on the SensorFusion object). Calling this at the right time
51 // enables us to measure the same latency that occurs for headset orientation
52 // changes.
53 // DisplayScreenColor - The latency tester works by sensing the color of the pixels directly
54 // beneath it. The color of these pixels can be set by drawing a small
55 // quad at the end of the rendering stage. The quad should be small
56 // such that it doesn't significantly impact the rendering of the scene,
57 // but large enough to be 'seen' by the sensor. See the SDK
58 // documentation for more information.
59 // GetResultsString - Call this to get a string containing the most recent results.
60 // If the string has already been gotten then NULL will be returned.
61 // The string pointer will remain valid until the next time this
62 // method is called.
63 //
64 
66 {
67 public:
69  ~LatencyTest();
70 
71  // Set the Latency Tester device that we'll use to send commands to and receive
72  // notification messages from.
73  bool SetDevice(LatencyTestDevice* device);
74 
75  // Returns true if this LatencyTestUtil has a Latency Tester device.
76  bool HasDevice() const
77  { return Handler.IsHandlerInstalled(); }
78 
79  void ProcessInputs();
80  bool DisplayScreenColor(Color& colorToDisplay);
81  const char* GetResultsString();
82 
83  bool IsMeasuringNow() const { return (State != State_WaitingForButton); }
84 
85  // Begin test. Equivalent to pressing the button on the latency tester.
86  void BeginTest();
87 
88 private:
89  LatencyTest* getThis() { return this; }
90 
92  {
96  };
97 
99  void handleMessage(const Message& msg, LatencyTestMessageType latencyTestMessage = LatencyTest_None);
100  void reset();
101  void setTimer(UInt32 timeMilliS);
102  void clearTimer();
103 
105  {
107  public:
108  LatencyTestHandler(LatencyTest* latencyTester) : pLatencyTestUtil(latencyTester) { }
110 
111  virtual void OnMessage(const Message& msg);
112  };
113 
114  bool areResultsComplete();
115  void processResults();
116  void updateForTimeouts();
117 
120 
122  {
132  };
134 
138 
140 
141  struct MeasurementResult : public ListNode<MeasurementResult>, public NewOverrideBase
142  {
147  StartTestSeconds(0.0),
148  TestStartedSeconds(0.0)
149  {}
150 
152 
154 
157 
160  };
161 
164 
166 
169 };
170 
171 }} // namespace OVR::Util
172 
173 #endif // OVR_Util_LatencyTest_h
LatencyTestHandler Handler
MeasurementResult * getActiveResult()
const char * GetResultsString()
void setTimer(UInt32 timeMilliS)
#define NULL
bool DisplayScreenColor(Color &colorToDisplay)
void handleMessage(const Message &msg, LatencyTestMessageType latencyTestMessage=LatencyTest_None)
uint32_t UInt32
Definition: OVR_Types.h:253
LatencyTest * getThis()
Ptr< LatencyTestDevice > Device
LatencyTestHandler(LatencyTest *latencyTester)
List< MeasurementResult > Results
LatencyTest(LatencyTestDevice *device=NULL)
bool SetDevice(LatencyTestDevice *device)
bool IsHandlerInstalled() const
bool IsMeasuringNow() const
virtual void OnMessage(const Message &msg)
UInt32 getRandomComponent(UInt32 range)