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

Public Member Functions

 SkRandomAccessWStream ()
 
size_t pos () const
 
size_t size () const
 
void write (const void *src, size_t bytes)
 
void seek (size_t pos)
 
sk_sp< SkDatadetachAsData ()
 

Detailed Description

Definition at line 17 of file SkVideoEncoder.cpp.

Constructor & Destructor Documentation

◆ SkRandomAccessWStream()

SkRandomAccessWStream::SkRandomAccessWStream ( )
inline

Definition at line 22 of file SkVideoEncoder.cpp.

22{}

Member Function Documentation

◆ detachAsData()

sk_sp< SkData > SkRandomAccessWStream::detachAsData ( )
inline

Definition at line 53 of file SkVideoEncoder.cpp.

53 {
54 // TODO: could add an efficient detach to SkTDArray if we wanted, w/o copy
55 return SkData::MakeWithCopy(fStorage.begin(), fStorage.size());
56 }
static sk_sp< SkData > MakeWithCopy(const void *data, size_t length)
Definition: SkData.cpp:111
int size() const
Definition: SkTDArray.h:138
T * begin()
Definition: SkTDArray.h:150

◆ pos()

size_t SkRandomAccessWStream::pos ( ) const
inline

Definition at line 24 of file SkVideoEncoder.cpp.

24{ return fPos; }

◆ seek()

void SkRandomAccessWStream::seek ( size_t  pos)
inline

Definition at line 48 of file SkVideoEncoder.cpp.

48 {
49 SkASSERT(pos <= fStorage.size());
50 fPos = pos;
51 }
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ size()

size_t SkRandomAccessWStream::size ( ) const
inline

Definition at line 26 of file SkVideoEncoder.cpp.

26{ return fStorage.size(); }

◆ write()

void SkRandomAccessWStream::write ( const void *  src,
size_t  bytes 
)
inline

Definition at line 28 of file SkVideoEncoder.cpp.

28 {
29 size_t len = fStorage.size();
30 SkASSERT(fPos <= len);
31
32 size_t overwrite = std::min(len - fPos, bytes);
33 if (overwrite) {
34 SkDebugf("overwrite %zu bytes at %zu offset with %zu remaining\n", overwrite, fPos, bytes - overwrite);
35 memcpy(&fStorage[fPos], src, overwrite);
36 fPos += overwrite;
37 src = (const char*)src + overwrite;
38 bytes -= overwrite;
39 }
40 // bytes now represents the amount to append
41 if (bytes) {
42 fStorage.append(bytes, (const char*)src);
43 fPos += bytes;
44 }
45 SkASSERT(fPos <= fStorage.size());
46 }
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
T * append()
Definition: SkTDArray.h:191
static float min(float r, float g, float b)
Definition: hsl.cpp:48

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