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" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 56 } |
57 | 57 |
58 void SkRandomScalerContext::generateAdvance(SkGlyph* glyph) { | 58 void SkRandomScalerContext::generateAdvance(SkGlyph* glyph) { |
59 fProxy->getAdvance(glyph); | 59 fProxy->getAdvance(glyph); |
60 } | 60 } |
61 | 61 |
62 void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) { | 62 void SkRandomScalerContext::generateMetrics(SkGlyph* glyph) { |
63 // Here we will change the mask format of the glyph | 63 // Here we will change the mask format of the glyph |
64 // NOTE this is being overridden by the base class | 64 // NOTE this is being overridden by the base class |
65 SkMask::Format format; | 65 SkMask::Format format; |
66 switch (glyph->getGlyphID() % 4) { | 66 switch (glyph->getGlyphID() % 3) { |
67 case 0: | 67 case 0: |
68 format = SkMask::kLCD16_Format; | 68 format = SkMask::kLCD16_Format; |
69 break; | 69 break; |
70 case 1: | 70 case 1: |
71 format = SkMask::kA8_Format; | 71 format = SkMask::kA8_Format; |
72 break; | 72 break; |
73 case 2: | 73 case 2: |
74 format = SkMask::kARGB32_Format; | 74 format = SkMask::kARGB32_Format; |
75 break; | 75 break; |
76 case 3: | |
77 format = SkMask::kBW_Format; | |
78 break; | |
79 } | 76 } |
80 | 77 |
81 fProxy->getMetrics(glyph); | 78 fProxy->getMetrics(glyph); |
82 | 79 |
83 glyph->fMaskFormat = format; | 80 glyph->fMaskFormat = format; |
84 if (fFakeIt) { | 81 if (fFakeIt) { |
85 return; | 82 return; |
86 } | 83 } |
87 if (SkMask::kARGB32_Format == format) { | 84 if (SkMask::kARGB32_Format == format) { |
88 SkPath path; | 85 SkPath path; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 break; | 125 break; |
129 default: | 126 default: |
130 break; | 127 break; |
131 } | 128 } |
132 } | 129 } |
133 } | 130 } |
134 } | 131 } |
135 | 132 |
136 void SkRandomScalerContext::generateImage(const SkGlyph& glyph) { | 133 void SkRandomScalerContext::generateImage(const SkGlyph& glyph) { |
137 SkMask::Format format = (SkMask::Format)glyph.fMaskFormat; | 134 SkMask::Format format = (SkMask::Format)glyph.fMaskFormat; |
138 switch (glyph.getGlyphID() % 4) { | 135 switch (glyph.getGlyphID() % 3) { |
139 case 0: | 136 case 0: |
140 format = SkMask::kLCD16_Format; | 137 format = SkMask::kLCD16_Format; |
141 break; | 138 break; |
142 case 1: | 139 case 1: |
143 format = SkMask::kA8_Format; | 140 format = SkMask::kA8_Format; |
144 break; | 141 break; |
145 case 2: | 142 case 2: |
146 format = SkMask::kARGB32_Format; | 143 format = SkMask::kARGB32_Format; |
147 break; | 144 break; |
148 case 3: | |
149 format = SkMask::kBW_Format; | |
150 break; | |
151 } | 145 } |
152 const_cast<SkGlyph&>(glyph).fMaskFormat = format; | 146 const_cast<SkGlyph&>(glyph).fMaskFormat = format; |
153 | 147 |
154 // if the format is ARGB, we just draw the glyph from path ourselves. Other
wise, we force | 148 // if the format is ARGB, we just draw the glyph from path ourselves. Other
wise, we force |
155 // our proxy context to generate the image from paths. | 149 // our proxy context to generate the image from paths. |
156 if (!fFakeIt) { | 150 if (!fFakeIt) { |
157 if (SkMask::kARGB32_Format == glyph.fMaskFormat) { | 151 if (SkMask::kARGB32_Format == glyph.fMaskFormat) { |
158 SkPath path; | 152 SkPath path; |
159 fProxy->getPath(glyph, &path); | 153 fProxy->getPath(glyph, &path); |
160 | 154 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 243 |
250 int SkRandomTypeface::onGetTableTags(SkFontTableTag tags[]) const { | 244 int SkRandomTypeface::onGetTableTags(SkFontTableTag tags[]) const { |
251 return fProxy->getTableTags(tags); | 245 return fProxy->getTableTags(tags); |
252 } | 246 } |
253 | 247 |
254 size_t SkRandomTypeface::onGetTableData(SkFontTableTag tag, size_t offset, | 248 size_t SkRandomTypeface::onGetTableData(SkFontTableTag tag, size_t offset, |
255 size_t length, void* data) const { | 249 size_t length, void* data) const { |
256 return fProxy->getTableData(tag, offset, length, data); | 250 return fProxy->getTableData(tag, offset, length, data); |
257 } | 251 } |
258 | 252 |
OLD | NEW |