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

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

Issue 1566943002: SkTreatAsSprite should take AA into account (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: 4 subpixel bits 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, int width, int height, 1626 bool SkTreatAsSprite(const SkMatrix& mat, const SkISize& size, const SkPaint& pa int) {
1627 unsigned subpixelBits) { 1627 static const unsigned kAntiAliasSubpixelBits = 4;
reed1 2016/01/07 15:29:59 maybe a comment, like "our path aa is 2-bits, and
f(malita) 2016/01/07 15:39:35 Done.
1628
1629 const unsigned subpixelBits = paint.isAntiAlias() ? kAntiAliasSubpixelBits : 0;
1630
1628 // quick reject on affine or perspective 1631 // quick reject on affine or perspective
1629 if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) { 1632 if (mat.getType() & ~(SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) {
1630 return false; 1633 return false;
1631 } 1634 }
1632 1635
1633 // quick success check 1636 // quick success check
1634 if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) { 1637 if (!subpixelBits && !(mat.getType() & ~SkMatrix::kTranslate_Mask)) {
1635 return true; 1638 return true;
1636 } 1639 }
1637 1640
1638 // mapRect supports negative scales, so we eliminate those first 1641 // mapRect supports negative scales, so we eliminate those first
1639 if (mat.getScaleX() < 0 || mat.getScaleY() < 0) { 1642 if (mat.getScaleX() < 0 || mat.getScaleY() < 0) {
1640 return false; 1643 return false;
1641 } 1644 }
1642 1645
1643 SkRect dst; 1646 SkRect dst;
1644 SkIRect isrc = { 0, 0, width, height }; 1647 SkIRect isrc = SkIRect::MakeSize(size);
1645 1648
1646 { 1649 {
1647 SkRect src; 1650 SkRect src;
1648 src.set(isrc); 1651 src.set(isrc);
1649 mat.mapRect(&dst, src); 1652 mat.mapRect(&dst, src);
1650 } 1653 }
1651 1654
1652 // just apply the translate to isrc 1655 // just apply the translate to isrc
1653 isrc.offset(SkScalarRoundToInt(mat.getTranslateX()), 1656 isrc.offset(SkScalarRoundToInt(mat.getTranslateX()),
1654 SkScalarRoundToInt(mat.getTranslateY())); 1657 SkScalarRoundToInt(mat.getTranslateY()));
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 const SkScalar m11 = m00; 1795 const SkScalar m11 = m00;
1793 const SkScalar m12 = fTy; 1796 const SkScalar m12 = fTy;
1794 1797
1795 quad[0].set(m02, m12); 1798 quad[0].set(m02, m12);
1796 quad[1].set(m00 * width + m02, m10 * width + m12); 1799 quad[1].set(m00 * width + m02, m10 * width + m12);
1797 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12); 1800 quad[2].set(m00 * width + m01 * height + m02, m10 * width + m11 * height + m 12);
1798 quad[3].set(m01 * height + m02, m11 * height + m12); 1801 quad[3].set(m01 * height + m02, m11 * height + m12);
1799 #endif 1802 #endif
1800 } 1803 }
1801 1804
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