joshualitt | aa2f658 | 2015-07-29 10:14:58 -0700 | [diff] [blame] | 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 | #ifndef SkRandomScalerContext_DEFINED |
| 9 | #define SkRandomScalerContext_DEFINED |
| 10 | |
| 11 | #include "SkScalerContext.h" |
| 12 | #include "SkTypeface.h" |
| 13 | |
| 14 | /* |
| 15 | * This scaler context is for debug only purposes. It will 'randomly' but deterministically return |
| 16 | * LCD / A8 / BW / RBGA masks based off of the Glyph ID |
| 17 | */ |
| 18 | |
| 19 | class SkRandomTypeface : public SkTypeface { |
| 20 | public: |
bungeman | 13b9c95 | 2016-05-12 10:09:30 -0700 | [diff] [blame] | 21 | SkRandomTypeface(sk_sp<SkTypeface> proxy, const SkPaint&, bool fakeit); |
joshualitt | aa2f658 | 2015-07-29 10:14:58 -0700 | [diff] [blame] | 22 | |
bungeman | 13b9c95 | 2016-05-12 10:09:30 -0700 | [diff] [blame] | 23 | SkTypeface* proxy() const { return fProxy.get(); } |
joshualitt | aa2f658 | 2015-07-29 10:14:58 -0700 | [diff] [blame] | 24 | const SkPaint& paint() const { return fPaint; } |
| 25 | |
| 26 | protected: |
reed | a9322c2 | 2016-04-12 06:47:05 -0700 | [diff] [blame] | 27 | SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&, |
| 28 | const SkDescriptor*) const override; |
joshualitt | aa2f658 | 2015-07-29 10:14:58 -0700 | [diff] [blame] | 29 | void onFilterRec(SkScalerContextRec*) const override; |
Hal Canary | 46cc3da | 2018-05-09 11:50:34 -0400 | [diff] [blame] | 30 | void getGlyphToUnicodeMap(SkUnichar*) const override; |
Hal Canary | 209e4b1 | 2017-05-04 14:23:55 -0400 | [diff] [blame] | 31 | std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override; |
joshualitt | aa2f658 | 2015-07-29 10:14:58 -0700 | [diff] [blame] | 32 | SkStreamAsset* onOpenStream(int* ttcIndex) const override; |
Bruce Wang | 536ad2c | 2018-06-25 11:37:25 -0400 | [diff] [blame] | 33 | sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override; |
joshualitt | aa2f658 | 2015-07-29 10:14:58 -0700 | [diff] [blame] | 34 | void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const override; |
| 35 | |
| 36 | int onCharsToGlyphs(const void* chars, Encoding encoding, |
| 37 | uint16_t glyphs[], int glyphCount) const override; |
| 38 | int onCountGlyphs() const override; |
| 39 | int onGetUPEM() const override; |
| 40 | |
| 41 | void onGetFamilyName(SkString* familyName) const override; |
| 42 | SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override; |
| 43 | |
Ben Wagner | fc49734 | 2017-02-24 11:15:26 -0500 | [diff] [blame] | 44 | int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[], |
| 45 | int coordinateCount) const override; |
Ben Wagner | e346b1e | 2018-06-26 11:22:37 -0400 | [diff] [blame] | 46 | int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[], |
| 47 | int parameterCount) const override; |
joshualitt | aa2f658 | 2015-07-29 10:14:58 -0700 | [diff] [blame] | 48 | int onGetTableTags(SkFontTableTag tags[]) const override; |
| 49 | size_t onGetTableData(SkFontTableTag, size_t offset, |
| 50 | size_t length, void* data) const override; |
| 51 | |
| 52 | private: |
bungeman | 13b9c95 | 2016-05-12 10:09:30 -0700 | [diff] [blame] | 53 | sk_sp<SkTypeface> fProxy; |
| 54 | SkPaint fPaint; |
| 55 | bool fFakeIt; |
joshualitt | aa2f658 | 2015-07-29 10:14:58 -0700 | [diff] [blame] | 56 | }; |
| 57 | |
| 58 | #endif |