| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkFontDescriptor.h" | 8 #include "SkFontDescriptor.h" |
| 9 #include "SkStream.h" | 9 #include "SkStream.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 skip_string(stream); | 89 skip_string(stream); |
| 90 break; | 90 break; |
| 91 default: | 91 default: |
| 92 SkDEBUGFAIL("Unknown id used by a font descriptor"); | 92 SkDEBUGFAIL("Unknown id used by a font descriptor"); |
| 93 return false; | 93 return false; |
| 94 } | 94 } |
| 95 } | 95 } |
| 96 | 96 |
| 97 size_t length = stream->readPackedUInt(); | 97 size_t length = stream->readPackedUInt(); |
| 98 if (length > 0) { | 98 if (length > 0) { |
| 99 SkAutoTUnref<SkData> data(SkData::NewUninitialized(length)); | 99 sk_sp<SkData> data(SkData::MakeUninitialized(length)); |
| 100 if (stream->read(data->writable_data(), length) == length) { | 100 if (stream->read(data->writable_data(), length) == length) { |
| 101 result->fFontData.reset(new SkFontData(new SkMemoryStream(data), | 101 result->fFontData.reset(new SkFontData(new SkMemoryStream(data), |
| 102 index, axis, axisCount)); | 102 index, axis, axisCount)); |
| 103 } else { | 103 } else { |
| 104 SkDEBUGFAIL("Could not read font data"); | 104 SkDEBUGFAIL("Could not read font data"); |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 return true; | 108 return true; |
| 109 } | 109 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 130 | 130 |
| 131 if (fFontData.get() && fFontData->hasStream()) { | 131 if (fFontData.get() && fFontData->hasStream()) { |
| 132 SkAutoTDelete<SkStreamAsset> fontData(fFontData->detachStream()); | 132 SkAutoTDelete<SkStreamAsset> fontData(fFontData->detachStream()); |
| 133 size_t length = fontData->getLength(); | 133 size_t length = fontData->getLength(); |
| 134 stream->writePackedUInt(length); | 134 stream->writePackedUInt(length); |
| 135 stream->writeStream(fontData, length); | 135 stream->writeStream(fontData, length); |
| 136 } else { | 136 } else { |
| 137 stream->writePackedUInt(0); | 137 stream->writePackedUInt(0); |
| 138 } | 138 } |
| 139 } | 139 } |
| OLD | NEW |