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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 133 } |
134 | 134 |
135 bool SkWStream::write32(uint32_t value) { | 135 bool SkWStream::write32(uint32_t value) { |
136 return this->write(&value, 4); | 136 return this->write(&value, 4); |
137 } | 137 } |
138 | 138 |
139 bool SkWStream::writeScalar(SkScalar value) { | 139 bool SkWStream::writeScalar(SkScalar value) { |
140 return this->write(&value, sizeof(value)); | 140 return this->write(&value, sizeof(value)); |
141 } | 141 } |
142 | 142 |
| 143 int SkWStream::SizeOfPackedUInt(size_t value) { |
| 144 if (value <= SK_MAX_BYTE_FOR_U8) { |
| 145 return 1; |
| 146 } else if (value <= 0xFFFF) { |
| 147 return 3; |
| 148 } |
| 149 return 5; |
| 150 } |
| 151 |
143 bool SkWStream::writePackedUInt(size_t value) { | 152 bool SkWStream::writePackedUInt(size_t value) { |
144 uint8_t data[5]; | 153 uint8_t data[5]; |
145 size_t len = 1; | 154 size_t len = 1; |
146 if (value <= SK_MAX_BYTE_FOR_U8) { | 155 if (value <= SK_MAX_BYTE_FOR_U8) { |
147 data[0] = value; | 156 data[0] = value; |
148 len = 1; | 157 len = 1; |
149 } else if (value <= 0xFFFF) { | 158 } else if (value <= 0xFFFF) { |
150 uint16_t value16 = value; | 159 uint16_t value16 = value; |
151 data[0] = SK_BYTE_SENTINEL_FOR_U16; | 160 data[0] = SK_BYTE_SENTINEL_FOR_U16; |
152 memcpy(&data[1], &value16, 2); | 161 memcpy(&data[1], &value16, 2); |
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
829 | 838 |
830 // If we get here, then our attempt at using mmap failed, so try normal | 839 // If we get here, then our attempt at using mmap failed, so try normal |
831 // file access. | 840 // file access. |
832 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path)); | 841 SkFILEStream* stream = SkNEW_ARGS(SkFILEStream, (path)); |
833 if (!stream->isValid()) { | 842 if (!stream->isValid()) { |
834 stream->unref(); | 843 stream->unref(); |
835 stream = NULL; | 844 stream = NULL; |
836 } | 845 } |
837 return stream; | 846 return stream; |
838 } | 847 } |
OLD | NEW |