Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | List of all members
SkBmpStandardCodec Class Reference

#include <SkBmpStandardCodec.h>

Inheritance diagram for SkBmpStandardCodec:
SkBmpBaseCodec SkBmpCodec SkCodec SkNoncopyable

Public Member Functions

 SkBmpStandardCodec (SkEncodedInfo &&info, std::unique_ptr< SkStream > stream, uint16_t bitsPerPixel, uint32_t numColors, uint32_t bytesPerColor, uint32_t offset, SkCodec::SkScanlineOrder rowOrder, bool isOpaque, bool inIco)
 
- 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
 
bool onInIco () const override
 
SkCodec::Result onPrepareToDecode (const SkImageInfo &dstInfo, const SkCodec::Options &options) override
 
SkSamplergetSampler (bool createIfNecessary) 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
 
virtual SkCodec::Result onPrepareToDecode (const SkImageInfo &dstInfo, const SkCodec::Options &options)=0
 
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 SkEncodedImageFormat onGetEncodedFormat () const =0
 
virtual Result onGetPixels (const SkImageInfo &info, void *pixels, size_t rowBytes, const Options &, int *rowsDecoded)=0
 
virtual bool onQueryYUVAInfo (const SkYUVAPixmapInfo::SupportedDataTypes &, SkYUVAPixmapInfo *) const
 
virtual Result onGetYUVAPlanes (const SkYUVAPixmaps &)
 
virtual bool onGetValidSubset (SkIRect *) const
 
bool rewindIfNeeded ()
 
virtual bool onRewind ()
 
SkStreamstream ()
 
virtual SkScanlineOrder onGetScanlineOrder () const
 
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 ()
 

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 32 of file SkBmpStandardCodec.h.

Constructor & Destructor Documentation

◆ SkBmpStandardCodec()

SkBmpStandardCodec::SkBmpStandardCodec ( SkEncodedInfo &&  info,
std::unique_ptr< SkStream stream,
uint16_t  bitsPerPixel,
uint32_t  numColors,
uint32_t  bytesPerColor,
uint32_t  offset,
SkCodec::SkScanlineOrder  rowOrder,
bool  isOpaque,
bool  inIco 
)

Definition at line 29 of file SkBmpStandardCodec.cpp.

34 : INHERITED(std::move(info), std::move(stream), bitsPerPixel, rowOrder)
35 , fColorTable(nullptr)
36 , fNumColors(numColors)
37 , fBytesPerColor(bytesPerColor)
38 , fOffset(offset)
39 , fSwizzler(nullptr)
40 , fIsOpaque(isOpaque)
41 , fInIco(inIco)
42 , fAndMaskRowBytes(fInIco ? SkAlign4(compute_row_bytes(this->dimensions().width(), 1)) : 0)
43{}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static constexpr T SkAlign4(T x)
Definition: SkAlign.h:16
static size_t compute_row_bytes(int width, uint32_t bitsPerPixel)
Definition: SkCodecPriv.h:130
uint16_t bitsPerPixel() const
Definition: SkBmpCodec.h:87
bool inIco() const
Definition: SkBmpCodec.h:63
SkISize dimensions() const
Definition: SkCodec.h:230
SkStream * stream()
Definition: SkCodec.h:865
int32_t width
SeparatedVector2 offset

Member Function Documentation

◆ getSampler()

SkSampler * SkBmpStandardCodec::getSampler ( bool  )
inlineoverrideprotectedvirtual

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 72 of file SkBmpStandardCodec.h.

72 {
73 SkASSERT(fSwizzler);
74 return fSwizzler.get();
75 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ onGetPixels()

SkCodec::Result SkBmpStandardCodec::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 48 of file SkBmpStandardCodec.cpp.

51 {
52 if (opts.fSubset) {
53 // Subsets are not supported.
54 return kUnimplemented;
55 }
56 if (dstInfo.dimensions() != this->dimensions()) {
57 SkCodecPrintf("Error: scaling not supported.\n");
58 return kInvalidScale;
59 }
60
61 Result result = this->prepareToDecode(dstInfo, opts);
62 if (kSuccess != result) {
63 return result;
64 }
65 int rows = this->decodeRows(dstInfo, dst, dstRowBytes, opts);
66 if (rows != dstInfo.height()) {
67 *rowsDecoded = rows;
68 return kIncompleteInput;
69 }
70 return kSuccess;
71}
#define SkCodecPrintf(...)
Definition: SkCodecPriv.h:23
SkCodec::Result prepareToDecode(const SkImageInfo &dstInfo, const SkCodec::Options &options)
Definition: SkBmpCodec.cpp:642
const SkImageInfo & dstInfo() const
Definition: SkCodec.h:878
Result
Definition: SkCodec.h:76
@ kInvalidScale
Definition: SkCodec.h:100
@ kIncompleteInput
Definition: SkCodec.h:84
@ kUnimplemented
Definition: SkCodec.h:123
@ kSuccess
Definition: SkCodec.h:80
GAsyncResult * result
dst
Definition: cp.py:12
SkISize dimensions() const
Definition: SkImageInfo.h:421
int height() const
Definition: SkImageInfo.h:371

◆ onInIco()

bool SkBmpStandardCodec::onInIco ( ) const
inlineoverrideprotectedvirtual

Reimplemented from SkBmpCodec.

Definition at line 65 of file SkBmpStandardCodec.h.

65 {
66 return fInIco;
67 }

◆ onPrepareToDecode()

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

Implements SkBmpCodec.

Definition at line 207 of file SkBmpStandardCodec.cpp.

208 {
209 if (this->xformOnDecode()) {
210 this->resetXformBuffer(dstInfo.width());
211 }
212
213 // Create the color table if necessary and prepare the stream for decode
214 // Note that if it is non-NULL, inputColorCount will be modified
215 if (!this->createColorTable(dstInfo.colorType(), dstInfo.alphaType())) {
216 SkCodecPrintf("Error: could not create color table.\n");
218 }
219
220 // Initialize a swizzler
221 this->initializeSwizzler(dstInfo, options);
222 return SkCodec::kSuccess;
223}
void resetXformBuffer(int count)
Definition: SkBmpCodec.h:105
bool xformOnDecode() const
Definition: SkCodec.h:907
@ kInvalidInput
Definition: SkCodec.h:109
const Options & options() const
Definition: SkCodec.h:880
int width() const
Definition: SkImageInfo.h:365
SkAlphaType alphaType() const
Definition: SkImageInfo.h:375
SkColorType colorType() const
Definition: SkImageInfo.h:373

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