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); |