SkReadBuffer.h revision 76be9c8dc0e5306ef81c2987848088cdec7ccd3f
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 { 4288fd0fbcccea615f2d2cd61a121ac9e3185adfe4mtklein /* 437ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org kFilterLevelIsEnum_Version = 23, 447ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org kGradientFlippedFlag_Version = 24, 457ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org kDashWritesPhaseIntervals_Version = 25, 467ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org kColorShaderNoBool_Version = 26, 4783f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org kNoUnitMappers_Version = 27, 48968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org kNoMoreBitmapFlatten_Version = 28, 49c870d494dd0dc88f3f4155a0d6257a1be8280880scroggo kSimplifyLocalMatrix_Version = 30, 5055b6d8be997a447ef9ce0f029697677a940bfc24senorblanco kImageFilterUniqueID_Version = 31, 513b6255493e458c6b2c1412af908581f0bf3f6b70djsollen kRemoveAndroidPaintOpts_Version = 32, 529fa60daad4d5f54c0dbe3dbcc7608a8f6d721187reed kFlattenCreateProc_Version = 33, 5388fd0fbcccea615f2d2cd61a121ac9e3185adfe4mtklein */ 54c5e15a1afab2621e860a251c3fcf5917867ad49freed kRemoveColorTableAlpha_Version = 36, 55234f036b3e731e06e616c5291157d3bb4fbfdee2sugoi kDropShadowMode_Version = 37, 565234075b1c6bcada4ad17ed5a83bfcb53df66b7fJustin Novosad kPictureImageFilterResolution_Version = 38, 57f3c78ccf5694d22d2e4a7061a80399a7e69b59dbjunov kPictureImageFilterLevel_Version = 39, 584a22a433bfb972dcd96f76e3d3b0613c26d8fc86senorblanco kImageFilterNoUniqueID_Version = 40, 5976be9c8dc0e5306ef81c2987848088cdec7ccd3fmtklein kBitmapSourceFilterQuality_Version = 41, 6076be9c8dc0e5306ef81c2987848088cdec7ccd3fmtklein kPictureShaderHasPictureBool_Version = 42, 617ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org }; 627ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org 637ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org /** 647ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org * Returns true IFF the version is older than the specified version. 657ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org */ 667ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org bool isVersionLT(Version targetVersion) const { 677ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org SkASSERT(targetVersion > 0); 687ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org return fVersion > 0 && fVersion < targetVersion; 697ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org } 700943f5f58abcff15c7583faafe44549b9a44f47acommit-bot@chromium.org 710943f5f58abcff15c7583faafe44549b9a44f47acommit-bot@chromium.org /** This may be called at most once; most clients of SkReadBuffer should not mess with it. */ 727ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org void setVersion(int version) { 737ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org SkASSERT(0 == fVersion || version == fVersion); 747ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org fVersion = version; 750943f5f58abcff15c7583faafe44549b9a44f47acommit-bot@chromium.org } 760943f5f58abcff15c7583faafe44549b9a44f47acommit-bot@chromium.org 778b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org enum Flags { 788b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org kCrossProcess_Flag = 1 << 0, 798b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org kScalarIsFloat_Flag = 1 << 1, 808b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org kPtrIs64Bit_Flag = 1 << 2, 818b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org kValidation_Flag = 1 << 3, 828b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org }; 838b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 848b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setFlags(uint32_t flags) { fFlags = flags; } 858b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org uint32_t getFlags() const { return fFlags; } 868b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 878b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool isCrossProcess() const { 888b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org return this->isValidating() || SkToBool(fFlags & kCrossProcess_Flag); 898b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 908b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool isScalarFloat() const { return SkToBool(fFlags & kScalarIsFloat_Flag); } 918b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool isPtr64Bit() const { return SkToBool(fFlags & kPtrIs64Bit_Flag); } 928b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool isValidating() const { return SkToBool(fFlags & kValidation_Flag); } 938b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 948b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkReader32* getReader32() { return &fReader; } 958b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 96f117781362ecf673f43f93918781853690f0e145commit-bot@chromium.org size_t size() { return fReader.size(); } 97f117781362ecf673f43f93918781853690f0e145commit-bot@chromium.org size_t offset() { return fReader.offset(); } 988b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool eof() { return fReader.eof(); } 990951fe12984944406e0f1bb105b9fa4c54fcdcddsugoi virtual const void* skip(size_t size) { return fReader.skip(size); } 10039426e2bcc8463b88872d22d6ed2729c68323073commit-bot@chromium.org void* readFunctionPtr() { return fReader.readPtr(); } 1018b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1028b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // primitives 1038b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readBool(); 1048b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkColor readColor(); 1058b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkFixed readFixed(); 1068b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual int32_t readInt(); 1078b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkScalar readScalar(); 1088b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual uint32_t readUInt(); 1098b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual int32_t read32(); 1108b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1118b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // strings -- the caller is responsible for freeing the string contents 1128b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readString(SkString* string); 1138b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void* readEncodedString(size_t* length, SkPaint::TextEncoding encoding); 1148b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1158b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // common data structures 1168b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readPoint(SkPoint* point); 1178b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkPoint readPoint() { SkPoint p; this->readPoint(&p); return p; } 1188b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readMatrix(SkMatrix* matrix); 1198b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readIRect(SkIRect* rect); 1208b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readRect(SkRect* rect); 1218b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readRegion(SkRegion* region); 12288fd0fbcccea615f2d2cd61a121ac9e3185adfe4mtklein 1238b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual void readPath(SkPath* path); 1248b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void readPaint(SkPaint* paint) { paint->unflatten(*this); } 1258b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1268b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkFlattenable* readFlattenable(SkFlattenable::Type); 1278b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org template <typename T> T* readFlattenable() { 1288b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org return (T*) this->readFlattenable(T::GetFlattenableType()); 1298b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1308b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkColorFilter* readColorFilter() { return this->readFlattenable<SkColorFilter>(); } 1318b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkDrawLooper* readDrawLooper() { return this->readFlattenable<SkDrawLooper>(); } 1328b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkImageFilter* readImageFilter() { return this->readFlattenable<SkImageFilter>(); } 1338b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkMaskFilter* readMaskFilter() { return this->readFlattenable<SkMaskFilter>(); } 1348b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkPathEffect* readPathEffect() { return this->readFlattenable<SkPathEffect>(); } 1358b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkRasterizer* readRasterizer() { return this->readFlattenable<SkRasterizer>(); } 1368b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkShader* readShader() { return this->readFlattenable<SkShader>(); } 1378b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkXfermode* readXfermode() { return this->readFlattenable<SkXfermode>(); } 1388b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 13983f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org /** 14083f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org * Like readFlattenable() but explicitly just skips the data that was written for the 14183f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org * flattenable (or the sentinel that there wasn't one). 14283f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org */ 14383f23d87f1d67e6e73873e1ef7cda621c43703a0commit-bot@chromium.org virtual void skipFlattenable(); 1448b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1458b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // binary data and arrays 1468b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readByteArray(void* value, size_t size); 1478b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readColorArray(SkColor* colors, size_t size); 1488b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readIntArray(int32_t* values, size_t size); 1498b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readPointArray(SkPoint* points, size_t size); 1508b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool readScalarArray(SkScalar* values, size_t size); 1518b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1528b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkData* readByteArrayAsData() { 1538b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org size_t len = this->getArrayCount(); 1548b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org if (!this->validateAvailable(len)) { 1558b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org return SkData::NewEmpty(); 1568b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1578b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void* buffer = sk_malloc_throw(len); 1588b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org this->readByteArray(buffer, len); 1598b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org return SkData::NewFromMalloc(buffer, len); 1608b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1618b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1628b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // helpers to get info about arrays and binary data 1638b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual uint32_t getArrayCount(); 1648b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 165968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org /** 166968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org * Returns false if the bitmap could not be completely read. In that case, it will be set 167968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org * to have width/height, but no pixels. 168968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org */ 169968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org bool readBitmap(SkBitmap* bitmap); 170968edcafa61442dc4f7f8ed8f89523d0f353e9fbcommit-bot@chromium.org 1718b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual SkTypeface* readTypeface(); 1728b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1738b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setBitmapStorage(SkBitmapHeapReader* bitmapStorage) { 1748b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkRefCnt_SafeAssign(fBitmapStorage, bitmapStorage); 1758b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1768b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1778b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setTypefaceArray(SkTypeface* array[], int count) { 1788b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fTFArray = array; 1798b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fTFCount = count; 1808b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1818b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1828b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org /** 1838b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * Call this with a pre-loaded array of Factories, in the same order as 1848b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * were created/written by the writer. SkPicture uses this. 1858b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org */ 1868b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setFactoryPlayback(SkFlattenable::Factory array[], int count) { 1878b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryTDArray = NULL; 1888b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryArray = array; 1898b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryCount = count; 1908b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 1918b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 1928b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org /** 1938b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * Call this with an initially empty array, so the reader can cache each 1948b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * factory it sees by name. Used by the pipe code in conjunction with 1958b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * SkWriteBuffer::setNamedFactoryRecorder. 1968b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org */ 1978b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setFactoryArray(SkTDArray<SkFlattenable::Factory>* array) { 1988b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryTDArray = array; 1998b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryArray = NULL; 2008b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fFactoryCount = 0; 2018b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 2028b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2038b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org /** 2048b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * Provide a function to decode an SkBitmap from encoded data. Only used if the writer 2058b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * encoded the SkBitmap. If the proper decoder cannot be used, a red bitmap with the 2068b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org * appropriate size will be used. 2078b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org */ 2088b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void setBitmapDecoder(SkPicture::InstallPixelRefProc bitmapDecoder) { 2098b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org fBitmapDecoder = bitmapDecoder; 2108b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org } 2118b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2128b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // Default impelementations don't check anything. 2138b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool validate(bool isValid) { return true; } 2148b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool isValid() const { return true; } 2158b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org virtual bool validateAvailable(size_t size) { return true; } 2168b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2179e5f85e89d03a850d435fc951e74e9861a0c1bddcommit-bot@chromium.orgprotected: 2189e5f85e89d03a850d435fc951e74e9861a0c1bddcommit-bot@chromium.org SkReader32 fReader; 2199e5f85e89d03a850d435fc951e74e9861a0c1bddcommit-bot@chromium.org 2208b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgprivate: 2218b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org bool readArray(void* value, size_t size, size_t elementSize); 2228b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2238b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org uint32_t fFlags; 2247ed173b1ebac84671fb0dc1b9bd323a5e6e63771commit-bot@chromium.org int fVersion; 2258b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2268b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org void* fMemoryPtr; 2278b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2288b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkBitmapHeapReader* fBitmapStorage; 2298b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkTypeface** fTFArray; 2308b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org int fTFCount; 2318b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2328b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkTDArray<SkFlattenable::Factory>* fFactoryTDArray; 2338b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkFlattenable::Factory* fFactoryArray; 2348b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org int fFactoryCount; 2358b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2368b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org SkPicture::InstallPixelRefProc fBitmapDecoder; 2378b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2388b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#ifdef DEBUG_NON_DETERMINISTIC_ASSERT 2398b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // Debugging counter to keep track of how many bitmaps we 2408b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org // have decoded. 2418b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org int fDecodedBitmapIndex; 2428b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#endif // DEBUG_NON_DETERMINISTIC_ASSERT 2438b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org}; 2448b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org 2458b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.org#endif // SkReadBuffer_DEFINED 246