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