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

Side by Side Diff: src/sfnt/SkOTUtils.cpp

Issue 560653004: SkData can allocate room for its contents in the same block (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update dox, change fPtr to non const Created 6 years, 3 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/SkPDFShader.cpp ('k') | src/utils/SkTextureCompressor.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 "SkData.h" 8 #include "SkData.h"
9 #include "SkEndian.h" 9 #include "SkEndian.h"
10 #include "SkSFNTHeader.h" 10 #include "SkSFNTHeader.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 size_t nameTableLogicalSize = sizeof(SkOTTableName) + (namesCount * sizeof(S kOTTableName::Record)) + (fontNameLen * sizeof(wchar_t)); 76 size_t nameTableLogicalSize = sizeof(SkOTTableName) + (namesCount * sizeof(S kOTTableName::Record)) + (fontNameLen * sizeof(wchar_t));
77 size_t nameTablePhysicalSize = (nameTableLogicalSize + 3) & ~3; // Rounded u p to a multiple of 4. 77 size_t nameTablePhysicalSize = (nameTableLogicalSize + 3) & ~3; // Rounded u p to a multiple of 4.
78 78
79 size_t oldNameTablePhysicalSize = (SkEndian_SwapBE32(tableEntry.logicalLengt h) + 3) & ~3; // Rounded up to a multiple of 4. 79 size_t oldNameTablePhysicalSize = (SkEndian_SwapBE32(tableEntry.logicalLengt h) + 3) & ~3; // Rounded up to a multiple of 4.
80 size_t oldNameTableOffset = SkEndian_SwapBE32(tableEntry.offset); 80 size_t oldNameTableOffset = SkEndian_SwapBE32(tableEntry.offset);
81 81
82 //originalDataSize is the size of the original data without the name table. 82 //originalDataSize is the size of the original data without the name table.
83 size_t originalDataSize = fontData->getLength() - oldNameTablePhysicalSize; 83 size_t originalDataSize = fontData->getLength() - oldNameTablePhysicalSize;
84 size_t newDataSize = originalDataSize + nameTablePhysicalSize; 84 size_t newDataSize = originalDataSize + nameTablePhysicalSize;
85 85
86 SK_OT_BYTE* data = static_cast<SK_OT_BYTE*>(sk_malloc_throw(newDataSize)); 86 SkAutoTUnref<SkData> rewrittenFontData(SkData::NewUninitialized(newDataSize) );
87 SkAutoTUnref<SkData> rewrittenFontData(SkData::NewFromMalloc(data, newDataSi ze)); 87 SK_OT_BYTE* data = static_cast<SK_OT_BYTE*>(rewrittenFontData->writable_data ());
88 88
89 if (fontData->read(data, oldNameTableOffset) < oldNameTableOffset) { 89 if (fontData->read(data, oldNameTableOffset) < oldNameTableOffset) {
90 return NULL; 90 return NULL;
91 } 91 }
92 if (fontData->skip(oldNameTablePhysicalSize) < oldNameTablePhysicalSize) { 92 if (fontData->skip(oldNameTablePhysicalSize) < oldNameTablePhysicalSize) {
93 return NULL; 93 return NULL;
94 } 94 }
95 if (fontData->read(data + oldNameTableOffset, originalDataSize - oldNameTabl eOffset) < originalDataSize - oldNameTableOffset) { 95 if (fontData->read(data + oldNameTableOffset, originalDataSize - oldNameTabl eOffset) < originalDataSize - oldNameTableOffset) {
96 return NULL; 96 return NULL;
97 } 97 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 fFamilyNameIter.reset(fTypes[fTypesIndex]); 194 fFamilyNameIter.reset(fTypes[fTypesIndex]);
195 } while (true); 195 } while (true);
196 } 196 }
197 197
198 SkOTTableName::Record::NameID::Predefined::Value 198 SkOTTableName::Record::NameID::Predefined::Value
199 SkOTUtils::LocalizedStrings_NameTable::familyNameTypes[3] = { 199 SkOTUtils::LocalizedStrings_NameTable::familyNameTypes[3] = {
200 SkOTTableName::Record::NameID::Predefined::FontFamilyName, 200 SkOTTableName::Record::NameID::Predefined::FontFamilyName,
201 SkOTTableName::Record::NameID::Predefined::PreferredFamily, 201 SkOTTableName::Record::NameID::Predefined::PreferredFamily,
202 SkOTTableName::Record::NameID::Predefined::WWSFamilyName, 202 SkOTTableName::Record::NameID::Predefined::WWSFamilyName,
203 }; 203 };
OLDNEW
« no previous file with comments | « src/pdf/SkPDFShader.cpp ('k') | src/utils/SkTextureCompressor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698