Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
SkWbmpCodec Class Referencefinal

#include <SkWbmpCodec.h>

Inheritance diagram for SkWbmpCodec:
SkCodec SkNoncopyable

Static Public Member Functions

static bool IsWbmp (const void *, size_t)
 
static std::unique_ptr< SkCodecMakeFromStream (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 *))
 

Protected Member Functions

SkEncodedImageFormat onGetEncodedFormat () const override
 
Result onGetPixels (const SkImageInfo &, void *, size_t, const Options &, int *) override
 
bool onRewind () override
 
bool conversionSupported (const SkImageInfo &dst, bool srcIsOpaque, bool needsXform) override
 
bool usesColorXform () const override
 
- 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 ()
 
virtual SkScanlineOrder onGetScanlineOrder () const
 
const SkImageInfodstInfo () const
 
const Optionsoptions () const
 
int currScanline () const
 
virtual int onOutputScanline (int inputScanline) 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 onGetScanlines (void *dst, int count, size_t dstRowBytes) override
 
bool onSkipScanlines (int count) override
 
Result onStartScanlineDecode (const SkImageInfo &dstInfo, const Options &options) 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 }
 
- 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 ()
 
- 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
 

Detailed Description

Definition at line 26 of file SkWbmpCodec.h.

Member Function Documentation

◆ conversionSupported()

bool SkWbmpCodec::conversionSupported ( const SkImageInfo dst,
bool  srcIsOpaque,
bool  needsColorXform 
)
overrideprotectedvirtual

Return whether we can convert to dst.

Will be called for the appropriate frame, prior to initializing the colorXform.

Reimplemented from SkCodec.

Definition at line 119 of file SkWbmpCodec.cpp.

120 {
121 return valid_color_type(dst) && valid_alpha(dst.alphaType(), srcIsOpaque);
122}
static bool valid_alpha(SkAlphaType dstAlpha, bool srcIsOpaque)
Definition SkCodecPriv.h:90
static bool valid_color_type(const SkImageInfo &dstInfo)
dst
Definition cp.py:12

◆ getSampler()

SkSampler * SkWbmpCodec::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 47 of file SkWbmpCodec.h.

47 {
48 SkASSERT(fSwizzler || !createIfNecessary);
49 return fSwizzler.get();
50 }
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ IsWbmp()

bool SkWbmpCodec::IsWbmp ( const void *  buffer,
size_t  bytesRead 
)
static

Definition at line 154 of file SkWbmpCodec.cpp.

154 {
155 SkMemoryStream stream(buffer, bytesRead, false);
156 return read_header(&stream, nullptr);
157}
static SkCodec::Result read_header(SkStream *stream, SkPngChunkReader *chunkReader, SkCodec **outCodec, png_structp *png_ptrp, png_infop *info_ptrp)
SkStream * stream()
Definition SkCodec.h:865
static const uint8_t buffer[]

◆ MakeFromStream()

std::unique_ptr< SkCodec > SkWbmpCodec::MakeFromStream ( std::unique_ptr< SkStream stream,
Result result 
)
static

Definition at line 159 of file SkWbmpCodec.cpp.

160 {
162 if (!stream) {
164 return nullptr;
165 }
167 if (!read_header(stream.get(), &size)) {
168 // This already succeeded in IsWbmp, so this stream was corrupted in/
169 // after rewind.
171 return nullptr;
172 }
173 *result = kSuccess;
176 return std::unique_ptr<SkCodec>(new SkWbmpCodec(std::move(info), std::move(stream)));
177}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition DM.cpp:213
@ kInvalidInput
Definition SkCodec.h:109
@ kCouldNotRewind
Definition SkCodec.h:114
@ kSuccess
Definition SkCodec.h:80
GAsyncResult * result
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition switches.h:259
static SkEncodedInfo Make(int width, int height, Color color, Alpha alpha, int bitsPerComponent)

◆ onGetEncodedFormat()

SkEncodedImageFormat SkWbmpCodec::onGetEncodedFormat ( ) const
overrideprotectedvirtual

Implements SkCodec.

