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

Unified Diff: src/pipe/SkGPipeWrite.cpp

Issue 563783003: Ensure blob typeface information survives SkGPipe serialization. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Read/write the typeface array in one swoop (when !cross-process) Created 6 years, 3 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 f361e5ed67ecf092b4fd3a10f41f793e4f5cac69..cee106ea5ab1741b2bf506b6e5c645968f693287 100644
--- a/src/pipe/SkGPipeWrite.cpp
+++ b/src/pipe/SkGPipeWrite.cpp
@@ -22,6 +22,7 @@
#include "SkPatchUtils.h"
#include "SkPathEffect.h"
#include "SkPictureFlat.h"
+#include "SkPtrRecorder.h"
#include "SkRasterizer.h"
#include "SkRRect.h"
#include "SkShader.h"
@@ -944,14 +945,33 @@ void SkGPipeCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar
this->writePaint(paint);
// FIXME: this is inefficient but avoids duplicating the blob serialization logic.
+ SkRefCntSet typefaceSet;
SkWriteBuffer blobBuffer;
+ blobBuffer.setTypefaceRecorder(&typefaceSet);
blob->flatten(blobBuffer);
- size_t size = sizeof(uint32_t) + 2 * sizeof(SkScalar) + blobBuffer.bytesWritten();
+ int typefaceCount = typefaceSet.count();
+ SkAutoSTMalloc<16, SkTypeface*> storage(typefaceCount);
+ SkTypeface** array = (SkTypeface**)storage.get();
mtklein 2014/09/12 16:07:17 Out of curiosity, why this cast? Doesn't storage.
f(malita) 2014/09/12 22:20:49 Indeed it does. Removed.
+ typefaceSet.copyToArray((SkRefCnt**)array);
+
+ size_t size = 2 * sizeof(uint32_t) + 2 * sizeof(SkScalar) + blobBuffer.bytesWritten();
mtklein 2014/09/12 16:07:17 Can you add some comments explaining what the diff
f(malita) 2014/09/12 22:20:49 Done.
+ size += typefaceCount * (isCrossProcess(fFlags) ? sizeof(uint32_t) : sizeof(void*));
+
if (this->needOpBytes(size)) {
this->writeOp(kDrawTextBlob_DrawOp);
fWriter.writeScalar(x);
fWriter.writeScalar(y);
+
+ fWriter.write32(typefaceCount);
+ if (isCrossProcess(fFlags)) {
+ for (int i = 0; i < typefaceCount; ++i) {
+ fWriter.write32(this->getTypefaceID(array[i]));
+ }
+ } else {
+ fWriter.write(array, typefaceCount * sizeof(SkTypeface*));
+ }
+
fWriter.write32(SkToU32(blobBuffer.bytesWritten()));
uint32_t* pad = fWriter.reservePad(blobBuffer.bytesWritten());
blobBuffer.writeToMemory(pad);
« 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