OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. |
3 * 2010 Dirk Schulze <krit@webkit.org> | 3 * 2010 Dirk Schulze <krit@webkit.org> |
4 * Copyright (C) 2013 Google Inc. All rights reserved. | 4 * Copyright (C) 2013 Google Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
11 * 2. Redistributions in binary form must reproduce the above copyright | 11 * 2. Redistributions in binary form must reproduce the above copyright |
12 * notice, this list of conditions and the following disclaimer in the | 12 * notice, this list of conditions and the following disclaimer in the |
13 * documentation and/or other materials provided with the distribution. | 13 * documentation and/or other materials provided with the distribution. |
14 * | 14 * |
15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 15 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "config.h" | 28 #include "config.h" |
29 #include "core/platform/graphics/transforms/AffineTransform.h" | 29 #include "platform/transforms/AffineTransform.h" |
30 | 30 |
31 #include "core/platform/FloatConversion.h" | 31 #include "platform/FloatConversion.h" |
32 #include "core/platform/graphics/FloatQuad.h" | 32 #include "platform/geometry/FloatQuad.h" |
33 #include "core/platform/graphics/FloatRect.h" | 33 #include "platform/geometry/FloatRect.h" |
34 #include "core/platform/graphics/IntRect.h" | 34 #include "platform/geometry/IntRect.h" |
35 #include "core/platform/graphics/skia/SkiaUtils.h" | |
36 | |
37 #include "wtf/MathExtras.h" | 35 #include "wtf/MathExtras.h" |
38 | 36 |
39 namespace WebCore { | 37 namespace WebCore { |
40 | 38 |
41 AffineTransform::AffineTransform() | 39 AffineTransform::AffineTransform() |
42 { | 40 { |
43 setMatrix(1, 0, 0, 1, 0, 0); | 41 setMatrix(1, 0, 0, 1, 0, 0); |
44 } | 42 } |
45 | 43 |
46 AffineTransform::AffineTransform(double a, double b, double c, double d, double e, double f) | 44 AffineTransform::AffineTransform(double a, double b, double c, double d, double e, double f) |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 | 340 |
343 this->recompose(srA); | 341 this->recompose(srA); |
344 } | 342 } |
345 | 343 |
346 TransformationMatrix AffineTransform::toTransformationMatrix() const | 344 TransformationMatrix AffineTransform::toTransformationMatrix() const |
347 { | 345 { |
348 return TransformationMatrix(m_transform[0], m_transform[1], m_transform[2], | 346 return TransformationMatrix(m_transform[0], m_transform[1], m_transform[2], |
349 m_transform[3], m_transform[4], m_transform[5]); | 347 m_transform[3], m_transform[4], m_transform[5]); |
350 } | 348 } |
351 | 349 |
350 static inline SkScalar WebCoreDoubleToSkScalar(double d) | |
pdr.
2013/10/01 23:21:28
Code duplication :(
| |
351 { | |
352 return SkDoubleToScalar(std::isfinite(d) ? d : 0); | |
353 } | |
354 | |
352 AffineTransform::operator SkMatrix() const | 355 AffineTransform::operator SkMatrix() const |
353 { | 356 { |
354 SkMatrix result; | 357 SkMatrix result; |
355 | 358 |
356 result.setScaleX(WebCoreDoubleToSkScalar(a())); | 359 result.setScaleX(WebCoreDoubleToSkScalar(a())); |
357 result.setSkewX(WebCoreDoubleToSkScalar(c())); | 360 result.setSkewX(WebCoreDoubleToSkScalar(c())); |
358 result.setTranslateX(WebCoreDoubleToSkScalar(e())); | 361 result.setTranslateX(WebCoreDoubleToSkScalar(e())); |
359 | 362 |
360 result.setScaleY(WebCoreDoubleToSkScalar(d())); | 363 result.setScaleY(WebCoreDoubleToSkScalar(d())); |
361 result.setSkewY(WebCoreDoubleToSkScalar(b())); | 364 result.setSkewY(WebCoreDoubleToSkScalar(b())); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
416 this->setB(decomp.remainderB); | 419 this->setB(decomp.remainderB); |
417 this->setC(decomp.remainderC); | 420 this->setC(decomp.remainderC); |
418 this->setD(decomp.remainderD); | 421 this->setD(decomp.remainderD); |
419 this->setE(decomp.translateX); | 422 this->setE(decomp.translateX); |
420 this->setF(decomp.translateY); | 423 this->setF(decomp.translateY); |
421 this->rotate(rad2deg(decomp.angle)); | 424 this->rotate(rad2deg(decomp.angle)); |
422 this->scale(decomp.scaleX, decomp.scaleY); | 425 this->scale(decomp.scaleX, decomp.scaleY); |
423 } | 426 } |
424 | 427 |
425 } | 428 } |
OLD | NEW |