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

Side by Side Diff: cc/math_util.cc

Issue 11312154: cc: Add some early outs to avoid expensive operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Extra casts 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
« no previous file with comments | « no previous file | cc/occlusion_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "config.h" 5 #include "config.h"
6 6
7 #include "cc/math_util.h" 7 #include "cc/math_util.h"
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <limits> 10 #include <limits>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co nst gfx::RectF& srcRect) 111 gfx::RectF MathUtil::mapClippedRect(const WebTransformationMatrix& transform, co nst gfx::RectF& srcRect)
112 { 112 {
113 if (transform.isIdentityOrTranslation()) { 113 if (transform.isIdentityOrTranslation()) {
114 gfx::RectF mappedRect(srcRect); 114 gfx::RectF mappedRect(srcRect);
115 mappedRect.Offset(static_cast<float>(transform.m41()), static_cast<float >(transform.m42())); 115 mappedRect.Offset(static_cast<float>(transform.m41()), static_cast<float >(transform.m42()));
116 return mappedRect; 116 return mappedRect;
117 } 117 }
118 118
119 // Apply the transform, but retain the result in homogeneous coordinates. 119 // Apply the transform, but retain the result in homogeneous coordinates.
120 gfx::QuadF q = gfx::QuadF(gfx::RectF(srcRect)); 120 gfx::QuadF q = gfx::QuadF(srcRect);
121 HomogeneousCoordinate h1 = mapHomogeneousPoint(transform, gfx::Point3F(q.p1( ))); 121 HomogeneousCoordinate h1 = mapHomogeneousPoint(transform, gfx::Point3F(q.p1( )));
122 HomogeneousCoordinate h2 = mapHomogeneousPoint(transform, gfx::Point3F(q.p2( ))); 122 HomogeneousCoordinate h2 = mapHomogeneousPoint(transform, gfx::Point3F(q.p2( )));
123 HomogeneousCoordinate h3 = mapHomogeneousPoint(transform, gfx::Point3F(q.p3( ))); 123 HomogeneousCoordinate h3 = mapHomogeneousPoint(transform, gfx::Point3F(q.p3( )));
124 HomogeneousCoordinate h4 = mapHomogeneousPoint(transform, gfx::Point3F(q.p4( ))); 124 HomogeneousCoordinate h4 = mapHomogeneousPoint(transform, gfx::Point3F(q.p4( )));
125 125
126 return computeEnclosingClippedRect(h1, h2, h3, h4); 126 return computeEnclosingClippedRect(h1, h2, h3, h4);
127 } 127 }
128 128
129 gfx::RectF MathUtil::projectClippedRect(const WebTransformationMatrix& transform , const gfx::RectF& srcRect) 129 gfx::RectF MathUtil::projectClippedRect(const WebTransformationMatrix& transform , const gfx::RectF& srcRect)
130 { 130 {
131 if (transform.isIdentityOrTranslation()) {
132 gfx::RectF projectedRect(srcRect);
133 projectedRect.Offset(static_cast<float>(transform.m41()), static_cast<fl oat>(transform.m42()));
134 return projectedRect;
135 }
136
131 // Perform the projection, but retain the result in homogeneous coordinates. 137 // Perform the projection, but retain the result in homogeneous coordinates.
132 gfx::QuadF q = gfx::QuadF(gfx::RectF(srcRect)); 138 gfx::QuadF q = gfx::QuadF(srcRect);
133 HomogeneousCoordinate h1 = projectHomogeneousPoint(transform, q.p1()); 139 HomogeneousCoordinate h1 = projectHomogeneousPoint(transform, q.p1());
134 HomogeneousCoordinate h2 = projectHomogeneousPoint(transform, q.p2()); 140 HomogeneousCoordinate h2 = projectHomogeneousPoint(transform, q.p2());
135 HomogeneousCoordinate h3 = projectHomogeneousPoint(transform, q.p3()); 141 HomogeneousCoordinate h3 = projectHomogeneousPoint(transform, q.p3());
136 HomogeneousCoordinate h4 = projectHomogeneousPoint(transform, q.p4()); 142 HomogeneousCoordinate h4 = projectHomogeneousPoint(transform, q.p4());
137 143
138 return computeEnclosingClippedRect(h1, h2, h3, h4); 144 return computeEnclosingClippedRect(h1, h2, h3, h4);
139 } 145 }
140 146
141 void MathUtil::mapClippedQuad(const WebTransformationMatrix& transform, const gf x::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad) 147 void MathUtil::mapClippedQuad(const WebTransformationMatrix& transform, const gf x::QuadF& srcQuad, gfx::PointF clippedQuad[8], int& numVerticesInClippedQuad)
142 { 148 {
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 return static_cast<float>(Rad2Deg(std::acos(dotProduct))); 397 return static_cast<float>(Rad2Deg(std::acos(dotProduct)));
392 } 398 }
393 399
394 gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des tination) 400 gfx::Vector2dF MathUtil::projectVector(gfx::Vector2dF source, gfx::Vector2dF des tination)
395 { 401 {
396 float projectedLength = gfx::DotProduct(source, destination) / destination.L engthSquared(); 402 float projectedLength = gfx::DotProduct(source, destination) / destination.L engthSquared();
397 return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * d estination.y()); 403 return gfx::Vector2dF(projectedLength * destination.x(), projectedLength * d estination.y());
398 } 404 }
399 405
400 } // namespace cc 406 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/occlusion_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698