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

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

Issue 1774963002: work around leftshift for negative values (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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkEdge.h" 10 #include "SkEdge.h"
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 /* f(1/3) = (8a + 12b + 6c + d) / 27 319 /* f(1/3) = (8a + 12b + 6c + d) / 27
320 f(2/3) = (a + 6b + 12c + 8d) / 27 320 f(2/3) = (a + 6b + 12c + 8d) / 27
321 321
322 f(1/3)-b = (8a - 15b + 6c + d) / 27 322 f(1/3)-b = (8a - 15b + 6c + d) / 27
323 f(2/3)-c = (a + 6b - 15c + 8d) / 27 323 f(2/3)-c = (a + 6b - 15c + 8d) / 27
324 324
325 use 16/512 to approximate 1/27 325 use 16/512 to approximate 1/27
326 */ 326 */
327 static SkFDot6 cubic_delta_from_line(SkFDot6 a, SkFDot6 b, SkFDot6 c, SkFDot6 d) 327 static SkFDot6 cubic_delta_from_line(SkFDot6 a, SkFDot6 b, SkFDot6 c, SkFDot6 d)
328 { 328 {
329 SkFDot6 oneThird = ((a << 3) - ((b << 4) - b) + 6*c + d) * 19 >> 9; 329 // since our parameters may be negative, we don't use << to avoid ASAN warni ngs
330 SkFDot6 twoThird = (a + 6*b - ((c << 4) - c) + (d << 3)) * 19 >> 9; 330 SkFDot6 oneThird = (a*8 - b*15 + 6*c + d) * 19 >> 9;
331 SkFDot6 twoThird = (a + 6*b - c*15 + d*8) * 19 >> 9;
caryclark 2016/03/08 14:20:23 I'm curious how this works. If the bug is that the
reed1 2016/03/08 14:26:44 I don't think that is the bug. I think the bug fro
331 332
332 return SkMax32(SkAbs32(oneThird), SkAbs32(twoThird)); 333 return SkMax32(SkAbs32(oneThird), SkAbs32(twoThird));
333 } 334 }
334 335
335 int SkCubicEdge::setCubic(const SkPoint pts[4], int shift) { 336 int SkCubicEdge::setCubic(const SkPoint pts[4], int shift) {
336 SkFDot6 x0, y0, x1, y1, x2, y2, x3, y3; 337 SkFDot6 x0, y0, x1, y1, x2, y2, x3, y3;
337 338
338 { 339 {
339 #ifdef SK_RASTERIZE_EVEN_ROUNDING 340 #ifdef SK_RASTERIZE_EVEN_ROUNDING
340 x0 = SkScalarRoundToFDot6(pts[0].fX, shift); 341 x0 = SkScalarRoundToFDot6(pts[0].fX, shift);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 success = this->updateLine(oldx, oldy, newx, newy); 471 success = this->updateLine(oldx, oldy, newx, newy);
471 oldx = newx; 472 oldx = newx;
472 oldy = newy; 473 oldy = newy;
473 } while (count < 0 && !success); 474 } while (count < 0 && !success);
474 475
475 fCx = newx; 476 fCx = newx;
476 fCy = newy; 477 fCy = newy;
477 fCurveCount = SkToS8(count); 478 fCurveCount = SkToS8(count);
478 return success; 479 return success;
479 } 480 }
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