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

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

Issue 1181913003: add SkCanvas::drawAtlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 6 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
« samplecode/SampleAtlas.cpp ('K') | « src/core/SkCanvas.cpp ('k') | 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 "SkMatrix.h" 8 #include "SkMatrix.h"
9 #include "SkFloatBits.h" 9 #include "SkFloatBits.h"
10 #include "SkRSXform.h"
10 #include "SkString.h" 11 #include "SkString.h"
11 #include "SkNx.h" 12 #include "SkNx.h"
12 13
13 #include <stddef.h> 14 #include <stddef.h>
14 15
15 static void normalize_perspective(SkScalar mat[9]) { 16 static void normalize_perspective(SkScalar mat[9]) {
16 // If it was interesting to never store the last element, we could divide al l 8 other 17 // If it was interesting to never store the last element, we could divide al l 8 other
17 // elements here by the 9th, making it 1.0... 18 // elements here by the 9th, making it 1.0...
18 // 19 //
19 // When SkScalar was SkFixed, we would sometimes rescale the entire matrix t o keep its 20 // When SkScalar was SkFixed, we would sometimes rescale the entire matrix t o keep its
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 fMat[kMSkewY] = sinV; 434 fMat[kMSkewY] = sinV;
434 fMat[kMScaleY] = cosV; 435 fMat[kMScaleY] = cosV;
435 fMat[kMTransY] = sdot(-sinV, px, oneMinusCosV, py); 436 fMat[kMTransY] = sdot(-sinV, px, oneMinusCosV, py);
436 437
437 fMat[kMPersp0] = fMat[kMPersp1] = 0; 438 fMat[kMPersp0] = fMat[kMPersp1] = 0;
438 fMat[kMPersp2] = 1; 439 fMat[kMPersp2] = 1;
439 440
440 this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask); 441 this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask);
441 } 442 }
442 443
444 SkMatrix& SkMatrix::setRSXform(const SkRSXform& xform) {
445 fMat[kMScaleX] = xform.fSCos;
446 fMat[kMSkewX] = -xform.fSSin;
447 fMat[kMTransX] = xform.fTx;
448
449 fMat[kMSkewY] = xform.fSSin;
450 fMat[kMScaleY] = xform.fSCos;
451 fMat[kMTransY] = xform.fTy;
452
453 fMat[kMPersp0] = fMat[kMPersp1] = 0;
454 fMat[kMPersp2] = 1;
455
robertphillips 2015/06/15 16:12:55 Seems like we could do better than this.
reed1 2015/06/15 18:52:33 Acknowledged.
456 this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask);
457 return *this;
458 }
459
443 void SkMatrix::setSinCos(SkScalar sinV, SkScalar cosV) { 460 void SkMatrix::setSinCos(SkScalar sinV, SkScalar cosV) {
444 fMat[kMScaleX] = cosV; 461 fMat[kMScaleX] = cosV;
445 fMat[kMSkewX] = -sinV; 462 fMat[kMSkewX] = -sinV;
446 fMat[kMTransX] = 0; 463 fMat[kMTransX] = 0;
447 464
448 fMat[kMSkewY] = sinV; 465 fMat[kMSkewY] = sinV;
449 fMat[kMScaleY] = cosV; 466 fMat[kMScaleY] = cosV;
450 fMat[kMTransY] = 0; 467 fMat[kMTransY] = 0;
451 468
452 fMat[kMPersp0] = fMat[kMPersp1] = 0; 469 fMat[kMPersp0] = fMat[kMPersp1] = 0;
(...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 rotation1->fX = cos1; 1810 rotation1->fX = cos1;
1794 rotation1->fY = sin1; 1811 rotation1->fY = sin1;
1795 } 1812 }
1796 if (rotation2) { 1813 if (rotation2) {
1797 rotation2->fX = cos2; 1814 rotation2->fX = cos2;
1798 rotation2->fY = sin2; 1815 rotation2->fY = sin2;
1799 } 1816 }
1800 1817
1801 return true; 1818 return true;
1802 } 1819 }
1820
1821 //////////////////////////////////////////////////////////////////////////////// //////////////////
1822
1823 void SkRSXform::toQuad(SkScalar width, SkScalar height, SkPoint quad[4]) const {
1824 quad[0].set(0, 0);
1825 quad[1].set(width, 0);
1826 quad[2].set(width, height);
1827 quad[3].set(0, height);
1828 SkMatrix m;
1829 m.setRSXform(*this).mapPoints(quad, quad, 4);
1830 }
1831
OLDNEW
« samplecode/SampleAtlas.cpp ('K') | « src/core/SkCanvas.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698