| 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 /** |
| 24 * Fill the remainder of the destination with a single color | 48 * Fill the remainder of the destination with a single color |
| 25 * | 49 * |
| 26 * @param info | 50 * @param info |
| 27 * Contains the color type of the rows to fill. | 51 * Contains the color type of the rows to fill. |
| 28 * Contains the width of the destination rows to fill | 52 * Contains the width of the destination rows to fill |
| 29 * Contains the number of rows that we need to fill. | 53 * Contains the number of rows that we need to fill. |
| 30 * | 54 * |
| 31 * @param dst | 55 * @param dst |
| 32 * The destination row to fill from. | 56 * The destination row to fill from. |
| 33 * | 57 * |
| (...skipping 14 matching lines...) Expand all Loading... |
| 48 */ | 72 */ |
| 49 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes, | 73 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes, |
| 50 uint64_t colorOrIndex, SkCodec::ZeroInitialized zeroInit); | 74 uint64_t colorOrIndex, SkCodec::ZeroInitialized zeroInit); |
| 51 | 75 |
| 52 /** | 76 /** |
| 53 * Allow subclasses to implement unique versions of fill(). | 77 * Allow subclasses to implement unique versions of fill(). |
| 54 */ | 78 */ |
| 55 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes, | 79 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes, |
| 56 uint64_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {} | 80 uint64_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {} |
| 57 | 81 |
| 82 SkSampler() |
| 83 : fSampleY(1) |
| 84 {} |
| 85 |
| 58 virtual ~SkSampler() {} | 86 virtual ~SkSampler() {} |
| 59 private: | 87 private: |
| 88 int fSampleY; |
| 60 | 89 |
| 61 virtual int onSetSampleX(int) = 0; | 90 virtual int onSetSampleX(int) = 0; |
| 62 }; | 91 }; |
| 63 | 92 |
| 64 #endif // SkSampler_DEFINED | 93 #endif // SkSampler_DEFINED |
| OLD | NEW |