Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
SkSampler Class Referenceabstract

#include <SkSampler.h>

Inheritance diagram for SkSampler:
SkNoncopyable SkBmpRLESampler SkMaskSwizzler SkSwizzler

Public Member Functions

int setSampleX (int sampleX)
 
void setSampleY (int sampleY)
 
int sampleY () const
 
bool rowNeeded (int row) const
 
virtual int fillWidth () const =0
 
 SkSampler ()
 
virtual ~SkSampler ()
 
- Public Member Functions inherited from SkNoncopyable
 SkNoncopyable ()=default
 
 SkNoncopyable (SkNoncopyable &&)=default
 
SkNoncopyableoperator= (SkNoncopyable &&)=default
 

Static Public Member Functions

static void Fill (const SkImageInfo &info, void *dst, size_t rowBytes, SkCodec::ZeroInitialized zeroInit)
 

Private Member Functions

virtual int onSetSampleX (int)=0
 

Detailed Description

Definition at line 19 of file SkSampler.h.

Constructor & Destructor Documentation

◆ SkSampler()

SkSampler::SkSampler ( )
inline

Definition at line 78 of file SkSampler.h.

79 : fSampleY(1)
80 {}

◆ ~SkSampler()

virtual SkSampler::~SkSampler ( )
inlinevirtual

Definition at line 82 of file SkSampler.h.

82{}

Member Function Documentation

◆ Fill()

void SkSampler::Fill ( const SkImageInfo info,
void *  dst,
size_t  rowBytes,
SkCodec::ZeroInitialized  zeroInit 
)
static

Fill the remainder of the destination with 0.

0 has a different meaning depending on the SkColorType. For color types with transparency, this means transparent. For k565 and kGray, 0 is black.

Parameters
infoContains the color type of the rows to fill. Contains the pixel width of the destination rows to fill Contains the number of rows that we need to fill.
dstThe destination row to fill.
rowBytesStride in bytes of the destination.
zeroInitIndicates whether memory is already zero initialized.

Definition at line 20 of file SkSampler.cpp.

21 {
22 SkASSERT(dst != nullptr);
23
24 if (SkCodec::kYes_ZeroInitialized == zeroInit) {
25 return;
26 }
27
28 const int width = info.width();
29 const int numRows = info.height();
30
31 // Use the proper memset routine to fill the remaining bytes
32 switch (info.colorType()) {
35 uint32_t* dstRow = (uint32_t*) dst;
36 for (int row = 0; row < numRows; row++) {
37 SkOpts::memset32(dstRow, 0, width);
38 dstRow = SkTAddOffset<uint32_t>(dstRow, rowBytes);
39 }
40 break;
41 }
43 uint16_t* dstRow = (uint16_t*) dst;
44 for (int row = 0; row < numRows; row++) {
45 SkOpts::memset16(dstRow, 0, width);
46 dstRow = SkTAddOffset<uint16_t>(dstRow, rowBytes);
47 }
48 break;
49 }
51 uint8_t* dstRow = (uint8_t*) dst;
52 for (int row = 0; row < numRows; row++) {
53 memset(dstRow, 0, width);
54 dstRow = SkTAddOffset<uint8_t>(dstRow, rowBytes);
55 }
56 break;
57 }
59 uint64_t* dstRow = (uint64_t*) dst;
60 for (int row = 0; row < numRows; row++) {
61 SkOpts::memset64(dstRow, 0, width);
62 dstRow = SkTAddOffset<uint64_t>(dstRow, rowBytes);
63 }
64 break;
65 }
66 default:
67 SkCodecPrintf("Error: Unsupported dst color type for fill(). Doing nothing.\n");
68 SkASSERT(false);
69 break;
70 }
71}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
#define SkASSERT(cond)
Definition SkAssert.h:116
#define SkCodecPrintf(...)
Definition SkCodecPriv.h:23
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
Definition SkColorType.h:26
@ kRGBA_F16_SkColorType
pixel with half floats for red, green, blue, alpha;
Definition SkColorType.h:38
@ kGray_8_SkColorType
pixel with grayscale level in 8-bit byte
Definition SkColorType.h:35
@ kRGB_565_SkColorType
pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word
Definition SkColorType.h:22
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition SkColorType.h:24
@ kYes_ZeroInitialized
Definition SkCodec.h:308
void(* memset64)(uint64_t[], uint64_t, int)
void(* memset16)(uint16_t[], uint16_t, int)
void(* memset32)(uint32_t[], uint32_t, int)
int32_t width

◆ fillWidth()

virtual int SkSampler::fillWidth ( ) const
pure virtual

Implemented in SkBmpRLESampler, SkMaskSwizzler, and SkSwizzler.

◆ onSetSampleX()

virtual int SkSampler::onSetSampleX ( int  )
privatepure virtual

Implemented in SkBmpRLESampler, SkMaskSwizzler, and SkSwizzler.

◆ rowNeeded()

bool SkSampler::rowNeeded ( int  row) const
inline

Based on fSampleY, return whether this row belongs in the output.

Parameters
rowRow of the image, starting with the first row in the subset.

Definition at line 48 of file SkSampler.h.

48 {
49 return (row - get_start_coord(fSampleY)) % fSampleY == 0;
50 }
static int get_start_coord(int sampleFactor)
Definition SkCodecPriv.h:57

◆ sampleY()

int SkSampler::sampleY ( ) const
inline

Retrieve the value set for sampleY.

Definition at line 39 of file SkSampler.h.

39 {
40 return fSampleY;
41 }

◆ setSampleX()

int SkSampler::setSampleX ( int  sampleX)
inline

Update the sampler to sample every sampleX'th pixel. Returns the width after sampling.

Definition at line 25 of file SkSampler.h.

25 {
26 return this->onSetSampleX(sampleX);
27 }
virtual int onSetSampleX(int)=0

◆ setSampleY()

void SkSampler::setSampleY ( int  sampleY)
inline

Update the sampler to sample every sampleY'th row.

Definition at line 32 of file SkSampler.h.

32 {
33 fSampleY = sampleY;
34 }
int sampleY() const
Definition SkSampler.h:39

The documentation for this class was generated from the following files: