Flutter Engine
The Flutter Engine
Classes | Functions
SkStreamPriv.h File Reference
#include "include/core/SkRefCnt.h"
#include "include/core/SkStream.h"
#include "src/base/SkEndian.h"
#include <cstdint>

Go to the source code of this file.

Classes

class  SkDebugfStream
 

Functions

sk_sp< SkDataSkCopyStreamToData (SkStream *stream)
 
bool SkStreamCopy (SkWStream *out, SkStream *input)
 
bool SkWStreamWriteU16BE (SkWStream *s, uint16_t value)
 
bool SkWStreamWriteU32BE (SkWStream *s, uint32_t value)
 
bool SkWStreamWriteS32BE (SkWStream *s, int32_t value)
 
bool StreamRemainingLengthIsBelow (SkStream *stream, size_t len)
 

Function Documentation

◆ SkCopyStreamToData()

sk_sp< SkData > SkCopyStreamToData ( SkStream stream)

Copy the provided stream to an SkData variable.

Note: Assumes the stream is at the beginning. If it has a length, but is not at the beginning, this call will fail (return NULL).

Parameters
streamSkStream to be copied into data.
Returns
The resulting SkData after the copy, nullptr on failure.

Definition at line 937 of file SkStream.cpp.

937 {
938 SkASSERT(stream != nullptr);
939
940 if (stream->hasLength()) {
941 return SkData::MakeFromStream(stream, stream->getLength());
942 }
943
944 SkDynamicMemoryWStream tempStream;
945 const size_t bufferSize = 4096;
946 char buffer[bufferSize];
947 do {
948 size_t bytesRead = stream->read(buffer, bufferSize);
949 tempStream.write(buffer, bytesRead);
950 } while (!stream->isAtEnd());
951 return tempStream.detachAsData();
952}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static sk_sp< SkData > MakeFromStream(SkStream *, size_t size)
Definition: SkData.cpp:208
bool write(const void *buffer, size_t size) override
Definition: SkStream.cpp:535
sk_sp< SkData > detachAsData()
Definition: SkStream.cpp:707
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126

◆ SkStreamCopy()

bool SkStreamCopy ( SkWStream out,
SkStream input 
)

Copies the input stream from the current position to the end. Does not rewind the input stream.

Definition at line 954 of file SkStream.cpp.

954 {
955 const char* base = static_cast<const char*>(input->getMemoryBase());
956 if (base && input->hasPosition() && input->hasLength()) {
957 // Shortcut that avoids the while loop.
958 size_t position = input->getPosition();
959 size_t length = input->getLength();
960 SkASSERT(length >= position);
961 return out->write(&base[position], length - position);
962 }
963 char scratch[4096];
964 size_t count;
965 while (true) {
966 count = input->read(scratch, sizeof(scratch));
967 if (0 == count) {
968 return true;
969 }
970 if (!out->write(scratch, count)) {
971 return false;
972 }
973 }
974}
int count
Definition: FontMgrTest.cpp:50
virtual bool hasPosition() const
Definition: SkStream.h:117
virtual size_t getPosition() const
Definition: SkStream.h:119
virtual size_t getLength() const
Definition: SkStream.h:137
virtual const void * getMemoryBase()
Definition: SkStream.h:141
virtual bool hasLength() const
Definition: SkStream.h:135
virtual size_t read(void *buffer, size_t size)=0
size_t length

◆ SkWStreamWriteS32BE()

bool SkWStreamWriteS32BE ( SkWStream s,
int32_t  value 
)
inline

Definition at line 59 of file SkStreamPriv.h.

59 {
61 return s->write(&value, sizeof(value));
62}
#define SkEndian_SwapBE32(n)
Definition: SkEndian.h:136
struct MyStruct s
uint8_t value

◆ SkWStreamWriteU16BE()

bool SkWStreamWriteU16BE ( SkWStream s,
uint16_t  value 
)
inline

Helper functions to write big-endian values to a stream.

Definition at line 49 of file SkStreamPriv.h.

49 {
51 return s->write(&value, sizeof(value));
52}
#define SkEndian_SwapBE16(n)
Definition: SkEndian.h:135

◆ SkWStreamWriteU32BE()

bool SkWStreamWriteU32BE ( SkWStream s,
uint32_t  value 
)
inline

Definition at line 54 of file SkStreamPriv.h.

54 {
56 return s->write(&value, sizeof(value));
57}

◆ StreamRemainingLengthIsBelow()

bool StreamRemainingLengthIsBelow ( SkStream stream,
size_t  len 
)

Definition at line 976 of file SkStream.cpp.

976 {
978 if (stream->hasLength()) {
979 if (stream->hasPosition()) {
980 size_t remainingBytes = stream->getLength() - stream->getPosition();
981 return remainingBytes < len;
982 }
983 // We don't know the position, but we can still return true if the
984 // stream's entire length is shorter than the requested length.
985 return stream->getLength() < len;
986 }
987 return false;
988}