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 | 9 |
10 #include "SkBitmapHeap.h" | 10 #include "SkBitmapHeap.h" |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 return fSharedHeap; | 187 return fSharedHeap; |
188 } | 188 } |
189 | 189 |
190 void addTypeface() { | 190 void addTypeface() { |
191 size_t size = fReader->read32(); | 191 size_t size = fReader->read32(); |
192 const void* data = fReader->skip(SkAlign4(size)); | 192 const void* data = fReader->skip(SkAlign4(size)); |
193 SkMemoryStream stream(data, size, false); | 193 SkMemoryStream stream(data, size, false); |
194 *fTypefaces.append() = SkTypeface::Deserialize(&stream); | 194 *fTypefaces.append() = SkTypeface::Deserialize(&stream); |
195 } | 195 } |
196 | 196 |
197 void setTypeface(SkPaint* paint, unsigned id) { | 197 SkTypeface* getTypeface(unsigned id) const { |
198 paint->setTypeface(id ? fTypefaces[id - 1] : NULL); | 198 return id ? fTypefaces[id - 1] : NULL; |
199 } | 199 } |
200 | 200 |
201 private: | 201 private: |
202 void updateReader() { | 202 void updateReader() { |
203 if (NULL == fReader) { | 203 if (NULL == fReader) { |
204 return; | 204 return; |
205 } | 205 } |
206 bool crossProcess = SkToBool(fFlags & SkGPipeWriter::kCrossProcess_Flag)
; | 206 bool crossProcess = SkToBool(fFlags & SkGPipeWriter::kCrossProcess_Flag)
; |
207 fReader->setFlags(SkSetClearMask(fReader->getFlags(), crossProcess, | 207 fReader->setFlags(SkSetClearMask(fReader->getFlags(), crossProcess, |
208 SkReadBuffer::kCrossProcess_Flag)); | 208 SkReadBuffer::kCrossProcess_Flag)); |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 static void drawPicture_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 669 static void drawPicture_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
670 SkGPipeState* state) { | 670 SkGPipeState* state) { |
671 UNIMPLEMENTED | 671 UNIMPLEMENTED |
672 } | 672 } |
673 | 673 |
674 static void drawTextBlob_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, | 674 static void drawTextBlob_rp(SkCanvas* canvas, SkReader32* reader, uint32_t op32, |
675 SkGPipeState* state) { | 675 SkGPipeState* state) { |
676 SkScalar x = reader->readScalar(); | 676 SkScalar x = reader->readScalar(); |
677 SkScalar y = reader->readScalar(); | 677 SkScalar y = reader->readScalar(); |
678 | 678 |
| 679 int typefaceCount = reader->readU32(); |
| 680 SkAutoSTMalloc<16, SkTypeface*> typefaceArray(typefaceCount); |
| 681 if (state->getFlags() & SkGPipeWriter::kCrossProcess_Flag) { |
| 682 for (int i = 0; i < typefaceCount; ++i) { |
| 683 typefaceArray[i] = state->getTypeface(reader->readU32()); |
| 684 } |
| 685 } else { |
| 686 reader->read(typefaceArray.get(), typefaceCount * sizeof(SkTypeface*)); |
| 687 } |
| 688 |
679 size_t blobSize = reader->readU32(); | 689 size_t blobSize = reader->readU32(); |
680 const void* data = reader->skip(SkAlign4(blobSize)); | 690 const void* data = reader->skip(SkAlign4(blobSize)); |
681 | 691 |
682 if (state->shouldDraw()) { | 692 if (state->shouldDraw()) { |
683 SkReadBuffer blobBuffer(data, blobSize); | 693 SkReadBuffer blobBuffer(data, blobSize); |
| 694 blobBuffer.setTypefaceArray(typefaceArray.get(), typefaceCount); |
684 SkAutoTUnref<const SkTextBlob> blob(SkTextBlob::CreateFromBuffer(blobBuf
fer)); | 695 SkAutoTUnref<const SkTextBlob> blob(SkTextBlob::CreateFromBuffer(blobBuf
fer)); |
685 SkASSERT(blob.get()); | 696 SkASSERT(blob.get()); |
686 | 697 |
687 canvas->drawTextBlob(blob, x, y, state->paint()); | 698 canvas->drawTextBlob(blob, x, y, state->paint()); |
688 } | 699 } |
689 } | 700 } |
690 /////////////////////////////////////////////////////////////////////////////// | 701 /////////////////////////////////////////////////////////////////////////////// |
691 | 702 |
692 static void paintOp_rp(SkCanvas*, SkReader32* reader, uint32_t op32, | 703 static void paintOp_rp(SkCanvas*, SkReader32* reader, uint32_t op32, |
693 SkGPipeState* state) { | 704 SkGPipeState* state) { |
(...skipping 30 matching lines...) Expand all Loading... |
724 case kFlatIndex_PaintOp: { | 735 case kFlatIndex_PaintOp: { |
725 PaintFlats pf = (PaintFlats)PaintOp_unpackFlags(p32); | 736 PaintFlats pf = (PaintFlats)PaintOp_unpackFlags(p32); |
726 unsigned index = data; | 737 unsigned index = data; |
727 set_paintflat(p, state->getFlat(index), pf); | 738 set_paintflat(p, state->getFlat(index), pf); |
728 break; | 739 break; |
729 } | 740 } |
730 | 741 |
731 case kTypeface_PaintOp: | 742 case kTypeface_PaintOp: |
732 SkASSERT(SkToBool(state->getFlags() & | 743 SkASSERT(SkToBool(state->getFlags() & |
733 SkGPipeWriter::kCrossProcess_Flag)); | 744 SkGPipeWriter::kCrossProcess_Flag)); |
734 state->setTypeface(p, data); break; | 745 p->setTypeface(state->getTypeface(data)); |
| 746 break; |
735 default: SkDEBUGFAIL("bad paintop"); return; | 747 default: SkDEBUGFAIL("bad paintop"); return; |
736 } | 748 } |
737 SkASSERT(reader->offset() <= stop); | 749 SkASSERT(reader->offset() <= stop); |
738 } while (reader->offset() < stop); | 750 } while (reader->offset() < stop); |
739 } | 751 } |
740 | 752 |
741 static void typeface_rp(SkCanvas*, SkReader32* reader, uint32_t, | 753 static void typeface_rp(SkCanvas*, SkReader32* reader, uint32_t, |
742 SkGPipeState* state) { | 754 SkGPipeState* state) { |
743 SkASSERT(!SkToBool(state->getFlags() & SkGPipeWriter::kCrossProcess_Flag)); | 755 SkASSERT(!SkToBool(state->getFlags() & SkGPipeWriter::kCrossProcess_Flag)); |
744 SkPaint* p = state->editPaint(); | 756 SkPaint* p = state->editPaint(); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 status = kReadAtom_Status; | 957 status = kReadAtom_Status; |
946 break; | 958 break; |
947 } | 959 } |
948 } | 960 } |
949 | 961 |
950 if (bytesRead) { | 962 if (bytesRead) { |
951 *bytesRead = reader.offset(); | 963 *bytesRead = reader.offset(); |
952 } | 964 } |
953 return status; | 965 return status; |
954 } | 966 } |
OLD | NEW |