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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 143883006: No deduping dictionaries for matrices and regions. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bump picture version Created 6 years, 11 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 | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 27f0c58c6de9cf4d5ec6edc0c53bbb1b39769e79..38f7deb111ba296f5a560810d1381b0c498329da 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -96,9 +96,7 @@ SkPicturePlayback::SkPicturePlayback(const SkPictureRecord& record, bool deepCop
record.fFlattenableHeap.setupPlaybacks();
fBitmaps = record.fBitmapHeap->extractBitmaps();
- fMatrices = record.fMatrices.unflattenToArray();
fPaints = record.fPaints.unflattenToArray();
- fRegions = record.fRegions.unflattenToArray();
fBitmapHeap.reset(SkSafeRef(record.fBitmapHeap));
fPathHeap.reset(SkSafeRef(record.fPathHeap));
@@ -170,8 +168,6 @@ SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInf
fBitmapHeap.reset(SkSafeRef(src.fBitmapHeap.get()));
fPathHeap.reset(SkSafeRef(src.fPathHeap.get()));
- fMatrices = SkSafeRef(src.fMatrices);
- fRegions = SkSafeRef(src.fRegions);
fOpData = SkSafeRef(src.fOpData);
fBoundingHierarchy = src.fBoundingHierarchy;
@@ -261,10 +257,8 @@ SkPicturePlayback::SkPicturePlayback(const SkPicturePlayback& src, SkPictCopyInf
void SkPicturePlayback::init() {
fBitmaps = NULL;
- fMatrices = NULL;
fPaints = NULL;
fPictureRefs = NULL;
- fRegions = NULL;
fPictureCount = 0;
fOpData = NULL;
fFactoryPlayback = NULL;
@@ -276,9 +270,7 @@ SkPicturePlayback::~SkPicturePlayback() {
fOpData->unref();
SkSafeUnref(fBitmaps);
- SkSafeUnref(fMatrices);
SkSafeUnref(fPaints);
- SkSafeUnref(fRegions);
SkSafeUnref(fBoundingHierarchy);
SkSafeUnref(fStateTree);
@@ -291,13 +283,11 @@ SkPicturePlayback::~SkPicturePlayback() {
}
void SkPicturePlayback::dumpSize() const {
- SkDebugf("--- picture size: ops=%d bitmaps=%d [%d] matrices=%d [%d] paints=%d [%d] paths=%d regions=%d\n",
+ SkDebugf("--- picture size: ops=%d bitmaps=%d [%d] paints=%d [%d] paths=%d\n",
fOpData->size(),
SafeCount(fBitmaps), SafeCount(fBitmaps) * sizeof(SkBitmap),
- SafeCount(fMatrices), SafeCount(fMatrices) * sizeof(SkMatrix),
SafeCount(fPaints), SafeCount(fPaints) * sizeof(SkPaint),
- SafeCount(fPathHeap.get()),
- SafeCount(fRegions));
+ SafeCount(fPathHeap.get()));
}
bool SkPicturePlayback::containsBitmaps() const {
@@ -324,10 +314,8 @@ bool SkPicturePlayback::containsBitmaps() const {
#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_MATRIX_BUFFER_TAG SkSetFourByteTag('m', 't', 'r', 'x')
#define PICT_PAINT_BUFFER_TAG SkSetFourByteTag('p', 'n', 't', ' ')
#define PICT_PATH_BUFFER_TAG SkSetFourByteTag('p', 't', 'h', ' ')
-#define PICT_REGION_BUFFER_TAG SkSetFourByteTag('r', 'g', 'n', ' ')
// Always write this guy last (with no length field afterwards)
#define PICT_EOF_TAG SkSetFourByteTag('e', 'o', 'f', ' ')
@@ -392,14 +380,6 @@ void SkPicturePlayback::flattenToBuffer(SkOrderedWriteBuffer& buffer) const {
}
}
- if ((n = SafeCount(fMatrices)) > 0) {
- writeTagSize(buffer, PICT_MATRIX_BUFFER_TAG, n);
- for (i = 0; i < n; i++) {
- buffer.writeMatrix((*fMatrices)[i]);
- }
-
- }
-
if ((n = SafeCount(fPaints)) > 0) {
writeTagSize(buffer, PICT_PAINT_BUFFER_TAG, n);
for (i = 0; i < n; i++) {
@@ -411,13 +391,6 @@ void SkPicturePlayback::flattenToBuffer(SkOrderedWriteBuffer& buffer) const {
writeTagSize(buffer, PICT_PATH_BUFFER_TAG, n);
fPathHeap->flatten(buffer);
}
-
- if ((n = SafeCount(fRegions)) > 0) {
- writeTagSize(buffer, PICT_REGION_BUFFER_TAG, n);
- for (i = 0; i < n; i++) {
- buffer.writeRegion((*fRegions)[i]);
- }
- }
}
void SkPicturePlayback::serialize(SkWStream* stream,
@@ -592,12 +565,6 @@ bool SkPicturePlayback::parseBufferTag(SkOrderedReadBuffer& buffer,
bm->setImmutable();
}
} break;
- case PICT_MATRIX_BUFFER_TAG:
- fMatrices = SkTRefArray<SkMatrix>::Create(size);
- for (size_t i = 0; i < size; ++i) {
- buffer.readMatrix(&fMatrices->writableAt(i));
- }
- break;
case PICT_PAINT_BUFFER_TAG: {
fPaints = SkTRefArray<SkPaint>::Create(size);
for (size_t i = 0; i < size; ++i) {
@@ -609,12 +576,6 @@ bool SkPicturePlayback::parseBufferTag(SkOrderedReadBuffer& buffer,
fPathHeap.reset(SkNEW_ARGS(SkPathHeap, (buffer)));
}
break;
- case PICT_REGION_BUFFER_TAG: {
- fRegions = SkTRefArray<SkRegion>::Create(size);
- for (size_t i = 0; i < size; ++i) {
- buffer.readRegion(&fRegions->writableAt(i));
- }
- } break;
default:
// The tag was invalid.
return false;
@@ -822,7 +783,8 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
}
} break;
case CLIP_REGION: {
- const SkRegion& region = getRegion(reader);
+ SkRegion region;
+ this->getRegion(reader, &region);
uint32_t packed = reader.readInt();
SkRegion::Op regionOp = ClipParams_unpackRegionOp(packed);
size_t offsetToRestore = reader.readInt();
@@ -866,9 +828,12 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
reader.setOffset(offsetToRestore);
}
} break;
- case CONCAT:
- canvas.concat(*getMatrix(reader));
+ case CONCAT: {
+ SkMatrix matrix;
+ this->getMatrix(reader, &matrix);
+ canvas.concat(matrix);
break;
+ }
case DRAW_BITMAP: {
const SkPaint* paint = getPaint(reader);
const SkBitmap& bitmap = getBitmap(reader);
@@ -887,8 +852,9 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
case DRAW_BITMAP_MATRIX: {
const SkPaint* paint = getPaint(reader);
const SkBitmap& bitmap = getBitmap(reader);
- const SkMatrix* matrix = getMatrix(reader);
- canvas.drawBitmapMatrix(bitmap, *matrix, paint);
+ SkMatrix matrix;
+ this->getMatrix(reader, &matrix);
+ canvas.drawBitmapMatrix(bitmap, matrix, paint);
} break;
case DRAW_BITMAP_NINE: {
const SkPaint* paint = getPaint(reader);
@@ -1019,9 +985,9 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
const SkPaint& paint = *getPaint(reader);
getText(reader, &text);
const SkPath& path = getPath(reader);
- const SkMatrix* matrix = getMatrix(reader);
- canvas.drawTextOnPath(text.text(), text.length(), path,
- matrix, paint);
+ SkMatrix matrix;
+ this->getMatrix(reader, &matrix);
+ canvas.drawTextOnPath(text.text(), text.length(), path, &matrix, paint);
} break;
case DRAW_VERTICES: {
SkAutoTUnref<SkXfermode> xfer;
@@ -1079,7 +1045,8 @@ void SkPicturePlayback::draw(SkCanvas& canvas, SkDrawPictureCallback* callback)
} break;
case SET_MATRIX: {
SkMatrix matrix;
- matrix.setConcat(initialMatrix, *getMatrix(reader));
+ this->getMatrix(reader, &matrix);
+ matrix.postConcat(initialMatrix);
canvas.setMatrix(matrix);
} break;
case SKEW: {
@@ -1162,16 +1129,6 @@ int SkPicturePlayback::paths(size_t* size) {
*size = result;
return fPathCount;
}
-
-int SkPicturePlayback::regions(size_t* size) {
- size_t result = 0;
- for (int index = 0; index < fRegionCount; index++) {
- // const SkRegion& region = fRegions[index];
- result += sizeof(SkRegion); // region->size();
- }
- *size = result;
- return fRegionCount;
-}
#endif
#ifdef SK_DEBUG_DUMP
@@ -1471,7 +1428,6 @@ void SkPicturePlayback::dumpStream() {
DUMP_INT(offsetToRestore);
} break;
case CLIP_REGION: {
- DUMP_PTR(SkRegion, &getRegion());
DUMP_INT(SkRegion::Op);
DUMP_INT(offsetToRestore);
} break;
@@ -1481,7 +1437,6 @@ void SkPicturePlayback::dumpStream() {
DUMP_INT(offsetToRestore);
} break;
case CONCAT:
- DUMP_PTR(SkMatrix, getMatrix());
break;
case DRAW_BITMAP: {
DUMP_PTR(SkPaint, getPaint());
@@ -1543,7 +1498,6 @@ void SkPicturePlayback::dumpStream() {
DUMP_PTR(SkPaint, getPaint());
DUMP_TEXT();
DUMP_PTR(SkPath, &getPath());
- DUMP_PTR(SkMatrix, getMatrix());
} break;
case RESTORE:
break;
@@ -1596,21 +1550,6 @@ void SkPicturePlayback::dump() const {
if (fBitmapCount > 0)
SkDebugf("%s0};\n", pBuffer);
- if (fMatrixCount > 0)
- SkDebugf("// matrices (%d)\n", fMatrixCount);
- for (index = 0; index < fMatrixCount; index++) {
- const SkMatrix& matrix = fMatrices[index];
- dumpMatrix(matrix);
- }
- bufferPtr = pBuffer;
- if (fMatrixCount > 0)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
- "Matrices matrices = {");
- for (index = 0; index < fMatrixCount; index++)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
- "matrix%p, ", &fMatrices[index]);
- if (fMatrixCount > 0)
- SkDebugf("%s0};\n", pBuffer);
if (fPaintCount > 0)
SkDebugf("// paints (%d)\n", fPaintCount);
@@ -1655,20 +1594,6 @@ void SkPicturePlayback::dump() const {
if (fPictureCount > 0)
SkDebugf("%s0};\n", pBuffer);
- for (index = 0; index < fRegionCount; index++) {
- const SkRegion& region = fRegions[index];
- dumpRegion(region);
- }
- bufferPtr = pBuffer;
- if (fRegionCount > 0)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
- "Regions regions = {");
- for (index = 0; index < fRegionCount; index++)
- bufferPtr += snprintf(bufferPtr, DUMP_BUFFER_SIZE - (bufferPtr - pBuffer),
- "region%p, ", &fRegions[index]);
- if (fRegionCount > 0)
- SkDebugf("%s0};\n", pBuffer);
-
const_cast<SkPicturePlayback*>(this)->dumpStream();
}
« no previous file with comments | « src/core/SkPicturePlayback.h ('k') | src/core/SkPictureRecord.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698