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

Side by Side Diff: cc/math_util.h

Issue 11369018: cc: Switch from WebCore::FloatPoint3D to gfx::Point3F and gfx::Vector3dF in the compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Missing base files Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #ifndef CCMathUtil_h 5 #ifndef CCMathUtil_h
6 #define CCMathUtil_h 6 #define CCMathUtil_h
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "ui/gfx/point_f.h" 9 #include "ui/gfx/point_f.h"
10 #include "FloatPoint3D.h" 10 #include "ui/gfx/point3_f.h"
11 11
12 namespace WebKit { 12 namespace WebKit {
13 class WebTransformationMatrix; 13 class WebTransformationMatrix;
14 } 14 }
15 15
16 namespace gfx { 16 namespace gfx {
17 class Rect; 17 class Rect;
18 class RectF; 18 class RectF;
19 } 19 }
20 20
(...skipping 20 matching lines...) Expand all
41 { 41 {
42 if (w == 1) 42 if (w == 1)
43 return gfx::PointF(x, y); 43 return gfx::PointF(x, y);
44 44
45 // For now, because this code is used privately only by MathUtil, it sho uld never be called when w == 0, and we do not yet need to handle that case. 45 // For now, because this code is used privately only by MathUtil, it sho uld never be called when w == 0, and we do not yet need to handle that case.
46 DCHECK(w); 46 DCHECK(w);
47 double invW = 1.0 / w; 47 double invW = 1.0 / w;
48 return gfx::PointF(x * invW, y * invW); 48 return gfx::PointF(x * invW, y * invW);
49 } 49 }
50 50
51 FloatPoint3D cartesianPoint3d() const 51 gfx::Point3F cartesianPoint3d() const
52 { 52 {
53 if (w == 1) 53 if (w == 1)
54 return FloatPoint3D(x, y, z); 54 return gfx::Point3F(x, y, z);
55 55
56 // For now, because this code is used privately only by MathUtil, it sho uld never be called when w == 0, and we do not yet need to handle that case. 56 // For now, because this code is used privately only by MathUtil, it sho uld never be called when w == 0, and we do not yet need to handle that case.
57 DCHECK(w); 57 DCHECK(w);
58 double invW = 1.0 / w; 58 double invW = 1.0 / w;
59 return FloatPoint3D(x * invW, y * invW, z * invW); 59 return gfx::Point3F(x * invW, y * invW, z * invW);
60 } 60 }
61 61
62 double x; 62 double x;
63 double y; 63 double y;
64 double z; 64 double z;
65 double w; 65 double w;
66 }; 66 };
67 67
68 class MathUtil { 68 class MathUtil {
69 public: 69 public:
(...skipping 16 matching lines...) Expand all
86 // none of the vertices in the array are valid. 86 // none of the vertices in the array are valid.
87 static void mapClippedQuad(const WebKit::WebTransformationMatrix&, const Flo atQuad& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad); 87 static void mapClippedQuad(const WebKit::WebTransformationMatrix&, const Flo atQuad& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad);
88 88
89 static gfx::RectF computeEnclosingRectOfVertices(gfx::PointF vertices[], int numVertices); 89 static gfx::RectF computeEnclosingRectOfVertices(gfx::PointF vertices[], int numVertices);
90 static gfx::RectF computeEnclosingClippedRect(const HomogeneousCoordinate& h 1, const HomogeneousCoordinate& h2, const HomogeneousCoordinate& h3, const Homog eneousCoordinate& h4); 90 static gfx::RectF computeEnclosingClippedRect(const HomogeneousCoordinate& h 1, const HomogeneousCoordinate& h2, const HomogeneousCoordinate& h3, const Homog eneousCoordinate& h4);
91 91
92 // NOTE: These functions do not do correct clipping against w = 0 plane, but they 92 // NOTE: These functions do not do correct clipping against w = 0 plane, but they
93 // correctly detect the clipped condition via the boolean clipped. 93 // correctly detect the clipped condition via the boolean clipped.
94 static FloatQuad mapQuad(const WebKit::WebTransformationMatrix&, const Float Quad&, bool& clipped); 94 static FloatQuad mapQuad(const WebKit::WebTransformationMatrix&, const Float Quad&, bool& clipped);
95 static gfx::PointF mapPoint(const WebKit::WebTransformationMatrix&, const gf x::PointF&, bool& clipped); 95 static gfx::PointF mapPoint(const WebKit::WebTransformationMatrix&, const gf x::PointF&, bool& clipped);
96 static FloatPoint3D mapPoint(const WebKit::WebTransformationMatrix&, const F loatPoint3D&, bool& clipped); 96 static gfx::Point3F mapPoint(const WebKit::WebTransformationMatrix&, const g fx::Point3F&, bool& clipped);
97 static FloatQuad projectQuad(const WebKit::WebTransformationMatrix&, const F loatQuad&, bool& clipped); 97 static FloatQuad projectQuad(const WebKit::WebTransformationMatrix&, const F loatQuad&, bool& clipped);
98 static gfx::PointF projectPoint(const WebKit::WebTransformationMatrix&, cons t gfx::PointF&, bool& clipped); 98 static gfx::PointF projectPoint(const WebKit::WebTransformationMatrix&, cons t gfx::PointF&, bool& clipped);
99 99
100 static void flattenTransformTo2d(WebKit::WebTransformationMatrix&); 100 static void flattenTransformTo2d(WebKit::WebTransformationMatrix&);
101 101
102 static gfx::PointF computeTransform2dScaleComponents(const WebKit::WebTransf ormationMatrix&); 102 static gfx::PointF computeTransform2dScaleComponents(const WebKit::WebTransf ormationMatrix&);
103 103
104 // Returns the smallest angle between the given two vectors in degrees. Neit her vector is 104 // Returns the smallest angle between the given two vectors in degrees. Neit her vector is
105 // assumed to be normalized. 105 // assumed to be normalized.
106 static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&) ; 106 static float smallestAngleBetweenVectors(const FloatSize&, const FloatSize&) ;
107 107
108 // Projects the |source| vector onto |destination|. Neither vector is assume d to be normalized. 108 // Projects the |source| vector onto |destination|. Neither vector is assume d to be normalized.
109 static FloatSize projectVector(const FloatSize& source, const FloatSize& des tination); 109 static FloatSize projectVector(const FloatSize& source, const FloatSize& des tination);
110 }; 110 };
111 111
112 } // namespace cc 112 } // namespace cc
113 113
114 #endif // #define CCMathUtil_h 114 #endif // #define CCMathUtil_h
OLDNEW
« cc/cc.gyp ('K') | « cc/layer_sorter.cc ('k') | cc/math_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698