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

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

Issue 1569873003: Revert of SkTreatAsSprite should take AA into account (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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/SkDraw.cpp ('k') | src/core/SkMatrixUtils.h » ('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 "SkRSXform.h" 10 #include "SkRSXform.h"
(...skipping 1605 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, const SkISize& size, const SkPaint& pa int) { 1626 bool SkTreatAsSprite(const SkMatrix& mat, int width, int height,
1627 // Our path aa is 2-bits, and our rect aa is 8, so we could use 8, 1627 unsigned subpixelBits) {
1628 // but in practice 4 seems enough (still looks smooth) and allows
1629 // more slightly fractional cases to fall into the fast (sprite) case.
1630 static const unsigned kAntiAliasSubpixelBits = 4;
1631
1632 const unsigned subpixelBits = paint.isAntiAlias() ? kAntiAliasSubpixelBits : 0;
1633
1634 // quick reject on affine or perspective 1628 // quick reject on affine or perspective
1635 if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) { 1629 if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) {
1636 return false; 1630 return false;
1637 } 1631 }
1638 1632
1639 // quick success check 1633 // quick success check
1640 if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) { 1634 if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) {
1641 return true; 1635 return true;
1642 } 1636 }
1643 1637
1644 // mapRect supports negative scales, so we eliminate those first 1638 // mapRect supports negative scales, so we eliminate those first
1645 if (mat.getScaleX() < 0 || mat.getScaleY() < 0) { 1639 if (mat.getScaleX() < 0 || mat.getScaleY() < 0) {
1646 return false; 1640 return false;
1647 } 1641 }
1648 1642
1649 SkRect dst; 1643 SkRect dst;
1650 SkIRect isrc = SkIRect::MakeSize(size); 1644 SkIRect isrc = { 0, 0, width, height };
1651 1645
1652 { 1646 {
1653 SkRect src; 1647 SkRect src;
1654 src.set(isrc); 1648 src.set(isrc);
1655 mat.mapRect(&dst, src); 1649 mat.mapRect(&dst, src);
1656 } 1650 }
1657 1651
1658 // just apply the translate to isrc 1652 // just apply the translate to isrc
1659 isrc.offset(SkScalarRoundToInt(mat.getTranslateX()), 1653 isrc.offset(SkScalarRoundToInt(mat.getTranslateX()),
1660 SkScalarRoundToInt(mat.getTranslateY())); 1654 SkScalarRoundToInt(mat.getTranslateY()));
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 const SkScalar m11 = m00; 1792 const SkScalar m11 = m00;
1799 const SkScalar m12 = fTy; 1793 const SkScalar m12 = fTy;
1800 1794
1801 quad[0].set(m02, m12); 1795 quad[0].set(m02, m12);
1802 quad[1].set(m00 * width + m02, m10 * width + m12); 1796 quad[1].set(m00 * width + m02, m10 * width + m12);
1803 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); 1797 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12);
1804 quad[3].set(m01 * height + m02, m11 * height + m12); 1798 quad[3].set(m01 * height + m02, m11 * height + m12);
1805 #endif 1799 #endif
1806 } 1800 }
1807 1801
OLDNEW
« no previous file with comments | « src/core/SkDraw.cpp ('k') | src/core/SkMatrixUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698