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

Unified Diff: src/pipe/SkGPipeWrite.cpp

Issue 511783005: SkTextBlob GPipe serialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: review 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
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pipe/SkGPipeWrite.cpp
diff --git a/src/pipe/SkGPipeWrite.cpp b/src/pipe/SkGPipeWrite.cpp
index 32af81d9217a196d19cdfe1de7f8368039296dcc..b5d2522348e0c422123da72af134328876b595b5 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -26,6 +26,7 @@
#include "SkRRect.h"
#include "SkShader.h"
#include "SkStream.h"
+#include "SkTextBlob.h"
#include "SkTSearch.h"
#include "SkTypeface.h"
#include "SkWriter32.h"
@@ -939,9 +940,22 @@ void SkGPipeCanvas::onDrawTextOnPath(const void* text, size_t byteLength, const
void SkGPipeCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y,
const SkPaint& paint) {
- // FIXME: blob serialization only supports SkWriteBuffers
- // -- convert to SkWriter32 to avoid unrolling?
- this->INHERITED::onDrawTextBlob(blob, x, y, paint);
+ NOTIFY_SETUP(this);
+ this->writePaint(paint);
+
+ // FIXME: this is inefficient but avoids duplicating the blob serialization logic.
+ SkWriteBuffer blobBuffer;
+ blob->flatten(blobBuffer);
+
+ size_t size = sizeof(uint32_t) + 2 * sizeof(SkScalar) + blobBuffer.bytesWritten();
+ if (this->needOpBytes(size)) {
+ this->writeOp(kDrawTextBlob_DrawOp);
+ fWriter.writeScalar(x);
+ fWriter.writeScalar(y);
+ fWriter.write32(SkToU32(blobBuffer.bytesWritten()));
+ uint32_t* pad = fWriter.reservePad(blobBuffer.bytesWritten());
+ blobBuffer.writeToMemory(pad);
+ }
}
void SkGPipeCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matrix,
« no previous file with comments | « src/pipe/SkGPipeRead.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698