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

Unified Diff: src/core/SkPicturePlayback.cpp

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: More const API, minimal docs. 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/SkPicturePlayback.cpp
diff --git a/src/core/SkPicturePlayback.cpp b/src/core/SkPicturePlayback.cpp
index 6197d88d6655e3d46ea07aee6a0852f8bda6fd97..3655018cdb5a719d693f5f55d12d3d4cc23e3844 100644
--- a/src/core/SkPicturePlayback.cpp
+++ b/src/core/SkPicturePlayback.cpp
@@ -12,6 +12,7 @@
#include "SkPictureRecord.h"
#include "SkPictureStateTree.h"
#include "SkReader32.h"
+#include "SkTextBlob.h"
#include "SkTDArray.h"
#include "SkTypes.h"
@@ -442,6 +443,41 @@ void SkPicturePlayback::handleOp(SkReader32* reader,
reader->readMatrix(&matrix);
canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, paint);
} break;
+ case DRAW_TEXT_BLOB: {
+ const SkPaint& paint = *fPictureData->getPaint(reader);
+ uint32_t chunkCount = reader->readInt();
+ const SkPoint& offset = reader->skipT<SkPoint>();
+
+ SkTextBlobBuilder blobBuilder;
+ for (unsigned i = 0; i < chunkCount; ++i) {
+ uint32_t glyphCount = reader->readInt();
+ const SkPaint& glyphPaint = *fPictureData->getPaint(reader);
+ unsigned scalarsPerPos = reader->readInt();
+ const SkRect* boundsPtr = get_rect_ptr(reader);
+ const uint16_t* glyphs = (uint16_t*)reader->skip(
+ SkAlign4(glyphCount * sizeof(uint16_t)));
+ const SkTextChunk* chunk;
+ if (scalarsPerPos > 0) {
+ const SkScalar* pos = (const SkScalar*)reader->skip(
+ SkAlign4(glyphCount * sizeof(SkScalar) * scalarsPerPos));
+ if (1 == scalarsPerPos) {
+ chunk = SkTextChunk::Create(glyphs, glyphCount, pos, glyphPaint, boundsPtr);
+ } else {
+ SkASSERT(2 == scalarsPerPos);
+ chunk = SkTextChunk::Create(glyphs, glyphCount, (const SkPoint*)pos,
+ glyphPaint, boundsPtr);
+ }
+
+ } else {
+ chunk = SkTextChunk::Create(glyphs, glyphCount, glyphPaint, boundsPtr);
+ }
+
+ blobBuilder.addChunk(chunk);
+ }
+
+ SkAutoTUnref<const SkTextBlob> blob(blobBuilder.build());
+ canvas->drawTextBlob(blob, offset, paint);
+ } break;
case DRAW_VERTICES: {
SkAutoTUnref<SkXfermode> xfer;
const SkPaint& paint = *fPictureData->getPaint(reader);

Powered by Google App Engine
This is Rietveld 408576698