OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 "SkStream.h" | 10 #include "SkStream.h" |
(...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 | 614 |
615 while (block != NULL) { | 615 while (block != NULL) { |
616 size_t size = block->written(); | 616 size_t size = block->written(); |
617 memcpy(dst, block->start(), size); | 617 memcpy(dst, block->start(), size); |
618 dst = (void*)((char*)dst + size); | 618 dst = (void*)((char*)dst + size); |
619 block = block->fNext; | 619 block = block->fNext; |
620 } | 620 } |
621 } | 621 } |
622 } | 622 } |
623 | 623 |
| 624 void SkDynamicMemoryWStream::writeToStream(SkWStream* dst) const { |
| 625 for (Block* block = fHead; block != NULL; block = block->fNext) { |
| 626 dst->write(block->start(), block->written()); |
| 627 } |
| 628 } |
| 629 |
624 void SkDynamicMemoryWStream::padToAlign4() | 630 void SkDynamicMemoryWStream::padToAlign4() |
625 { | 631 { |
626 // cast to remove unary-minus warning | 632 // cast to remove unary-minus warning |
627 int padBytes = -(int)fBytesWritten & 0x03; | 633 int padBytes = -(int)fBytesWritten & 0x03; |
628 if (padBytes == 0) | 634 if (padBytes == 0) |
629 return; | 635 return; |
630 int zero = 0; | 636 int zero = 0; |
631 write(&zero, padBytes); | 637 write(&zero, padBytes); |
632 } | 638 } |
633 | 639 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 SkDynamicMemoryWStream tempStream; | 908 SkDynamicMemoryWStream tempStream; |
903 const size_t bufferSize = 4096; | 909 const size_t bufferSize = 4096; |
904 char buffer[bufferSize]; | 910 char buffer[bufferSize]; |
905 do { | 911 do { |
906 size_t bytesRead = stream->read(buffer, bufferSize); | 912 size_t bytesRead = stream->read(buffer, bufferSize); |
907 tempStream.write(buffer, bytesRead); | 913 tempStream.write(buffer, bytesRead); |
908 } while (!stream->isAtEnd()); | 914 } while (!stream->isAtEnd()); |
909 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream, | 915 return tempStream.detachAsStream(); // returns a SkBlockMemoryStream, |
910 // cheaper than copying to SkData | 916 // cheaper than copying to SkData |
911 } | 917 } |
OLD | NEW |