• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:
21     SkRandomTypeface(sk_sp<SkTypeface> proxy, const SkPaint&, bool fakeit);
22 
proxy()23     SkTypeface* proxy() const { return fProxy.get(); }
paint()24     const SkPaint& paint() const { return fPaint; }
25 
26 protected:
27     SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
28                                            const SkDescriptor*) const override;
29     void onFilterRec(SkScalerContextRec*) const override;
30     SkAdvancedTypefaceMetrics* onGetAdvancedTypefaceMetrics(
31         PerGlyphInfo,
32         const uint32_t* glyphIDs,
33         uint32_t glyphIDsCount) const override;
34     SkStreamAsset* onOpenStream(int* ttcIndex) const override;
35     void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const override;
36 
37     int onCharsToGlyphs(const void* chars, Encoding encoding,
38                         uint16_t glyphs[], int glyphCount) const override;
39     int onCountGlyphs() const override;
40     int onGetUPEM() const override;
41 
42     void onGetFamilyName(SkString* familyName) const override;
43     SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
44 
45     int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],
46                                      int coordinateCount) const override;
47     int onGetTableTags(SkFontTableTag tags[]) const override;
48     size_t onGetTableData(SkFontTableTag, size_t offset,
49                           size_t length, void* data) const override;
50 
51 private:
52     sk_sp<SkTypeface>   fProxy;
53     SkPaint             fPaint;
54     bool                fFakeIt;
55 };
56 
57 #endif
58