remove unused drawData
BUG=skia:
Review URL: https://codereview.chromium.org/830083002
diff --git a/experimental/PdfViewer/SkNulCanvas.h b/experimental/PdfViewer/SkNulCanvas.h
index 20ac79c..16337ca 100644
--- a/experimental/PdfViewer/SkNulCanvas.h
+++ b/experimental/PdfViewer/SkNulCanvas.h
@@ -48,7 +48,6 @@
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) SK_OVERRIDE {}
- virtual void drawData(const void* data, size_t length) SK_OVERRIDE {}
virtual void beginCommentGroup(const char* description) SK_OVERRIDE {}
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE {}
virtual void endCommentGroup() SK_OVERRIDE {}
diff --git a/gyp/skia_for_android_framework_defines.gypi b/gyp/skia_for_android_framework_defines.gypi
index bde7f50..50f7e0e 100644
--- a/gyp/skia_for_android_framework_defines.gypi
+++ b/gyp/skia_for_android_framework_defines.gypi
@@ -20,6 +20,7 @@
'SK_SUPPORT_LEGACY_CLIPTOLAYERFLAG',
# TODO(tfarina): Remove this when Android is fixed. skbug.com/3178
'SK_SUPPORT_LEGACY_PORTER_DUFF',
+ 'SK_SUPPORT_LEGACY_DRAWDATA',
],
},
}
diff --git a/gyp/skia_for_chromium_defines.gypi b/gyp/skia_for_chromium_defines.gypi
index 6a9adf5..7752127 100644
--- a/gyp/skia_for_chromium_defines.gypi
+++ b/gyp/skia_for_chromium_defines.gypi
@@ -13,6 +13,7 @@
# If these become 'permanent', they should be moved into skia_common.gypi
#
'skia_for_chromium_defines': [
+ 'SK_SUPPORT_LEGACY_DRAWDATA',
],
},
}
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 121239d..cb4fede 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -1017,15 +1017,15 @@
void EXPERIMENTAL_drawDrawable(SkCanvasDrawable*);
+#ifdef SK_SUPPORT_LEGACY_DRAWDATA
/** Send a blob of data to the canvas.
For canvases that draw, this call is effectively a no-op, as the data
is not parsed, but just ignored. However, this call exists for
subclasses like SkPicture's recording canvas, that can store the data
and then play it back later (via another call to drawData).
*/
- virtual void drawData(const void* /*data*/, size_t /*length*/) {
- // do nothing. Subclasses may do something with the data
- }
+ virtual void drawData(const void* /*data*/, size_t /*length*/) {}
+#endif
/** Add comments. beginCommentGroup/endCommentGroup open/close a new group.
Each comment added via addComment is notionally attached to its
diff --git a/include/utils/SkDumpCanvas.h b/include/utils/SkDumpCanvas.h
index 63c0a39..0c66506 100644
--- a/include/utils/SkDumpCanvas.h
+++ b/include/utils/SkDumpCanvas.h
@@ -47,7 +47,7 @@
kDrawPicture_Verb,
kDrawVertices_Verb,
kDrawPatch_Verb,
- kDrawData_Verb,
+ kDrawData_Verb, // obsolete
kBeginCommentGroup_Verb,
kAddComment_Verb,
@@ -94,7 +94,6 @@
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) SK_OVERRIDE;
- virtual void drawData(const void*, size_t) SK_OVERRIDE;
virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
virtual void endCommentGroup() SK_OVERRIDE;
diff --git a/include/utils/SkLuaCanvas.h b/include/utils/SkLuaCanvas.h
index 7eede85..d2019d4 100644
--- a/include/utils/SkLuaCanvas.h
+++ b/include/utils/SkLuaCanvas.h
@@ -39,7 +39,6 @@
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) SK_OVERRIDE;
- virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
protected:
virtual void willSave() SK_OVERRIDE;
diff --git a/include/utils/SkNWayCanvas.h b/include/utils/SkNWayCanvas.h
index ee78010..5e8c52d 100644
--- a/include/utils/SkNWayCanvas.h
+++ b/include/utils/SkNWayCanvas.h
@@ -50,7 +50,6 @@
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint&) SK_OVERRIDE;
- virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
virtual SkDrawFilter* setDrawFilter(SkDrawFilter*) SK_OVERRIDE;
diff --git a/include/utils/SkProxyCanvas.h b/include/utils/SkProxyCanvas.h
index 49fcf5f..c8a830f 100644
--- a/include/utils/SkProxyCanvas.h
+++ b/include/utils/SkProxyCanvas.h
@@ -50,7 +50,6 @@
const SkColor colors[], SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) SK_OVERRIDE;
- virtual void drawData(const void* data, size_t length) SK_OVERRIDE;
virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
diff --git a/samplecode/SampleFilterFuzz.cpp b/samplecode/SampleFilterFuzz.cpp
index 6ddc87c..894e4fa 100644
--- a/samplecode/SampleFilterFuzz.cpp
+++ b/samplecode/SampleFilterFuzz.cpp
@@ -248,15 +248,10 @@
canvas->drawBitmap(make_bitmap(), 0, 0, NULL);
canvas->restore();
- const char beforeStr[] = "before circle";
- const char afterStr[] = "after circle";
-
paint.setAntiAlias(true);
paint.setColor(SK_ColorRED);
- canvas->drawData(beforeStr, sizeof(beforeStr));
canvas->drawCircle(SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/3), paint);
- canvas->drawData(afterStr, sizeof(afterStr));
paint.setColor(SK_ColorBLACK);
paint.setTextSize(SkIntToScalar(kBitmapSize/3));
canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint);
diff --git a/samplecode/SamplePicture.cpp b/samplecode/SamplePicture.cpp
index 28256e5..46c57d7 100644
--- a/samplecode/SamplePicture.cpp
+++ b/samplecode/SamplePicture.cpp
@@ -112,16 +112,11 @@
canvas->drawBitmap(fBitmap, 0, 0, NULL);
canvas->restore();
- const char beforeStr[] = "before circle";
- const char afterStr[] = "after circle";
-
paint.setAntiAlias(true);
paint.setColor(SK_ColorRED);
- canvas->drawData(beforeStr, sizeof(beforeStr));
canvas->drawCircle(SkIntToScalar(50), SkIntToScalar(50),
SkIntToScalar(40), paint);
- canvas->drawData(afterStr, sizeof(afterStr));
paint.setColor(SK_ColorBLACK);
paint.setTextSize(SkIntToScalar(40));
canvas->drawText("Picture", 7, SkIntToScalar(50), SkIntToScalar(62),
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 1c9b13e..94d5190 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -192,8 +192,9 @@
canvas->clear(reader->readInt());
break;
case DRAW_DATA: {
+ // This opcode is now dead, just need to skip it for backwards compatibility
size_t length = reader->readInt();
- canvas->drawData(reader->skip(length), length);
+ (void)reader->skip(length);
// skip handles padding the read out to a multiple of 4
} break;
case DRAW_DRRECT: {
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index 6448d1e..fcae49a 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -799,15 +799,6 @@
this->validate(initialOffset, size);
}
-void SkPictureRecord::drawData(const void* data, size_t length) {
- // op + length + 'length' worth of data
- size_t size = 2 * kUInt32Size + SkAlign4(length);
- size_t initialOffset = this->addDraw(DRAW_DATA, &size);
- this->addInt(SkToInt(length));
- fWriter.writePad(data, length);
- this->validate(initialOffset, size);
-}
-
void SkPictureRecord::beginCommentGroup(const char* description) {
// op/size + length of string + \0 terminated chars
size_t length = strlen(description);
diff --git a/src/core/SkPictureRecord.h b/src/core/SkPictureRecord.h
index d1a9e92..0095063 100644
--- a/src/core/SkPictureRecord.h
+++ b/src/core/SkPictureRecord.h
@@ -50,7 +50,6 @@
const SkColor colors[], SkXfermode*,
const uint16_t indices[], int indexCount,
const SkPaint&) SK_OVERRIDE;
- virtual void drawData(const void*, size_t) SK_OVERRIDE;
virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
virtual void endCommentGroup() SK_OVERRIDE;
diff --git a/src/core/SkRecordDraw.cpp b/src/core/SkRecordDraw.cpp
index 3d6f3a0..08c9154 100644
--- a/src/core/SkRecordDraw.cpp
+++ b/src/core/SkRecordDraw.cpp
@@ -120,7 +120,6 @@
DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, &r.matrix, r.paint));
DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,
r.xmode.get(), r.indices, r.indexCount, r.paint));
-DRAW(DrawData, drawData(r.data, r.length));
#undef DRAW
template <> void Draw::draw(const DrawDrawable& r) {
@@ -290,7 +289,6 @@
void trackBounds(const BeginCommentGroup&) { this->pushControl(); }
void trackBounds(const AddComment&) { this->pushControl(); }
void trackBounds(const EndCommentGroup&) { this->pushControl(); }
- void trackBounds(const DrawData&) { this->pushControl(); }
// For all other ops, we can calculate and store the bounds directly now.
template <typename T> void trackBounds(const T& op) {
diff --git a/src/core/SkRecorder.cpp b/src/core/SkRecorder.cpp
index 7d5d252..55b8a00 100644
--- a/src/core/SkRecorder.cpp
+++ b/src/core/SkRecorder.cpp
@@ -333,6 +333,3 @@
APPEND(EndCommentGroup);
}
-void SkRecorder::drawData(const void* data, size_t length) {
- APPEND(DrawData, copy((const char*)data), length);
-}
diff --git a/src/core/SkRecorder.h b/src/core/SkRecorder.h
index 6f37ff3..0e4252b 100644
--- a/src/core/SkRecorder.h
+++ b/src/core/SkRecorder.h
@@ -133,7 +133,6 @@
void beginCommentGroup(const char*) SK_OVERRIDE;
void addComment(const char*, const char*) SK_OVERRIDE;
void endCommentGroup() SK_OVERRIDE;
- void drawData(const void*, size_t) SK_OVERRIDE;
SkSurface* onNewSurface(const SkImageInfo&, const SkSurfaceProps&) SK_OVERRIDE { return NULL; }
diff --git a/src/core/SkRecords.h b/src/core/SkRecords.h
index ed5eaf3..1cf29f2 100644
--- a/src/core/SkRecords.h
+++ b/src/core/SkRecords.h
@@ -61,7 +61,6 @@
M(DrawRect) \
M(DrawSprite) \
M(DrawTextBlob) \
- M(DrawData) \
M(DrawVertices)
// Defines SkRecords::Type, an enum of all record types.
@@ -305,8 +304,6 @@
BoundedPath, path,
TypedMatrix, matrix);
-RECORD2(DrawData, PODArray<char>, data, size_t, length);
-
RECORD5(DrawPatch, SkPaint, paint,
PODArray<SkPoint>, cubics,
PODArray<SkColor>, colors,
diff --git a/src/pipe/SkGPipePriv.h b/src/pipe/SkGPipePriv.h
index 2ea6ba5..447e768 100644
--- a/src/pipe/SkGPipePriv.h
+++ b/src/pipe/SkGPipePriv.h
@@ -43,7 +43,6 @@
kDrawBitmapNine_DrawOp,
kDrawBitmapRectToRect_DrawOp,
kDrawClear_DrawOp,
- kDrawData_DrawOp,
kDrawDRRect_DrawOp,
kDrawOval_DrawOp,
kDrawPaint_DrawOp,
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index bdd925e..dab6178 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -640,19 +640,6 @@
///////////////////////////////////////////////////////////////////////////////
-static void drawData_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
- SkGPipeState* state) {
- // since we don't have a paint, we can use data for our (small) sizes
- size_t size = DrawOp_unpackData(op32);
- if (0 == size) {
- size = reader->readU32();
- }
- const void* data = reader->skip(SkAlign4(size));
- if (state->shouldDraw()) {
- canvas->drawData(data, size);
- }
-}
-
static void drawPicture_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
SkGPipeState* state) {
UNIMPLEMENTED
@@ -815,7 +802,6 @@
drawBitmapNine_rp,
drawBitmapRect_rp,
drawClear_rp,
- drawData_rp,
drawDRRect_rp,
drawOval_rp,
drawPaint_rp,
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 9f56f6f..45b26db 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -253,7 +253,6 @@
const SkColor colors[], SkXfermode*,
const uint16_t indices[], int indexCount,
const SkPaint&) SK_OVERRIDE;
- virtual void drawData(const void*, size_t) SK_OVERRIDE;
virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
virtual void endCommentGroup() SK_OVERRIDE;
@@ -1086,23 +1085,6 @@
}
}
-void SkGPipeCanvas::drawData(const void* ptr, size_t size) {
- if (size && ptr) {
- NOTIFY_SETUP(this);
- unsigned data = 0;
- if (size < (1 << DRAWOPS_DATA_BITS)) {
- data = (unsigned)size;
- }
- if (this->needOpBytes(4 + SkAlign4(size))) {
- this->writeOp(kDrawData_DrawOp, 0, data);
- if (0 == data) {
- fWriter.write32(SkToU32(size));
- }
- fWriter.writePad(ptr, size);
- }
- }
-}
-
void SkGPipeCanvas::beginCommentGroup(const char* description) {
// ignore for now
}
diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp
index d619248..1bfb1ba 100644
--- a/src/utils/SkDumpCanvas.cpp
+++ b/src/utils/SkDumpCanvas.cpp
@@ -457,12 +457,6 @@
texCoords[2].x(), texCoords[2].y(), texCoords[3].x(), texCoords[3].y());
}
-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,
- SkTMin<size_t>(length, 64), data);
-}
-
void SkDumpCanvas::beginCommentGroup(const char* description) {
this->dump(kBeginCommentGroup_Verb, NULL, "beginCommentGroup(%s)", description);
}
diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp
index baa9a90..ca04ba9 100644
--- a/src/utils/SkLuaCanvas.cpp
+++ b/src/utils/SkLuaCanvas.cpp
@@ -284,7 +284,3 @@
AUTO_LUA("drawVertices");
lua.pushPaint(paint, "paint");
}
-
-void SkLuaCanvas::drawData(const void* data, size_t length) {
- AUTO_LUA("drawData");
-}
diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp
index c2a90a6..f696de8 100644
--- a/src/utils/SkNWayCanvas.cpp
+++ b/src/utils/SkNWayCanvas.cpp
@@ -304,13 +304,6 @@
}
}
-void SkNWayCanvas::drawData(const void* data, size_t length) {
- Iter iter(fList);
- while (iter.next()) {
- iter->drawData(data, length);
- }
-}
-
SkDrawFilter* SkNWayCanvas::setDrawFilter(SkDrawFilter* filter) {
Iter iter(fList);
while (iter.next()) {
diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp
index 9adc81c..161f3c0 100644
--- a/src/utils/SkProxyCanvas.cpp
+++ b/src/utils/SkProxyCanvas.cpp
@@ -167,10 +167,6 @@
fProxy->drawPatch(cubics, colors, texCoords, xmode, paint);
}
-void SkProxyCanvas::drawData(const void* data, size_t length) {
- fProxy->drawData(data, length);
-}
-
void SkProxyCanvas::beginCommentGroup(const char* description) {
fProxy->beginCommentGroup(description);
}
diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp
index 46c0b8b..238d468 100644
--- a/src/utils/debugger/SkDebugCanvas.cpp
+++ b/src/utils/debugger/SkDebugCanvas.cpp
@@ -448,10 +448,6 @@
this->addDrawCommand(new SkDrawBitmapNineCommand(bitmap, center, dst, paint));
}
-void SkDebugCanvas::drawData(const void* data, size_t length) {
- this->addDrawCommand(new SkDrawDataCommand(data, length));
-}
-
void SkDebugCanvas::beginCommentGroup(const char* description) {
this->addDrawCommand(new SkBeginCommentGroupCommand(description));
}
diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h
index a526525..a74c413 100644
--- a/src/utils/debugger/SkDebugCanvas.h
+++ b/src/utils/debugger/SkDebugCanvas.h
@@ -158,8 +158,6 @@
virtual void drawBitmapNine(const SkBitmap& bitmap, const SkIRect& center,
const SkRect& dst, const SkPaint*) SK_OVERRIDE;
- virtual void drawData(const void*, size_t) SK_OVERRIDE;
-
virtual void beginCommentGroup(const char* description) SK_OVERRIDE;
virtual void addComment(const char* kywd, const char* value) SK_OVERRIDE;
diff --git a/src/utils/debugger/SkDrawCommand.cpp b/src/utils/debugger/SkDrawCommand.cpp
index e7989cc..be7fdfc 100644
--- a/src/utils/debugger/SkDrawCommand.cpp
+++ b/src/utils/debugger/SkDrawCommand.cpp
@@ -368,22 +368,6 @@
return true;
}
-SkDrawDataCommand::SkDrawDataCommand(const void* data, size_t length)
- : INHERITED(DRAW_DATA) {
- fData = new char[length];
- memcpy(fData, data, length);
- fLength = length;
-
- // TODO: add display of actual data?
- SkString* str = new SkString;
- str->appendf("length: %d", (int) length);
- fInfo.push(str);
-}
-
-void SkDrawDataCommand::execute(SkCanvas* canvas) const {
- canvas->drawData(fData, fLength);
-}
-
SkBeginCommentGroupCommand::SkBeginCommentGroupCommand(const char* description)
: INHERITED(BEGIN_COMMENT_GROUP)
, fDescription(description) {
diff --git a/src/utils/debugger/SkDrawCommand.h b/src/utils/debugger/SkDrawCommand.h
index 951d15e..831dffc 100644
--- a/src/utils/debugger/SkDrawCommand.h
+++ b/src/utils/debugger/SkDrawCommand.h
@@ -237,18 +237,6 @@
typedef SkDrawCommand INHERITED;
};
-class SkDrawDataCommand : public SkDrawCommand {
-public:
- SkDrawDataCommand(const void* data, size_t length);
- virtual ~SkDrawDataCommand() { delete [] fData; }
- virtual void execute(SkCanvas* canvas) const SK_OVERRIDE;
-private:
- char* fData;
- size_t fLength;
-
- typedef SkDrawCommand INHERITED;
-};
-
class SkBeginCommentGroupCommand : public SkDrawCommand {
public:
SkBeginCommentGroupCommand(const char* description);
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index e0abace..4fac1af 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -69,20 +69,6 @@
REPORTER_ASSERT(r, 1 == tally.count<SkRecords::EndCommentGroup>());
}
-// DrawData is similar to comment groups. It doesn't affect drawing, but
-// it's a pass-through we provide to the client. Again, a simple reg. test.
-DEF_TEST(Recorder_DrawData, r) {
- SkRecord record;
- SkRecorder recorder(&record, 100, 100);
-
- const char* data = "This sure is some data, eh?";
- recorder.drawData(data, strlen(data));
-
- Tally tally;
- tally.apply(record);
- REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawData>());
-}
-
// Regression test for leaking refs held by optional arguments.
DEF_TEST(Recorder_RefLeaking, r) {
// We use SaveLayer to test:
diff --git a/tests/SerializationTest.cpp b/tests/SerializationTest.cpp
index dd9b938..cd5bc60 100644
--- a/tests/SerializationTest.cpp
+++ b/tests/SerializationTest.cpp
@@ -397,15 +397,10 @@
canvas->drawBitmap(bitmap, 0, 0, NULL);
canvas->restore();
- const char beforeStr[] = "before circle";
- const char afterStr[] = "after circle";
-
paint.setAntiAlias(true);
paint.setColor(SK_ColorRED);
- canvas->drawData(beforeStr, sizeof(beforeStr));
canvas->drawCircle(SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/3), paint);
- canvas->drawData(afterStr, sizeof(afterStr));
paint.setColor(SK_ColorBLACK);
paint.setTextSize(SkIntToScalar(kBitmapSize/3));
canvas->drawText("Picture", 7, SkIntToScalar(kBitmapSize/2), SkIntToScalar(kBitmapSize/4), paint);