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/SkScan_AntiPath.cpp

Issue 1503423003: ubsan shift fixes (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add cast to work around win compiler Created 5 years 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/SkFloatBits.cpp ('k') | src/core/SkScan_Antihair.cpp » ('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 /* 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 "SkScanPriv.h" 10 #include "SkScanPriv.h"
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 return; 538 return;
539 } 539 }
540 540
541 #ifdef SK_DEBUG 541 #ifdef SK_DEBUG
542 { 542 {
543 int ix = x >> SHIFT; 543 int ix = x >> SHIFT;
544 SkASSERT(ix >= fMask.fBounds.fLeft && ix < fMask.fBounds.fRight); 544 SkASSERT(ix >= fMask.fBounds.fLeft && ix < fMask.fBounds.fRight);
545 } 545 }
546 #endif 546 #endif
547 547
548 x -= (fMask.fBounds.fLeft << SHIFT); 548 x -= SkLeftShift(fMask.fBounds.fLeft, SHIFT);
549 549
550 // hack, until I figure out why my cubics (I think) go beyond the bounds 550 // hack, until I figure out why my cubics (I think) go beyond the bounds
551 if (x < 0) { 551 if (x < 0) {
552 width += x; 552 width += x;
553 x = 0; 553 x = 0;
554 } 554 }
555 555
556 uint8_t* row = fMask.fImage + iy * fMask.fRowBytes + (x >> SHIFT); 556 uint8_t* row = fMask.fImage + iy * fMask.fRowBytes + (x >> SHIFT);
557 557
558 int start = x; 558 int start = x;
(...skipping 26 matching lines...) Expand all
585 /////////////////////////////////////////////////////////////////////////////// 585 ///////////////////////////////////////////////////////////////////////////////
586 586
587 static bool fitsInsideLimit(const SkRect& r, SkScalar max) { 587 static bool fitsInsideLimit(const SkRect& r, SkScalar max) {
588 const SkScalar min = -max; 588 const SkScalar min = -max;
589 return r.fLeft > min && r.fTop > min && 589 return r.fLeft > min && r.fTop > min &&
590 r.fRight < max && r.fBottom < max; 590 r.fRight < max && r.fBottom < max;
591 } 591 }
592 592
593 static int overflows_short_shift(int value, int shift) { 593 static int overflows_short_shift(int value, int shift) {
594 const int s = 16 + shift; 594 const int s = 16 + shift;
595 return (value << s >> s) - value; 595 return (SkLeftShift(value, s) >> s) - value;
596 } 596 }
597 597
598 /** 598 /**
599 Would any of the coordinates of this rectangle not fit in a short, 599 Would any of the coordinates of this rectangle not fit in a short,
600 when left-shifted by shift? 600 when left-shifted by shift?
601 */ 601 */
602 static int rect_overflows_short_shift(SkIRect rect, int shift) { 602 static int rect_overflows_short_shift(SkIRect rect, int shift) {
603 SkASSERT(!overflows_short_shift(8191, SHIFT)); 603 SkASSERT(!overflows_short_shift(8191, SHIFT));
604 SkASSERT(overflows_short_shift(8192, SHIFT)); 604 SkASSERT(overflows_short_shift(8192, SHIFT));
605 SkASSERT(!overflows_short_shift(32767, 0)); 605 SkASSERT(!overflows_short_shift(32767, 0));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 AntiFillPath(path, clip.bwRgn(), blitter); 758 AntiFillPath(path, clip.bwRgn(), blitter);
759 } else { 759 } else {
760 SkRegion tmp; 760 SkRegion tmp;
761 SkAAClipBlitter aaBlitter; 761 SkAAClipBlitter aaBlitter;
762 762
763 tmp.setRect(clip.getBounds()); 763 tmp.setRect(clip.getBounds());
764 aaBlitter.init(blitter, &clip.aaRgn()); 764 aaBlitter.init(blitter, &clip.aaRgn());
765 SkScan::AntiFillPath(path, tmp, &aaBlitter, true); 765 SkScan::AntiFillPath(path, tmp, &aaBlitter, true);
766 } 766 }
767 } 767 }
OLDNEW
« no previous file with comments | « src/core/SkFloatBits.cpp ('k') | src/core/SkScan_Antihair.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698