Definition at line 115 of file SkWbmpCodec.cpp.

◆ onGetPixels()

SkCodec::Result SkWbmpCodec::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 124 of file SkWbmpCodec.cpp.

128 {
129 if (options.fSubset) {
130 // Subsets are not supported.
131 return kUnimplemented;
132 }
133
134 // Initialize the swizzler
135 std::unique_ptr<SkSwizzler> swizzler = SkSwizzler::Make(this->getEncodedInfo(), nullptr, info,
136 options);
137 SkASSERT(swizzler);
138
139 // Perform the decode
140 SkISize size = info.dimensions();
141 AutoTMalloc<uint8_t> src(fSrcRowBytes);
142 void* dstRow = dst;
143 for (int y = 0; y < size.height(); ++y) {
144 if (!this->readRow(src.get())) {
145 *rowsDecoded = y;
146 return kIncompleteInput;
147 }
148 swizzler->swizzle(dstRow, src.get());
149 dstRow = SkTAddOffset<void>(dstRow, rowBytes);
150 }
151 return kSuccess;
152}
const SkEncodedInfo & getEncodedInfo() const
Definition SkCodec.h:788
@ kIncompleteInput
Definition SkCodec.h:84
@ kUnimplemented
Definition SkCodec.h:123
const Options & options() const
Definition SkCodec.h:880
static std::unique_ptr< SkSwizzler > Make(const SkEncodedInfo &encodedInfo, const SkPMColor *ctable, const SkImageInfo &dstInfo, const SkCodec::Options &, const SkIRect *frame=nullptr)
double y
const SkIRect * fSubset
Definition SkCodec.h:347

◆ onGetScanlines()

int SkWbmpCodec::onGetScanlines ( void *  dst,
int  count,
size_t  dstRowBytes 
)
overrideprivatevirtual

Reimplemented from SkCodec.

Definition at line 179 of file SkWbmpCodec.cpp.

179 {
180 void* dstRow = dst;
181 for (int y = 0; y < count; ++y) {
182 if (!this->readRow(fSrcBuffer.get())) {
183 return y;
184 }
185 fSwizzler->swizzle(dstRow, fSrcBuffer.get());
186 dstRow = SkTAddOffset<void>(dstRow, dstRowBytes);
187 }
188 return count;
189}
int count

◆ onRewind()

bool SkWbmpCodec::onRewind ( )
overrideprotectedvirtual

Called by rewindIfNeeded, if the stream needed to be rewound.

Subclasses should do any set up needed after a rewind.

Reimplemented from SkCodec.

Definition at line 99 of file SkWbmpCodec.cpp.

99 {
100 return read_header(this->stream(), nullptr);
101}

◆ onSkipScanlines()

bool SkWbmpCodec::onSkipScanlines ( int  count)
overrideprivatevirtual

Reimplemented from SkCodec.

Definition at line 191 of file SkWbmpCodec.cpp.

191 {
192 const size_t bytesToSkip = count * fSrcRowBytes;
193 return this->stream()->skip(bytesToSkip) == bytesToSkip;
194}
size_t skip(size_t size)
Definition SkStream.h:51

◆ onStartScanlineDecode()

SkCodec::Result SkWbmpCodec::onStartScanlineDecode ( const SkImageInfo dstInfo,
const Options options 
)
overrideprivatevirtual

Reimplemented from SkCodec.

Definition at line 196 of file SkWbmpCodec.cpp.

197 {
198 if (options.fSubset) {
199 // Subsets are not supported.
200 return kUnimplemented;
201 }
202
203 fSwizzler = SkSwizzler::Make(this->getEncodedInfo(), nullptr, dstInfo, options);
204 SkASSERT(fSwizzler);
205
206 fSrcBuffer.reset(fSrcRowBytes);
207
208 return kSuccess;
209}
T * reset(size_t count=0)

◆ usesColorXform()

bool SkWbmpCodec::usesColorXform ( ) const
inlineoverrideprotectedvirtual

Reimplemented from SkCodec.

Definition at line 45 of file SkWbmpCodec.h.

45{ return false; }

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