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

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

Issue 1609873003: remove fragile assert (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 11 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 "SkBitmapCache.h" 8 #include "SkBitmapCache.h"
9 #include "SkBitmapController.h" 9 #include "SkBitmapController.h"
10 #include "SkBitmapProcState.h" 10 #include "SkBitmapProcState.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); 368 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn);
369 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); 369 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
370 SkASSERT(s.fInvKy == 0); 370 SkASSERT(s.fInvKy == 0);
371 SkASSERT(count > 0 && colors != nullptr); 371 SkASSERT(count > 0 && colors != nullptr);
372 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); 372 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
373 373
374 const int maxX = s.fPixmap.width() - 1; 374 const int maxX = s.fPixmap.width() - 1;
375 const int maxY = s.fPixmap.height() - 1; 375 const int maxY = s.fPixmap.height() - 1;
376 int ix = s.fFilterOneX + x; 376 int ix = s.fFilterOneX + x;
377 int iy = SkClampMax(s.fFilterOneY + y, maxY); 377 int iy = SkClampMax(s.fFilterOneY + y, maxY);
378 #ifdef SK_DEBUG
379 {
380 SkPoint pt;
381 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
382 SkIntToScalar(y) + SK_ScalarHalf, &pt);
383 int iy2 = SkClampMax(SkScalarFloorToInt(pt.fY), maxY);
384 int ix2 = SkScalarFloorToInt(pt.fX);
385
386 SkASSERT(iy == iy2);
387 SkASSERT(ix == ix2);
388 }
389 #endif
390 const SkPMColor* row = s.fPixmap.addr32(0, iy); 378 const SkPMColor* row = s.fPixmap.addr32(0, iy);
391 379
392 // clamp to the left 380 // clamp to the left
393 if (ix < 0) { 381 if (ix < 0) {
394 int n = SkMin32(-ix, count); 382 int n = SkMin32(-ix, count);
395 sk_memset32(colors, row[0], n); 383 sk_memset32(colors, row[0], n);
396 count -= n; 384 count -= n;
397 if (0 == count) { 385 if (0 == count) {
398 return; 386 return;
399 } 387 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); 431 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn);
444 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); 432 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0);
445 SkASSERT(s.fInvKy == 0); 433 SkASSERT(s.fInvKy == 0);
446 SkASSERT(count > 0 && colors != nullptr); 434 SkASSERT(count > 0 && colors != nullptr);
447 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); 435 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel);
448 436
449 const int stopX = s.fPixmap.width(); 437 const int stopX = s.fPixmap.width();
450 const int stopY = s.fPixmap.height(); 438 const int stopY = s.fPixmap.height();
451 int ix = s.fFilterOneX + x; 439 int ix = s.fFilterOneX + x;
452 int iy = sk_int_mod(s.fFilterOneY + y, stopY); 440 int iy = sk_int_mod(s.fFilterOneY + y, stopY);
453 #ifdef SK_DEBUG
454 {
455 SkPoint pt;
456 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf,
457 SkIntToScalar(y) + SK_ScalarHalf, &pt);
458 int iy2 = sk_int_mod(SkScalarFloorToInt(pt.fY), stopY);
459 int ix2 = SkScalarFloorToInt(pt.fX);
460
461 SkASSERT(iy == iy2);
462 SkASSERT(ix == ix2);
463 }
464 #endif
465 const SkPMColor* row = s.fPixmap.addr32(0, iy); 441 const SkPMColor* row = s.fPixmap.addr32(0, iy);
466 442
467 ix = sk_int_mod(ix, stopX); 443 ix = sk_int_mod(ix, stopX);
468 for (;;) { 444 for (;;) {
469 int n = SkMin32(stopX - ix, count); 445 int n = SkMin32(stopX - ix, count);
470 memcpy(colors, row + ix, n * sizeof(SkPMColor)); 446 memcpy(colors, row + ix, n * sizeof(SkPMColor));
471 count -= n; 447 count -= n;
472 if (0 == count) { 448 if (0 == count) {
473 return; 449 return;
474 } 450 }
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 fx += dx; 803 fx += dx;
828 } 804 }
829 } else { 805 } else {
830 for (int i = 0; i < count; ++i) { 806 for (int i = 0; i < count; ++i) {
831 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; 807 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)];
832 fx += dx; 808 fx += dx;
833 } 809 }
834 } 810 }
835 } 811 }
836 812
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