Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
SkBmpMaskCodec Class Reference

#include <SkBmpMaskCodec.h>

Inheritance diagram for SkBmpMaskCodec:
SkBmpBaseCodec SkBmpCodec SkCodec SkNoncopyable

Public Member Functions

 SkBmpMaskCodec (SkEncodedInfo &&info, std::unique_ptr< SkStream >, uint16_t bitsPerPixel, SkMasks *masks, SkCodec::SkScanlineOrder rowOrder)
 
- Public Member Functions inherited from SkBmpBaseCodec
 ~SkBmpBaseCodec () override
 
bool didCreateSrcBuffer () const
 
- Public Member Functions inherited from SkCodec
virtual ~SkCodec ()
 
SkImageInfo getInfo () const
 
SkISize dimensions () const
 
SkIRect bounds () const
 
const skcms_ICCProfilegetICCProfile () const
 
SkEncodedOrigin getOrigin () const
 
SkISize getScaledDimensions (float desiredScale) const
 
bool getValidSubset (SkIRect *desiredSubset) const
 
SkEncodedImageFormat getEncodedFormat () const
 
virtual std::unique_ptr< SkStreamgetEncodedData () const
 
Result getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const Options *)
 
Result getPixels (const SkImageInfo &info, void *pixels, size_t rowBytes)
 
Result getPixels (const SkPixmap &pm, const Options *opts=nullptr)
 
std::tuple< sk_sp< SkImage >, SkCodec::ResultgetImage (const SkImageInfo &info, const Options *opts=nullptr)
 
std::tuple< sk_sp< SkImage >, SkCodec::ResultgetImage ()
 
bool queryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &supportedDataTypes, SkYUVAPixmapInfo *yuvaPixmapInfo) const
 
Result getYUVAPlanes (const SkYUVAPixmaps &yuvaPixmaps)
 
Result startIncrementalDecode (const SkImageInfo &dstInfo, void *dst, size_t rowBytes, const Options *)
 
Result startIncrementalDecode (const SkImageInfo &dstInfo, void *dst, size_t rowBytes)
 
Result incrementalDecode (int *rowsDecoded=nullptr)
 
Result startScanlineDecode (const SkImageInfo &dstInfo, const Options *options)
 
Result startScanlineDecode (const SkImageInfo &dstInfo)
 
int getScanlines (void *dst, int countLines, size_t rowBytes)
 
bool skipScanlines (int countLines)
 
SkScanlineOrder getScanlineOrder () const
 
int nextScanline () const
 
int outputScanline (int inputScanline) const
 
int getFrameCount ()
 
bool getFrameInfo (int index, FrameInfo *info) const
 
std::vector< FrameInfogetFrameInfo ()
 
int getRepetitionCount ()
 

Protected Member Functions

Result onGetPixels (const SkImageInfo &dstInfo, void *dst, size_t dstRowBytes, const Options &, int *) override
 
SkCodec::Result onPrepareToDecode (const SkImageInfo &dstInfo, const SkCodec::Options &options) override
 
- Protected Member Functions inherited from SkBmpBaseCodec
 SkBmpBaseCodec (SkEncodedInfo &&info, std::unique_ptr< SkStream >, uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder)
 
uint8_t * srcBuffer ()
 
- Protected Member Functions inherited from SkBmpCodec
 SkBmpCodec (SkEncodedInfo &&info, std::unique_ptr< SkStream >, uint16_t bitsPerPixel, SkCodec::SkScanlineOrder rowOrder)
 
SkEncodedImageFormat onGetEncodedFormat () const override
 
bool onRewind () override
 
bool inIco () const
 
virtual bool onInIco () const
 
int32_t getDstRow (int32_t y, int32_t height) const
 
uint16_t bitsPerPixel () const
 
SkScanlineOrder onGetScanlineOrder () const override
 
size_t srcRowBytes () const
 
SkCodec::Result prepareToDecode (const SkImageInfo &dstInfo, const SkCodec::Options &options)
 
