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

Side by Side Diff: src/codec/SkSampler.h

Issue 1997703003: Make SkPngCodec decode progressively. (Closed) Base URL: https://skia.googlesource.com/skia.git@foil
Patch Set: Fixes for ICO/SampledCodec Created 4 years, 6 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
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 #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 13 matching lines...) Expand all
47 */ 71 */
48 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes, 72 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes,
49 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit); 73 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit);
50 74
51 /** 75 /**
52 * Allow subclasses to implement unique versions of fill(). 76 * Allow subclasses to implement unique versions of fill().
53 */ 77 */
54 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes, 78 virtual void fill(const SkImageInfo& info, void* dst, size_t rowBytes,
55 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {} 79 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit) {}
56 80
81 SkSampler()
82 : fSampleY(1)
83 {}
84
57 virtual ~SkSampler() {} 85 virtual ~SkSampler() {}
58 private: 86 private:
87 int fSampleY;
59 88
60 virtual int onSetSampleX(int) = 0; 89 virtual int onSetSampleX(int) = 0;
61 }; 90 };
62 91
63 #endif // SkSampler_DEFINED 92 #endif // SkSampler_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698