memcpy(info.fMagic, kMagic, sizeof(kMagic));
// Set picture info after magic bytes in the header
- info.fVersion = CURRENT_PICTURE_VERSION;
+ info.setVersion(CURRENT_PICTURE_VERSION);
info.fCullRect = this->cullRect();
info.fFlags = SkPictInfo::kCrossProcess_Flag;
// TODO: remove this flag, since we're always float (now)
if (0 != memcmp(info.fMagic, kMagic, sizeof(kMagic))) {
return false;
}
- if (info.fVersion < MIN_PICTURE_VERSION || info.fVersion > CURRENT_PICTURE_VERSION) {
+ if (info.getVersion() < MIN_PICTURE_VERSION || info.getVersion() > CURRENT_PICTURE_VERSION) {
return false;
}
return true;
return false;
}
- info.fVersion = stream->readU32();
+ info.setVersion( stream->readU32());
info.fCullRect.fLeft = stream->readScalar();
info.fCullRect.fTop = stream->readScalar();
info.fCullRect.fRight = stream->readScalar();
return false;
}
- info.fVersion = buffer->readUInt();
+ info.setVersion(buffer->readUInt());
buffer->readRect(&info.fCullRect);
info.fFlags = buffer->readUInt();
SkAutoTDelete<SkPictureData> data(this->backport());
buffer.writeByteArray(&info.fMagic, sizeof(info.fMagic));
- buffer.writeUInt(info.fVersion);
+ buffer.writeUInt(info.getVersion());
buffer.writeRect(info.fCullRect);
buffer.writeUInt(info.fFlags);
if (data) {
/* Should we use SkValidatingReadBuffer instead? */
SkReadBuffer buffer(storage.get(), size);
buffer.setFlags(pictInfoFlagsToReadBufferFlags(fInfo.fFlags));
- buffer.setVersion(fInfo.fVersion);
+ buffer.setVersion(fInfo.getVersion());
if (!fFactoryPlayback) {
return false;
SkPictureData* SkPictureData::CreateFromBuffer(SkReadBuffer& buffer,
const SkPictInfo& info) {
SkAutoTDelete<SkPictureData> data(new SkPictureData(info));
- buffer.setVersion(info.fVersion);
+ buffer.setVersion(info.getVersion());
if (!data->parseBuffer(buffer)) {
return nullptr;
kPtrIs64Bit_Flag = 1 << 2,
};
+ SkPictInfo() : fVersion(~0U) {}
+
+ uint32_t getVersion() const {
+ SkASSERT(fVersion != ~0U);
+ return fVersion;
+ }
+
+ void setVersion(uint32_t version) {
+ SkASSERT(version != ~0U);
+ fVersion = version;
+ }
+
+public:
char fMagic[8];
+private:
uint32_t fVersion;
+public:
SkRect fCullRect;
uint32_t fFlags;
};
return fVersion > 0 && fVersion < targetVersion;
}
+ uint32_t getVersion() const { return fVersion; }
+
/** This may be called at most once; most clients of SkReadBuffer should not mess with it. */
void setVersion(int version) {
SkASSERT(0 == fVersion || version == fVersion);
// Unflatten into a SkPictureData.
SkPictInfo info;
+ info.setVersion(buffer.getVersion());
info.fCullRect = bounds;
+ info.fFlags = 0; // ???
SkAutoTDelete<SkPictureData> pictureData(SkPictureData::CreateFromBuffer(buffer, info));
if (!pictureData) {
return nullptr;
}
if (FLAGS_version && !FLAGS_quiet) {
- SkDebugf("Version: %d\n", info.fVersion);
+ SkDebugf("Version: %d\n", info.getVersion());
}
if (FLAGS_cullRect && !FLAGS_quiet) {
SkDebugf("Cull Rect: %f,%f,%f,%f\n",