1 /* 2 * Copyright 2013 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef SkStreamPriv_DEFINED 9 #define SkStreamPriv_DEFINED 10 11 #include "include/core/SkRefCnt.h" 12 #include "include/core/SkStream.h" 13 14 class SkData; 15 16 /** 17 * Copy the provided stream to an SkData variable. 18 * 19 * Note: Assumes the stream is at the beginning. If it has a length, 20 * but is not at the beginning, this call will fail (return NULL). 21 * 22 * @param stream SkStream to be copied into data. 23 * @return The resulting SkData after the copy, nullptr on failure. 24 */ 25 sk_sp<SkData> SkCopyStreamToData(SkStream* stream); 26 27 /** 28 * Copies the input stream from the current position to the end. 29 * Does not rewind the input stream. 30 */ 31 bool SkStreamCopy(SkWStream* out, SkStream* input); 32 33 /** A SkWStream that writes all output to SkDebugf, for debugging purposes. */ 34 class SkDebugfStream final : public SkWStream { 35 public: 36 bool write(const void* buffer, size_t size) override; 37 size_t bytesWritten() const override; 38 39 private: 40 size_t fBytesWritten = 0; 41 }; 42 43 #endif // SkStreamPriv_DEFINED 44