| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "SkChecksum.h" | |
| 9 #include "SkFontDescriptor.h" | 8 #include "SkFontDescriptor.h" |
| 9 #include "SkOpts.h" |
| 10 #include "SkStream.h" | 10 #include "SkStream.h" |
| 11 #include "SkString.h" | 11 #include "SkString.h" |
| 12 #include "SkTypeface.h" | 12 #include "SkTypeface.h" |
| 13 #include "SkUtils.h" | 13 #include "SkUtils.h" |
| 14 #include "../sfnt/SkOTUtils.h" | 14 #include "../sfnt/SkOTUtils.h" |
| 15 | 15 |
| 16 #include "SkWhitelistChecksums.inc" | 16 #include "SkWhitelistChecksums.inc" |
| 17 | 17 |
| 18 #define WHITELIST_DEBUG 0 | 18 #define WHITELIST_DEBUG 0 |
| 19 | 19 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 73 } |
| 74 SkTDArray<char> data; | 74 SkTDArray<char> data; |
| 75 size_t length = fontStream->getLength(); | 75 size_t length = fontStream->getLength(); |
| 76 if (!length) { | 76 if (!length) { |
| 77 return 0; | 77 return 0; |
| 78 } | 78 } |
| 79 data.setCount((int) length); | 79 data.setCount((int) length); |
| 80 if (!fontStream->peek(data.begin(), length)) { | 80 if (!fontStream->peek(data.begin(), length)) { |
| 81 return 0; | 81 return 0; |
| 82 } | 82 } |
| 83 return SkChecksum::Murmur3(data.begin(), length); | 83 return SkOpts::hash(data.begin(), length); |
| 84 } | 84 } |
| 85 | 85 |
| 86 static void serialize_sub(const char* fontName, SkFontStyle style, SkWStream* ws
tream) { | 86 static void serialize_sub(const char* fontName, SkFontStyle style, SkWStream* ws
tream) { |
| 87 SkFontDescriptor desc; | 87 SkFontDescriptor desc; |
| 88 SkString subName(SUBNAME_PREFIX); | 88 SkString subName(SUBNAME_PREFIX); |
| 89 subName.append(fontName); | 89 subName.append(fontName); |
| 90 const char* familyName = subName.c_str(); | 90 const char* familyName = subName.c_str(); |
| 91 desc.setFamilyName(familyName); | 91 desc.setFamilyName(familyName); |
| 92 desc.setStyle(style); | 92 desc.setStyle(style); |
| 93 desc.serialize(wstream); | 93 desc.serialize(wstream); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 const char* fontName = whitelist[i].fFontName; | 264 const char* fontName = whitelist[i].fFontName; |
| 265 sk_sp<SkTypeface> tf(SkTypeface::MakeFromName(fontName, SkFontStyle())); | 265 sk_sp<SkTypeface> tf(SkTypeface::MakeFromName(fontName, SkFontStyle())); |
| 266 uint32_t checksum = compute_checksum(tf.get()); | 266 uint32_t checksum = compute_checksum(tf.get()); |
| 267 line.printf(checksumEntry, fontName, checksum); | 267 line.printf(checksumEntry, fontName, checksum); |
| 268 sk_fwrite(line.c_str(), line.size(), file); | 268 sk_fwrite(line.c_str(), line.size(), file); |
| 269 } | 269 } |
| 270 sk_fwrite(checksumTrailer, sizeof(checksumTrailer) - 1, file); | 270 sk_fwrite(checksumTrailer, sizeof(checksumTrailer) - 1, file); |
| 271 sk_fclose(file); | 271 sk_fclose(file); |
| 272 return true; | 272 return true; |
| 273 } | 273 } |
| OLD | NEW |