aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-03 19:18:39 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-03-03 19:18:39 +0000
commit6f4fb0f1296422a44d5d0dac155d82595dc5ebec (patch)
tree4901983c0553090f68884a15b3b82c2649f94ef9 /src
parent1b94819fcbe766039a488ad3975db2e1a8a25e28 (diff)
Generating the 1M skps frequently yields truncated skps. This tool is intended to help automate weeding these out.
Please see skbug:1057 rmistry for tools, gyp mtklein for src\core & include\core BUG=skia:1057 R=rmistry@google.com, mtklein@google.com, reed@google.com Author: robertphillips@google.com Review URL: https://codereview.chromium.org/176863004 git-svn-id: http://skia.googlecode.com/svn/trunk@13643 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkPicture.cpp14
-rw-r--r--src/core/SkPicturePlayback.cpp59
-rw-r--r--src/core/SkPicturePlayback.h15
3 files changed, 44 insertions, 44 deletions
diff --git a/src/core/SkPicture.cpp b/src/core/SkPicture.cpp
index b2c19e8e9c..2ea4641bf8 100644
--- a/src/core/SkPicture.cpp
+++ b/src/core/SkPicture.cpp
@@ -256,7 +256,7 @@ void SkPicture::draw(SkCanvas* surface, SkDrawPictureCallback* callback) {
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) {
+bool SkPicture::InternalOnly_StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
if (NULL == stream) {
return false;
}
@@ -283,7 +283,7 @@ bool SkPicture::StreamIsSKP(SkStream* stream, SkPictInfo* pInfo) {
return true;
}
-bool SkPicture::BufferIsSKP(SkReadBuffer& buffer, SkPictInfo* pInfo) {
+bool SkPicture::InternalOnly_BufferIsSKP(SkReadBuffer& buffer, SkPictInfo* pInfo) {
// Check magic bytes.
char magic[sizeof(kMagic)];
@@ -316,7 +316,7 @@ SkPicture::SkPicture(SkPicturePlayback* playback, int width, int height)
SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc proc) {
SkPictInfo info;
- if (!StreamIsSKP(stream, &info)) {
+ if (!InternalOnly_StreamIsSKP(stream, &info)) {
return NULL;
}
@@ -337,7 +337,7 @@ SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro
SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) {
SkPictInfo info;
- if (!BufferIsSKP(buffer, &info)) {
+ if (!InternalOnly_BufferIsSKP(buffer, &info)) {
return NULL;
}
@@ -360,7 +360,7 @@ void SkPicture::createHeader(void* header) const {
SkASSERT(sizeof(kMagic) == 8);
memcpy(header, kMagic, sizeof(kMagic));
- // Set piture info after magic bytes in the header
+ // Set picture info after magic bytes in the header
SkPictInfo* info = (SkPictInfo*)(((char*)header) + sizeof(kMagic));
info->fVersion = CURRENT_PICTURE_VERSION;
info->fWidth = fWidth;
@@ -382,7 +382,7 @@ void SkPicture::serialize(SkWStream* stream, EncodeBitmap encoder) const {
}
char header[kHeaderSize];
- createHeader(&header);
+ this->createHeader(&header);
stream->write(header, kHeaderSize);
if (playback) {
stream->writeBool(true);
@@ -404,7 +404,7 @@ void SkPicture::flatten(SkWriteBuffer& buffer) const {
}
char header[kHeaderSize];
- createHeader(&header);
+ this->createHeader(&header);
buffer.writeByteArray(header, kHeaderSize);
if (playback) {
buffer.writeBool(true);
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index f170476241..7cc2a556be 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -305,21 +305,6 @@ bool SkPicturePlayback::containsBitmaps() const {
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-#define PICT_READER_TAG SkSetFourByteTag('r', 'e', 'a', 'd')
-#define PICT_FACTORY_TAG SkSetFourByteTag('f', 'a', 'c', 't')
-#define PICT_TYPEFACE_TAG SkSetFourByteTag('t', 'p', 'f', 'c')
-#define PICT_PICTURE_TAG SkSetFourByteTag('p', 'c', 't', 'r')
-
-// This tag specifies the size of the ReadBuffer, needed for the following tags
-#define PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y')
-// these are all inside the ARRAYS tag
-#define PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p')
-#define PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ')
-#define PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ')
-
-// Always write this guy last (with no length field afterwards)
-#define PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ')
-
#include "SkStream.h"
static void writeTagSize(SkWriteBuffer& buffer, uint32_t tag,
@@ -337,7 +322,7 @@ static void writeTagSize(SkWStream* stream, uint32_t tag,
static void writeFactories(SkWStream* stream, const SkFactorySet& rec) {
int count = rec.count();
- writeTagSize(stream, PICT_FACTORY_TAG, count);
+ writeTagSize(stream, SK_PICT_FACTORY_TAG, count);
SkAutoSTMalloc<16, SkFlattenable::Factory> storage(count);
SkFlattenable::Factory* array = (SkFlattenable::Factory*)storage.get();
@@ -359,7 +344,7 @@ static void writeFactories(SkWStream* stream, const SkFactorySet& rec) {
static void writeTypefaces(SkWStream* stream, const SkRefCntSet& rec) {
int count = rec.count();
- writeTagSize(stream, PICT_TYPEFACE_TAG, count);
+ writeTagSize(stream, SK_PICT_TYPEFACE_TAG, count);
SkAutoSTMalloc<16, SkTypeface*> storage(count);
SkTypeface** array = (SkTypeface**)storage.get();
@@ -374,32 +359,32 @@ void SkPicturePlayback::flattenToBuffer(SkWriteBuffer& buffer) const {
int i, n;
if ((n = SafeCount(fBitmaps)) > 0) {
- writeTagSize(buffer, PICT_BITMAP_BUFFER_TAG, n);
+ writeTagSize(buffer, SK_PICT_BITMAP_BUFFER_TAG, n);
for (i = 0; i < n; i++) {
buffer.writeBitmap((*fBitmaps)[i]);
}
}
if ((n = SafeCount(fPaints)) > 0) {
- writeTagSize(buffer, PICT_PAINT_BUFFER_TAG, n);
+ writeTagSize(buffer, SK_PICT_PAINT_BUFFER_TAG, n);
for (i = 0; i < n; i++) {
buffer.writePaint((*fPaints)[i]);
}
}
if ((n = SafeCount(fPathHeap.get())) > 0) {
- writeTagSize(buffer, PICT_PATH_BUFFER_TAG, n);
+ writeTagSize(buffer, SK_PICT_PATH_BUFFER_TAG, n);
fPathHeap->flatten(buffer);
}
}
void SkPicturePlayback::serialize(SkWStream* stream,
SkPicture::EncodeBitmap encoder) const {
- writeTagSize(stream, PICT_READER_TAG, fOpData->size());
+ writeTagSize(stream, SK_PICT_READER_TAG, fOpData->size());
stream->write(fOpData->bytes(), fOpData->size());
if (fPictureCount > 0) {
- writeTagSize(stream, PICT_PICTURE_TAG, fPictureCount);
+ writeTagSize(stream, SK_PICT_PICTURE_TAG, fPictureCount);
for (int i = 0; i < fPictureCount; i++) {
fPictureRefs[i]->serialize(stream, encoder);
}
@@ -424,19 +409,19 @@ void SkPicturePlayback::serialize(SkWStream* stream,
writeFactories(stream, factSet);
writeTypefaces(stream, typefaceSet);
- writeTagSize(stream, PICT_BUFFER_SIZE_TAG, buffer.bytesWritten());
+ writeTagSize(stream, SK_PICT_BUFFER_SIZE_TAG, buffer.bytesWritten());
buffer.writeToStream(stream);
}
- stream->write32(PICT_EOF_TAG);
+ stream->write32(SK_PICT_EOF_TAG);
}
void SkPicturePlayback::flatten(SkWriteBuffer& buffer) const {
- writeTagSize(buffer, PICT_READER_TAG, fOpData->size());
+ writeTagSize(buffer, SK_PICT_READER_TAG, fOpData->size());
buffer.writeByteArray(fOpData->bytes(), fOpData->size());
if (fPictureCount > 0) {
- writeTagSize(buffer, PICT_PICTURE_TAG, fPictureCount);
+ writeTagSize(buffer, SK_PICT_PICTURE_TAG, fPictureCount);
for (int i = 0; i < fPictureCount; i++) {
fPictureRefs[i]->flatten(buffer);
}
@@ -444,7 +429,7 @@ void SkPicturePlayback::flatten(SkWriteBuffer& buffer) const {
// Write this picture playback's data into a writebuffer
this->flattenToBuffer(buffer);
- buffer.write32(PICT_EOF_TAG);
+ buffer.write32(SK_PICT_EOF_TAG);
}
///////////////////////////////////////////////////////////////////////////////
@@ -486,7 +471,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
SkDEBUGCODE(bool haveBuffer = false;)
switch (tag) {
- case PICT_READER_TAG: {
+ case SK_PICT_READER_TAG: {
SkAutoMalloc storage(size);
if (stream->read(storage.get(), size) != size) {
return false;
@@ -494,7 +479,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
SkASSERT(NULL == fOpData);
fOpData = SkData::NewFromMalloc(storage.detach(), size);
} break;
- case PICT_FACTORY_TAG: {
+ case SK_PICT_FACTORY_TAG: {
SkASSERT(!haveBuffer);
fFactoryPlayback = SkNEW_ARGS(SkFactoryPlayback, (size));
for (size_t i = 0; i < size; i++) {
@@ -507,7 +492,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
fFactoryPlayback->base()[i] = SkFlattenable::NameToFactory(str.c_str());
}
} break;
- case PICT_TYPEFACE_TAG: {
+ case SK_PICT_TYPEFACE_TAG: {
SkASSERT(!haveBuffer);
fTFPlayback.setCount(size);
for (size_t i = 0; i < size; i++) {
@@ -520,7 +505,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
fTFPlayback.set(i, tf);
}
} break;
- case PICT_PICTURE_TAG: {
+ case SK_PICT_PICTURE_TAG: {
fPictureCount = size;
fPictureRefs = SkNEW_ARRAY(SkPicture*, fPictureCount);
bool success = true;
@@ -543,7 +528,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
return false;
}
} break;
- case PICT_BUFFER_SIZE_TAG: {
+ case SK_PICT_BUFFER_SIZE_TAG: {
SkAutoMalloc storage(size);
if (stream->read(storage.get(), size) != size) {
return false;
@@ -572,7 +557,7 @@ bool SkPicturePlayback::parseStreamTag(SkStream* stream, const SkPictInfo& info,
bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer,
uint32_t tag, size_t size) {
switch (tag) {
- case PICT_BITMAP_BUFFER_TAG: {
+ case SK_PICT_BITMAP_BUFFER_TAG: {
fBitmaps = SkTRefArray<SkBitmap>::Create(size);
for (size_t i = 0; i < size; ++i) {
SkBitmap* bm = &fBitmaps->writableAt(i);
@@ -580,13 +565,13 @@ bool SkPicturePlayback::parseBufferTag(SkReadBuffer& buffer,
bm->setImmutable();
}
} break;
- case PICT_PAINT_BUFFER_TAG: {
+ case SK_PICT_PAINT_BUFFER_TAG: {
fPaints = SkTRefArray<SkPaint>::Create(size);
for (size_t i = 0; i < size; ++i) {
buffer.readPaint(&fPaints->writableAt(i));
}
} break;
- case PICT_PATH_BUFFER_TAG:
+ case SK_PICT_PATH_BUFFER_TAG:
if (size > 0) {
fPathHeap.reset(SkNEW_ARGS(SkPathHeap, (buffer)));
}
@@ -622,7 +607,7 @@ bool SkPicturePlayback::parseStream(SkStream* stream, const SkPictInfo& info,
SkPicture::InstallPixelRefProc proc) {
for (;;) {
uint32_t tag = stream->readU32();
- if (PICT_EOF_TAG == tag) {
+ if (SK_PICT_EOF_TAG == tag) {
break;
}
@@ -637,7 +622,7 @@ bool SkPicturePlayback::parseStream(SkStream* stream, const SkPictInfo& info,
bool SkPicturePlayback::parseBuffer(SkReadBuffer& buffer) {
for (;;) {
uint32_t tag = buffer.readUInt();
- if (PICT_EOF_TAG == tag) {
+ if (SK_PICT_EOF_TAG == tag) {
break;
}
diff --git a/src/core/SkPicturePlayback.h b/src/core/SkPicturePlayback.h
index 909488b4b7..48d782696d 100644
--- a/src/core/SkPicturePlayback.h
+++ b/src/core/SkPicturePlayback.h
@@ -45,6 +45,21 @@ struct SkPictInfo {
uint32_t fFlags;
};
+#define SK_PICT_READER_TAG SkSetFourByteTag('r', 'e', 'a', 'd')
+#define SK_PICT_FACTORY_TAG SkSetFourByteTag('f', 'a', 'c', 't')
+#define SK_PICT_TYPEFACE_TAG SkSetFourByteTag('t', 'p', 'f', 'c')
+#define SK_PICT_PICTURE_TAG SkSetFourByteTag('p', 'c', 't', 'r')
+
+// This tag specifies the size of the ReadBuffer, needed for the following tags
+#define SK_PICT_BUFFER_SIZE_TAG SkSetFourByteTag('a', 'r', 'a', 'y')
+// these are all inside the ARRAYS tag
+#define SK_PICT_BITMAP_BUFFER_TAG SkSetFourByteTag('b', 't', 'm', 'p')
+#define SK_PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ')
+#define SK_PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ')
+
+// Always write this guy last (with no length field afterwards)
+#define SK_PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ')
+
/**
* Container for data that is needed to deep copy a SkPicture. The container
* enables the data to be generated once and reused for subsequent copies.