uint32_t * xformBuffer () const
 
void resetXformBuffer (int count)
 
- Protected Member Functions inherited from SkCodec
const SkEncodedInfogetEncodedInfo () const
 
 SkCodec (SkEncodedInfo &&, XformFormat srcFormat, std::unique_ptr< SkStream >, SkEncodedOrigin=kTopLeft_SkEncodedOrigin)
 
void setSrcXformFormat (XformFormat pixelFormat)
 
XformFormat getSrcXformFormat () const
 
virtual bool onGetGainmapInfo (SkGainmapInfo *, std::unique_ptr< SkStream > *)
 
virtual SkISize onGetScaledDimensions (float) const
 
virtual bool onDimensionsSupported (const SkISize &)
 
virtual bool onQueryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &, SkYUVAPixmapInfo *) const
 
virtual Result onGetYUVAPlanes (const SkYUVAPixmaps &)
 
virtual bool onGetValidSubset (SkIRect *) const
 
bool rewindIfNeeded ()
 
SkStreamstream ()
 
const SkImageInfodstInfo () const
 
const Optionsoptions () const
 
int currScanline () const
 
virtual int onOutputScanline (int inputScanline) const
 
virtual bool conversionSupported (const SkImageInfo &dst, bool srcIsOpaque, bool needsColorXform)
 
virtual bool usesColorXform () const
 
void applyColorXform (void *dst, const void *src, int count) const
 
bool colorXform () const
 
bool xformOnDecode () const
 
virtual int onGetFrameCount ()
 
virtual bool onGetFrameInfo (int, FrameInfo *) const
 
virtual int onGetRepetitionCount ()
 

Private Member Functions

SkSamplergetSampler (bool createIfNecessary) override
 
int decodeRows (const SkImageInfo &dstInfo, void *dst, size_t dstRowBytes, const Options &opts) override
 

Additional Inherited Members

- Public Types inherited from SkCodec
enum  Result {
  kSuccess , kIncompleteInput , kErrorInInput , kInvalidConversion ,
  kInvalidScale , kInvalidParameters , kInvalidInput , kCouldNotRewind ,
  kInternalError , kUnimplemented
}
 
enum class  SelectionPolicy { kPreferStillImage , kPreferAnimation }
 
enum  ZeroInitialized { kYes_ZeroInitialized , kNo_ZeroInitialized }
 
enum  SkScanlineOrder { kTopDown_SkScanlineOrder , kBottomUp_SkScanlineOrder }
 
- Static Public Member Functions inherited from SkBmpCodec
static bool IsBmp (const void *, size_t)
 
static std::unique_ptr< SkCodecMakeFromStream (std::unique_ptr< SkStream >, Result *)
 
static std::unique_ptr< SkCodecMakeFromIco (std::unique_ptr< SkStream >, Result *)
 
- Static Public Member Functions inherited from SkCodec
static constexpr size_t MinBufferedBytesNeeded ()
 
static const char * ResultToString (Result)
 
static std::unique_ptr< SkCodecMakeFromStream (std::unique_ptr< SkStream >, SkSpan< const SkCodecs::Decoder > decoders, Result *=nullptr, SkPngChunkReader *=nullptr, SelectionPolicy selectionPolicy=SelectionPolicy::kPreferStillImage)
 
static std::unique_ptr< SkCodecMakeFromStream (std::unique_ptr< SkStream >, Result *=nullptr, SkPngChunkReader *=nullptr, SelectionPolicy selectionPolicy=SelectionPolicy::kPreferStillImage)
 
static std::unique_ptr< SkCodecMakeFromData (sk_sp< SkData >, SkSpan< const SkCodecs::Decoder > decoders, SkPngChunkReader *=nullptr)
 
static std::unique_ptr< SkCodecMakeFromData (sk_sp< SkData >, SkPngChunkReader *=nullptr)
 
