Chromium Code Reviews| 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 "SkRSXform.h" |
| (...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1616 void SkMatrix::toString(SkString* str) const { | 1616 void SkMatrix::toString(SkString* str) const { |
| 1617 str->appendf("[%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f]", | 1617 str->appendf("[%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f][%8.4f %8.4f %8.4f]", |
| 1618 fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5], | 1618 fMat[0], fMat[1], fMat[2], fMat[3], fMat[4], fMat[5], |
| 1619 fMat[6], fMat[7], fMat[8]); | 1619 fMat[6], fMat[7], fMat[8]); |
| 1620 } | 1620 } |
| 1621 | 1621 |
| 1622 /////////////////////////////////////////////////////////////////////////////// | 1622 /////////////////////////////////////////////////////////////////////////////// |
| 1623 | 1623 |
| 1624 #include "SkMatrixUtils.h" | 1624 #include "SkMatrixUtils.h" |
| 1625 | 1625 |
| 1626 bool SkTreatAsSprite(const SkMatrix& mat, int width, int height, | 1626 bool SkTreatAsSprite(const SkMatrix& mat, const SkISize& size, const SkPaint& pa int) { |
| 1627 unsigned subpixelBits) { | 1627 // AA is applied using alpha modulation => 8 bits. |
| 1628 static const unsigned kAntiAliasSubpixelBits = 8; | |
|
reed1
2016/01/07 14:40:50
we have various AA techniques: paths get 2 subpixe
f(malita)
2016/01/07 15:19:00
4 seems to work just as well, and it matches the p
| |
| 1629 | |
| 1630 const unsigned subpixelBits = paint.isAntiAlias() ? kAntiAliasSubpixelBits : 0; | |
| 1631 | |
| 1628 // quick reject on affine or perspective | 1632 // quick reject on affine or perspective |
| 1629 if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) { | 1633 if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) { |
| 1630 return false; | 1634 return false; |
| 1631 } | 1635 } |
| 1632 | 1636 |
| 1633 // quick success check | 1637 // quick success check |
| 1634 if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) { | 1638 if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) { |
| 1635 return true; | 1639 return true; |
| 1636 } | 1640 } |
| 1637 | 1641 |
| 1638 // mapRect supports negative scales, so we eliminate those first | 1642 // mapRect supports negative scales, so we eliminate those first |
| 1639 if (mat.getScaleX() < 0 || mat.getScaleY() < 0) { | 1643 if (mat.getScaleX() < 0 || mat.getScaleY() < 0) { |
| 1640 return false; | 1644 return false; |
| 1641 } | 1645 } |
| 1642 | 1646 |
| 1643 SkRect dst; | 1647 SkRect dst; |
| 1644 SkIRect isrc = { 0, 0, width, height }; | 1648 SkIRect isrc = SkIRect::MakeSize(size); |
| 1645 | 1649 |
| 1646 { | 1650 { |
| 1647 SkRect src; | 1651 SkRect src; |
| 1648 src.set(isrc); | 1652 src.set(isrc); |
| 1649 mat.mapRect(&dst, src); | 1653 mat.mapRect(&dst, src); |
| 1650 } | 1654 } |
| 1651 | 1655 |
| 1652 // just apply the translate to isrc | 1656 // just apply the translate to isrc |
| 1653 isrc.offset(SkScalarRoundToInt(mat.getTranslateX()), | 1657 isrc.offset(SkScalarRoundToInt(mat.getTranslateX()), |
| 1654 SkScalarRoundToInt(mat.getTranslateY())); | 1658 SkScalarRoundToInt(mat.getTranslateY())); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1792 const SkScalar m11 = m00; | 1796 const SkScalar m11 = m00; |
| 1793 const SkScalar m12 = fTy; | 1797 const SkScalar m12 = fTy; |
| 1794 | 1798 |
| 1795 quad[0].set(m02, m12); | 1799 quad[0].set(m02, m12); |
| 1796 quad[1].set(m00 * width + m02, m10 * width + m12); | 1800 quad[1].set(m00 * width + m02, m10 * width + m12); |
| 1797 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); | 1801 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); |
| 1798 quad[3].set(m01 * height + m02, m11 * height + m12); | 1802 quad[3].set(m01 * height + m02, m11 * height + m12); |
| 1799 #endif | 1803 #endif |
| 1800 } | 1804 } |
| 1801 | 1805 |
| OLD | NEW |