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 874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
885 const size_t length = stream->getLength(); | 885 const size_t length = stream->getLength(); |
886 void* dst = storage->reset(length); | 886 void* dst = storage->reset(length); |
887 if (stream->read(dst, length) != length) { | 887 if (stream->read(dst, length) != length) { |
888 return 0; | 888 return 0; |
889 } | 889 } |
890 return length; | 890 return length; |
891 } | 891 } |
892 | 892 |
893 SkDynamicMemoryWStream tempStream; | 893 SkDynamicMemoryWStream tempStream; |
894 // Arbitrary buffer size. | 894 // Arbitrary buffer size. |
| 895 #if defined(GOOGLE3) |
| 896 // Stack frame size is limited in GOOGLE3. |
| 897 const size_t bufferSize = 8 * 1024; // 8KB |
| 898 #else |
895 const size_t bufferSize = 256 * 1024; // 256KB | 899 const size_t bufferSize = 256 * 1024; // 256KB |
| 900 #endif |
896 char buffer[bufferSize]; | 901 char buffer[bufferSize]; |
897 SkDEBUGCODE(size_t debugLength = 0;) | 902 SkDEBUGCODE(size_t debugLength = 0;) |
898 do { | 903 do { |
899 size_t bytesRead = stream->read(buffer, bufferSize); | 904 size_t bytesRead = stream->read(buffer, bufferSize); |
900 tempStream.write(buffer, bytesRead); | 905 tempStream.write(buffer, bytesRead); |
901 SkDEBUGCODE(debugLength += bytesRead); | 906 SkDEBUGCODE(debugLength += bytesRead); |
902 SkASSERT(tempStream.bytesWritten() == debugLength); | 907 SkASSERT(tempStream.bytesWritten() == debugLength); |
903 } while (!stream->isAtEnd()); | 908 } while (!stream->isAtEnd()); |
904 const size_t length = tempStream.bytesWritten(); | 909 const size_t length = tempStream.bytesWritten(); |
905 void* dst = storage->reset(length); | 910 void* dst = storage->reset(length); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 while (true) { | 972 while (true) { |
968 count = input->read(scratch, sizeof(scratch)); | 973 count = input->read(scratch, sizeof(scratch)); |
969 if (0 == count) { | 974 if (0 == count) { |
970 return true; | 975 return true; |
971 } | 976 } |
972 if (!out->write(scratch, count)) { | 977 if (!out->write(scratch, count)) { |
973 return false; | 978 return false; |
974 } | 979 } |
975 } | 980 } |
976 } | 981 } |
OLD | NEW |