static void Register (bool(*peek)(const void *, size_t), std::unique_ptr< SkCodec >(*make)(std::unique_ptr< SkStream >, SkCodec::Result *))
 
- Static Public Attributes inherited from SkCodec
static constexpr int kNoFrame = -1
 
static constexpr int kRepetitionCountInfinite = -1
 
- Protected Types inherited from SkCodec
using XformFormat = skcms_PixelFormat
 
- Static Protected Member Functions inherited from SkBmpCodec
static Result ReadHeader (SkStream *, bool inIco, std::unique_ptr< SkCodec > *codecOut)
 
- Static Protected Attributes inherited from SkBmpCodec
static constexpr SkColorType kXformSrcColorType = kBGRA_8888_SkColorType
 
static constexpr auto kXformSrcColorFormat = skcms_PixelFormat_BGRA_8888
 

Detailed Description

Definition at line 29 of file SkBmpMaskCodec.h.

Constructor & Destructor Documentation

◆ SkBmpMaskCodec()

SkBmpMaskCodec::SkBmpMaskCodec ( SkEncodedInfo &&  info,
std::unique_ptr< SkStream stream,
uint16_t  bitsPerPixel,
SkMasks masks,
SkCodec::SkScanlineOrder  rowOrder 
)

Definition at line 23 of file SkBmpMaskCodec.cpp.

27 : INHERITED(std::move(info), std::move(stream), bitsPerPixel, rowOrder)
28 , fMasks(masks)
29 , fMaskSwizzler(nullptr)
30{}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
uint16_t bitsPerPixel() const
Definition SkBmpCodec.h:87
SkStream * stream()
Definition SkCodec.h:865

Member Function Documentation

◆ decodeRows()

int SkBmpMaskCodec::decodeRows ( const SkImageInfo dstInfo,
void *  dst,
size_t  dstRowBytes,
const Options opts 
)
overrideprivatevirtual

Implements SkBmpCodec.

Definition at line 86 of file SkBmpMaskCodec.cpp.

88 {
89 // Iterate over rows of the image
90 uint8_t* srcRow = this->srcBuffer();
91 const int height = dstInfo.height();
92 for (int y = 0; y < height; y++) {
93 // Read a row of the input
94 if (this->stream()->read(srcRow, this->srcRowBytes()) != this->srcRowBytes()) {
95 SkCodecPrintf("Warning: incomplete input stream.\n");
96 return y;
97 }
98
99 // Decode the row in destination format
100 uint32_t row = this->getDstRow(y, height);
101 void* dstRow = SkTAddOffset<void>(dst, row * dstRowBytes);
102
103 if (this->colorXform()) {
104 fMaskSwizzler->swizzle(this->xformBuffer(), srcRow);
105 this->applyColorXform(dstRow, this->xformBuffer(), fMaskSwizzler->swizzleWidth());
106 } else {
107 fMaskSwizzler->swizzle(dstRow, srcRow);
108 }
109 }
110
111 // Finished decoding the entire image
112 return height;
113}
#define SkCodecPrintf(...)
Definition SkCodecPriv.h:23
static bool read(SkStream *stream, void *buffer, size_t amount)
uint8_t * srcBuffer()
int32_t getDstRow(int32_t y, int32_t height) const
size_t srcRowBytes() const
Definition SkBmpCodec.h:89
uint32_t * xformBuffer() const
Definition SkBmpCodec.h:104
void applyColorXform(void *dst, const void *src, int count) const
Definition SkCodec.cpp:853
bool colorXform() const
Definition SkCodec.h:906
double y
int32_t height
int height() const

◆ getSampler()

SkSampler * SkBmpMaskCodec::getSampler ( bool  )
inlineoverrideprivatevirtual

Return an object which will allow forcing scanline decodes to sample in X.

May create a sampler, if one is not currently being used. Otherwise, does not affect ownership.

Only valid during scanline decoding or incremental decoding.

Reimplemented from SkCodec.

