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 "SkRandomScalerContext.h" | 8 #include "SkRandomScalerContext.h" |
9 #include "SkGlyph.h" | 9 #include "SkGlyph.h" |
10 #include "SkPath.h" | 10 #include "SkPath.h" |
11 #include "SkCanvas.h" | 11 #include "SkCanvas.h" |
12 #include "SkRasterizer.h" | 12 #include "SkRasterizer.h" |
13 | 13 |
14 class SkRandomScalerContext : public SkScalerContext { | 14 class SkRandomScalerContext : public SkScalerContext { |
15 public: | 15 public: |
16 SkRandomScalerContext(SkRandomTypeface*, const SkDescriptor*, bool fFakeIt); | 16 SkRandomScalerContext(SkRandomTypeface*, const SkScalerContextEffects&, |
| 17 const SkDescriptor*, bool fFakeIt); |
17 virtual ~SkRandomScalerContext(); | 18 virtual ~SkRandomScalerContext(); |
18 | 19 |
19 protected: | 20 protected: |
20 unsigned generateGlyphCount() override; | 21 unsigned generateGlyphCount() override; |
21 uint16_t generateCharToGlyph(SkUnichar) override; | 22 uint16_t generateCharToGlyph(SkUnichar) override; |
22 void generateAdvance(SkGlyph*) override; | 23 void generateAdvance(SkGlyph*) override; |
23 void generateMetrics(SkGlyph*) override; | 24 void generateMetrics(SkGlyph*) override; |
24 void generateImage(const SkGlyph&) override; | 25 void generateImage(const SkGlyph&) override; |
25 void generatePath(const SkGlyph&, SkPath*) override; | 26 void generatePath(const SkGlyph&, SkPath*) override; |
26 void generateFontMetrics(SkPaint::FontMetrics*) override; | 27 void generateFontMetrics(SkPaint::FontMetrics*) override; |
27 | 28 |
28 private: | 29 private: |
29 SkRandomTypeface* fFace; | 30 SkRandomTypeface* fFace; |
30 SkScalerContext* fProxy; | 31 SkScalerContext* fProxy; |
31 bool fFakeIt; | 32 bool fFakeIt; |
32 }; | 33 }; |
33 | 34 |
34 #define STD_SIZE 1 | 35 #define STD_SIZE 1 |
35 | 36 |
36 #include "SkDescriptor.h" | 37 #include "SkDescriptor.h" |
37 | 38 |
38 SkRandomScalerContext::SkRandomScalerContext(SkRandomTypeface* face, const SkDes
criptor* desc, | 39 SkRandomScalerContext::SkRandomScalerContext(SkRandomTypeface* face, |
| 40 const SkScalerContextEffects& effec
ts, |
| 41 const SkDescriptor* desc, |
39 bool fakeIt) | 42 bool fakeIt) |
40 : SkScalerContext(face, desc) | 43 : SkScalerContext(face, effects, desc) |
41 , fFace(face) | 44 , fFace(face) |
42 , fFakeIt(fakeIt) { | 45 , fFakeIt(fakeIt) { |
43 fProxy = face->proxy()->createScalerContext(desc); | 46 fProxy = face->proxy()->createScalerContext(effects, desc); |
44 } | 47 } |
45 | 48 |
46 SkRandomScalerContext::~SkRandomScalerContext() { delete fProxy; } | 49 SkRandomScalerContext::~SkRandomScalerContext() { delete fProxy; } |
47 | 50 |
48 unsigned SkRandomScalerContext::generateGlyphCount() { | 51 unsigned SkRandomScalerContext::generateGlyphCount() { |
49 return fProxy->getGlyphCount(); | 52 return fProxy->getGlyphCount(); |
50 } | 53 } |
51 | 54 |
52 uint16_t SkRandomScalerContext::generateCharToGlyph(SkUnichar uni) { | 55 uint16_t SkRandomScalerContext::generateCharToGlyph(SkUnichar uni) { |
53 return fProxy->charToGlyphID(uni); | 56 return fProxy->charToGlyphID(uni); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 SkRandomTypeface::SkRandomTypeface(SkTypeface* proxy, const SkPaint& paint, bool
fakeIt) | 193 SkRandomTypeface::SkRandomTypeface(SkTypeface* proxy, const SkPaint& paint, bool
fakeIt) |
191 : SkTypeface(proxy->fontStyle(), SkTypefaceCache::NewFontID(), false) | 194 : SkTypeface(proxy->fontStyle(), SkTypefaceCache::NewFontID(), false) |
192 , fProxy(SkRef(proxy)) | 195 , fProxy(SkRef(proxy)) |
193 , fPaint(paint) | 196 , fPaint(paint) |
194 , fFakeIt(fakeIt) {} | 197 , fFakeIt(fakeIt) {} |
195 | 198 |
196 SkRandomTypeface::~SkRandomTypeface() { | 199 SkRandomTypeface::~SkRandomTypeface() { |
197 fProxy->unref(); | 200 fProxy->unref(); |
198 } | 201 } |
199 | 202 |
200 SkScalerContext* SkRandomTypeface::onCreateScalerContext( | 203 SkScalerContext* SkRandomTypeface::onCreateScalerContext(const SkScalerContextEf
fects& effects, |
201 const SkDescriptor* desc) const { | 204 const SkDescriptor* des
c) const { |
202 return new SkRandomScalerContext(const_cast<SkRandomTypeface*>(this), desc,
fFakeIt); | 205 return new SkRandomScalerContext(const_cast<SkRandomTypeface*>(this), effect
s, desc, fFakeIt); |
203 } | 206 } |
204 | 207 |
205 void SkRandomTypeface::onFilterRec(SkScalerContextRec* rec) const { | 208 void SkRandomTypeface::onFilterRec(SkScalerContextRec* rec) const { |
206 fProxy->filterRec(rec); | 209 fProxy->filterRec(rec); |
207 rec->setHinting(SkPaint::kNo_Hinting); | 210 rec->setHinting(SkPaint::kNo_Hinting); |
208 rec->fMaskFormat = SkMask::kARGB32_Format; | 211 rec->fMaskFormat = SkMask::kARGB32_Format; |
209 } | 212 } |
210 | 213 |
211 SkAdvancedTypefaceMetrics* SkRandomTypeface::onGetAdvancedTypefaceMetrics( | 214 SkAdvancedTypefaceMetrics* SkRandomTypeface::onGetAdvancedTypefaceMetrics( |
212 PerGlyphInfo info, | 215 PerGlyphInfo info, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 | 250 |
248 int SkRandomTypeface::onGetTableTags(SkFontTableTag tags[]) const { | 251 int SkRandomTypeface::onGetTableTags(SkFontTableTag tags[]) const { |
249 return fProxy->getTableTags(tags); | 252 return fProxy->getTableTags(tags); |
250 } | 253 } |
251 | 254 |
252 size_t SkRandomTypeface::onGetTableData(SkFontTableTag tag, size_t offset, | 255 size_t SkRandomTypeface::onGetTableData(SkFontTableTag tag, size_t offset, |
253 size_t length, void* data) const { | 256 size_t length, void* data) const { |
254 return fProxy->getTableData(tag, offset, length, data); | 257 return fProxy->getTableData(tag, offset, length, data); |
255 } | 258 } |
256 | 259 |
OLD | NEW |