• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "src/core/SkArenaAlloc.h"
9 #include "src/core/SkDistanceFieldGen.h"
10 #include "src/core/SkStrikeSpec.h"
11 #include "src/gpu/GrCaps.h"
12 #include "src/gpu/GrColor.h"
13 #include "src/gpu/GrDistanceFieldGenFromVector.h"
14 #include "src/gpu/text/GrAtlasManager.h"
15 #include "src/gpu/text/GrStrikeCache.h"
16 
~GrStrikeCache()17 GrStrikeCache::~GrStrikeCache() {
18     this->freeAll();
19 }
20 
freeAll()21 void GrStrikeCache::freeAll() {
22     fCache.reset();
23 }
24 
25 ///////////////////////////////////////////////////////////////////////////////
26 
27 /*
28     The text strike is specific to a given font/style/matrix setup, which is
29     represented by the GrHostFontScaler object we are given in getGlyph().
30 
31     We map a 32bit glyphID to a GrGlyph record, which in turn points to a
32     atlas and a position within that texture.
33  */
34 
GrTextStrike(const SkDescriptor & key)35 GrTextStrike::GrTextStrike(const SkDescriptor& key) : fFontScalerKey(key) {}
36 
getGlyph(SkPackedGlyphID packedGlyphID)37 GrGlyph* GrTextStrike::getGlyph(SkPackedGlyphID packedGlyphID) {
38     GrGlyph* grGlyph = fCache.findOrNull(packedGlyphID);
39     if (grGlyph == nullptr) {
40         grGlyph = fAlloc.make<GrGlyph>(packedGlyphID);
41         fCache.set(grGlyph);
42     }
43     return grGlyph;
44 }
45 
46