Definition at line 59 of file SkBmpMaskCodec.h.

59 {
60 SkASSERT(fMaskSwizzler);
61 return fMaskSwizzler.get();
62 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ onGetPixels()

SkCodec::Result SkBmpMaskCodec::onGetPixels ( const SkImageInfo info,
void *  pixels,
size_t  rowBytes,
const Options ,
int rowsDecoded 
)
overrideprotectedvirtual
Parameters
rowsDecodedWhen the encoded image stream is incomplete, this function will return kIncompleteInput and rowsDecoded will be set to the number of scanlines that were successfully decoded. This will allow getPixels() to fill the uninitialized memory.

Implements SkCodec.

Definition at line 35 of file SkBmpMaskCodec.cpp.

38 {
39 if (opts.fSubset) {
40 // Subsets are not supported.
41 return kUnimplemented;
42 }
43 if (dstInfo.dimensions() != this->dimensions()) {
44 SkCodecPrintf("Error: scaling not supported.\n");
45 return kInvalidScale;
46 }
47
48 Result result = this->prepareToDecode(dstInfo, opts);
49 if (kSuccess != result) {
50 return result;
51 }
52
53 int rows = this->decodeRows(dstInfo, dst, dstRowBytes, opts);
54 if (rows != dstInfo.height()) {
55 *rowsDecoded = rows;
56 return kIncompleteInput;
57 }
58 return kSuccess;
59}
SkCodec::Result prepareToDecode(const SkImageInfo &dstInfo, const SkCodec::Options &options)
int decodeRows(const SkImageInfo &dstInfo, void *dst, size_t dstRowBytes, const Options &opts) override
const SkImageInfo & dstInfo() const
Definition SkCodec.h:878
@ kInvalidScale
Definition SkCodec.h:100
@ kIncompleteInput
Definition SkCodec.h:84
@ kUnimplemented
Definition SkCodec.h:123
@ kSuccess
Definition SkCodec.h:80
GAsyncResult * result
SkISize dimensions() const

◆ onPrepareToDecode()

SkCodec::Result SkBmpMaskCodec::onPrepareToDecode ( const SkImageInfo dstInfo,
const SkCodec::Options options 
)
overrideprotectedvirtual

Implements SkBmpCodec.

Definition at line 61 of file SkBmpMaskCodec.cpp.

62 {
63 if (this->colorXform()) {
64 this->resetXformBuffer(dstInfo.width());
65 }
66
67 SkImageInfo swizzlerInfo = dstInfo;
68 if (this->colorXform()) {
69 swizzlerInfo = swizzlerInfo.makeColorType(kXformSrcColorType);
71 swizzlerInfo = swizzlerInfo.makeAlphaType(kUnpremul_SkAlphaType);
72 }
73 }
74
75 bool srcIsOpaque = this->getEncodedInfo().opaque();
76 fMaskSwizzler.reset(SkMaskSwizzler::CreateMaskSwizzler(swizzlerInfo, srcIsOpaque,
77 fMasks.get(), this->bitsPerPixel(), options));
78 SkASSERT(fMaskSwizzler);
79
80 return SkCodec::kSuccess;
81}
kUnpremul_SkAlphaType
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition SkAlphaType.h:29
void resetXformBuffer(int count)
Definition SkBmpCodec.h:105
static constexpr SkColorType kXformSrcColorType
Definition SkBmpCodec.h:111
const SkEncodedInfo & getEncodedInfo() const
Definition SkCodec.h:788
const Options & options() const
Definition SkCodec.h:880
static SkMaskSwizzler * CreateMaskSwizzler(const SkImageInfo &dstInfo, bool srcIsOpaque, SkMasks *masks, uint32_t bitsPerPixel, const SkCodec::Options &options)
bool opaque() const
SkImageInfo makeAlphaType(SkAlphaType newAlphaType) const
int width() const
SkAlphaType alphaType() const
SkImageInfo makeColorType(SkColorType newColorType) const

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