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

Side by Side Diff: src/core/SkMatrixPriv.h

Issue 2276603002: combine setRectFan and mapRect (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rearrange parameter order Created 4 years, 4 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 | src/gpu/GrQuad.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 2016 Google Inc. 2 * Copyright 2016 Google Inc.
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 #ifndef SkMatrixPriv_DEFINE 8 #ifndef SkMatrixPriv_DEFINE
9 #define SkMatrixPriv_DEFINE 9 #define SkMatrixPriv_DEFINE
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } 58 }
59 // Insert other special-cases here (e.g. scale+translate) 59 // Insert other special-cases here (e.g. scale+translate)
60 60
61 // general case 61 // general case
62 SkMatrix::MapXYProc proc = mx.getMapXYProc(); 62 SkMatrix::MapXYProc proc = mx.getMapXYProc();
63 for (int i = 0; i < count; ++i) { 63 for (int i = 0; i < count; ++i) {
64 proc(mx, pts->fX, pts->fY, pts); 64 proc(mx, pts->fX, pts->fY, pts);
65 pts = (SkPoint*)((intptr_t)pts + stride); 65 pts = (SkPoint*)((intptr_t)pts + stride);
66 } 66 }
67 } 67 }
68
69 static void SetMappedRectFan(const SkMatrix& mx, const SkRect& rect, SkPoint quad[4]) {
70 SkMatrix::TypeMask tm = mx.getType();
71 SkScalar l = rect.fLeft;
72 SkScalar t = rect.fTop;
73 SkScalar r = rect.fRight;
74 SkScalar b = rect.fBottom;
75 if (tm <= (SkMatrix::kScale_Mask | SkMatrix::kTranslate_Mask)) {
76 const SkScalar tx = mx.getTranslateX();
77 const SkScalar ty = mx.getTranslateY();
78 if (tm <= SkMatrix::kTranslate_Mask) {
79 l += tx;
80 t += ty;
81 r += tx;
82 b += ty;
83 } else {
84 const SkScalar sx = mx.getScaleX();
85 const SkScalar sy = mx.getScaleY();
86 l = sx * l + tx;
87 t = sy * t + ty;
88 r = sx * r + tx;
89 b = sy * b + ty;
90 }
91 quad[0].set(l, t);
92 quad[1].set(l, b);
93 quad[2].set(r, b);
94 quad[3].set(r, t);
95 } else {
96 quad[0].setRectFan(l, t, r, b);
97 mx.mapPoints(quad, quad, 4);
98 }
99 }
68 }; 100 };
69 101
70 #endif 102 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrQuad.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698