aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-12-04 21:32:27 +0000
committerGravatar reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2009-12-04 21:32:27 +0000
commitcb60844b34766aad4151df5e87c144d4a57e9abe (patch)
tree293a58c2a6e98685bffaa05ca4f5e8afbc3ecf5a /src
parentb1501a3cde99f68c9c419d9db4ad15b8fed814f3 (diff)
add drawData() to canvas, to record data blobs
git-svn-id: http://skia.googlecode.com/svn/trunk@452 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/core/SkCanvas.cpp4
-rw-r--r--src/core/SkPictureFlat.h1
-rw-r--r--src/core/SkPicturePlayback.cpp5
-rw-r--r--src/core/SkPictureRecord.cpp6
-rw-r--r--src/core/SkPictureRecord.h1
-rw-r--r--src/utils/SkDumpCanvas.cpp6
-rw-r--r--src/utils/SkProxyCanvas.cpp4
7 files changed, 27 insertions, 0 deletions
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 0bf0614264..a5529af633 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -1239,6 +1239,10 @@ void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
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 86a161d144..2c0af5a2ec 100644
--- a/src/core/SkPictureFlat.h
+++ b/src/core/SkPictureFlat.h
@@ -18,6 +18,7 @@ enum DrawType {
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 03cdc1681c..f488565b41 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -589,6 +589,11 @@ void SkPicturePlayback::draw(SkCanvas& canvas) {
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 b565fc11a8..9844a480cd 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -410,6 +410,12 @@ void SkPictureRecord::drawVertices(VertexMode vmode, int vertexCount,
}
}
+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 05761afd0b..f9c967d32f 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -56,6 +56,7 @@ public:
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 215113300c..4ff7a50fc8 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -379,6 +379,12 @@ void SkDumpCanvas::drawVertices(VertexMode vmode, int vertexCount,
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 cb0d44a88a..c643c8277e 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -151,6 +151,10 @@ void SkProxyCanvas::drawVertices(VertexMode vmode, int vertexCount,
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);
}