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

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

Issue 1779263003: Make sp variants for SkData (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « src/core/SkFlattenableSerialization.cpp ('k') | src/core/SkPaint.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 * 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
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
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 }
OLDNEW
« no previous file with comments | « src/core/SkFlattenableSerialization.cpp ('k') | src/core/SkPaint.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698