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 #ifndef SkPictureFlat_DEFINED | 8 #ifndef SkPictureFlat_DEFINED |
9 #define SkPictureFlat_DEFINED | 9 #define SkPictureFlat_DEFINED |
10 | 10 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 | 522 |
523 // Layout of fScratch: [ SkFlatData header, 20 bytes ] [ data ..., 4-byt
e aligned ] | 523 // Layout of fScratch: [ SkFlatData header, 20 bytes ] [ data ..., 4-byt
e aligned ] |
524 fScratch.reset(); | 524 fScratch.reset(); |
525 fScratch.reserve(sizeof(SkFlatData)); | 525 fScratch.reserve(sizeof(SkFlatData)); |
526 Traits::Flatten(fScratch, element); | 526 Traits::Flatten(fScratch, element); |
527 const size_t dataSize = fScratch.bytesWritten() - sizeof(SkFlatData); | 527 const size_t dataSize = fScratch.bytesWritten() - sizeof(SkFlatData); |
528 | 528 |
529 // Reinterpret data in fScratch as an SkFlatData. | 529 // Reinterpret data in fScratch as an SkFlatData. |
530 SkFlatData* scratch = (SkFlatData*)fScratch.getWriter32()->contiguousArr
ay(); | 530 SkFlatData* scratch = (SkFlatData*)fScratch.getWriter32()->contiguousArr
ay(); |
531 SkASSERT(scratch != NULL); | 531 SkASSERT(scratch != NULL); |
532 scratch->stampHeader(index, dataSize); | 532 scratch->stampHeader(index, SkToS32(dataSize)); |
533 return *scratch; | 533 return *scratch; |
534 } | 534 } |
535 | 535 |
536 // This result is owned by fController and lives as long as it does (unless
unalloc'd). | 536 // This result is owned by fController and lives as long as it does (unless
unalloc'd). |
537 SkFlatData* detachScratch() { | 537 SkFlatData* detachScratch() { |
538 // Allocate a new SkFlatData exactly big enough to hold our current scra
tch. | 538 // Allocate a new SkFlatData exactly big enough to hold our current scra
tch. |
539 // We use the controller for this allocation to extend the allocation's
lifetime and allow | 539 // We use the controller for this allocation to extend the allocation's
lifetime and allow |
540 // the controller to do whatever memory management it wants. | 540 // the controller to do whatever memory management it wants. |
541 SkFlatData* detached = (SkFlatData*)fController->allocThrow(fScratch.byt
esWritten()); | 541 SkFlatData* detached = (SkFlatData*)fController->allocThrow(fScratch.byt
esWritten()); |
542 | 542 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 } | 599 } |
600 | 600 |
601 private: | 601 private: |
602 SkChunkAlloc fHeap; | 602 SkChunkAlloc fHeap; |
603 SkAutoTUnref<SkRefCntSet> fTypefaceSet; | 603 SkAutoTUnref<SkRefCntSet> fTypefaceSet; |
604 void* fLastAllocated; | 604 void* fLastAllocated; |
605 mutable SkTypefacePlayback fTypefacePlayback; | 605 mutable SkTypefacePlayback fTypefacePlayback; |
606 }; | 606 }; |
607 | 607 |
608 #endif | 608 #endif |
OLD | NEW |