Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(496)

Side by Side Diff: src/core/SkStream.cpp

Issue 943423002: SkStream: Add SkDynamicMemoryWStream::writeToStream(SkWStream*) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2015-02-23 (Monday) 15:03:08 EST Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkStream.h ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « include/core/SkStream.h ('k') | src/pdf/SkPDFDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698