Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SkSampler.h
Go to the documentation of this file.
1/*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#ifndef SkSampler_DEFINED
8#define SkSampler_DEFINED
9
14
15#include <cstddef>
16
17struct SkImageInfo;
18
19class SkSampler : public SkNoncopyable {
20public:
21 /**
22 * Update the sampler to sample every sampleX'th pixel. Returns the
23 * width after sampling.
24 */
25 int setSampleX(int sampleX) {
26 return this->onSetSampleX(sampleX);
27 }
28
29 /**
30 * Update the sampler to sample every sampleY'th row.
31 */
32 void setSampleY(int sampleY) {
33 fSampleY = sampleY;
34 }
35
36 /**
37 * Retrieve the value set for sampleY.
38 */
39 int sampleY() const {
40 return fSampleY;
41 }
42
43 /**
44 * Based on fSampleY, return whether this row belongs in the output.
45 *
46 * @param row Row of the image, starting with the first row in the subset.
47 */
48 bool rowNeeded(int row) const {
49 return (row - get_start_coord(fSampleY)) % fSampleY == 0;
50 }
51
52 /**
53 * Fill the remainder of the destination with 0.
54 *
55 * 0 has a different meaning depending on the SkColorType. For color types
56 * with transparency, this means transparent. For k565 and kGray, 0 is
57 * black.
58 *
59 * @param info
60 * Contains the color type of the rows to fill.
61 * Contains the pixel width of the destination rows to fill
62 * Contains the number of rows that we need to fill.
63 *
64 * @param dst
65 * The destination row to fill.
66 *
67 * @param rowBytes
68 * Stride in bytes of the destination.
69 *
70 * @param zeroInit
71 * Indicates whether memory is already zero initialized.
72 */
73 static void Fill(const SkImageInfo& info, void* dst, size_t rowBytes,
75
76 virtual int fillWidth() const = 0;
77
79 : fSampleY(1)
80 {}
81
82 virtual ~SkSampler() {}
83private:
84 int fSampleY;
85
86 virtual int onSetSampleX(int) = 0;
87};
88
89#endif // SkSampler_DEFINED
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
static int get_start_coord(int sampleFactor)
Definition SkCodecPriv.h:57
ZeroInitialized
Definition SkCodec.h:303
virtual ~SkSampler()
Definition SkSampler.h:82
int sampleY() const
Definition SkSampler.h:39
virtual int fillWidth() const =0
virtual int onSetSampleX(int)=0
void setSampleY(int sampleY)
Definition SkSampler.h:32
int setSampleX(int sampleX)
Definition SkSampler.h:25
bool rowNeeded(int row) const
Definition SkSampler.h:48
static void Fill(const SkImageInfo &info, void *dst, size_t rowBytes, SkCodec::ZeroInitialized zeroInit)
Definition SkSampler.cpp:20