1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/utils/SkFrontBufferedStream.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,35 @@ 1.4 +/* 1.5 + * Copyright 2013 Google Inc. 1.6 + * 1.7 + * Use of this source code is governed by a BSD-style license that can be 1.8 + * found in the LICENSE file. 1.9 + */ 1.10 + 1.11 +#include "SkTypes.h" 1.12 + 1.13 +class SkStream; 1.14 +class SkStreamRewindable; 1.15 + 1.16 +/** 1.17 + * Specialized stream that buffers the first X bytes of a stream, 1.18 + * where X is passed in by the user. Note that unlike some buffered 1.19 + * stream APIs, once more bytes than can fit in the buffer are read, 1.20 + * no more buffering is done. This stream is designed for a use case 1.21 + * where the caller knows that rewind will only be called from within 1.22 + * X bytes (inclusive), and the wrapped stream is not necessarily 1.23 + * able to rewind at all. 1.24 + */ 1.25 +class SkFrontBufferedStream { 1.26 +public: 1.27 + /** 1.28 + * Creates a new stream that wraps and buffers an SkStream. 1.29 + * @param stream SkStream to buffer. If stream is NULL, NULL is 1.30 + * returned. When this call succeeds (i.e. returns non NULL), 1.31 + * SkFrontBufferedStream is expected to be the only owner of 1.32 + * stream, so it should be unreffed and no longer used directly. 1.33 + * @param minBufferSize Minimum size of buffer required. 1.34 + * @return An SkStream that can buffer at least minBufferSize, or 1.35 + * NULL on failure. 1.36 + */ 1.37 + static SkStreamRewindable* Create(SkStream* stream, size_t minBufferSize); 1.38 +};