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

Side by Side Diff: src/core/SkMatrix.cpp

Issue 1022003003: Revert of add SkMatrix::decomposeScale (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | src/core/SkPictureShader.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkString.h" 10 #include "SkString.h"
(...skipping 1585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 SK_COMPILE_ASSERT(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typem ask), BadfTypeMask); 1596 SK_COMPILE_ASSERT(offsetof(SkMatrix, fTypeMask) == offsetof(PODMatrix, typem ask), BadfTypeMask);
1597 1597
1598 static const PODMatrix invalid = 1598 static const PODMatrix invalid =
1599 { {SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, 1599 { {SK_ScalarMax, SK_ScalarMax, SK_ScalarMax,
1600 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax, 1600 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax,
1601 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax }, 1601 SK_ScalarMax, SK_ScalarMax, SK_ScalarMax },
1602 kTranslate_Mask | kScale_Mask | kAffine_Mask | kPerspective_Mask }; 1602 kTranslate_Mask | kScale_Mask | kAffine_Mask | kPerspective_Mask };
1603 return invalid.asSkMatrix(); 1603 return invalid.asSkMatrix();
1604 } 1604 }
1605 1605
1606 bool SkMatrix::decomposeScale(SkSize* scale, SkMatrix* remaining) const {
1607 if (this->hasPerspective()) {
1608 return false;
1609 }
1610
1611 const SkScalar sx = SkVector::Length(this->getScaleX(), this->getSkewY());
1612 const SkScalar sy = SkVector::Length(this->getSkewX(), this->getScaleY());
1613 if (!SkScalarIsFinite(sx) || !SkScalarIsFinite(sy) ||
1614 SkScalarNearlyZero(sx) || SkScalarNearlyZero(sy)) {
1615 return false;
1616 }
1617
1618 if (scale) {
1619 scale->set(sx, sy);
1620 }
1621 if (remaining) {
1622 *remaining = *this;
1623 remaining->postScale(SkScalarInvert(sx), SkScalarInvert(sy));
1624 }
1625 return true;
1626 }
1627
1628 /////////////////////////////////////////////////////////////////////////////// 1606 ///////////////////////////////////////////////////////////////////////////////
1629 1607
1630 size_t SkMatrix::writeToMemory(void* buffer) const { 1608 size_t SkMatrix::writeToMemory(void* buffer) const {
1631 // TODO write less for simple matrices 1609 // TODO write less for simple matrices
1632 static const size_t sizeInMemory = 9 * sizeof(SkScalar); 1610 static const size_t sizeInMemory = 9 * sizeof(SkScalar);
1633 if (buffer) { 1611 if (buffer) {
1634 memcpy(buffer, fMat, sizeInMemory); 1612 memcpy(buffer, fMat, sizeInMemory);
1635 } 1613 }
1636 return sizeInMemory; 1614 return sizeInMemory;
1637 } 1615 }
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1806 rotation1->fX = cos1; 1784 rotation1->fX = cos1;
1807 rotation1->fY = sin1; 1785 rotation1->fY = sin1;
1808 } 1786 }
1809 if (rotation2) { 1787 if (rotation2) {
1810 rotation2->fX = cos2; 1788 rotation2->fX = cos2;
1811 rotation2->fY = sin2; 1789 rotation2->fY = sin2;
1812 } 1790 }
1813 1791
1814 return true; 1792 return true;
1815 } 1793 }
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.cpp ('k') | src/core/SkPictureShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698