OLD | NEW |
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 "FloatQuad.h" | 9 #include "FloatQuad.h" |
10 #include "FloatSize.h" | 10 #include "FloatSize.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 gfx::RectF MathUtil::computeEnclosingClippedRect(const HomogeneousCoordinate& h1
, const HomogeneousCoordinate& h2, const HomogeneousCoordinate& h3, const Homoge
neousCoordinate& h4) | 190 gfx::RectF MathUtil::computeEnclosingClippedRect(const HomogeneousCoordinate& h1
, const HomogeneousCoordinate& h2, const HomogeneousCoordinate& h3, const Homoge
neousCoordinate& h4) |
191 { | 191 { |
192 // This function performs clipping as necessary and computes the enclosing 2
d | 192 // This function performs clipping as necessary and computes the enclosing 2
d |
193 // gfx::RectF of the vertices. Doing these two steps simultaneously allows u
s to avoid | 193 // gfx::RectF of the vertices. Doing these two steps simultaneously allows u
s to avoid |
194 // the overhead of storing an unknown number of clipped vertices. | 194 // the overhead of storing an unknown number of clipped vertices. |
195 | 195 |
196 // If no vertices on the quad are clipped, then we can simply return the enc
losing rect directly. | 196 // If no vertices on the quad are clipped, then we can simply return the enc
losing rect directly. |
197 bool somethingClipped = h1.shouldBeClipped() || h2.shouldBeClipped() || h3.s
houldBeClipped() || h4.shouldBeClipped(); | 197 bool somethingClipped = h1.shouldBeClipped() || h2.shouldBeClipped() || h3.s
houldBeClipped() || h4.shouldBeClipped(); |
198 if (!somethingClipped) { | 198 if (!somethingClipped) { |
199 FloatQuad mappedQuad = FloatQuad(h1.cartesianPoint2d(), h2.cartesianPoin
t2d(), h3.cartesianPoint2d(), h4.cartesianPoint2d()); | 199 FloatQuad mappedQuad = FloatQuad(h1.cartesianPoint2d(), h2.cartesianPoin
t2d(), h3.cartesianPoint2d(), h4.cartesianPoint2d()); |
200 return cc::FloatRect(mappedQuad.boundingBox()); | 200 return mappedQuad.boundingBox(); |
201 } | 201 } |
202 | 202 |
203 bool everythingClipped = h1.shouldBeClipped() && h2.shouldBeClipped() && h3.
shouldBeClipped() && h4.shouldBeClipped(); | 203 bool everythingClipped = h1.shouldBeClipped() && h2.shouldBeClipped() && h3.
shouldBeClipped() && h4.shouldBeClipped(); |
204 if (everythingClipped) | 204 if (everythingClipped) |
205 return gfx::RectF(); | 205 return gfx::RectF(); |
206 | 206 |
207 | 207 |
208 float xmin = std::numeric_limits<float>::max(); | 208 float xmin = std::numeric_limits<float>::max(); |
209 float xmax = -std::numeric_limits<float>::max(); | 209 float xmax = -std::numeric_limits<float>::max(); |
210 float ymin = std::numeric_limits<float>::max(); | 210 float ymin = std::numeric_limits<float>::max(); |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 } | 387 } |
388 | 388 |
389 FloatSize MathUtil::projectVector(const FloatSize& source, const FloatSize& dest
ination) | 389 FloatSize MathUtil::projectVector(const FloatSize& source, const FloatSize& dest
ination) |
390 { | 390 { |
391 float sourceDotDestination = source.width() * destination.width() + source.h
eight() * destination.height(); | 391 float sourceDotDestination = source.width() * destination.width() + source.h
eight() * destination.height(); |
392 float projectedLength = sourceDotDestination / destination.diagonalLengthSqu
ared(); | 392 float projectedLength = sourceDotDestination / destination.diagonalLengthSqu
ared(); |
393 return FloatSize(projectedLength * destination.width(), projectedLength * de
stination.height()); | 393 return FloatSize(projectedLength * destination.width(), projectedLength * de
stination.height()); |
394 } | 394 } |
395 | 395 |
396 } // namespace cc | 396 } // namespace cc |
OLD | NEW |