SkTextBlob GPipe serialization.
Instead of relying on unrolling blobs in SkCanvas, serialize when
passing through a GPipe.
This is a prerequisite for pushing the blob draw op to the device.
R=mtklein@google.com, reed@google.com, robertphillips@google.com
Author: fmalita@chromium.org
Review URL: https://codereview.chromium.org/511783005
diff --git a/src/pipe/SkGPipeRead.cpp b/src/pipe/SkGPipeRead.cpp
index e48baf3..4bd4fa6 100644
--- a/src/pipe/SkGPipeRead.cpp
+++ b/src/pipe/SkGPipeRead.cpp
@@ -26,6 +26,7 @@
#include "SkRasterizer.h"
#include "SkRRect.h"
#include "SkShader.h"
+#include "SkTextBlob.h"
#include "SkTypeface.h"
#include "SkXfermode.h"
@@ -672,7 +673,19 @@
static void drawTextBlob_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32,
SkGPipeState* state) {
- UNIMPLEMENTED
+ SkScalar x = reader->readScalar();
+ SkScalar y = reader->readScalar();
+
+ size_t blobSize = reader->readU32();
+ const void* data = reader->skip(SkAlign4(blobSize));
+
+ if (state->shouldDraw()) {
+ SkReadBuffer blobBuffer(data, blobSize);
+ SkAutoTUnref<const SkTextBlob> blob(SkTextBlob::CreateFromBuffer(blobBuffer));
+ SkASSERT(blob.get());
+
+ canvas->drawTextBlob(blob, x, y, state->paint());
+ }
}
///////////////////////////////////////////////////////////////////////////////