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

Side by Side Diff: src/codec/SkSwizzler.cpp

Issue 1407603003: Fix SkSwizzler bug (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments Created 5 years, 2 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
« src/codec/SkSwizzler.h ('K') | « src/codec/SkSwizzler.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 2015 Google Inc. 2 * Copyright 2015 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 "SkCodecPriv.h" 8 #include "SkCodecPriv.h"
9 #include "SkColorPriv.h" 9 #include "SkColorPriv.h"
10 #include "SkScaledCodec.h" 10 #include "SkScaledCodec.h"
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 return nullptr; 683 return nullptr;
684 } 684 }
685 685
686 // Store deltaSrc in bytes if it is an even multiple, otherwise use bits 686 // Store deltaSrc in bytes if it is an even multiple, otherwise use bits
687 int deltaSrc = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) : BitsPerPix el(sc); 687 int deltaSrc = SkIsAlign8(BitsPerPixel(sc)) ? BytesPerPixel(sc) : BitsPerPix el(sc);
688 688
689 return new SkSwizzler(proc, ctable, deltaSrc, dstInfo.width()); 689 return new SkSwizzler(proc, ctable, deltaSrc, dstInfo.width());
690 } 690 }
691 691
692 SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable, 692 SkSwizzler::SkSwizzler(RowProc proc, const SkPMColor* ctable,
693 int deltaSrc, int srcWidth) 693 int deltaSrc, int subsetWidth)
694 : fRowProc(proc) 694 : fRowProc(proc)
695 , fColorTable(ctable) 695 , fColorTable(ctable)
696 , fDeltaSrc(deltaSrc) 696 , fDeltaSrc(deltaSrc)
697 , fSrcWidth(srcWidth) 697 , fSubsetWidth(subsetWidth)
698 , fDstWidth(srcWidth) 698 , fDstWidth(subsetWidth)
699 , fSampleX(1) 699 , fSampleX(1)
700 , fX0(0) 700 , fX0(0)
701 {} 701 {}
702 702
703 int SkSwizzler::onSetSampleX(int sampleX) { 703 int SkSwizzler::onSetSampleX(int sampleX) {
704 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be 704 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be
705 // way to report failure? 705 // way to report failure?
706 fSampleX = sampleX; 706 fSampleX = sampleX;
707 fX0 = get_start_coord(sampleX); 707 fX0 = get_start_coord(sampleX);
708 fDstWidth = get_scaled_dimension(fSrcWidth, sampleX); 708 fDstWidth = get_scaled_dimension(fSubsetWidth, sampleX);
709 709
710 // check that fX0 is less than original width 710 // check that fX0 is valid
711 SkASSERT(fX0 >= 0 && fX0 < fSrcWidth); 711 SkASSERT(fX0 >= 0);
712 return fDstWidth; 712 return fDstWidth;
713 } 713 }
714 714
715 SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRIC T src) { 715 SkSwizzler::ResultAlpha SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRIC T src) {
716 SkASSERT(nullptr != dst && nullptr != src); 716 SkASSERT(nullptr != dst && nullptr != src);
717 return fRowProc(dst, src, fDstWidth, fDeltaSrc, fSampleX * fDeltaSrc, 717 return fRowProc(dst, src, fDstWidth, fDeltaSrc, fSampleX * fDeltaSrc,
718 fX0 * fDeltaSrc, fColorTable); 718 fX0 * fDeltaSrc, fColorTable);
719 } 719 }
OLDNEW
« src/codec/SkSwizzler.h ('K') | « src/codec/SkSwizzler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698