Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: src/core/SkPicture.cpp

Issue 153583007: Revert "Serialization of SkPictureImageFilter" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/core/SkPicturePlayback.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicture.cpp
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index e226c2642ac1e0d4a6ad23a8ce4a218795937c06..ca1b6fa22a94cf0f84d7bd6ac0c61a7338f7c12e 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -265,7 +265,6 @@ void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) {
#include "SkStream.h"
static const char kMagic[] = { 's', 'k', 'i', 'a', 'p', 'i', 'c', 't' };
-static const size_t kHeaderSize = sizeof(kMagic) + sizeof(SkPictInfo);
bool SkPicture::StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
if (NULL == stream) {
@@ -274,8 +273,8 @@ bool SkPicture::StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
// Check magic bytes.
char magic[sizeof(kMagic)];
- if (!stream->read(magic, sizeof(kMagic)) ||
- (0 != memcmp(magic, kMagic, sizeof(kMagic)))) {
+ stream->read(magic, sizeof(kMagic));
+ if (0 != memcmp(magic, kMagic, sizeof(kMagic))) {
return false;
}
@@ -294,30 +293,6 @@ bool SkPicture::StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
return true;
}
-bool SkPicture::BufferIsSKP(SkReadBuffer& buffer, SkPictInfo* pInfo) {
- // Check magic bytes.
- char magic[sizeof(kMagic)];
-
- if (!buffer.readByteArray(magic, sizeof(kMagic)) ||
- (0 != memcmp(magic, kMagic, sizeof(kMagic)))) {
- return false;
- }
-
- SkPictInfo info;
- if (!buffer.readByteArray(&info, sizeof(SkPictInfo))) {
- return false;
- }
-
- if (PICTURE_VERSION != info.fVersion) {
- return false;
- }
-
- if (pInfo != NULL) {
- *pInfo = info;
- }
- return true;
-}
-
SkPicture::SkPicture(SkPicturePlayback* playback, int width, int height)
: fPlayback(playback)
, fRecord(NULL)
@@ -345,56 +320,31 @@ SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro
return SkNEW_ARGS(SkPicture, (playback, info.fWidth, info.fHeight));
}
-SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) {
- SkPictInfo info;
-
- if (!BufferIsSKP(buffer, &info)) {
- return NULL;
- }
+void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
+ SkPicturePlayback* playback = fPlayback;
- SkPicturePlayback* playback;
- // Check to see if there is a playback to recreate.
- if (buffer.readBool()) {
- playback = SkPicturePlayback::CreateFromBuffer(buffer);
- if (NULL == playback) {
- return NULL;
- }
- } else {
- playback = NULL;
+ if (NULL == playback && fRecord) {
+ playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord));
}
- return SkNEW_ARGS(SkPicture, (playback, info.fWidth, info.fHeight));
-}
+ SkPictInfo info;
-void SkPicture::createHeader(void* header) const {
- // Copy magic bytes at the beginning of the header
- SkASSERT(sizeof(kMagic) == 8);
- memcpy(header, kMagic, sizeof(kMagic));
-
- // Set piture info after magic bytes in the header
- SkPictInfo* info = (SkPictInfo*)(((char*)header) + sizeof(kMagic));
- info->fVersion = PICTURE_VERSION;
- info->fWidth = fWidth;
- info->fHeight = fHeight;
- info->fFlags = SkPictInfo::kCrossProcess_Flag;
+ info.fVersion = PICTURE_VERSION;
+ info.fWidth = fWidth;
+ info.fHeight = fHeight;
+ info.fFlags = SkPictInfo::kCrossProcess_Flag;
// TODO: remove this flag, since we're always float (now)
- info->fFlags |= SkPictInfo::kScalarIsFloat_Flag;
+ info.fFlags |= SkPictInfo::kScalarIsFloat_Flag;
if (8 == sizeof(void*)) {
- info->fFlags |= SkPictInfo::kPtrIs64Bit_Flag;
+ info.fFlags |= SkPictInfo::kPtrIs64Bit_Flag;
}
-}
-
-void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
- SkPicturePlayback* playback = fPlayback;
- if (NULL == playback && fRecord) {
- playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord));
- }
+ // Write 8 magic bytes to ID this file format.
+ SkASSERT(sizeof(kMagic) == 8);
+ stream->write(kMagic, sizeof(kMagic));
- char header[kHeaderSize];
- createHeader(&header);
- stream->write(header, kHeaderSize);
+ stream->write(&info, sizeof(info));
if (playback) {
stream->writeBool(true);
playback->serialize(stream, encoder);
@@ -407,28 +357,6 @@ void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
}
}
-void SkPicture::flatten(SkWriteBuffer& buffer) const {
- SkPicturePlayback* playback = fPlayback;
-
- if (NULL == playback && fRecord) {
- playback = SkNEW_ARGS(SkPicturePlayback, (*fRecord));
- }
-
- char header[kHeaderSize];
- createHeader(&header);
- buffer.writeByteArray(header, kHeaderSize);
- if (playback) {
- buffer.writeBool(true);
- playback->flatten(buffer);
- // delete playback if it is a local version (i.e. cons'd up just now)
- if (playback != fPlayback) {
- SkDELETE(playback);
- }
- } else {
- buffer.writeBool(false);
- }
-}
-
bool SkPicture::willPlayBackBitmaps() const {
if (!fPlayback) return false;
return fPlayback->containsBitmaps();
« no previous file with comments | « samplecode/SampleFilterFuzz.cpp ('k') | src/core/SkPicturePlayback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698