remove unused drawData

BUG=skia:

Review URL: https://codereview.chromium.org/830083002
This commit is contained in:
reed 2015-01-02 06:39:51 -08:00 committed by Commit bot
parent 7c339ae1e3
commit c4fda92f45
30 changed files with 8 additions and 146 deletions

View File

@ -48,7 +48,6 @@ public:
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 {}

View File

@ -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',
],
},
}

View File

@ -13,6 +13,7 @@
# If these become 'permanent', they should be moved into skia_common.gypi
#
'skia_for_chromium_defines': [
'SK_SUPPORT_LEGACY_DRAWDATA',
],
},
}

View File

@ -1017,15 +1017,15 @@ public:
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

View File

@ -47,7 +47,7 @@ public:
kDrawPicture_Verb,
kDrawVertices_Verb,
kDrawPatch_Verb,
kDrawData_Verb,
kDrawData_Verb, // obsolete
kBeginCommentGroup_Verb,
kAddComment_Verb,
@ -94,7 +94,6 @@ public:
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;

View File

@ -39,7 +39,6 @@ public:
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;

View File

@ -50,7 +50,6 @@ public:
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;

View File

@ -50,7 +50,6 @@ public:
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;

View File

@ -248,15 +248,10 @@ static void drawSomething(SkCanvas* canvas) {
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);

View File

@ -112,16 +112,11 @@ protected:
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),

View File

@ -192,8 +192,9 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
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: {

View File

@ -799,15 +799,6 @@ void SkPictureRecord::onDrawPatch(const SkPoint cubics[12], const SkColor colors
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);

View File

@ -50,7 +50,6 @@ public:
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;

View File

@ -120,7 +120,6 @@ DRAW(DrawTextBlob, drawTextBlob(r.blob, r.x, r.y, r.paint));
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 @@ private:
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) {

View File

@ -333,6 +333,3 @@ void SkRecorder::endCommentGroup() {
APPEND(EndCommentGroup);
}
void SkRecorder::drawData(const void* data, size_t length) {
APPEND(DrawData, copy((const char*)data), length);
}

View File

@ -133,7 +133,6 @@ public:
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; }

View File

@ -61,7 +61,6 @@ namespace SkRecords {
M(DrawRect) \
M(DrawSprite) \
M(DrawTextBlob) \
M(DrawData) \
M(DrawVertices)
// Defines SkRecords::Type, an enum of all record types.
@ -305,8 +304,6 @@ RECORD5(DrawTextOnPath, SkPaint, paint,
BoundedPath, path,
TypedMatrix, matrix);
RECORD2(DrawData, PODArray<char>, data, size_t, length);
RECORD5(DrawPatch, SkPaint, paint,
PODArray<SkPoint>, cubics,
PODArray<SkColor>, colors,

View File

@ -43,7 +43,6 @@ enum DrawOps {
kDrawBitmapNine_DrawOp,
kDrawBitmapRectToRect_DrawOp,
kDrawClear_DrawOp,
kDrawData_DrawOp,
kDrawDRRect_DrawOp,
kDrawOval_DrawOp,
kDrawPaint_DrawOp,

View File

@ -640,19 +640,6 @@ static void drawSprite_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
///////////////////////////////////////////////////////////////////////////////
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 @@ static const ReadProc gReadTable[] = {
drawBitmapNine_rp,
drawBitmapRect_rp,
drawClear_rp,
drawData_rp,
drawDRRect_rp,
drawOval_rp,
drawPaint_rp,

View File

@ -253,7 +253,6 @@ public:
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::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4
}
}
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
}

View File

@ -457,12 +457,6 @@ void SkDumpCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4]
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);
}

View File

@ -284,7 +284,3 @@ void SkLuaCanvas::drawVertices(VertexMode vmode, int vertexCount,
AUTO_LUA("drawVertices");
lua.pushPaint(paint, "paint");
}
void SkLuaCanvas::drawData(const void* data, size_t length) {
AUTO_LUA("drawData");
}

View File

@ -304,13 +304,6 @@ void SkNWayCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4]
}
}
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()) {

View File

@ -167,10 +167,6 @@ void SkProxyCanvas::onDrawPatch(const SkPoint cubics[12], const SkColor colors[4
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);
}

View File

@ -448,10 +448,6 @@ void SkDebugCanvas::drawBitmapNine(const SkBitmap& bitmap,
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));
}

View File

@ -158,8 +158,6 @@ public:
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;

View File

@ -368,22 +368,6 @@ bool SkDrawBitmapRectCommand::render(SkCanvas* canvas) const {
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) {

View File

@ -237,18 +237,6 @@ private:
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);

View File

@ -69,20 +69,6 @@ DEF_TEST(Recorder_CommentGroups, r) {
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:

View File

@ -397,15 +397,10 @@ static void draw_something(SkCanvas* canvas) {
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);