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

Unified Diff: src/core/SkCanvas.cpp

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Consolidated blob constructor + comments. 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
Index: src/core/SkCanvas.cpp
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 240dc9ccc52c87e7fbba3e515bc40c369a7c6975..87ecf3b6632784264b9db8e74da53f0cfceecf10 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"
@@ -2221,6 +2222,30 @@ void SkCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const SkPat
LOOPER_END
}
+void SkCanvas::onDrawTextBlob(const SkTextBlob* blob, const SkPoint& offset,
+ const SkPaint& paint) {
+ SkASSERT(blob);
+
+ // FIXME: should we send the offset to the device?
+ if (!offset.isZero()) {
+ translate(offset.x(), offset.y());
+ }
+
+ LOOPER_BEGIN(paint, SkDrawFilter::kText_Type, NULL)
+
+ while (iter.next()) {
+ SkDeviceFilteredPaint dfp(iter.fDevice, looper.paint());
+ iter.fDevice->drawTextBlob(iter, blob, dfp.paint());
+ // DrawTextDecorations?
+ }
+
+ LOOPER_END
+
+ if (!offset.isZero()) {
+ translate(-offset.x(), -offset.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) {
@@ -2239,6 +2264,13 @@ void SkCanvas::drawTextOnPath(const void* text, size_t byteLength, const SkPath&
this->onDrawTextOnPath(text, byteLength, path, matrix, paint);
}
+void SkCanvas::drawTextBlob(const SkTextBlob* blob, const SkPoint& offset,
+ const SkPaint& paint) {
+ if (NULL != blob) {
+ this->onDrawTextBlob(blob, offset, paint);
+ }
+}
+
void SkCanvas::drawVertices(VertexMode vmode, int vertexCount,
const SkPoint verts[], const SkPoint texs[],
const SkColor colors[], SkXfermode* xmode,

Powered by Google App Engine
This is Rietveld 408576698