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

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

Issue 1616753003: Use fActualProc to choose fFastProc or fSlowProc in SkSwizzler (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comment 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 | « 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 "SkOpts.h" 10 #include "SkOpts.h"
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 srcWidth = frame->width(); 762 srcWidth = frame->width();
763 } 763 }
764 764
765 return new SkSwizzler(fastProc, proc, ctable, srcOffset, srcWidth, dstOffset , dstWidth, 765 return new SkSwizzler(fastProc, proc, ctable, srcOffset, srcWidth, dstOffset , dstWidth,
766 srcBPP, dstBPP); 766 srcBPP, dstBPP);
767 } 767 }
768 768
769 SkSwizzler::SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcOffset, 769 SkSwizzler::SkSwizzler(RowProc fastProc, RowProc proc, const SkPMColor* ctable, int srcOffset,
770 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP) 770 int srcWidth, int dstOffset, int dstWidth, int srcBPP, int dstBPP)
771 : fFastProc(fastProc) 771 : fFastProc(fastProc)
772 , fProc(proc) 772 , fSlowProc(proc)
773 , fActualProc(fFastProc ? fFastProc : fSlowProc)
773 , fColorTable(ctable) 774 , fColorTable(ctable)
774 , fSrcOffset(srcOffset) 775 , fSrcOffset(srcOffset)
775 , fDstOffset(dstOffset) 776 , fDstOffset(dstOffset)
776 , fSrcOffsetUnits(srcOffset * srcBPP) 777 , fSrcOffsetUnits(srcOffset * srcBPP)
777 , fDstOffsetBytes(dstOffset * dstBPP) 778 , fDstOffsetBytes(dstOffset * dstBPP)
778 , fSrcWidth(srcWidth) 779 , fSrcWidth(srcWidth)
779 , fDstWidth(dstWidth) 780 , fDstWidth(dstWidth)
780 , fSwizzleWidth(srcWidth) 781 , fSwizzleWidth(srcWidth)
781 , fAllocatedWidth(dstWidth) 782 , fAllocatedWidth(dstWidth)
782 , fSampleX(1) 783 , fSampleX(1)
783 , fSrcBPP(srcBPP) 784 , fSrcBPP(srcBPP)
784 , fDstBPP(dstBPP) 785 , fDstBPP(dstBPP)
785 {} 786 {}
786 787
787 int SkSwizzler::onSetSampleX(int sampleX) { 788 int SkSwizzler::onSetSampleX(int sampleX) {
788 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be 789 SkASSERT(sampleX > 0); // Surely there is an upper limit? Should there be
789 // way to report failure? 790 // way to report failure?
790 fSampleX = sampleX; 791 fSampleX = sampleX;
791 fSrcOffsetUnits = (get_start_coord(sampleX) + fSrcOffset) * fSrcBPP; 792 fSrcOffsetUnits = (get_start_coord(sampleX) + fSrcOffset) * fSrcBPP;
792 fDstOffsetBytes = (fDstOffset / sampleX) * fDstBPP; 793 fDstOffsetBytes = (fDstOffset / sampleX) * fDstBPP;
793 fSwizzleWidth = get_scaled_dimension(fSrcWidth, sampleX); 794 fSwizzleWidth = get_scaled_dimension(fSrcWidth, sampleX);
794 fAllocatedWidth = get_scaled_dimension(fDstWidth, sampleX); 795 fAllocatedWidth = get_scaled_dimension(fDstWidth, sampleX);
795 796
796 // The optimized swizzler routines do not (yet) support sampling. 797 // The optimized swizzler routines do not (yet) support sampling.
797 fFastProc = nullptr; 798 if (1 == fSampleX && fFastProc) {
799 fActualProc = fFastProc;
800 } else {
801 fActualProc = fSlowProc;
802 }
798 803
799 return fAllocatedWidth; 804 return fAllocatedWidth;
800 } 805 }
801 806
802 void SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) { 807 void SkSwizzler::swizzle(void* dst, const uint8_t* SK_RESTRICT src) {
803 SkASSERT(nullptr != dst && nullptr != src); 808 SkASSERT(nullptr != dst && nullptr != src);
804 RowProc proc = fFastProc ? fFastProc : fProc; 809 fActualProc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth, fS rcBPP,
805 proc(SkTAddOffset<void>(dst, fDstOffsetBytes), src, fSwizzleWidth, fSrcBPP,
806 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable); 810 fSampleX * fSrcBPP, fSrcOffsetUnits, fColorTable);
807 } 811 }
OLDNEW
« no previous file with comments | « src/codec/SkSwizzler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698