OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <assert.h> | 5 #include <assert.h> |
6 #include <math.h> | 6 #include <math.h> |
7 #include <ppapi/c/ppb_input_event.h> | 7 #include <ppapi/c/ppb_input_event.h> |
8 #include <ppapi/cpp/input_event.h> | 8 #include <ppapi/cpp/input_event.h> |
9 #include <ppapi/cpp/var.h> | 9 #include <ppapi/cpp/var.h> |
10 #include <ppapi/cpp/var_array.h> | 10 #include <ppapi/cpp/var_array.h> |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "ppapi_simple/ps_event.h" | 25 #include "ppapi_simple/ps_event.h" |
26 #include "ppapi_simple/ps_interface.h" | 26 #include "ppapi_simple/ps_interface.h" |
27 #include "ppapi_simple/ps_main.h" | 27 #include "ppapi_simple/ps_main.h" |
28 #include "sdk_util/macros.h" | 28 #include "sdk_util/macros.h" |
29 #include "sdk_util/thread_pool.h" | 29 #include "sdk_util/thread_pool.h" |
30 | 30 |
31 using namespace sdk_util; // For sdk_util::ThreadPool | 31 using namespace sdk_util; // For sdk_util::ThreadPool |
32 | 32 |
33 // Global properties used to setup Earth demo. | 33 // Global properties used to setup Earth demo. |
34 namespace { | 34 namespace { |
35 const float kHugeZ = 1.0e38f; | |
36 const float kPI = M_PI; | 35 const float kPI = M_PI; |
37 const float kTwoPI = kPI * 2.0f; | 36 const float kTwoPI = kPI * 2.0f; |
38 const float kOneOverPI = 1.0f / kPI; | 37 const float kOneOverPI = 1.0f / kPI; |
39 const float kOneOver2PI = 1.0f / kTwoPI; | 38 const float kOneOver2PI = 1.0f / kTwoPI; |
40 const float kOneOver255 = 1.0f / 255.0f; | 39 const float kOneOver255 = 1.0f / 255.0f; |
41 const int kArcCosineTableSize = 4096; | 40 const int kArcCosineTableSize = 4096; |
42 const int kFramesToBenchmark = 100; | 41 const int kFramesToBenchmark = 100; |
43 const float kZoomMin = 1.0f; | 42 const float kZoomMin = 1.0f; |
44 const float kZoomMax = 50.0f; | 43 const float kZoomMax = 50.0f; |
45 const float kWheelSpeed = 2.0f; | 44 const float kWheelSpeed = 2.0f; |
46 const float kLightMin = 0.0f; | 45 const float kLightMin = 0.0f; |
47 const float kLightMax = 2.0f; | 46 const float kLightMax = 2.0f; |
48 const int kFrameTimeBufferSize = 512; | |
49 | 47 |
50 // Timer helper for benchmarking. Returns seconds elapsed since program start, | 48 // Timer helper for benchmarking. Returns seconds elapsed since program start, |
51 // as a double. | 49 // as a double. |
52 timeval start_tv; | 50 timeval start_tv; |
53 int start_tv_retv = gettimeofday(&start_tv, NULL); | 51 int start_tv_retv = gettimeofday(&start_tv, NULL); |
54 | 52 |
55 inline double getseconds() { | 53 inline double getseconds() { |
56 const double usec_to_sec = 0.000001; | 54 const double usec_to_sec = 0.000001; |
57 timeval tv; | 55 timeval tv; |
58 if ((0 == start_tv_retv) && (0 == gettimeofday(&tv, NULL))) | 56 if ((0 == start_tv_retv) && (0 == gettimeofday(&tv, NULL))) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 Convert u(f); | 138 Convert u(f); |
141 return u.AsInt(); | 139 return u.AsInt(); |
142 } | 140 } |
143 | 141 |
144 inline const float AsFloat(const int i) { | 142 inline const float AsFloat(const int i) { |
145 Convert u(i); | 143 Convert u(i); |
146 return u.AsFloat(); | 144 return u.AsFloat(); |
147 } | 145 } |
148 | 146 |
149 const long int kOneAsInteger = AsInteger(1.0f); | 147 const long int kOneAsInteger = AsInteger(1.0f); |
150 const float kScaleUp = float(0x00800000); | |
151 const float kScaleDown = 1.0f / kScaleUp; | |
152 | 148 |
153 inline float inline_quick_sqrt(float x) { | 149 inline float inline_quick_sqrt(float x) { |
154 int i; | 150 int i; |
155 i = (AsInteger(x) >> 1) + (kOneAsInteger >> 1); | 151 i = (AsInteger(x) >> 1) + (kOneAsInteger >> 1); |
156 return AsFloat(i); | 152 return AsFloat(i); |
157 } | 153 } |
158 | 154 |
159 inline float inline_sqrt(float x) { | 155 inline float inline_sqrt(float x) { |
160 float y; | 156 float y; |
161 y = inline_quick_sqrt(x); | 157 y = inline_quick_sqrt(x); |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 // Do simulation, render and present. | 813 // Do simulation, render and present. |
818 earth.Update(); | 814 earth.Update(); |
819 } | 815 } |
820 | 816 |
821 return 0; | 817 return 0; |
822 } | 818 } |
823 | 819 |
824 // Register the function to call once the Instance Object is initialized. | 820 // Register the function to call once the Instance Object is initialized. |
825 // see: pappi_simple/ps_main.h | 821 // see: pappi_simple/ps_main.h |
826 PPAPI_SIMPLE_REGISTER_MAIN(example_main); | 822 PPAPI_SIMPLE_REGISTER_MAIN(example_main); |
OLD | NEW |