OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkAnnotation.h" | 9 #include "SkAnnotation.h" |
10 #include "SkBitmapDevice.h" | 10 #include "SkBitmapDevice.h" |
11 #include "SkBitmapHeap.h" | 11 #include "SkBitmapHeap.h" |
12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
13 #include "SkColorFilter.h" | 13 #include "SkColorFilter.h" |
14 #include "SkData.h" | 14 #include "SkData.h" |
15 #include "SkDrawLooper.h" | 15 #include "SkDrawLooper.h" |
16 #include "SkGPipe.h" | 16 #include "SkGPipe.h" |
17 #include "SkGPipePriv.h" | 17 #include "SkGPipePriv.h" |
18 #include "SkImageFilter.h" | 18 #include "SkImageFilter.h" |
19 #include "SkMaskFilter.h" | 19 #include "SkMaskFilter.h" |
20 #include "SkWriteBuffer.h" | 20 #include "SkWriteBuffer.h" |
21 #include "SkPaint.h" | 21 #include "SkPaint.h" |
22 #include "SkPatchUtils.h" | 22 #include "SkPatchUtils.h" |
23 #include "SkPathEffect.h" | 23 #include "SkPathEffect.h" |
24 #include "SkPictureFlat.h" | 24 #include "SkPictureFlat.h" |
25 #include "SkPtrRecorder.h" | |
25 #include "SkRasterizer.h" | 26 #include "SkRasterizer.h" |
26 #include "SkRRect.h" | 27 #include "SkRRect.h" |
27 #include "SkShader.h" | 28 #include "SkShader.h" |
28 #include "SkStream.h" | 29 #include "SkStream.h" |
29 #include "SkTextBlob.h" | 30 #include "SkTextBlob.h" |
30 #include "SkTSearch.h" | 31 #include "SkTSearch.h" |
31 #include "SkTypeface.h" | 32 #include "SkTypeface.h" |
32 #include "SkWriter32.h" | 33 #include "SkWriter32.h" |
33 | 34 |
34 enum { | 35 enum { |
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
937 } | 938 } |
938 } | 939 } |
939 } | 940 } |
940 | 941 |
941 void SkGPipeCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, | 942 void SkGPipeCanvas::onDrawTextBlob(const SkTextBlob* blob, SkScalar x, SkScalar y, |
942 const SkPaint& paint) { | 943 const SkPaint& paint) { |
943 NOTIFY_SETUP(this); | 944 NOTIFY_SETUP(this); |
944 this->writePaint(paint); | 945 this->writePaint(paint); |
945 | 946 |
946 // FIXME: this is inefficient but avoids duplicating the blob serialization logic. | 947 // FIXME: this is inefficient but avoids duplicating the blob serialization logic. |
948 SkRefCntSet typefaceSet; | |
947 SkWriteBuffer blobBuffer; | 949 SkWriteBuffer blobBuffer; |
950 blobBuffer.setTypefaceRecorder(&typefaceSet); | |
948 blob->flatten(blobBuffer); | 951 blob->flatten(blobBuffer); |
949 | 952 |
950 size_t size = sizeof(uint32_t) + 2 * sizeof(SkScalar) + blobBuffer.bytesWrit ten(); | 953 int typefaceCount = typefaceSet.count(); |
954 SkAutoSTMalloc<16, SkTypeface*> storage(typefaceCount); | |
955 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.
| |
956 typefaceSet.copyToArray((SkRefCnt**)array); | |
957 | |
958 size_t size = 2 * sizeof(uint32_t) + 2 * sizeof(SkScalar) + blobBuffer.bytes Written(); | |
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.
| |
959 size += typefaceCount * (isCrossProcess(fFlags) ? sizeof(uint32_t) : sizeof( void*)); | |
960 | |
951 if (this->needOpBytes(size)) { | 961 if (this->needOpBytes(size)) { |
952 this->writeOp(kDrawTextBlob_DrawOp); | 962 this->writeOp(kDrawTextBlob_DrawOp); |
953 fWriter.writeScalar(x); | 963 fWriter.writeScalar(x); |
954 fWriter.writeScalar(y); | 964 fWriter.writeScalar(y); |
965 | |
966 fWriter.write32(typefaceCount); | |
967 if (isCrossProcess(fFlags)) { | |
968 for (int i = 0; i < typefaceCount; ++i) { | |
969 fWriter.write32(this->getTypefaceID(array[i])); | |
970 } | |
971 } else { | |
972 fWriter.write(array, typefaceCount * sizeof(SkTypeface*)); | |
973 } | |
974 | |
955 fWriter.write32(SkToU32(blobBuffer.bytesWritten())); | 975 fWriter.write32(SkToU32(blobBuffer.bytesWritten())); |
956 uint32_t* pad = fWriter.reservePad(blobBuffer.bytesWritten()); | 976 uint32_t* pad = fWriter.reservePad(blobBuffer.bytesWritten()); |
957 blobBuffer.writeToMemory(pad); | 977 blobBuffer.writeToMemory(pad); |
958 } | 978 } |
959 } | 979 } |
960 | 980 |
961 void SkGPipeCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matr ix, | 981 void SkGPipeCanvas::onDrawPicture(const SkPicture* picture, const SkMatrix* matr ix, |
962 const SkPaint* paint) { | 982 const SkPaint* paint) { |
963 // we want to playback the picture into individual draw calls | 983 // we want to playback the picture into individual draw calls |
964 // | 984 // |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1336 return fCanvas->shuttleBitmap(bitmap, slot); | 1356 return fCanvas->shuttleBitmap(bitmap, slot); |
1337 } | 1357 } |
1338 | 1358 |
1339 void BitmapShuttle::removeCanvas() { | 1359 void BitmapShuttle::removeCanvas() { |
1340 if (NULL == fCanvas) { | 1360 if (NULL == fCanvas) { |
1341 return; | 1361 return; |
1342 } | 1362 } |
1343 fCanvas->unref(); | 1363 fCanvas->unref(); |
1344 fCanvas = NULL; | 1364 fCanvas = NULL; |
1345 } | 1365 } |
OLD | NEW |