1 /* 2 * Copyright 2015 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 #ifndef SkSampler_DEFINED 8 #define SkSampler_DEFINED 9 10 #include "SkCodec.h" 11 #include "SkTypes.h" 12 13 class SkSampler : public SkNoncopyable { 14 public: 15 /** 16 * Update the sampler to sample every sampleX'th pixel. Returns the 17 * width after sampling. 18 */ setSampleX(int sampleX)19 int setSampleX(int sampleX) { 20 return this->onSetSampleX(sampleX); 21 } 22 23 /** 24 * Fill the remainder of the destination with a single color 25 * 26 * @param info 27 * Contains the color type of the rows to fill. 28 * Contains the width of the destination rows to fill 29 * Contains the number of rows that we need to fill. 30 * 31 * @param dst 32 * The destination row to fill from. 33 * 34 * @param rowBytes 35 * Stride in bytes of the destination. 36 * 37 * @param colorOrIndex 38 * If colorType is kN32, colorOrIndex is treated as a 32-bit color. 39 * If colorType is k565, colorOrIndex is treated as a 16-bit color. 40 * If colorType is kGray, colorOrIndex is treated as an 8-bit color. 41 * If colorType is kIndex, colorOrIndex is treated as an 8-bit index. 42 * Other SkColorTypes are not supported. 43 * 44 * @param zeroInit 45 * Indicates whether memory is already zero initialized. 46 * 47 */ 48 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes, 49 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit); 50 51 /** 52 * Allow subclasses to implement unique versions of fill(). 53 */ fill(const SkImageInfo & info,void * dst,size_t rowBytes,uint32_t colorOrIndex,SkCodec::ZeroInitialized zeroInit)54 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes, 55 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {} 56 ~SkSampler()57 virtual ~SkSampler() {} 58 private: 59 60 virtual int onSetSampleX(int) = 0; 61 }; 62 63 #endif // SkSampler_DEFINED 64