Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
SkRawAssetStream Class Reference
Inheritance diagram for SkRawAssetStream:
SkRawStream

Public Member Functions

 SkRawAssetStream (std::unique_ptr< SkStream > stream)
 
 ~SkRawAssetStream () override
 
uint64 getLength () override
 
bool read (void *data, size_t offset, size_t length) override
 
std::unique_ptr< SkMemoryStreamtransferBuffer (size_t offset, size_t size) override
 
- Public Member Functions inherited from SkRawStream
virtual ~SkRawStream ()
 
virtual uint64 getLength ()=0
 
virtual bool read (void *data, size_t offset, size_t length)=0
 
virtual std::unique_ptr< SkMemoryStreamtransferBuffer (size_t offset, size_t size)=0
 

Detailed Description

Definition at line 351 of file SkRawCodec.cpp.

Constructor & Destructor Documentation

◆ SkRawAssetStream()

SkRawAssetStream::SkRawAssetStream ( std::unique_ptr< SkStream stream)
inlineexplicit

Definition at line 353 of file SkRawCodec.cpp.

354 : fStream(std::move(stream))
355 {
356 // Only use SkRawAssetStream when the stream is an asset stream.
357 SkASSERT(is_asset_stream(*fStream));
358 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ ~SkRawAssetStream()

SkRawAssetStream::~SkRawAssetStream ( )
inlineoverride

Definition at line 360 of file SkRawCodec.cpp.

360{}

Member Function Documentation

◆ getLength()

uint64 SkRawAssetStream::getLength ( )
inlineoverridevirtual

Implements SkRawStream.

Definition at line 362 of file SkRawCodec.cpp.

362 {
363 return fStream->getLength();
364 }

◆ read()

bool SkRawAssetStream::read ( void *  data,
size_t  offset,
size_t  length 
)
inlineoverridevirtual

Implements SkRawStream.

Definition at line 367 of file SkRawCodec.cpp.

367 {
368 if (length == 0) {
369 return true;
370 }
371
372 size_t sum;
373 if (!safe_add_to_size_t(offset, length, &sum)) {
374 return false;
375 }
376
377 return fStream->seek(offset) && (fStream->read(data, length) == length);
378 }
size_t length
SeparatedVector2 offset
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ transferBuffer()

std::unique_ptr< SkMemoryStream > SkRawAssetStream::transferBuffer ( size_t  offset,
size_t  size 
)
inlineoverridevirtual

Implements SkRawStream.

Definition at line 380 of file SkRawCodec.cpp.

380 {
381 if (fStream->getLength() < offset) {
382 return nullptr;
383 }
384
385 size_t sum;
386 if (!safe_add_to_size_t(offset, size, &sum)) {
387 return nullptr;
388 }
389
390 // This will allow read less than the requested "size", because the JPEG codec wants to
391 // handle also a partial JPEG file.
392 const size_t bytesToRead = std::min(sum, fStream->getLength()) - offset;
393 if (bytesToRead == 0) {
394 return nullptr;
395 }
396
397 if (fStream->getMemoryBase()) { // directly copy if getMemoryBase() is available.
399 static_cast<const uint8_t*>(fStream->getMemoryBase()) + offset, bytesToRead));
400 fStream.reset();
402 } else {
404 if (!fStream->seek(offset)) {
405 return nullptr;
406 }
407 const size_t bytesRead = fStream->read(data->writable_data(), bytesToRead);
408 if (bytesRead < bytesToRead) {
409 data = SkData::MakeSubset(data.get(), 0, bytesRead);
410 }
412 }
413 }
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition: SkData.cpp:116
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition: SkData.cpp:111
static sk_sp< SkData > MakeSubset(const SkData *src, size_t offset, size_t length)
Definition: SkData.cpp:173
static std::unique_ptr< SkMemoryStream > Make(sk_sp< SkData > data)
Definition: SkStream.cpp:314
static float min(float r, float g, float b)
Definition: hsl.cpp:48
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

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