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

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

Issue 1332053002: Fill incomplete images in SkCodec parent class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Response to comments in 8 and 11 Created 5 years, 2 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 "SkTypes.h" 10 #include "SkTypes.h"
11 11
12 class SkSampler : public SkNoncopyable { 12 class SkSampler : public SkNoncopyable {
13 public: 13 public:
14 /** 14 /**
15 * Update the sampler to sample every sampleX'th pixel. Returns the 15 * Update the sampler to sample every sampleX'th pixel. Returns the
16 * width after sampling. 16 * width after sampling.
17 */ 17 */
18 int setSampleX(int sampleX) { 18 int setSampleX(int sampleX) {
19 return this->onSetSampleX(sampleX); 19 return this->onSetSampleX(sampleX);
20 } 20 }
21 21
22 /**
23 * Get the the scaled width of the image.
24 *
25 * SkSampler needs the scaled width to fill uninitialized memory in
26 * incomplete images.
27 */
28 int getScaledWidth() {
29 return this->onGetScaledWidth();
30 }
31
32 /**
33 * Fill the remainder of the destination with a single color
34 *
35 * @param dst
36 * The destination row to fill from.
37 *
38 * @param colorType
39 * The color type of the rows to fill.
40 *
41 * @param width
42 * The width of the destination rows to fill
43 *
44 * @param numRows
45 * The number of rows that we need to fill.
46 *
47 * @param rowBytes
48 * Stride in bytes of the destination.
49 *
50 * @param colorOrIndex
51 * If colorType is kN32, colorOrIndex is treated as a 32-bit color.
52 * If colorType is k565, colorOrIndex is treated as a 16-bit color.
53 * If colorType is kGray, colorOrIndex is treated as an 8-bit color.
54 * If colorType is kIndex, colorOrIndex is treated as an 8-bit index.
55 * Other SkColorTypes are not supported.
56 *
57 * @param zeroInit
58 * Indicates whether memory is already zero initialized.
59 *
60 */
61 static void Fill(void* dst, SkColorType colorType, int width, int numRows, s ize_t rowBytes,
62 uint32_t colorOrIndex, SkCodec::ZeroInitialized zeroInit);
63
64 /**
65 * Alternate version of fill where the sampler provides the scaled width.
66 */
67 void fill(void* dst, SkColorType colorType, int numRows, size_t rowBytes, ui nt32_t colorOrIndex,
68 SkCodec::ZeroInitialized zeroInit) {
69 int width = this->onGetScaledWidth();
70 Fill(dst, colorType, width, numRows, rowBytes, colorOrIndex, zeroInit);
71 }
72
22 virtual ~SkSampler() {} 73 virtual ~SkSampler() {}
23 private: 74 private:
75
76 virtual int onGetScaledWidth() = 0;
77
24 virtual int onSetSampleX(int) = 0; 78 virtual int onSetSampleX(int) = 0;
25 }; 79 };
26 80
27 #endif // SkSampler_DEFINED 81 #endif // SkSampler_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698