Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Unified Diff: src/core/SkCanvas.cpp

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Build warnings fix. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkTextBlob.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 104dfc488d81fc099fbca6b10860997bfdf36e6f..5a694db3b8e68067f3a4c888eeedae3ddf845e7a 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -22,6 +22,7 @@
#include "SkSmallAllocator.h"
#include "SkSurface_Base.h"
#include "SkTemplates.h"
+#include "SkTextBlob.h"
#include "SkTextFormatParams.h"
#include "SkTLazy.h"
#include "SkUtils.h"
@@ -2215,6 +2216,43 @@ void SkCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPat
LOOPER_END
}
+void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
+ const SkPaint& paint) {
+ SkASSERT(blob);
+
+ // FIXME: dispatch to the device instead
+
+ if (x || y) {
+ this->translate(x, y);
+ }
+
+ SkTextBlob::RunIterator it(blob);
+ while (!it.done()) {
+ size_t textLen = it.glyphCount() * sizeof(uint16_t);
+ const SkPoint& offset = it.offset();
+
+ switch (it.positioning()) {
+ case SkTextBlob::kDefault_Positioning:
+ this->drawText(it.glyphs(), textLen, offset.x(), offset.y(), paint);
+ break;
+ case SkTextBlob::kHorizontal_Positioning:
+ this->drawPosTextH(it.glyphs(), textLen, it.pos(), offset.y(), paint);
+ break;
+ case SkTextBlob::kFull_Positioning:
+ this->drawPosText(it.glyphs(), textLen, (const SkPoint*)it.pos(), paint);
+ break;
+ default:
+ SkFAIL("unhandled positioning mode");
+ }
+
+ it.next();
+ }
+
+ if (x || y) {
+ this->translate(-x, -y);
+ }
+}
+
// 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) {
@@ -2232,6 +2270,12 @@ void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath&
const SkMatrix* matrix, const SkPaint& paint) {
this->onDrawTextOnPath(text, byteLength, path, matrix, paint);
}
+void SkCanvas::drawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
+ const SkPaint& paint) {
+ if (NULL != blob) {
+ this->onDrawTextBlob(blob, x, y, paint);
+ }
+}
void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
const SkPoint verts[], const SkPoint texs[],
« no previous file with comments | « include/core/SkTextBlob.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698