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

Side by Side Diff: cc/math_util.cc

Issue 11192030: cc: Switch to Chromium DCHECKs LOGs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebaseonenne Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « cc/math_util.h ('k') | 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 "CCMathUtil.h" 7 #include "CCMathUtil.h"
8 8
9 #include "FloatPoint.h" 9 #include "FloatPoint.h"
10 #include "FloatQuad.h" 10 #include "FloatQuad.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // p = (1-t) h1 + (t) h2 59 // p = (1-t) h1 + (t) h2
60 // 60 //
61 // We want to compute point p such that p.w == epsilon, where epsilon is a s mall 61 // We want to compute point p such that p.w == epsilon, where epsilon is a s mall
62 // non-zero number. (but the smaller the number is, the higher the risk of o verflow) 62 // non-zero number. (but the smaller the number is, the higher the risk of o verflow)
63 // To do this, we solve for t in the following equation: 63 // To do this, we solve for t in the following equation:
64 // p.w = epsilon = (1-t) * h1.w + (t) * h2.w 64 // p.w = epsilon = (1-t) * h1.w + (t) * h2.w
65 // 65 //
66 // Once paramter t is known, the rest of p can be computed via p = (1-t) h1 + (t) h2. 66 // Once paramter t is known, the rest of p can be computed via p = (1-t) h1 + (t) h2.
67 67
68 // Technically this is a special case of the following assertion, but its a good idea to keep it an explicit sanity check here. 68 // Technically this is a special case of the following assertion, but its a good idea to keep it an explicit sanity check here.
69 ASSERT(h2.w != h1.w); 69 DCHECK(h2.w != h1.w);
70 // Exactly one of h1 or h2 (but not both) must be on the negative side of th e w plane when this is called. 70 // Exactly one of h1 or h2 (but not both) must be on the negative side of th e w plane when this is called.
71 ASSERT(h1.shouldBeClipped() ^ h2.shouldBeClipped()); 71 DCHECK(h1.shouldBeClipped() ^ h2.shouldBeClipped());
72 72
73 double w = 0.00001; // or any positive non-zero small epsilon 73 double w = 0.00001; // or any positive non-zero small epsilon
74 74
75 double t = (w - h1.w) / (h2.w - h1.w); 75 double t = (w - h1.w) / (h2.w - h1.w);
76 76
77 double x = (1-t) * h1.x + t * h2.x; 77 double x = (1-t) * h1.x + t * h2.x;
78 double y = (1-t) * h1.y + t * h2.y; 78 double y = (1-t) * h1.y + t * h2.y;
79 double z = (1-t) * h1.z + t * h2.z; 79 double z = (1-t) * h1.z + t * h2.z;
80 80
81 return HomogeneousCoordinate(x, y, z, w); 81 return HomogeneousCoordinate(x, y, z, w);
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 158
159 if (h3.shouldBeClipped() ^ h4.shouldBeClipped()) 159 if (h3.shouldBeClipped() ^ h4.shouldBeClipped())
160 addVertexToClippedQuad(computeClippedPointForEdge(h3, h4).cartesianPoint 2d(), clippedQuad, numVerticesInClippedQuad); 160 addVertexToClippedQuad(computeClippedPointForEdge(h3, h4).cartesianPoint 2d(), clippedQuad, numVerticesInClippedQuad);
161 161
162 if (!h4.shouldBeClipped()) 162 if (!h4.shouldBeClipped())
163 addVertexToClippedQuad(h4.cartesianPoint2d(), clippedQuad, numVerticesIn ClippedQuad); 163 addVertexToClippedQuad(h4.cartesianPoint2d(), clippedQuad, numVerticesIn ClippedQuad);
164 164
165 if (h4.shouldBeClipped() ^ h1.shouldBeClipped()) 165 if (h4.shouldBeClipped() ^ h1.shouldBeClipped())
166 addVertexToClippedQuad(computeClippedPointForEdge(h4, h1).cartesianPoint 2d(), clippedQuad, numVerticesInClippedQuad); 166 addVertexToClippedQuad(computeClippedPointForEdge(h4, h1).cartesianPoint 2d(), clippedQuad, numVerticesInClippedQuad);
167 167
168 ASSERT(numVerticesInClippedQuad <= 8); 168 DCHECK(numVerticesInClippedQuad <= 8);
169 } 169 }
170 170
171 FloatRect CCMathUtil::computeEnclosingRectOfVertices(FloatPoint vertices[], int numVertices) 171 FloatRect CCMathUtil::computeEnclosingRectOfVertices(FloatPoint vertices[], int numVertices)
172 { 172 {
173 if (numVertices < 2) 173 if (numVertices < 2)
174 return FloatRect(); 174 return FloatRect();
175 175
176 float xmin = std::numeric_limits<float>::max(); 176 float xmin = std::numeric_limits<float>::max();
177 float xmax = -std::numeric_limits<float>::max(); 177 float xmax = -std::numeric_limits<float>::max();
178 float ymin = std::numeric_limits<float>::max(); 178 float ymin = std::numeric_limits<float>::max();
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 370 }
371 371
372 FloatSize CCMathUtil::projectVector(const FloatSize& source, const FloatSize& de stination) 372 FloatSize CCMathUtil::projectVector(const FloatSize& source, const FloatSize& de stination)
373 { 373 {
374 float sourceDotDestination = source.width() * destination.width() + source.h eight() * destination.height(); 374 float sourceDotDestination = source.width() * destination.width() + source.h eight() * destination.height();
375 float projectedLength = sourceDotDestination / destination.diagonalLengthSqu ared(); 375 float projectedLength = sourceDotDestination / destination.diagonalLengthSqu ared();
376 return FloatSize(projectedLength * destination.width(), projectedLength * de stination.height()); 376 return FloatSize(projectedLength * destination.width(), projectedLength * de stination.height());
377 } 377 }
378 378
379 } // namespace cc 379 } // namespace cc
OLDNEW
« no previous file with comments | « cc/math_util.h ('k') | cc/occlusion_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698