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

Side by Side Diff: src/pdf/SkPDFFont.cpp

Issue 1809733002: detach -> release (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: (C) 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/pdf/SkPDFDocument.cpp ('k') | src/pdf/SkPDFShader.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 2011 Google Inc. 2 * Copyright 2011 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 <ctype.h> 8 #include <ctype.h>
9 9
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 260 }
261 } 261 }
262 if (!highNibble) { 262 if (!highNibble) {
263 resultData[outputOffset++] = dataByte; 263 resultData[outputOffset++] = dataByte;
264 } 264 }
265 SkASSERT(outputOffset == *dataLen); 265 SkASSERT(outputOffset == *dataLen);
266 266
267 uint8_t* const resultTrailer = &(buffer[SkToInt(*headerLen + outputOffse t)]); 267 uint8_t* const resultTrailer = &(buffer[SkToInt(*headerLen + outputOffse t)]);
268 memcpy(resultTrailer, src + *headerLen + hexDataLen, *trailerLen); 268 memcpy(resultTrailer, src + *headerLen + hexDataLen, *trailerLen);
269 269
270 return SkData::NewFromMalloc(buffer.detach(), length); 270 return SkData::NewFromMalloc(buffer.release(), length);
271 } 271 }
272 return nullptr; 272 return nullptr;
273 } 273 }
274 274
275 // scale from em-units to base-1000, returning as a SkScalar 275 // scale from em-units to base-1000, returning as a SkScalar
276 SkScalar scaleFromFontUnits(int16_t val, uint16_t emSize) { 276 SkScalar scaleFromFontUnits(int16_t val, uint16_t emSize) {
277 SkScalar scaled = SkIntToScalar(val); 277 SkScalar scaled = SkIntToScalar(val);
278 if (emSize == 1000) { 278 if (emSize == 1000) {
279 return scaled; 279 return scaled;
280 } else { 280 } else {
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 break; 1070 break;
1071 } 1071 }
1072 } 1072 }
1073 #endif 1073 #endif
1074 sk_sp<SkPDFSharedStream> fontStream; 1074 sk_sp<SkPDFSharedStream> fontStream;
1075 SkAutoTDelete<SkStreamAsset> fontData( 1075 SkAutoTDelete<SkStreamAsset> fontData(
1076 this->typeface()->openStream(nullptr)); 1076 this->typeface()->openStream(nullptr));
1077 SkASSERT(fontData); 1077 SkASSERT(fontData);
1078 fontSize = fontData->getLength(); 1078 fontSize = fontData->getLength();
1079 SkASSERT(fontSize > 0); 1079 SkASSERT(fontSize > 0);
1080 fontStream.reset(new SkPDFSharedStream(fontData.detach())); 1080 fontStream.reset(new SkPDFSharedStream(fontData.release()));
1081 fontStream->dict()->insertInt("Length1", fontSize); 1081 fontStream->dict()->insertInt("Length1", fontSize);
1082 descriptor->insertObjRef("FontFile2", std::move(fontStream)); 1082 descriptor->insertObjRef("FontFile2", std::move(fontStream));
1083 break; 1083 break;
1084 } 1084 }
1085 case SkAdvancedTypefaceMetrics::kCFF_Font: 1085 case SkAdvancedTypefaceMetrics::kCFF_Font:
1086 case SkAdvancedTypefaceMetrics::kType1CID_Font: { 1086 case SkAdvancedTypefaceMetrics::kType1CID_Font: {
1087 sk_sp<SkPDFSharedStream> fontStream( 1087 sk_sp<SkPDFSharedStream> fontStream(
1088 new SkPDFSharedStream(this->typeface()->openStream(nullptr)) ); 1088 new SkPDFSharedStream(this->typeface()->openStream(nullptr)) );
1089 1089
1090 if (getType() == SkAdvancedTypefaceMetrics::kCFF_Font) { 1090 if (getType() == SkAdvancedTypefaceMetrics::kCFF_Font) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 sk_sp<const SkAdvancedTypefaceMetrics> fontMetrics( 1427 sk_sp<const SkAdvancedTypefaceMetrics> fontMetrics(
1428 face->getAdvancedTypefaceMetrics( 1428 face->getAdvancedTypefaceMetrics(
1429 SkTypeface::kNo_PerGlyphInfo, nullptr, 0)); 1429 SkTypeface::kNo_PerGlyphInfo, nullptr, 0));
1430 if (fontMetrics) { 1430 if (fontMetrics) {
1431 canEmbed = !SkToBool( 1431 canEmbed = !SkToBool(
1432 fontMetrics->fFlags & 1432 fontMetrics->fFlags &
1433 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag); 1433 SkAdvancedTypefaceMetrics::kNotEmbeddable_FontFlag);
1434 } 1434 }
1435 return *canon->fCanEmbedTypeface.set(id, canEmbed); 1435 return *canon->fCanEmbedTypeface.set(id, canEmbed);
1436 } 1436 }
OLDNEW
« no previous file with comments | « src/pdf/SkPDFDocument.cpp ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698