aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-26 12:46:59 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-11-26 12:46:59 +0000
commit6300f4d1f3bd2e1a4d991ab28e843bcc3d4a4691 (patch)
tree16dc678cca55bd343c9e82d49c7ffcc2f4ba1267 /src
parent7f78611271a121ffc1cd08be92018857b615204c (diff)
Add 'skiapict' magic bytes to SkPicture format.
Testing: out/Debug/tests && out/Release/gm --replay --serialize BUG= R=fmalita@google.com, reed@google.com, fmalita@chromium.org Author: mtklein@google.com Review URL: https://codereview.chromium.org/27408002 git-svn-id: http://skia.googlecode.com/svn/trunk@12391 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPicture.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index 4acc549377..2520e6b9c9 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -266,11 +266,20 @@ void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) {
#include "SkStream.h"
+static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' };
+
bool SkPicture::StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
if (NULL == stream) {
return false;
}
+ // Check magic bytes.
+ char magic[sizeof(kMagic)];
+ stream->read(magic, sizeof(kMagic));
+ if (0 != memcmp(magic, kMagic, sizeof(kMagic))) {
+ return false;
+ }
+
SkPictInfo info;
if (!stream->read(&info, sizeof(SkPictInfo))) {
return false;
@@ -341,6 +350,10 @@ void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
info.fFlags |= SkPictInfo::kPtrIs64Bit_Flag;
}
+ // Write 8 magic bytes to ID this file format.
+ SkASSERT(sizeof(kMagic) == 8);
+ stream->write(kMagic, sizeof(kMagic));
+
stream->write(&info, sizeof(info));
if (playback) {
stream->writeBool(true);