aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2016-10-04 15:12:01 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-10-04 19:33:23 +0000
commitb3f543d955637c6e10d7109554b5a46c6e25291a (patch)
tree40749b09947f6f04eb9ce6ef213f8a905d0ff197
parentd6699c8281f59062f50ab2b40b6a34017dd1ba8b (diff)
ensure we always set the pictinfo.fVersion
BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2932 Change-Id: I8864a60f629e0f68b7871e0c388b42f4b6d78dbe Reviewed-on: https://skia-review.googlesource.com/2932 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Reed <reed@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
-rw-r--r--src/core/SkPicture.cpp10
-rw-r--r--src/core/SkPictureData.cpp4
-rw-r--r--src/core/SkPictureData.h15
-rw-r--r--src/core/SkReadBuffer.h2
-rw-r--r--src/core/SkRecordedDrawable.cpp2
-rw-r--r--tools/skpinfo.cpp2
6 files changed, 27 insertions, 8 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 60987b64c0..88da70aacf 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -90,7 +90,7 @@ SkPictInfo SkPicture::createHeader() const {
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)
@@ -106,7 +106,7 @@ bool SkPicture::IsValidPictInfo(const SkPictInfo& info) {
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;
@@ -123,7 +123,7 @@ bool SkPicture::InternalOnly_StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
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();
@@ -144,7 +144,7 @@ bool SkPicture::InternalOnly_BufferIsSKP(SkReadBuffer* buffer, SkPictInfo* pInfo
return false;
}
- info.fVersion = buffer->readUInt();
+ info.setVersion(buffer->readUInt());
buffer->readRect(&info.fCullRect);
info.fFlags = buffer->readUInt();
@@ -249,7 +249,7 @@ void SkPicture::flatten(SkWriteBuffer& buffer) const {
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) {
diff --git a/src/core/SkPictureData.cpp b/src/core/SkPictureData.cpp
index 8c641097dc..68789acddf 100644
--- a/src/core/SkPictureData.cpp
+++ b/src/core/SkPictureData.cpp
@@ -426,7 +426,7 @@ bool SkPictureData::parseStreamTag(SkStream* stream,
/* 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;
@@ -591,7 +591,7 @@ SkPictureData* SkPictureData::CreateFromStream(SkStream* stream,
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;
diff --git a/src/core/SkPictureData.h b/src/core/SkPictureData.h
index 353bbd9357..332b799638 100644
--- a/src/core/SkPictureData.h
+++ b/src/core/SkPictureData.h
@@ -34,8 +34,23 @@ struct SkPictInfo {
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;
};
diff --git a/src/core/SkReadBuffer.h b/src/core/SkReadBuffer.h
index 3e6742fde0..8a3b7bac88 100644
--- a/src/core/SkReadBuffer.h
+++ b/src/core/SkReadBuffer.h
@@ -79,6 +79,8 @@ public:
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);
diff --git a/src/core/SkRecordedDrawable.cpp b/src/core/SkRecordedDrawable.cpp
index 041fdd20f5..9e68be1d25 100644
--- a/src/core/SkRecordedDrawable.cpp
+++ b/src/core/SkRecordedDrawable.cpp
@@ -78,7 +78,9 @@ sk_sp<SkFlattenable> SkRecordedDrawable::CreateProc(SkReadBuffer& buffer) {
// 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;
diff --git a/tools/skpinfo.cpp b/tools/skpinfo.cpp
index dd5fd75f19..be2aa22d5f 100644
--- a/tools/skpinfo.cpp
+++ b/tools/skpinfo.cpp
@@ -57,7 +57,7 @@ int tool_main(int argc, char** argv) {
}
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",