| OLD | NEW |
| 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 #ifndef SkSampler_DEFINED | 7 #ifndef SkSampler_DEFINED |
| 8 #define SkSampler_DEFINED | 8 #define SkSampler_DEFINED |
| 9 | 9 |
| 10 #include "SkCodec.h" | 10 #include "SkCodec.h" |
| 11 #include "SkTypes.h" | 11 #include "SkTypes.h" |
| 12 | 12 |
| 13 class SkSampler : public SkNoncopyable { | 13 class SkSampler : public SkNoncopyable { |
| 14 public: | 14 public: |
| 15 /** | 15 /** |
| 16 * Update the sampler to sample every sampleX'th pixel. Returns the | 16 * Update the sampler to sample every sampleX'th pixel. Returns the |
| 17 * width after sampling. | 17 * width after sampling. |
| 18 */ | 18 */ |
| 19 int setSampleX(int sampleX) { | 19 int setSampleX(int sampleX) { |
| 20 return this->onSetSampleX(sampleX); | 20 return this->onSetSampleX(sampleX); |
| 21 } | 21 } |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Update the sampler to sample every sampleY'th row. | |
| 25 */ | |
| 26 void setSampleY(int sampleY) { | |
| 27 fSampleY = sampleY; | |
| 28 } | |
| 29 | |
| 30 /** | |
| 31 * Retrieve the value set for sampleY. | |
| 32 */ | |
| 33 int sampleY() const { | |
| 34 return fSampleY; | |
| 35 } | |
| 36 | |
| 37 /** | |
| 38 * Based on fSampleY, return whether this row belongs in the output. | |
| 39 * | |
| 40 * @param row Row of the image, starting with the first row used in the | |
| 41 * output. | |
| 42 */ | |
| 43 bool rowNeeded(int row) const { | |
| 44 return row % fSampleY == 0; | |
| 45 } | |
| 46 | |
| 47 /** | |
| 48 * Fill the remainder of the destination with a single color | 24 * Fill the remainder of the destination with a single color |
| 49 * | 25 * |
| 50 * @param info | 26 * @param info |
| 51 * Contains the color type of the rows to fill. | 27 * Contains the color type of the rows to fill. |
| 52 * Contains the width of the destination rows to fill | 28 * Contains the width of the destination rows to fill |
| 53 * Contains the number of rows that we need to fill. | 29 * Contains the number of rows that we need to fill. |
| 54 * | 30 * |
| 55 * @param dst | 31 * @param dst |
| 56 * The destination row to fill from. | 32 * The destination row to fill from. |
| 57 * | 33 * |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 */ | 47 */ |
| 72 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes, | 48 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes, |
| 73 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit); | 49 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit); |
| 74 | 50 |
| 75 /** | 51 /** |
| 76 * Allow subclasses to implement unique versions of fill(). | 52 * Allow subclasses to implement unique versions of fill(). |
| 77 */ | 53 */ |
| 78 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes, | 54 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes, |
| 79 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {} | 55 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {} |
| 80 | 56 |
| 81 SkSampler() | |
| 82 : fSampleY(1) | |
| 83 {} | |
| 84 | |
| 85 virtual ~SkSampler() {} | 57 virtual ~SkSampler() {} |
| 86 private: | 58 private: |
| 87 int fSampleY; | |
| 88 | 59 |
| 89 virtual int onSetSampleX(int) = 0; | 60 virtual int onSetSampleX(int) = 0; |
| 90 }; | 61 }; |
| 91 | 62 |
| 92 #endif // SkSampler_DEFINED | 63 #endif // SkSampler_DEFINED |
| OLD | NEW |