add drawString helper to canvas
Many tests and examples use drawText with
a guess of how long the text is in bytes,
or a call to strlen(). Add a helper to
SkCanvas to simplify these examples.
Add another helper for SkString.
R=reed@google.com
Change-Id: I0204a31e938f065606f08ee7cd9a6b36db791ee2
Reviewed-on: https://skia-review.googlesource.com/13642
Commit-Queue: Cary Clark <caryclark@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Reviewed-by: Cary Clark <caryclark@skia.org>
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index dc5f68f..f339338 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -35,6 +35,7 @@
#include "SkShadowPaintFilterCanvas.h"
#include "SkShadowShader.h"
#include "SkSpecialImage.h"
+#include "SkString.h"
#include "SkSurface_Base.h"
#include "SkTextBlob.h"
#include "SkTextFormatParams.h"
@@ -2575,6 +2576,10 @@
fMCRec->fFilter = drawFilter;
}
+void SkCanvas::drawString(const SkString& string, SkScalar x, SkScalar y, const SkPaint& paint) {
+ this->drawText(string.c_str(), string.size(), x, y, paint);
+}
+
// These will become non-virtual, so they always call the (virtual) onDraw... method
void SkCanvas::drawText(const void* text, size_t byteLength, SkScalar x, SkScalar y,
const SkPaint& paint) {