18b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org/* 28b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * Copyright 2011 Google Inc. 38b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * 48b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * Use of this source code is governed by a BSD-style license that can be 58b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * found in the LICENSE file. 68b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org */ 78b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 88b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#ifndef SkReadBuffer_DEFINED 98b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#define SkReadBuffer_DEFINED 108b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 118b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkBitmapHeap.h" 128b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkColorFilter.h" 138b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkData.h" 148b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkDrawLooper.h" 158b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkImageFilter.h" 168b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkMaskFilter.h" 178b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkPath.h" 188b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkPathEffect.h" 198b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkPicture.h" 208b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkRasterizer.h" 218b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkReadBuffer.h" 228b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkReader32.h" 238b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkRefCnt.h" 248b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkShader.h" 258b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkWriteBuffer.h" 268b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#include "SkXfermode.h" 278b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 288b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgclass SkBitmap; 298b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 308b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_MAC) 318b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org #define DEBUG_NON_DETERMINISTIC_ASSERT 328b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#endif 338b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 348b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgclass SkReadBuffer { 358b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgpublic: 368b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkReadBuffer(); 378b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkReadBuffer(const void* data, size_t size); 388b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkReadBuffer(SkStream* stream); 398b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual ~SkReadBuffer(); 408b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 417ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org enum Version { 427ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org kFilterLevelIsEnum_Version = 23, 437ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org kGradientFlippedFlag_Version = 24, 447ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org kDashWritesPhaseIntervals_Version = 25, 457ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org kColorShaderNoBool_Version = 26, 4683f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org kNoUnitMappers_Version = 27, 47968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org kNoMoreBitmapFlatten_Version = 28, 48c870d494dd0dc88f3f4155a0d6257a1be8280880scroggo kSimplifyLocalMatrix_Version = 30, 4955b6d8be997a447ef9ce0f029697677a940bfc24senorblanco kImageFilterUniqueID_Version = 31, 503b6255493e458c6b2c1412af908581f0bf3f6b70djsollen kRemoveAndroidPaintOpts_Version = 32, 519fa60daad4d5f54c0dbe3dbcc7608a8f6d721187reed kFlattenCreateProc_Version = 33, 527ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org }; 537ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org 547ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org /** 557ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org * Returns true IFF the version is older than the specified version. 567ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org */ 577ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org bool isVersionLT(Version targetVersion) const { 587ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org SkASSERT(targetVersion > 0); 597ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org return fVersion > 0 && fVersion < targetVersion; 607ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org } 610943f5f58abcff15c7583faafe44549b9a44f47acommit-bot@chromium.org 620943f5f58abcff15c7583faafe44549b9a44f47acommit-bot@chromium.org /** This may be called at most once; most clients of SkReadBuffer should not mess with it. */ 637ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org void setVersion(int version) { 647ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org SkASSERT(0 == fVersion || version == fVersion); 657ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org fVersion = version; 660943f5f58abcff15c7583faafe44549b9a44f47acommit-bot@chromium.org } 670943f5f58abcff15c7583faafe44549b9a44f47acommit-bot@chromium.org 688b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org enum Flags { 698b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org kCrossProcess_Flag = 1 << 0, 708b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org kScalarIsFloat_Flag = 1 << 1, 718b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org kPtrIs64Bit_Flag = 1 << 2, 728b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org kValidation_Flag = 1 << 3, 738b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org }; 748b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 758b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setFlags(uint32_t flags) { fFlags = flags; } 768b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org uint32_t getFlags() const { return fFlags; } 778b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 788b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool isCrossProcess() const { 798b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org return this->isValidating() || SkToBool(fFlags & kCrossProcess_Flag); 808b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 818b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool isScalarFloat() const { return SkToBool(fFlags & kScalarIsFloat_Flag); } 828b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool isPtr64Bit() const { return SkToBool(fFlags & kPtrIs64Bit_Flag); } 838b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } 848b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 858b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkReader32* getReader32() { return &fReader; } 868b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 87f117781362ecf673f43f93918781853690f0e145commit-bot@chromium.org size_t size() { return fReader.size(); } 88f117781362ecf673f43f93918781853690f0e145commit-bot@chromium.org size_t offset() { return fReader.offset(); } 898b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool eof() { return fReader.eof(); } 900951fe12984944406e0f1bb105b9fa4c54fcdcddsugoi virtual const void* skip(size_t size) { return fReader.skip(size); } 9139426e2bcc8463b88872d22d6ed2729c68323073commit-bot@chromium.org void* readFunctionPtr() { return fReader.readPtr(); } 928b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 938b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // primitives 948b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readBool(); 958b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkColor readColor(); 968b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkFixed readFixed(); 978b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual int32_t readInt(); 988b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkScalar readScalar(); 998b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual uint32_t readUInt(); 1008b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual int32_t read32(); 1018b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1028b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // strings -- the caller is responsible for freeing the string contents 1038b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readString(SkString* string); 1048b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding); 1058b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1068b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // common data structures 1078b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readPoint(SkPoint* point); 1088b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; } 1098b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readMatrix(SkMatrix* matrix); 1108b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readIRect(SkIRect* rect); 1118b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readRect(SkRect* rect); 1128b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readRegion(SkRegion* region); 113b3c9d1c33caf325aada244204215eb790c228c12dandov 1148b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readPath(SkPath* path); 1158b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void readPaint(SkPaint* paint) { paint->unflatten(*this); } 1168b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1178b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkFlattenable* readFlattenable(SkFlattenable::Type); 1188b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org template <typename T> T* readFlattenable() { 1198b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org return (T*) this->readFlattenable(T::GetFlattenableType()); 1208b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1218b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkColorFilter* readColorFilter() { return this->readFlattenable<SkColorFilter>(); } 1228b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkDrawLooper* readDrawLooper() { return this->readFlattenable<SkDrawLooper>(); } 1238b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilter>(); } 1248b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); } 1258b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkPathEffect* readPathEffect() { return this->readFlattenable<SkPathEffect>(); } 1268b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer>(); } 1278b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkShader* readShader() { return this->readFlattenable<SkShader>(); } 1288b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(); } 1298b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 13083f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org /** 13183f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org * Like readFlattenable() but explicitly just skips the data that was written for the 13283f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org * flattenable (or the sentinel that there wasn't one). 13383f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org */ 13483f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org virtual void skipFlattenable(); 1358b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1368b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // binary data and arrays 1378b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readByteArray(void* value, size_t size); 1388b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readColorArray(SkColor* colors, size_t size); 1398b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readIntArray(int32_t* values, size_t size); 1408b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readPointArray(SkPoint* points, size_t size); 1418b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readScalarArray(SkScalar* values, size_t size); 1428b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1438b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkData* readByteArrayAsData() { 1448b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org size_t len = this->getArrayCount(); 1458b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org if (!this->validateAvailable(len)) { 1468b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org return SkData::NewEmpty(); 1478b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1488b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void* buffer = sk_malloc_throw(len); 1498b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org this->readByteArray(buffer, len); 1508b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org return SkData::NewFromMalloc(buffer, len); 1518b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1528b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1538b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // helpers to get info about arrays and binary data 1548b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual uint32_t getArrayCount(); 1558b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 156968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org /** 157968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org * Returns false if the bitmap could not be completely read. In that case, it will be set 158968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org * to have width/height, but no pixels. 159968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org */ 160968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org bool readBitmap(SkBitmap* bitmap); 161968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org 1628b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkTypeface* readTypeface(); 1638b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1648b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setBitmapStorage(SkBitmapHeapReader* bitmapStorage) { 1658b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkRefCnt_SafeAssign(fBitmapStorage, bitmapStorage); 1668b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1678b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1688b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setTypefaceArray(SkTypeface* array[], int count) { 1698b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fTFArray = array; 1708b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fTFCount = count; 1718b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1728b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1738b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org /** 1748b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * Call this with a pre-loaded array of Factories, in the same order as 1758b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * were created/written by the writer. SkPicture uses this. 1768b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org */ 1778b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setFactoryPlayback(SkFlattenable::Factory array[], int count) { 1788b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryTDArray = NULL; 1798b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryArray = array; 1808b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryCount = count; 1818b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1828b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1838b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org /** 1848b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * Call this with an initially empty array, so the reader can cache each 1858b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * factory it sees by name. Used by the pipe code in conjunction with 1868b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * SkWriteBuffer::setNamedFactoryRecorder. 1878b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org */ 1888b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setFactoryArray(SkTDArray<SkFlattenable::Factory>* array) { 1898b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryTDArray = array; 1908b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryArray = NULL; 1918b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryCount = 0; 1928b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1938b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1948b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org /** 1958b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * Provide a function to decode an SkBitmap from encoded data. Only used if the writer 1968b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap with the 1978b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * appropriate size will be used. 1988b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org */ 1998b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) { 2008b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fBitmapDecoder = bitmapDecoder; 2018b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 2028b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2038b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // Default impelementations don't check anything. 2048b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool validate(bool isValid) { return true; } 2058b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool isValid() const { return true; } 2068b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool validateAvailable(size_t size) { return true; } 2078b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2089e5f85e89d03a850d435fc951e74e9861a0c1bddcommit-bot@chromium.orgprotected: 2099e5f85e89d03a850d435fc951e74e9861a0c1bddcommit-bot@chromium.org SkReader32 fReader; 2109e5f85e89d03a850d435fc951e74e9861a0c1bddcommit-bot@chromium.org 2118b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgprivate: 2128b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool readArray(void* value, size_t size, size_t elementSize); 2138b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2148b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org uint32_t fFlags; 2157ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org int fVersion; 2168b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2178b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void* fMemoryPtr; 2188b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2198b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkBitmapHeapReader* fBitmapStorage; 2208b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkTypeface** fTFArray; 2218b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org int fTFCount; 2228b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2238b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkTDArray<SkFlattenable::Factory>* fFactoryTDArray; 2248b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkFlattenable::Factory* fFactoryArray; 2258b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org int fFactoryCount; 2268b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2278b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkPicture::InstallPixelRefProc fBitmapDecoder; 2288b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2298b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#ifdef DEBUG_NON_DETERMINISTIC_ASSERT 2308b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // Debugging counter to keep track of how many bitmaps we 2318b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // have decoded. 2328b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org int fDecodedBitmapIndex; 2338b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#endif // DEBUG_NON_DETERMINISTIC_ASSERT 2348b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org}; 2358b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2368b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#endif // SkReadBuffer_DEFINED 237