OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright 2010 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 "GrTextContext.h" | |
9 #include "GrFontScaler.h" | |
10 | |
11 #include "SkGlyphCache.h" | |
12 | |
13 bool GrTextContext::ShouldDisableLCD(const SkPaint& paint) { | |
14 if (!SkXfermode::AsMode(paint.getXfermode(), nullptr) || | |
15 paint.getMaskFilter() || | |
16 paint.getRasterizer() || | |
17 paint.getPathEffect() || | |
18 paint.isFakeBoldText() || | |
19 paint.getStyle() != SkPaint::kFill_Style) | |
20 { | |
21 return true; | |
22 } | |
23 return false; | |
24 } | |
25 | |
26 uint32_t GrTextContext::FilterTextFlags(const SkSurfaceProps& surfaceProps, cons
t SkPaint& paint) { | |
27 uint32_t flags = paint.getFlags(); | |
28 | |
29 if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { | |
30 return flags; | |
31 } | |
32 | |
33 if (kUnknown_SkPixelGeometry == surfaceProps.pixelGeometry() || ShouldDisabl
eLCD(paint)) { | |
34 flags &= ~SkPaint::kLCDRenderText_Flag; | |
35 flags |= SkPaint::kGenA8FromLCD_Flag; | |
36 } | |
37 | |
38 return flags; | |
39 } | |
40 | |
41 static void GlyphCacheAuxProc(void* data) { | |
42 GrFontScaler* scaler = (GrFontScaler*)data; | |
43 SkSafeUnref(scaler); | |
44 } | |
45 | |
46 GrFontScaler* GrTextContext::GetGrFontScaler(SkGlyphCache* cache) { | |
47 void* auxData; | |
48 GrFontScaler* scaler = nullptr; | |
49 | |
50 if (cache->getAuxProcData(GlyphCacheAuxProc, &auxData)) { | |
51 scaler = (GrFontScaler*)auxData; | |
52 } | |
53 if (nullptr == scaler) { | |
54 scaler = new GrFontScaler(cache); | |
55 cache->setAuxProc(GlyphCacheAuxProc, scaler); | |
56 } | |
57 | |
58 return scaler; | |
59 } | |
OLD | NEW |