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

Side by Side Diff: Source/Platform/chromium/public/WebDeviceMotionData.h

Issue 13866007: WebKit & WebCore part of the device motion implementation using the platform layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@devicemotion-webcore
Patch Set: fixed Eric's comments. Created 7 years, 8 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
(Empty)
1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef WebDeviceMotionData_h
32 #define WebDeviceMotionData_h
33
34 #if WEBKIT_IMPLEMENTATION
35 namespace WTF { template <typename T> class PassRefPtr; }
36 namespace WebCore { class DeviceMotionData; }
37 #endif
38
39 namespace WebKit {
40
41 #pragma pack(push, 1)
abarth-chromium 2013/04/23 21:36:26 Why is this needed?
timvolodine 2013/04/24 12:36:03 Here I am using a similar approach as the Gamepad
42
43 class WebDeviceMotionData {
44 public:
45 WebDeviceMotionData();
46 ~WebDeviceMotionData() { }
47
48 void setAccelerationX(double);
49 void setAccelerationY(double);
50 void setAccelerationZ(double);
51
52 void setAccelerationIncludingGravityX(double);
53 void setAccelerationIncludingGravityY(double);
54 void setAccelerationIncludingGravityZ(double);
55
56 void setRotationRateAlpha(double);
57 void setRotationRateBeta(double);
58 void setRotationRateGamma(double);
59
60 #if WEBKIT_IMPLEMENTATION
61 operator WTF::PassRefPtr<WebCore::DeviceMotionData>() const;
62 #endif
63
64 private:
65 double m_accelerationX;
66 double m_accelerationY;
67 double m_accelerationZ;
68
69 double m_accelerationIncludingGravityX;
70 double m_accelerationIncludingGravityY;
71 double m_accelerationIncludingGravityZ;
72
73 double m_rotationRateAlpha;
74 double m_rotationRateBeta;
75 double m_rotationRateGamma;
76
77 char m_hasAccelerationX : 1;
78 char m_hasAccelerationY : 1;
79 char m_hasAccelerationZ : 1;
80
81 char m_hasAccelerationIncludingGravityX : 1;
82 char m_hasAccelerationIncludingGravityY : 1;
83 char m_hasAccelerationIncludingGravityZ : 1;
84
85 char m_hasRotationRateAlpha : 1;
86 char m_hasRotationRateBeta : 1;
87 char m_hasRotationRateGamma : 1;
88 };
89
90 #if WEBKIT_IMPLEMENTATION
91 COMPILE_ASSERT(sizeof(WebDeviceMotionData) == (9*8 + 2), WebDeviceMotionData_has _wrong_size);
abarth-chromium 2013/04/23 21:36:26 Where does this magic number come from?
timvolodine 2013/04/24 12:36:03 8 doubles + 2 bytes for the bit-packed booleans.
92 #endif
93
94 #pragma pack(pop)
95
96 } // namespace WebKit
97
98 #endif // WebDeviceMotionData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698