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 * @param row Zero-based index into the subset. | |
40 */ | |
41 bool rowNeeded(int row) const { | |
42 return row % fSampleY == 0; | |
msarett
2016/05/24 13:14:07
Is this correct? I think we don't start at row 0.
scroggo
2016/05/24 14:24:50
I believe it's used correctly by SkPngCodec, but i
msarett
2016/05/24 14:28:33
Gotcha thanks.
| |
43 } | |
44 | |
45 /** | |
24 * Fill the remainder of the destination with a single color | 46 * Fill the remainder of the destination with a single color |
25 * | 47 * |
26 * @param info | 48 * @param info |
27 * Contains the color type of the rows to fill. | 49 * Contains the color type of the rows to fill. |
28 * Contains the width of the destination rows to fill | 50 * Contains the width of the destination rows to fill |
29 * Contains the number of rows that we need to fill. | 51 * Contains the number of rows that we need to fill. |
30 * | 52 * |
31 * @param dst | 53 * @param dst |
32 * The destination row to fill from. | 54 * The destination row to fill from. |
33 * | 55 * |
(...skipping 13 matching lines...) Expand all Loading... | |
47 */ | 69 */ |
48 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes, | 70 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes, |
49 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit); | 71 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit); |
50 | 72 |
51 /** | 73 /** |
52 * Allow subclasses to implement unique versions of fill(). | 74 * Allow subclasses to implement unique versions of fill(). |
53 */ | 75 */ |
54 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes, | 76 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes, |
55 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {} | 77 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {} |
56 | 78 |
79 SkSampler() | |
80 : fSampleY(1) | |
81 {} | |
82 | |
57 virtual ~SkSampler() {} | 83 virtual ~SkSampler() {} |
58 private: | 84 private: |
85 int fSampleY; | |
59 | 86 |
60 virtual int onSetSampleX(int) = 0; | 87 virtual int onSetSampleX(int) = 0; |
61 }; | 88 }; |
62 | 89 |
63 #endif // SkSampler_DEFINED | 90 #endif // SkSampler_DEFINED |
OLD | NEW |