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

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

Issue 1650403002: Remove SkBitmapProcStateAutoMapper's overflow check (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 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 | « src/core/SkBitmapProcState.h ('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 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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkBitmapController.h" 9 #include "SkBitmapController.h"
10 #include "SkBitmapProcState.h" 10 #include "SkBitmapProcState.h"
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 sk_memset32(colors, color, count); 579 sk_memset32(colors, color, count);
580 } 580 }
581 581
582 static void DoNothing_shaderproc(const void*, int x, int y, 582 static void DoNothing_shaderproc(const void*, int x, int y,
583 SkPMColor* SK_RESTRICT colors, int count) { 583 SkPMColor* SK_RESTRICT colors, int count) {
584 // if we get called, the matrix is too tricky, so we just draw nothing 584 // if we get called, the matrix is too tricky, so we just draw nothing
585 sk_memset32(colors, 0, count); 585 sk_memset32(colors, 0, count);
586 } 586 }
587 587
588 bool SkBitmapProcState::setupForTranslate() { 588 bool SkBitmapProcState::setupForTranslate() {
589 SkPoint pt;
590
589 #ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS 591 #ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS
590 SkPoint pt;
591 fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt); 592 fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt);
592
593 const SkScalar too_big = SkIntToScalar(1 << 30);
594 if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) {
595 return false;
596 }
597
598 fFilterOneX = SkScalarFloorToInt(pt.fX);
599 fFilterOneY = SkScalarFloorToInt(pt.fY);
600 #else 593 #else
601 SkBitmapProcStateAutoMapper mapper(*this, 0, 0); 594 const SkBitmapProcStateAutoMapper mapper(*this, 0, 0, &pt);
595 #endif
602 596
603 /* 597 /*
604 * if the translate is larger than our ints, we can get random results, or 598 * if the translate is larger than our ints, we can get random results, or
605 * worse, we might get 0x80000000, which wreaks havoc on us, since we can't 599 * worse, we might get 0x80000000, which wreaks havoc on us, since we can't
606 * negate it. 600 * negate it.
607 */ 601 */
608 if (mapper.isOverflow()) { 602 const SkScalar too_big = SkIntToScalar(1 << 30);
603 if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) {
609 return false; 604 return false;
610 } 605 }
611 606
607 #ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS
608 fFilterOneX = SkScalarFloorToInt(pt.fX);
609 fFilterOneY = SkScalarFloorToInt(pt.fY);
610 #else
612 // Since we know we're not filtered, we re-purpose these fields allow 611 // Since we know we're not filtered, we re-purpose these fields allow
613 // us to go from device -> src coordinates w/ just an integer add, 612 // us to go from device -> src coordinates w/ just an integer add,
614 // rather than running through the inverse-matrix 613 // rather than running through the inverse-matrix
615 fFilterOneX = SkFractionalIntToInt(mapper.x()); 614 fFilterOneX = SkFractionalIntToInt(mapper.x());
616 fFilterOneY = SkFractionalIntToInt(mapper.y()); 615 fFilterOneY = SkFractionalIntToInt(mapper.y());
617 #endif 616 #endif
618 617
619 return true; 618 return true;
620 } 619 }
621 620
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 fx += dx; 826 fx += dx;
828 } 827 }
829 } else { 828 } else {
830 for (int i = 0; i < count; ++i) { 829 for (int i = 0; i < count; ++i) {
831 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 830 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
832 fx += dx; 831 fx += dx;
833 } 832 }
834 } 833 }
835 } 834 }
836 835
OLDNEW
« no previous file with comments | « src/core/SkBitmapProcState.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698