From e0d9ce890e67d02727ac2811bb456ddb64f827d4 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Wed, 23 Apr 2014 04:00:17 +0000 Subject: Make drawText calls non-virtual, to ease SkFont and TextBlob (https://codereview.chromium.org/243853006/)" associated chrome change (to be committed with DEPS roll) https://codereview.chromium.org/248693002/ This reverts commit bfaceb53f58c9625b5471fcff35b5ca9ca3ae29c. TBR=bsalomon@google.com Review URL: https://codereview.chromium.org/248083002 git-svn-id: http://skia.googlecode.com/svn/trunk@14321 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/utils/SkDeferredCanvas.cpp | 19 ++++++++----------- src/utils/SkDumpCanvas.cpp | 18 ++++++++---------- src/utils/SkLuaCanvas.cpp | 18 ++++++++---------- src/utils/SkNWayCanvas.cpp | 18 ++++++++---------- src/utils/SkProxyCanvas.cpp | 18 ++++++++---------- src/utils/debugger/SkDebugCanvas.cpp | 16 ++++++++-------- src/utils/debugger/SkDebugCanvas.h | 22 ++++++++-------------- 7 files changed, 56 insertions(+), 73 deletions(-) (limited to 'src/utils') diff --git a/src/utils/SkDeferredCanvas.cpp b/src/utils/SkDeferredCanvas.cpp index 4836cd7be4..9f444e11f3 100644 --- a/src/utils/SkDeferredCanvas.cpp +++ b/src/utils/SkDeferredCanvas.cpp @@ -904,32 +904,29 @@ void SkDeferredCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, this->recordedDrawCommand(); } -void SkDeferredCanvas::drawText(const void* text, size_t byteLength, - SkScalar x, SkScalar y, const SkPaint& paint) { +void SkDeferredCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, + const SkPaint& paint) { AutoImmediateDrawIfNeeded autoDraw(*this, &paint); this->drawingCanvas()->drawText(text, byteLength, x, y, paint); this->recordedDrawCommand(); } -void SkDeferredCanvas::drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint& paint) { +void SkDeferredCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], + const SkPaint& paint) { AutoImmediateDrawIfNeeded autoDraw(*this, &paint); this->drawingCanvas()->drawPosText(text, byteLength, pos, paint); this->recordedDrawCommand(); } -void SkDeferredCanvas::drawPosTextH(const void* text, size_t byteLength, - const SkScalar xpos[], SkScalar constY, - const SkPaint& paint) { +void SkDeferredCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], + SkScalar constY, const SkPaint& paint) { AutoImmediateDrawIfNeeded autoDraw(*this, &paint); this->drawingCanvas()->drawPosTextH(text, byteLength, xpos, constY, paint); this->recordedDrawCommand(); } -void SkDeferredCanvas::drawTextOnPath(const void* text, size_t byteLength, - const SkPath& path, - const SkMatrix* matrix, - const SkPaint& paint) { +void SkDeferredCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, + const SkMatrix* matrix, const SkPaint& paint) { AutoImmediateDrawIfNeeded autoDraw(*this, &paint); this->drawingCanvas()->drawTextOnPath(text, byteLength, path, matrix, paint); this->recordedDrawCommand(); diff --git a/src/utils/SkDumpCanvas.cpp b/src/utils/SkDumpCanvas.cpp index 3bf90da9f5..9814fb5762 100644 --- a/src/utils/SkDumpCanvas.cpp +++ b/src/utils/SkDumpCanvas.cpp @@ -388,16 +388,16 @@ void SkDumpCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, x, y); } -void SkDumpCanvas::drawText(const void* text, size_t byteLength, SkScalar x, - SkScalar y, const SkPaint& paint) { +void SkDumpCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, + const SkPaint& paint) { SkString str; toString(text, byteLength, paint.getTextEncoding(), &str); this->dump(kDrawText_Verb, &paint, "drawText(%s [%d] %g %g)", str.c_str(), byteLength, SkScalarToFloat(x), SkScalarToFloat(y)); } -void SkDumpCanvas::drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint& paint) { +void SkDumpCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], + const SkPaint& paint) { SkString str; toString(text, byteLength, paint.getTextEncoding(), &str); this->dump(kDrawText_Verb, &paint, "drawPosText(%s [%d] %g %g ...)", @@ -405,9 +405,8 @@ void SkDumpCanvas::drawPosText(const void* text, size_t byteLength, SkScalarToFloat(pos[0].fY)); } -void SkDumpCanvas::drawPosTextH(const void* text, size_t byteLength, - const SkScalar xpos[], SkScalar constY, - const SkPaint& paint) { +void SkDumpCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], + SkScalar constY, const SkPaint& paint) { SkString str; toString(text, byteLength, paint.getTextEncoding(), &str); this->dump(kDrawText_Verb, &paint, "drawPosTextH(%s [%d] %g %g ...)", @@ -415,9 +414,8 @@ void SkDumpCanvas::drawPosTextH(const void* text, size_t byteLength, SkScalarToFloat(constY)); } -void SkDumpCanvas::drawTextOnPath(const void* text, size_t byteLength, - const SkPath& path, const SkMatrix* matrix, - const SkPaint& paint) { +void SkDumpCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, + const SkMatrix* matrix, const SkPaint& paint) { SkString str; toString(text, byteLength, paint.getTextEncoding(), &str); this->dump(kDrawText_Verb, &paint, "drawTextOnPath(%s [%d])", diff --git a/src/utils/SkLuaCanvas.cpp b/src/utils/SkLuaCanvas.cpp index 531cbb0064..7e7f1730ba 100644 --- a/src/utils/SkLuaCanvas.cpp +++ b/src/utils/SkLuaCanvas.cpp @@ -237,31 +237,29 @@ void SkLuaCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, } } -void SkLuaCanvas::drawText(const void* text, size_t byteLength, SkScalar x, - SkScalar y, const SkPaint& paint) { +void SkLuaCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, + const SkPaint& paint) { AUTO_LUA("drawText"); lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); lua.pushPaint(paint, "paint"); } -void SkLuaCanvas::drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint& paint) { +void SkLuaCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], + const SkPaint& paint) { AUTO_LUA("drawPosText"); lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); lua.pushPaint(paint, "paint"); } -void SkLuaCanvas::drawPosTextH(const void* text, size_t byteLength, - const SkScalar xpos[], SkScalar constY, - const SkPaint& paint) { +void SkLuaCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], + SkScalar constY, const SkPaint& paint) { AUTO_LUA("drawPosTextH"); lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); lua.pushPaint(paint, "paint"); } -void SkLuaCanvas::drawTextOnPath(const void* text, size_t byteLength, - const SkPath& path, const SkMatrix* matrix, - const SkPaint& paint) { +void SkLuaCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, + const SkMatrix* matrix, const SkPaint& paint) { AUTO_LUA("drawTextOnPath"); lua.pushPath(path, "path"); lua.pushEncodedText(paint.getTextEncoding(), text, byteLength); diff --git a/src/utils/SkNWayCanvas.cpp b/src/utils/SkNWayCanvas.cpp index 4e580c2ea1..f78c65382f 100644 --- a/src/utils/SkNWayCanvas.cpp +++ b/src/utils/SkNWayCanvas.cpp @@ -233,34 +233,32 @@ void SkNWayCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, } } -void SkNWayCanvas::drawText(const void* text, size_t byteLength, SkScalar x, - SkScalar y, const SkPaint& paint) { +void SkNWayCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, + const SkPaint& paint) { Iter iter(fList); while (iter.next()) { iter->drawText(text, byteLength, x, y, paint); } } -void SkNWayCanvas::drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint& paint) { +void SkNWayCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], + const SkPaint& paint) { Iter iter(fList); while (iter.next()) { iter->drawPosText(text, byteLength, pos, paint); } } -void SkNWayCanvas::drawPosTextH(const void* text, size_t byteLength, - const SkScalar xpos[], SkScalar constY, - const SkPaint& paint) { +void SkNWayCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], + SkScalar constY, const SkPaint& paint) { Iter iter(fList); while (iter.next()) { iter->drawPosTextH(text, byteLength, xpos, constY, paint); } } -void SkNWayCanvas::drawTextOnPath(const void* text, size_t byteLength, - const SkPath& path, const SkMatrix* matrix, - const SkPaint& paint) { +void SkNWayCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, + const SkMatrix* matrix, const SkPaint& paint) { Iter iter(fList); while (iter.next()) { iter->drawTextOnPath(text, byteLength, path, matrix, paint); diff --git a/src/utils/SkProxyCanvas.cpp b/src/utils/SkProxyCanvas.cpp index 26f2c73d18..e680caad26 100644 --- a/src/utils/SkProxyCanvas.cpp +++ b/src/utils/SkProxyCanvas.cpp @@ -116,25 +116,23 @@ void SkProxyCanvas::drawSprite(const SkBitmap& bitmap, int x, int y, fProxy->drawSprite(bitmap, x, y, paint); } -void SkProxyCanvas::drawText(const void* text, size_t byteLength, SkScalar x, - SkScalar y, const SkPaint& paint) { +void SkProxyCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, + const SkPaint& paint) { fProxy->drawText(text, byteLength, x, y, paint); } -void SkProxyCanvas::drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint& paint) { +void SkProxyCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], + const SkPaint& paint) { fProxy->drawPosText(text, byteLength, pos, paint); } -void SkProxyCanvas::drawPosTextH(const void* text, size_t byteLength, - const SkScalar xpos[], SkScalar constY, - const SkPaint& paint) { +void SkProxyCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], + SkScalar constY, const SkPaint& paint) { fProxy->drawPosTextH(text, byteLength, xpos, constY, paint); } -void SkProxyCanvas::drawTextOnPath(const void* text, size_t byteLength, - const SkPath& path, const SkMatrix* matrix, - const SkPaint& paint) { +void SkProxyCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, + const SkMatrix* matrix, const SkPaint& paint) { fProxy->drawTextOnPath(text, byteLength, path, matrix, paint); } diff --git a/src/utils/debugger/SkDebugCanvas.cpp b/src/utils/debugger/SkDebugCanvas.cpp index 18affcb418..ec201789fd 100644 --- a/src/utils/debugger/SkDebugCanvas.cpp +++ b/src/utils/debugger/SkDebugCanvas.cpp @@ -506,13 +506,13 @@ void SkDebugCanvas::drawPoints(PointMode mode, size_t count, this->addDrawCommand(new SkDrawPointsCommand(mode, count, pts, paint)); } -void SkDebugCanvas::drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint& paint) { +void SkDebugCanvas::onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], + const SkPaint& paint) { this->addDrawCommand(new SkDrawPosTextCommand(text, byteLength, pos, paint)); } -void SkDebugCanvas::drawPosTextH(const void* text, size_t byteLength, - const SkScalar xpos[], SkScalar constY, const SkPaint& paint) { +void SkDebugCanvas::onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], + SkScalar constY, const SkPaint& paint) { this->addDrawCommand( new SkDrawPosTextHCommand(text, byteLength, xpos, constY, paint)); } @@ -536,13 +536,13 @@ void SkDebugCanvas::drawSprite(const SkBitmap& bitmap, int left, int top, this->addDrawCommand(new SkDrawSpriteCommand(bitmap, left, top, paint)); } -void SkDebugCanvas::drawText(const void* text, size_t byteLength, SkScalar x, - SkScalar y, const SkPaint& paint) { +void SkDebugCanvas::onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, + const SkPaint& paint) { this->addDrawCommand(new SkDrawTextCommand(text, byteLength, x, y, paint)); } -void SkDebugCanvas::drawTextOnPath(const void* text, size_t byteLength, - const SkPath& path, const SkMatrix* matrix, const SkPaint& paint) { +void SkDebugCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, + const SkMatrix* matrix, const SkPaint& paint) { this->addDrawCommand( new SkDrawTextOnPathCommand(text, byteLength, path, matrix, paint)); } diff --git a/src/utils/debugger/SkDebugCanvas.h b/src/utils/debugger/SkDebugCanvas.h index d89cf9491f..d4fded7c1a 100644 --- a/src/utils/debugger/SkDebugCanvas.h +++ b/src/utils/debugger/SkDebugCanvas.h @@ -189,13 +189,6 @@ public: virtual void drawPoints(PointMode, size_t count, const SkPoint pts[], const SkPaint&) SK_OVERRIDE; - virtual void drawPosText(const void* text, size_t byteLength, - const SkPoint pos[], const SkPaint&) SK_OVERRIDE; - - virtual void drawPosTextH(const void* text, size_t byteLength, - const SkScalar xpos[], SkScalar constY, - const SkPaint&) SK_OVERRIDE; - virtual void drawRect(const SkRect& rect, const SkPaint&) SK_OVERRIDE; virtual void drawRRect(const SkRRect& rrect, const SkPaint& paint) SK_OVERRIDE; @@ -203,13 +196,6 @@ public: virtual void drawSprite(const SkBitmap&, int left, int top, const SkPaint*) SK_OVERRIDE; - virtual void drawText(const void* text, size_t byteLength, SkScalar x, - SkScalar y, const SkPaint&) SK_OVERRIDE; - - virtual void drawTextOnPath(const void* text, size_t byteLength, - const SkPath& path, const SkMatrix* matrix, - const SkPaint&) SK_OVERRIDE; - virtual void drawVertices(VertexMode, int vertexCount, const SkPoint vertices[], const SkPoint texs[], const SkColor colors[], SkXfermode*, @@ -250,6 +236,14 @@ protected: virtual void didSetMatrix(const SkMatrix&) SK_OVERRIDE; virtual void onDrawDRRect(const SkRRect&, const SkRRect&, const SkPaint&) SK_OVERRIDE; + virtual void onDrawText(const void* text, size_t byteLength, SkScalar x, SkScalar y, + const SkPaint&) SK_OVERRIDE; + virtual void onDrawPosText(const void* text, size_t byteLength, const SkPoint pos[], + const SkPaint&) SK_OVERRIDE; + virtual void onDrawPosTextH(const void* text, size_t byteLength, const SkScalar xpos[], + SkScalar constY, const SkPaint&) SK_OVERRIDE; + virtual void onDrawTextOnPath(const void* text, size_t byteLength, const SkPath& path, + const SkMatrix* matrix, const SkPaint&) SK_OVERRIDE; virtual void onPushCull(const SkRect& cullRect) SK_OVERRIDE; virtual void onPopCull() SK_OVERRIDE; -- cgit v1.2.3