add drawData() to canvas, to record data blobs
git-svn-id: http://skia.googlecode.com/svn/trunk@452 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 0bf0614..a5529af 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1239,6 +1239,10 @@
ITER_END
}
+void SkCanvas::drawData(const void* data, size_t length) {
+ // do nothing. Subclasses may do something with the data
+}
+
//////////////////////////////////////////////////////////////////////////////
// These methods are NOT virtual, and therefore must call back into virtual
// methods, rather than actually drawing themselves.
diff --git a/src/core/SkPictureFlat.h b/src/core/SkPictureFlat.h
index 86a161d..2c0af5a 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -18,6 +18,7 @@
DRAW_BITMAP,
DRAW_BITMAP_MATRIX,
DRAW_BITMAP_RECT,
+ DRAW_DATA,
DRAW_PAINT,
DRAW_PATH,
DRAW_PICTURE,
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 03cdc16..f488565 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -589,6 +589,11 @@
const SkMatrix* matrix = getMatrix();
canvas.drawBitmapMatrix(bitmap, *matrix, paint);
} break;
+ case DRAW_DATA: {
+ size_t length = getInt();
+ canvas.drawData(fReader.skip(length), length);
+ // skip handles padding the read out to a multiple of 4
+ } break;
case DRAW_PAINT:
canvas.drawPaint(*getPaint());
break;
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index b565fc1..9844a48 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -410,6 +410,12 @@
}
}
+void SkPictureRecord::drawData(const void* data, size_t length) {
+ addDraw(DRAW_DATA);
+ addInt(length);
+ fWriter.writePad(data, length);
+}
+
///////////////////////////////////////////////////////////////////////////////
void SkPictureRecord::reset() {
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index 05761af..f9c967d 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -56,6 +56,7 @@
const SkColor colors[], SkXfermode*,
const uint16_t indices[], int indexCount,
const SkPaint&);
+ virtual void drawData(const void*, size_t);
void addFontMetricsTopBottom(const SkPaint& paint, SkScalar baselineY);
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index 2151133..4ff7a50 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -379,6 +379,12 @@
SkScalarToFloat(vertices[0].fY));
}
+void SkDumpCanvas::drawData(const void* data, size_t length) {
+// this->dump(kDrawData_Verb, NULL, "drawData(%d)", length);
+ this->dump(kDrawData_Verb, NULL, "drawData(%d) %.*s", length,
+ SkMin32(length, 64), data);
+}
+
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp
index cb0d44a..c643c82 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -151,6 +151,10 @@
xmode, indices, indexCount, paint);
}
+void SkProxyCanvas::drawData(const void* data, size_t length) {
+ fProxy->drawData(data, length);
+}
+
SkBounder* SkProxyCanvas::setBounder(SkBounder* bounder) {
return fProxy->setBounder(bounder);
}