1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 6 #ifndef WebFloatPoint3D_h 7 #define WebFloatPoint3D_h 8 9 #include "WebCommon.h" 10 11 #if INSIDE_BLINK 12 #include "platform/geometry/FloatPoint3D.h" 13 #else 14 #include <ui/gfx/point3_f.h> 15 #endif 16 17 namespace blink { 18 19 struct WebFloatPoint3D { 20 float x; 21 float y; 22 float z; 23 WebFloatPoint3DWebFloatPoint3D24 WebFloatPoint3D() 25 : x(0.0f) 26 , y(0.0f) 27 , z(0.0f) 28 { 29 } 30 WebFloatPoint3DWebFloatPoint3D31 WebFloatPoint3D(float x, float y, float z) 32 : x(x) 33 , y(y) 34 , z(z) 35 { 36 } 37 38 #if INSIDE_BLINK WebFloatPoint3DWebFloatPoint3D39 WebFloatPoint3D(const WebCore::FloatPoint3D& p) 40 : x(p.x()) 41 , y(p.y()) 42 , z(p.z()) 43 { 44 } 45 46 WebFloatPoint3D& operator=(const WebCore::FloatPoint3D& p) 47 { 48 x = p.x(); 49 y = p.y(); 50 z = p.z(); 51 return *this; 52 } 53 FloatPoint3DWebFloatPoint3D54 operator WebCore::FloatPoint3D() const 55 { 56 return WebCore::FloatPoint3D(x, y, z); 57 } 58 #else WebFloatPoint3DWebFloatPoint3D59 WebFloatPoint3D(const gfx::Point3F& p) 60 : x(p.x()) 61 , y(p.y()) 62 , z(p.z()) 63 { 64 } 65 66 WebFloatPoint3D& operator=(const gfx::Point3F& p) 67 { 68 x = p.x(); 69 y = p.y(); 70 return *this; 71 } 72 Point3FWebFloatPoint3D73 operator gfx::Point3F() const 74 { 75 return gfx::Point3F(x, y, z); 76 } 77 78 #endif 79 }; 80 81 inline bool operator==(const WebFloatPoint3D& a, const WebFloatPoint3D& b) 82 { 83 return a.x == b.x && a.y == b.y && a.z == b.z; 84 } 85 86 inline bool operator!=(const WebFloatPoint3D& a, const WebFloatPoint3D& b) 87 { 88 return !(a == b); 89 } 90 91 } // namespace blink 92 93 #endif 94