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

Public Member Functions

 SkRawBufferedStream (std::unique_ptr< SkStream > stream)
 
 ~SkRawBufferedStream () 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 244 of file SkRawCodec.cpp.

Constructor & Destructor Documentation

◆ SkRawBufferedStream()

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

Definition at line 246 of file SkRawCodec.cpp.

247 : fStream(std::move(stream))
248 , fWholeStreamRead(false)
249 {
250 // Only use SkRawBufferedStream when the stream is not an asset stream.
251 SkASSERT(!is_asset_stream(*fStream));
252 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ ~SkRawBufferedStream()

SkRawBufferedStream::~SkRawBufferedStream ( )
inlineoverride

Definition at line 254 of file SkRawCodec.cpp.

254{}

Member Function Documentation

◆ getLength()

uint64 SkRawBufferedStream::getLength ( )
inlineoverridevirtual

Implements SkRawStream.

Definition at line 256 of file SkRawCodec.cpp.

256 {
257 if (!this->bufferMoreData(kReadToEnd)) { // read whole stream
258 ThrowReadFile();
259 }
260 return fStreamBuffer.bytesWritten();
261 }
size_t bytesWritten() const override
Definition: SkStream.cpp:526

◆ read()

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

Implements SkRawStream.

Definition at line 263 of file SkRawCodec.cpp.

263 {
264 if (length == 0) {
265 return true;
266 }
267
268 size_t sum;
269 if (!safe_add_to_size_t(offset, length, &sum)) {
270 return false;
271 }
272
273 return this->bufferMoreData(sum) && fStreamBuffer.read(data, offset, length);
274 }
bool read(void *buffer, size_t offset, size_t size)
Definition: SkStream.cpp:609
size_t length
SeparatedVector2 offset
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ transferBuffer()

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

Implements SkRawStream.

Definition at line 276 of file SkRawCodec.cpp.

276 {
278 if (offset > fStreamBuffer.bytesWritten()) {
279 // If the offset is not buffered, read from fStream directly and skip the buffering.
280 const size_t skipLength = offset - fStreamBuffer.bytesWritten();
281 if (fStream->skip(skipLength) != skipLength) {
282 return nullptr;
283 }
284 const size_t bytesRead = fStream->read(data->writable_data(), size);
285 if (bytesRead < size) {
286 data = SkData::MakeSubset(data.get(), 0, bytesRead);
287 }
288 } else {
289 const size_t alreadyBuffered = std::min(fStreamBuffer.bytesWritten() - offset, size);
290 if (alreadyBuffered > 0 &&
291 !fStreamBuffer.read(data->writable_data(), offset, alreadyBuffered)) {
292 return nullptr;
293 }
294
295 const size_t remaining = size - alreadyBuffered;
296 if (remaining) {
297 auto* dst = static_cast<uint8_t*>(data->writable_data()) + alreadyBuffered;
298 const size_t bytesRead = fStream->read(dst, remaining);
299 size_t newSize;
300 if (bytesRead < remaining) {
301 if (!safe_add_to_size_t(alreadyBuffered, bytesRead, &newSize)) {
302 return nullptr;
303 }
304 data = SkData::MakeSubset(data.get(), 0, newSize);
305 }
306 }
307 }
309 }
static sk_sp< SkData > MakeUninitialized(size_t length)
Definition: SkData.cpp:116
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
dst
Definition: cp.py:12

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