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

Side by Side Diff: src/gpu/GrFontScaler.cpp

Issue 1238473004: Cleanup of GrFontDescKey (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 5 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/gpu/GrFontScaler.h ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "GrTemplates.h" 10 #include "GrTemplates.h"
11 #include "GrFontScaler.h" 11 #include "GrFontScaler.h"
12 #include "SkDescriptor.h" 12 #include "SkDescriptor.h"
13 #include "SkDistanceFieldGen.h" 13 #include "SkDistanceFieldGen.h"
14 #include "SkGlyphCache.h" 14 #include "SkGlyphCache.h"
15 15
16 /////////////////////////////////////////////////////////////////////////////// 16 ///////////////////////////////////////////////////////////////////////////////
17 17
18 GrFontDescKey::GrFontDescKey(const SkDescriptor& desc) : fHash(desc.getChecksum( )) {
19 size_t size = desc.getLength();
20 if (size <= sizeof(fStorage)) {
21 fDesc = GrTCast<SkDescriptor*>(fStorage);
22 } else {
23 fDesc = SkDescriptor::Alloc(size);
24 }
25 memcpy(fDesc, &desc, size);
26 }
27
28 GrFontDescKey::~GrFontDescKey() {
29 if (fDesc != GrTCast<SkDescriptor*>(fStorage)) {
30 SkDescriptor::Free(fDesc);
31 }
32 }
33
34 bool GrFontDescKey::lt(const GrFontDescKey& rh) const {
35 const SkDescriptor* srcDesc = (&rh)->fDesc;
36 size_t lenLH = fDesc->getLength();
37 size_t lenRH = srcDesc->getLength();
38 int cmp = memcmp(fDesc, srcDesc, SkTMin<size_t>(lenLH, lenRH));
39 if (0 == cmp) {
40 return lenLH < lenRH;
41 } else {
42 return cmp < 0;
43 }
44 }
45
46 bool GrFontDescKey::eq(const GrFontDescKey& rh) const {
47 const SkDescriptor* srcDesc = (&rh)->fDesc;
48 return fDesc->equals(*srcDesc);
49 }
50
51 ///////////////////////////////////////////////////////////////////////////////
52
53 GrFontScaler::GrFontScaler(SkGlyphCache* strike) { 18 GrFontScaler::GrFontScaler(SkGlyphCache* strike) {
54 fStrike = strike; 19 fStrike = strike;
55 fKey = NULL; 20 fKey = NULL;
56 } 21 }
57 22
58 GrFontScaler::~GrFontScaler() { 23 GrFontScaler::~GrFontScaler() {
59 SkSafeUnref(fKey); 24 SkSafeUnref(fKey);
60 } 25 }
61 26
62 GrMaskFormat GrFontScaler::getMaskFormat() const { 27 GrMaskFormat GrFontScaler::getMaskFormat() const {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 bool GrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) { 198 bool GrFontScaler::getGlyphPath(uint16_t glyphID, SkPath* path) {
234 199
235 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID); 200 const SkGlyph& glyph = fStrike->getGlyphIDMetrics(glyphID);
236 const SkPath* skPath = fStrike->findPath(glyph); 201 const SkPath* skPath = fStrike->findPath(glyph);
237 if (skPath) { 202 if (skPath) {
238 *path = *skPath; 203 *path = *skPath;
239 return true; 204 return true;
240 } 205 }
241 return false; 206 return false;
242 } 207 }
OLDNEW
« no previous file with comments | « src/gpu/GrFontScaler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698