Index: src/core/SkPicture.cpp |
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp |
index 1df56a52d784bbd85ca1dc58d2651b021bb7d78e..d749e471f82ab51a91656b8826d884c22c42c43d 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' }; |
tfarina
2013/10/16 16:43:59
I assume the { 'f', 'o', 'o' }; syntax usage was i
|
+ |
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); |