Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
android::skia::FrontBufferedStream Class Reference

#include <FrontBufferedStream.h>

Static Public Member Functions

static std::unique_ptr< SkStreamRewindableMake (std::unique_ptr< SkStream > stream, size_t minBufferSize)
 

Detailed Description

Specialized stream that buffers the first X bytes of a stream, where X is passed in by the user. Note that unlike some buffered stream APIs, once more bytes than can fit in the buffer are read, no more buffering is done. This stream is designed for a use case where the caller knows that rewind will only be called from within X bytes (inclusive), and the wrapped stream is not necessarily able to rewind at all.

Definition at line 24 of file FrontBufferedStream.h.

Member Function Documentation

◆ Make()

std::unique_ptr< SkStreamRewindable > android::skia::FrontBufferedStream::Make ( std::unique_ptr< SkStream stream,
size_t  minBufferSize 
)
static

Creates a new stream that wraps and buffers an SkStream.

Parameters
streamSkStream to buffer. If stream is NULL, NULL is returned. When this call succeeds (i.e. returns non NULL), FrontBufferedStream is expected to be the only owner of stream, so it should no be longer used directly. FrontBufferedStream will delete stream upon deletion.
minBufferSizeMinimum size of buffer required.
Returns
An SkStream that can buffer at least minBufferSize, or NULL on failure. The caller is required to delete when finished with this object.

Definition at line 75 of file FrontBufferedStream.cpp.

76 {
77 if (!stream) {
78 return nullptr;
79 }
80 auto frontBufferedStream = std::make_unique<::FrontBufferedStream>(
81 std::move(stream), bufferSize);
82 if (frontBufferedStream->failedToAllocateBuffer()) {
83 return nullptr;
84 }
85
86 return frontBufferedStream;
87}

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