| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkMatrix.h" | 8 #include "SkMatrix.h" |
| 9 #include "SkFloatBits.h" | 9 #include "SkFloatBits.h" |
| 10 #include "SkRSXform.h" |
| 10 #include "SkString.h" | 11 #include "SkString.h" |
| 11 #include "SkNx.h" | 12 #include "SkNx.h" |
| 12 | 13 |
| 13 #include <stddef.h> | 14 #include <stddef.h> |
| 14 | 15 |
| 15 static void normalize_perspective(SkScalar mat[9]) { | 16 static void normalize_perspective(SkScalar mat[9]) { |
| 16 // If it was interesting to never store the last element, we could divide al
l 8 other | 17 // If it was interesting to never store the last element, we could divide al
l 8 other |
| 17 // elements here by the 9th, making it 1.0... | 18 // elements here by the 9th, making it 1.0... |
| 18 // | 19 // |
| 19 // When SkScalar was SkFixed, we would sometimes rescale the entire matrix t
o keep its | 20 // When SkScalar was SkFixed, we would sometimes rescale the entire matrix t
o keep its |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 fMat[kMSkewY] = sinV; | 434 fMat[kMSkewY] = sinV; |
| 434 fMat[kMScaleY] = cosV; | 435 fMat[kMScaleY] = cosV; |
| 435 fMat[kMTransY] = sdot(-sinV, px, oneMinusCosV, py); | 436 fMat[kMTransY] = sdot(-sinV, px, oneMinusCosV, py); |
| 436 | 437 |
| 437 fMat[kMPersp0] = fMat[kMPersp1] = 0; | 438 fMat[kMPersp0] = fMat[kMPersp1] = 0; |
| 438 fMat[kMPersp2] = 1; | 439 fMat[kMPersp2] = 1; |
| 439 | 440 |
| 440 this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); | 441 this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); |
| 441 } | 442 } |
| 442 | 443 |
| 444 SkMatrix& SkMatrix::setRSXform(const SkRSXform& xform) { |
| 445 fMat[kMScaleX] = xform.fSCos; |
| 446 fMat[kMSkewX] = -xform.fSSin; |
| 447 fMat[kMTransX] = xform.fTx; |
| 448 |
| 449 fMat[kMSkewY] = xform.fSSin; |
| 450 fMat[kMScaleY] = xform.fSCos; |
| 451 fMat[kMTransY] = xform.fTy; |
| 452 |
| 453 fMat[kMPersp0] = fMat[kMPersp1] = 0; |
| 454 fMat[kMPersp2] = 1; |
| 455 |
| 456 this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); |
| 457 return *this; |
| 458 } |
| 459 |
| 443 void SkMatrix::setSinCos(SkScalar sinV, SkScalar cosV) { | 460 void SkMatrix::setSinCos(SkScalar sinV, SkScalar cosV) { |
| 444 fMat[kMScaleX] = cosV; | 461 fMat[kMScaleX] = cosV; |
| 445 fMat[kMSkewX] = -sinV; | 462 fMat[kMSkewX] = -sinV; |
| 446 fMat[kMTransX] = 0; | 463 fMat[kMTransX] = 0; |
| 447 | 464 |
| 448 fMat[kMSkewY] = sinV; | 465 fMat[kMSkewY] = sinV; |
| 449 fMat[kMScaleY] = cosV; | 466 fMat[kMScaleY] = cosV; |
| 450 fMat[kMTransY] = 0; | 467 fMat[kMTransY] = 0; |
| 451 | 468 |
| 452 fMat[kMPersp0] = fMat[kMPersp1] = 0; | 469 fMat[kMPersp0] = fMat[kMPersp1] = 0; |
| (...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 rotation1->fX = cos1; | 1833 rotation1->fX = cos1; |
| 1817 rotation1->fY = sin1; | 1834 rotation1->fY = sin1; |
| 1818 } | 1835 } |
| 1819 if (rotation2) { | 1836 if (rotation2) { |
| 1820 rotation2->fX = cos2; | 1837 rotation2->fX = cos2; |
| 1821 rotation2->fY = sin2; | 1838 rotation2->fY = sin2; |
| 1822 } | 1839 } |
| 1823 | 1840 |
| 1824 return true; | 1841 return true; |
| 1825 } | 1842 } |
| 1843 |
| 1844 ////////////////////////////////////////////////////////////////////////////////
////////////////// |
| 1845 |
| 1846 void SkRSXform::toQuad(SkScalar width, SkScalar height, SkPoint quad[4]) const { |
| 1847 quad[0].set(0, 0); |
| 1848 quad[1].set(width, 0); |
| 1849 quad[2].set(width, height); |
| 1850 quad[3].set(0, height); |
| 1851 SkMatrix m; |
| 1852 m.setRSXform(*this).mapPoints(quad, quad, 4); |
| 1853 } |
| 1854 |
| OLD | NEW |