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

Side by Side Diff: src/gpu/GrPathUtils.cpp

Issue 1749373002: Force values to 0.0f in QuadUVMatrix::set (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | 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 2011 Google Inc. 2 * Copyright 2011 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 #include "GrPathUtils.h" 8 #include "GrPathUtils.h"
9 9
10 #include "GrTypes.h" 10 #include "GrTypes.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } else { 260 } else {
261 // It's a point. It should cover zero area. Just set the matrix such 261 // It's a point. It should cover zero area. Just set the matrix such
262 // that (u, v) will always be far away from the quad. 262 // that (u, v) will always be far away from the quad.
263 fM[0] = 0; fM[1] = 0; fM[2] = 100.f; 263 fM[0] = 0; fM[1] = 0; fM[2] = 100.f;
264 fM[3] = 0; fM[4] = 0; fM[5] = 100.f; 264 fM[3] = 0; fM[4] = 0; fM[5] = 100.f;
265 } 265 }
266 } else { 266 } else {
267 double scale = 1.0/det; 267 double scale = 1.0/det;
268 268
269 // compute adjugate matrix 269 // compute adjugate matrix
270 double a0, a1, a2, a3, a4, a5, a6, a7, a8; 270 double a2, a3, a4, a5, a6, a7, a8;
271 a0 = y1-y2;
272 a1 = x2-x1;
273 a2 = x1*y2-x2*y1; 271 a2 = x1*y2-x2*y1;
274 272
275 a3 = y2-y0; 273 a3 = y2-y0;
276 a4 = x0-x2; 274 a4 = x0-x2;
277 a5 = x2*y0-x0*y2; 275 a5 = x2*y0-x0*y2;
278 276
279 a6 = y0-y1; 277 a6 = y0-y1;
280 a7 = x1-x0; 278 a7 = x1-x0;
281 a8 = x0*y1-x1*y0; 279 a8 = x0*y1-x1*y0;
282 280
283 // this performs the uv_pts*adjugate(control_pts) multiply, 281 // this performs the uv_pts*adjugate(control_pts) multiply,
284 // then does the scale by 1/det afterwards to improve precision 282 // then does the scale by 1/det afterwards to improve precision
285 m[SkMatrix::kMScaleX] = (float)((0.5*a3 + a6)*scale); 283 m[SkMatrix::kMScaleX] = (float)((0.5*a3 + a6)*scale);
286 m[SkMatrix::kMSkewX] = (float)((0.5*a4 + a7)*scale); 284 m[SkMatrix::kMSkewX] = (float)((0.5*a4 + a7)*scale);
287 m[SkMatrix::kMTransX] = (float)((0.5*a5 + a8)*scale); 285 m[SkMatrix::kMTransX] = (float)((0.5*a5 + a8)*scale);
288 286
289 m[SkMatrix::kMSkewY] = (float)(a6*scale); 287 m[SkMatrix::kMSkewY] = (float)(a6*scale);
290 m[SkMatrix::kMScaleY] = (float)(a7*scale); 288 m[SkMatrix::kMScaleY] = (float)(a7*scale);
291 m[SkMatrix::kMTransY] = (float)(a8*scale); 289 m[SkMatrix::kMTransY] = (float)(a8*scale);
292 290
293 m[SkMatrix::kMPersp0] = (float)((a0 + a3 + a6)*scale); 291 // kMPersp0 & kMPersp1 should algebraically be zero
294 m[SkMatrix::kMPersp1] = (float)((a1 + a4 + a7)*scale); 292 m[SkMatrix::kMPersp0] = 0.0f;
293 m[SkMatrix::kMPersp1] = 0.0f;
295 m[SkMatrix::kMPersp2] = (float)((a2 + a5 + a8)*scale); 294 m[SkMatrix::kMPersp2] = (float)((a2 + a5 + a8)*scale);
296 295
297 // The matrix should not have perspective.
298 SkDEBUGCODE(static const SkScalar gTOL = 1.f / 100.f);
299 SkASSERT(SkScalarAbs(m.get(SkMatrix::kMPersp0)) < gTOL);
300 SkASSERT(SkScalarAbs(m.get(SkMatrix::kMPersp1)) < gTOL);
301
302 // It may not be normalized to have 1.0 in the bottom right 296 // It may not be normalized to have 1.0 in the bottom right
303 float m33 = m.get(SkMatrix::kMPersp2); 297 float m33 = m.get(SkMatrix::kMPersp2);
304 if (1.f != m33) { 298 if (1.f != m33) {
305 m33 = 1.f / m33; 299 m33 = 1.f / m33;
306 fM[0] = m33 * m.get(SkMatrix::kMScaleX); 300 fM[0] = m33 * m.get(SkMatrix::kMScaleX);
307 fM[1] = m33 * m.get(SkMatrix::kMSkewX); 301 fM[1] = m33 * m.get(SkMatrix::kMSkewX);
308 fM[2] = m33 * m.get(SkMatrix::kMTransX); 302 fM[2] = m33 * m.get(SkMatrix::kMTransX);
309 fM[3] = m33 * m.get(SkMatrix::kMSkewY); 303 fM[3] = m33 * m.get(SkMatrix::kMSkewY);
310 fM[4] = m33 * m.get(SkMatrix::kMScaleY); 304 fM[4] = m33 * m.get(SkMatrix::kMScaleY);
311 fM[5] = m33 * m.get(SkMatrix::kMTransY); 305 fM[5] = m33 * m.get(SkMatrix::kMTransY);
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 set_loop_klm(d, controlK, controlL, controlM); 813 set_loop_klm(d, controlK, controlL, controlM);
820 } else if (kCusp_SkCubicType == cType) { 814 } else if (kCusp_SkCubicType == cType) {
821 SkASSERT(0.f == d[0]); 815 SkASSERT(0.f == d[0]);
822 set_cusp_klm(d, controlK, controlL, controlM); 816 set_cusp_klm(d, controlK, controlL, controlM);
823 } else if (kQuadratic_SkCubicType == cType) { 817 } else if (kQuadratic_SkCubicType == cType) {
824 set_quadratic_klm(d, controlK, controlL, controlM); 818 set_quadratic_klm(d, controlK, controlL, controlM);
825 } 819 }
826 820
827 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]); 821 calc_cubic_klm(p, controlK, controlL, controlM, klm, &klm[3], &klm[6]);
828 } 822 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698