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

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

Issue 2154123003: Fix the assert and clamping in SkMatrix::get*Scale[s](). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | 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 "SkFloatBits.h" 8 #include "SkFloatBits.h"
9 #include "SkMatrix.h" 9 #include "SkMatrix.h"
10 #include "SkNx.h" 10 #include "SkNx.h"
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1564 } else if (kMax_MinMaxOrBoth == MIN_MAX_OR_BOTH) { 1564 } else if (kMax_MinMaxOrBoth == MIN_MAX_OR_BOTH) {
1565 results[0] = apluscdiv2 + x; 1565 results[0] = apluscdiv2 + x;
1566 } else { 1566 } else {
1567 results[0] = apluscdiv2 - x; 1567 results[0] = apluscdiv2 - x;
1568 results[1] = apluscdiv2 + x; 1568 results[1] = apluscdiv2 + x;
1569 } 1569 }
1570 } 1570 }
1571 if (!SkScalarIsFinite(results[0])) { 1571 if (!SkScalarIsFinite(results[0])) {
1572 return false; 1572 return false;
1573 } 1573 }
1574 if (results[0] < 0 && results[0] > -SK_ScalarNearlyZero) { 1574 SkASSERT(results[0] >= -SK_ScalarNearlyZero);
reed1 2016/07/18 14:10:06 Thanks, this is better. Lets add a comment why we'
1575 if (results[0] < 0) {
1575 results[0] = 0; 1576 results[0] = 0;
1576 } 1577 }
1577 SkASSERT(results[0] >= 0);
1578 results[0] = SkScalarSqrt(results[0]); 1578 results[0] = SkScalarSqrt(results[0]);
1579 if (kBoth_MinMaxOrBoth == MIN_MAX_OR_BOTH) { 1579 if (kBoth_MinMaxOrBoth == MIN_MAX_OR_BOTH) {
1580 if (!SkScalarIsFinite(results[1])) { 1580 if (!SkScalarIsFinite(results[1])) {
1581 return false; 1581 return false;
1582 } 1582 }
1583 if (results[1] < 0 && results[1] > -SK_ScalarNearlyZero) { 1583 SkASSERT(results[1] >= -SK_ScalarNearlyZero);
1584 if (results[1] < 0) {
1584 results[1] = 0; 1585 results[1] = 0;
1585 } 1586 }
1586 SkASSERT(results[1] >= 0);
1587 results[1] = SkScalarSqrt(results[1]); 1587 results[1] = SkScalarSqrt(results[1]);
1588 } 1588 }
1589 return true; 1589 return true;
1590 } 1590 }
1591 1591
1592 SkScalar SkMatrix::getMinScale() const { 1592 SkScalar SkMatrix::getMinScale() const {
1593 SkScalar factor; 1593 SkScalar factor;
1594 if (get_scale_factor<kMin_MinMaxOrBoth>(this->getType(), fMat, &factor)) { 1594 if (get_scale_factor<kMin_MinMaxOrBoth>(this->getType(), fMat, &factor)) {
1595 return factor; 1595 return factor;
1596 } else { 1596 } else {
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 const SkScalar m10 = -m01; 1883 const SkScalar m10 = -m01;
1884 const SkScalar m11 = m00; 1884 const SkScalar m11 = m00;
1885 const SkScalar m12 = fTy; 1885 const SkScalar m12 = fTy;
1886 1886
1887 quad[0].set(m02, m12); 1887 quad[0].set(m02, m12);
1888 quad[1].set(m00 * width + m02, m10 * width + m12); 1888 quad[1].set(m00 * width + m02, m10 * width + m12);
1889 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); 1889 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12);
1890 quad[3].set(m01 * height + m02, m11 * height + m12); 1890 quad[3].set(m01 * height + m02, m11 * height + m12);
1891 #endif 1891 #endif
1892 } 1892 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698