18a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2006 The Android Open Source Project 38a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Use of this source code is governed by a BSD-style license that can be 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * found in the LICENSE file. 68a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 78a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 88a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#ifndef SkStream_DEFINED 98a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#define SkStream_DEFINED 108a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkRefCnt.h" 128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkScalar.h" 138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 148d0b5770f8fcfdeb8ad9808e58c49116f14b6190reed@google.comclass SkData; 1570442a6cf73c9a822df23961f5e16dc3abc18f26reed@google.com 166cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SkStream; 176cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SkStreamRewindable; 186cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SkStreamSeekable; 196cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SkStreamAsset; 206cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SkStreamMemory; 216cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 223b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com/** 233b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * SkStream -- abstraction for a source of bytes. Subclasses can be backed by 243b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * memory, or a file, or something else. 253b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * 263b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * NOTE: 273b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * 283b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * Classic "streams" APIs are sort of async, in that on a request for N 293b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * bytes, they may return fewer than N bytes on a given call, in which case 303b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * the caller can "try again" to get more bytes, eventually (modulo an error) 313b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * receiving their total N bytes. 322b34fe01d7b5736b212eb4886afc723a7b9241aeskia.committer@gmail.com * 333b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * Skia streams behave differently. They are effectively synchronous, and will 343b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * always return all N bytes of the request if possible. If they return fewer 353b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * (the read() call returns the number of bytes read) then that means there is 363b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * no more data (at EOF or hit an error). The caller should *not* call again 373b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com * in hopes of fulfilling more of the request. 383b34505d79691f129d7babb5de607c6459ac9f4dreed@google.com */ 396cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SK_API SkStream : public SkRefCnt { //TODO: remove SkRefCnt 408a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 41e1575aa21619e252f6c6514317041c32d00ce5a6reed@google.com /** 42e1575aa21619e252f6c6514317041c32d00ce5a6reed@google.com * Attempts to open the specified file, and return a stream to it (using 43e1575aa21619e252f6c6514317041c32d00ce5a6reed@google.com * mmap if available). On success, the caller must call unref() on the 44e1575aa21619e252f6c6514317041c32d00ce5a6reed@google.com * returned object. On failure, returns NULL. 45e1575aa21619e252f6c6514317041c32d00ce5a6reed@google.com */ 466cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com static SkStreamAsset* NewFromFile(const char path[]); 478eaddb0089a170760e157646192813bd940c26e7skia.committer@gmail.com 4815e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com SK_DECLARE_INST_COUNT(SkStream) 4915e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com 506cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Reads or skips size number of bytes. 516cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * If buffer == NULL, skip size bytes, return how many were skipped. 526cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * If buffer != NULL, copy size bytes into buffer, return how many were copied. 536cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * @param buffer when NULL skip size bytes, otherwise copy size bytes into buffer 546cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * @param size the number of bytes to skip or copy 5588682b77d108a7413a166e3158e187f43211c46bbungeman@google.com * @return the number of bytes actually read. 566cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual size_t read(void* buffer, size_t size) = 0; 588a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 596cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Skip size number of bytes. 606cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * @return the actual number bytes that could be skipped. 616cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 626cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com size_t skip(size_t size) { 6304306921f45c91ceec73bb96a427e4c69cf9782cbungeman@google.com return this->read(NULL, size); 646cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com } 656cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 6688682b77d108a7413a166e3158e187f43211c46bbungeman@google.com /** Returns true when all the bytes in the stream have been read. 6788682b77d108a7413a166e3158e187f43211c46bbungeman@google.com * This may return true early (when there are no more bytes to be read) 6888682b77d108a7413a166e3158e187f43211c46bbungeman@google.com * or late (after the first unsuccessful read). 696cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 7004306921f45c91ceec73bb96a427e4c69cf9782cbungeman@google.com virtual bool isAtEnd() const = 0; 718a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int8_t readS8(); 738a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int16_t readS16(); 748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com int32_t readS32(); 758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint8_t readU8() { return (uint8_t)this->readS8(); } 778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint16_t readU16() { return (uint16_t)this->readS16(); } 788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com uint32_t readU32() { return (uint32_t)this->readS32(); } 798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool readBool() { return this->readU8() != 0; } 818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkScalar readScalar(); 828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com size_t readPackedUInt(); 8315e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com 846cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com//SkStreamRewindable 854d213ab944d96ad60a243ac1ad21c793c1acc80ascroggo@google.com /** Rewinds to the beginning of the stream. Returns true if the stream is known 864d213ab944d96ad60a243ac1ad21c793c1acc80ascroggo@google.com * to be at the beginning after this call returns. 874d213ab944d96ad60a243ac1ad21c793c1acc80ascroggo@google.com */ 886cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool rewind() { return false; } 896cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 906cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Duplicates this stream. If this cannot be done, returns NULL. 916cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * The returned stream will be positioned at the beginning of its data. 926cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 936cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamRewindable* duplicate() const { return NULL; } 946cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 956cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com//SkStreamSeekable 966cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Returns true if this stream can report it's current position. */ 976cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool hasPosition() const { return false; } 986cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Returns the current position in the stream. If this cannot be done, returns 0. */ 996cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual size_t getPosition() const { return 0; } 1006cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1016cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Seeks to an absolute position in the stream. If this cannot be done, returns false. 1026cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * If an attempt is made to seek past the end of the stream, the position will be set 1036cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * to the end of the stream. 1046cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 1056cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool seek(size_t position) { return false; } 1066cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1076cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Seeks to an relative offset in the stream. If this cannot be done, returns false. 1086cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * If an attempt is made to move to a position outside the stream, the position will be set 1096cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * to the closest point within the stream (beginning or end). 1106cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 1116cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool move(long offset) { return false; } 1126cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1136cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Duplicates this stream. If this cannot be done, returns NULL. 1146cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * The returned stream will be positioned the same as this stream. 1156cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 1166cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamSeekable* fork() const { return NULL; } 1176cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1186cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com//SkStreamAsset 1196cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Returns true if this stream can report it's total length. */ 1206cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool hasLength() const { return false; } 1216cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Returns the total length of the stream. If this cannot be done, returns 0. */ 12204306921f45c91ceec73bb96a427e4c69cf9782cbungeman@google.com virtual size_t getLength() const { return 0; } 1236cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1246cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com//SkStreamMemory 1256cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Returns the starting address for the data. If this cannot be done, returns NULL. */ 1266cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com //TODO: replace with virtual const SkData* getData() 1276cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual const void* getMemoryBase() { return NULL; } 1286cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 12915e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.comprivate: 13015e9d3e66e161ce23df30bc13f8a0c87d196b463robertphillips@google.com typedef SkRefCnt INHERITED; 1318a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 1328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1336cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com/** SkStreamRewindable is a SkStream for which rewind and duplicate are required. */ 1346cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SK_API SkStreamRewindable : public SkStream { 1356cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.compublic: 1366cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool rewind() SK_OVERRIDE = 0; 1376cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamRewindable* duplicate() const SK_OVERRIDE = 0; 1386cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com}; 1396cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1406cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com/** SkStreamSeekable is a SkStreamRewindable for which position, seek, move, and fork are required. */ 1416cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SK_API SkStreamSeekable : public SkStreamRewindable { 1426cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.compublic: 1436cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamSeekable* duplicate() const SK_OVERRIDE = 0; 1446cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1456cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool hasPosition() const SK_OVERRIDE { return true; } 1466cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual size_t getPosition() const SK_OVERRIDE = 0; 1476cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool seek(size_t position) SK_OVERRIDE = 0; 1486cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool move(long offset) SK_OVERRIDE = 0; 1496cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamSeekable* fork() const SK_OVERRIDE = 0; 1506cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com}; 1516cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1526cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com/** SkStreamAsset is a SkStreamSeekable for which getLength is required. */ 1536cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SK_API SkStreamAsset : public SkStreamSeekable { 1546cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.compublic: 1556cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamAsset* duplicate() const SK_OVERRIDE = 0; 1566cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamAsset* fork() const SK_OVERRIDE = 0; 1576cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1586cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool hasLength() const SK_OVERRIDE { return true; } 1596cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual size_t getLength() const SK_OVERRIDE = 0; 1606cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com}; 1616cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1626cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com/** SkStreamMemory is a SkStreamAsset for which getMemoryBase is required. */ 1636cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SK_API SkStreamMemory : public SkStreamAsset { 1646cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.compublic: 1656cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamMemory* duplicate() const SK_OVERRIDE = 0; 1666cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamMemory* fork() const SK_OVERRIDE = 0; 1676cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 1686cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual const void* getMemoryBase() SK_OVERRIDE = 0; 1696cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com}; 1706cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 171dfc5ffe478a2f0922b5d4541507481d14f2f55dbctguil@chromium.orgclass SK_API SkWStream : SkNoncopyable { 1728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 1733b429984664e88e0530eb6a1461a828898d8d96breed@google.com SK_DECLARE_INST_COUNT_ROOT(SkWStream) 1743b429984664e88e0530eb6a1461a828898d8d96breed@google.com 1758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkWStream(); 1768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Called to write bytes to a SkWStream. Returns true on success 1788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param buffer the address of at least size bytes to be written to the stream 1798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @param size The number of bytes in buffer to write to the stream 1808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com @return true on success 1818a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 1828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual bool write(const void* buffer, size_t size) = 0; 1838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void newline(); 1848a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void flush(); 1858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 186490fb6b4713463954cc0283a9c30e754c45c6004commit-bot@chromium.org virtual size_t bytesWritten() const = 0; 187490fb6b4713463954cc0283a9c30e754c45c6004commit-bot@chromium.org 1888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // helpers 189fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 1908a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool write8(U8CPU); 1918a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool write16(U16CPU); 1928a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool write32(uint32_t); 1938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 1948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool writeText(const char text[]); 1958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool writeDecAsText(int32_t); 196d877fdbb6e64692285c3e6532d88b9458f65b3cdvandebo@chromium.org bool writeBigDecAsText(int64_t, int minDigits = 0); 1978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool writeHexAsText(uint32_t, int minDigits = 0); 1988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool writeScalarAsText(SkScalar); 199fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 2008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool writeBool(bool v) { return this->write8(v); } 2018a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool writeScalar(SkScalar); 2028a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool writePackedUInt(size_t); 203fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 204dcb8e54ffdc9194744c0ec839969102bd0f582c6commit-bot@chromium.org bool writeStream(SkStream* input, size_t length); 2058a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com 2068e3fb2d6f416eaa882d1e17421f38a3c55e2d3ffepoger@google.com /** 207dcb8e54ffdc9194744c0ec839969102bd0f582c6commit-bot@chromium.org * This returns the number of bytes in the stream required to store 208dcb8e54ffdc9194744c0ec839969102bd0f582c6commit-bot@chromium.org * 'value'. 209dcb8e54ffdc9194744c0ec839969102bd0f582c6commit-bot@chromium.org */ 210dcb8e54ffdc9194744c0ec839969102bd0f582c6commit-bot@chromium.org static int SizeOfPackedUInt(size_t value); 2118a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 2128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com//////////////////////////////////////////////////////////////////////////////////////// 2148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#include "SkString.h" 216fab44db294846ff05d837b9cf0bf97a073891da7bungeman@google.com#include <stdio.h> 2178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comstruct SkFILE; 2198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2206cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com/** A stream that wraps a C FILE* file stream. */ 2216cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SK_API SkFILEStream : public SkStreamAsset { 2228a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 2233b429984664e88e0530eb6a1461a828898d8d96breed@google.com SK_DECLARE_INST_COUNT(SkFILEStream) 2243b429984664e88e0530eb6a1461a828898d8d96breed@google.com 2256cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Initialize the stream by calling sk_fopen on the specified path. 2266cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * This internal stream will be closed in the destructor. 2278a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com explicit SkFILEStream(const char path[] = NULL); 2296cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 2306cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com enum Ownership { 2316cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com kCallerPasses_Ownership, 2326cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com kCallerRetains_Ownership 2336cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com }; 2346cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Initialize the stream with an existing C file stream. 2356cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * While this stream exists, it assumes exclusive access to the C file stream. 2366cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * The C file stream will be closed in the destructor unless the caller specifies 2376cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * kCallerRetains_Ownership. 2386cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 2396cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com explicit SkFILEStream(FILE* file, Ownership ownership = kCallerPasses_Ownership); 2406cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 2418a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkFILEStream(); 2428a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2436cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Returns true if the current path could be opened. */ 2448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isValid() const { return fFILE != NULL; } 2456cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 2466cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Close the current file, and open a new file with the specified path. 2476cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * If path is NULL, just close the current file. 2486cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com */ 2498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void setPath(const char path[]); 2508a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2511341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com virtual size_t read(void* buffer, size_t size) SK_OVERRIDE; 2526cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool isAtEnd() const SK_OVERRIDE; 2538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2546cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool rewind() SK_OVERRIDE; 2556cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamAsset* duplicate() const SK_OVERRIDE; 2563b429984664e88e0530eb6a1461a828898d8d96breed@google.com 2576cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual size_t getPosition() const SK_OVERRIDE; 2586cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool seek(size_t position) SK_OVERRIDE; 2596cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool move(long offset) SK_OVERRIDE; 2606cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkStreamAsset* fork() const SK_OVERRIDE; 261fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 2626cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual size_t getLength() const SK_OVERRIDE; 263fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 26488682b77d108a7413a166e3158e187f43211c46bbungeman@google.com virtual const void* getMemoryBase() SK_OVERRIDE; 265fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 2668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 2676cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com SkFILE* fFILE; 2686cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com SkString fName; 2696cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com Ownership fOwnership; 2706cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com // fData is lazilly initialized when needed. 2716cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com mutable SkAutoTUnref<SkData> fData; 2723b429984664e88e0530eb6a1461a828898d8d96breed@google.com 2736cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com typedef SkStreamAsset INHERITED; 2748a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 2758a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2766cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.comclass SK_API SkMemoryStream : public SkStreamMemory { 2778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 2783b429984664e88e0530eb6a1461a828898d8d96breed@google.com SK_DECLARE_INST_COUNT(SkMemoryStream) 2793b429984664e88e0530eb6a1461a828898d8d96breed@google.com 2808a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkMemoryStream(); 2816cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 2826cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** We allocate (and free) the memory. Write to it via getMemoryBase() */ 2838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkMemoryStream(size_t length); 2846cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com 2856cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** If copyData is true, the stream makes a private copy of the data. */ 2868a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkMemoryStream(const void* data, size_t length, bool copyData = false); 287e490420efc931db8d2c8f397ddf704aab980295dscroggo@google.com 2886cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Use the specified data as the memory for this stream. 2896cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * The stream will call ref() on the data (assuming it is not NULL). 290e490420efc931db8d2c8f397ddf704aab980295dscroggo@google.com */ 291e490420efc931db8d2c8f397ddf704aab980295dscroggo@google.com SkMemoryStream(SkData*); 292e490420efc931db8d2c8f397ddf704aab980295dscroggo@google.com 2938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkMemoryStream(); 2948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 2958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Resets the stream to the specified data and length, 2968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com just like the constructor. 2978a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com if copyData is true, the stream makes a private copy of the data 2988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 2998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual void setMemory(const void* data, size_t length, 3008a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool copyData = false); 30157f4969724a1dd88c8d9ae35a863e6cf621181d5djsollen@google.com /** Replace any memory buffer with the specified buffer. The caller 30257f4969724a1dd88c8d9ae35a863e6cf621181d5djsollen@google.com must have allocated data with sk_malloc or sk_realloc, since it 30357f4969724a1dd88c8d9ae35a863e6cf621181d5djsollen@google.com will be freed with sk_free. 30457f4969724a1dd88c8d9ae35a863e6cf621181d5djsollen@google.com */ 30557f4969724a1dd88c8d9ae35a863e6cf621181d5djsollen@google.com void setMemoryOwned(const void* data, size_t length); 3068a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com 3076cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com /** Return the stream's data in a SkData. 3086cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * The caller must call unref() when it is finished using the data. 3098a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com */ 3108a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com SkData* copyToData() const; 3118a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com 3128a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com /** 3136cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * Use the specified data as the memory for this stream. 3146cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * The stream will call ref() on the data (assuming it is not NULL). 3156cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com * The function returns the data parameter as a convenience. 3168a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com */ 3178a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com SkData* setData(SkData*); 3188a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com 3198a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void skipToAlign4(); 3208a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com const void* getAtPos(); 3218a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com size_t peek() const { return fOffset; } 322fbfcd5602128ec010c82cb733c9cdc0a3254f9f3rmistry@google.com 3236cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual size_t read(void* buffer, size_t size) SK_OVERRIDE; 3246cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool isAtEnd() const SK_OVERRIDE; 3253b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3266cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool rewind() SK_OVERRIDE; 3276cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkMemoryStream* duplicate() const SK_OVERRIDE; 3288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3296cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual size_t getPosition() const SK_OVERRIDE; 3306cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool seek(size_t position) SK_OVERRIDE; 3316cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual bool move(long offset) SK_OVERRIDE; 3326cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual SkMemoryStream* fork() const SK_OVERRIDE; 3333b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3346cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com virtual size_t getLength() const SK_OVERRIDE; 3358a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3361341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com virtual const void* getMemoryBase() SK_OVERRIDE; 3378a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3388a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 3396cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com SkData* fData; 3406cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com size_t fOffset; 3413b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3426cab1a4b6a68aa81237731308ff37a646d48f51cbungeman@google.com typedef SkStreamMemory INHERITED; 3438a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 3448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com///////////////////////////////////////////////////////////////////////////////////////////// 3468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 347f7751ae229378595f8013de20ca2cc60a61903d1alokp@chromium.orgclass SK_API SkFILEWStream : public SkWStream { 3488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 3493b429984664e88e0530eb6a1461a828898d8d96breed@google.com SK_DECLARE_INST_COUNT(SkFILEWStream) 3503b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3513b429984664e88e0530eb6a1461a828898d8d96breed@google.com SkFILEWStream(const char path[]); 3528a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkFILEWStream(); 3538a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3548a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com /** Returns true if the current path could be opened. 3558a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com */ 3568a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool isValid() const { return fFILE != NULL; } 3578a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3581341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 3591341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com virtual void flush() SK_OVERRIDE; 360490fb6b4713463954cc0283a9c30e754c45c6004commit-bot@chromium.org virtual size_t bytesWritten() const SK_OVERRIDE; 3613b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3628a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 3638a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkFILE* fFILE; 3643b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3653b429984664e88e0530eb6a1461a828898d8d96breed@google.com typedef SkWStream INHERITED; 3668a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 3678a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3688a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comclass SkMemoryWStream : public SkWStream { 3698a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 3703b429984664e88e0530eb6a1461a828898d8d96breed@google.com SK_DECLARE_INST_COUNT(SkMemoryWStream) 3713b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3728a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkMemoryWStream(void* buffer, size_t size); 3731341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 374490fb6b4713463954cc0283a9c30e754c45c6004commit-bot@chromium.org virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; } 3751cc8f6f3c48b33430d0e39a4a36601ac0d1de04ajunov@chromium.org 3768a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 3778a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com char* fBuffer; 3788a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com size_t fMaxLength; 3798a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com size_t fBytesWritten; 3803b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3813b429984664e88e0530eb6a1461a828898d8d96breed@google.com typedef SkWStream INHERITED; 3828a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 3838a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 384dfc5ffe478a2f0922b5d4541507481d14f2f55dbctguil@chromium.orgclass SK_API SkDynamicMemoryWStream : public SkWStream { 3858a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 3863b429984664e88e0530eb6a1461a828898d8d96breed@google.com SK_DECLARE_INST_COUNT(SkDynamicMemoryWStream) 3873b429984664e88e0530eb6a1461a828898d8d96breed@google.com 3888a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com SkDynamicMemoryWStream(); 3898a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com virtual ~SkDynamicMemoryWStream(); 3908a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com 3911341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 392490fb6b4713463954cc0283a9c30e754c45c6004commit-bot@chromium.org virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; } 3938a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // random access write 3948a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // modifies stream and returns true if offset + size is less than or equal to getOffset() 3958a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool write(const void* buffer, size_t offset, size_t size); 3968a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com bool read(void* buffer, size_t offset, size_t size); 397a518086928494319b8968abc09808eff492c194fvandebo@chromium.org size_t getOffset() const { return fBytesWritten; } 3988a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 3998a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // copy what has been written to the stream into dst 4008a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com void copyTo(void* dst) const; 40170442a6cf73c9a822df23961f5e16dc3abc18f26reed@google.com 40270442a6cf73c9a822df23961f5e16dc3abc18f26reed@google.com /** 4038a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com * Return a copy of the data written so far. This call is responsible for 4048a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com * calling unref() when they are finished with the data. 40570442a6cf73c9a822df23961f5e16dc3abc18f26reed@google.com */ 4068d0b5770f8fcfdeb8ad9808e58c49116f14b6190reed@google.com SkData* copyToData() const; 40770442a6cf73c9a822df23961f5e16dc3abc18f26reed@google.com 40888682b77d108a7413a166e3158e187f43211c46bbungeman@google.com /** Reset, returning a reader stream with the current content. */ 409c29f3d8c6dec938fd0599db30cae590fcaa2108bbungeman@google.com SkStreamAsset* detachAsStream(); 41088682b77d108a7413a166e3158e187f43211c46bbungeman@google.com 41188682b77d108a7413a166e3158e187f43211c46bbungeman@google.com /** Reset the stream to its original, empty, state. */ 4128a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void reset(); 4138a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com void padToAlign4(); 4148a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comprivate: 4158a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com struct Block; 4168a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Block* fHead; 4178a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com Block* fTail; 4188a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com size_t fBytesWritten; 4198a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com mutable SkData* fCopy; // is invalidated if we write after it is created 4208a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com 4218a85d0c4938173476d037d7af0ee3b9436a1234ereed@google.com void invalidateCopy(); 4223b429984664e88e0530eb6a1461a828898d8d96breed@google.com 42388682b77d108a7413a166e3158e187f43211c46bbungeman@google.com // For access to the Block type. 42488682b77d108a7413a166e3158e187f43211c46bbungeman@google.com friend class SkBlockMemoryStream; 42588682b77d108a7413a166e3158e187f43211c46bbungeman@google.com friend class SkBlockMemoryRefCnt; 42688682b77d108a7413a166e3158e187f43211c46bbungeman@google.com 4273b429984664e88e0530eb6a1461a828898d8d96breed@google.com typedef SkWStream INHERITED; 4288a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 4298a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4308a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 431a718c5e0e56fb2d399273d068fcfedbef43ea90dreed@google.comclass SK_API SkDebugWStream : public SkWStream { 4328a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.compublic: 433490fb6b4713463954cc0283a9c30e754c45c6004commit-bot@chromium.org SkDebugWStream() : fBytesWritten(0) {} 4343b429984664e88e0530eb6a1461a828898d8d96breed@google.com SK_DECLARE_INST_COUNT(SkDebugWStream) 4353b429984664e88e0530eb6a1461a828898d8d96breed@google.com 4368a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com // overrides 4371341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com virtual bool write(const void* buffer, size_t size) SK_OVERRIDE; 4381341304449a60713bf9c8ea2e9489f35533f037atomhudson@google.com virtual void newline() SK_OVERRIDE; 439490fb6b4713463954cc0283a9c30e754c45c6004commit-bot@chromium.org virtual size_t bytesWritten() const SK_OVERRIDE { return fBytesWritten; } 4403b429984664e88e0530eb6a1461a828898d8d96breed@google.com 4413b429984664e88e0530eb6a1461a828898d8d96breed@google.comprivate: 442490fb6b4713463954cc0283a9c30e754c45c6004commit-bot@chromium.org size_t fBytesWritten; 4433b429984664e88e0530eb6a1461a828898d8d96breed@google.com typedef SkWStream INHERITED; 4448a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com}; 4458a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4468a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com// for now 4478a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.comtypedef SkFILEStream SkURLStream; 4488a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com 4498a1c16ff38322f0210116fa7293eb8817c7e477ereed@android.com#endif 450