blob: b71689d9e2d18a216fd72a612ec39eb4665735a9 [file] [log] [blame]
joshualittaa2f6582015-07-29 10:14:58 -07001/*
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
19class SkRandomTypeface : public SkTypeface {
20public:
bungeman13b9c952016-05-12 10:09:30 -070021 SkRandomTypeface(sk_sp<SkTypeface> proxy, const SkPaint&, bool fakeit);
joshualittaa2f6582015-07-29 10:14:58 -070022
bungeman13b9c952016-05-12 10:09:30 -070023 SkTypeface* proxy() const { return fProxy.get(); }
joshualittaa2f6582015-07-29 10:14:58 -070024 const SkPaint& paint() const { return fPaint; }
25
26protected:
reeda9322c22016-04-12 06:47:05 -070027 SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
28 const SkDescriptor*) const override;
joshualittaa2f6582015-07-29 10:14:58 -070029 void onFilterRec(SkScalerContextRec*) const override;
Hal Canary209e4b12017-05-04 14:23:55 -040030 std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override;
joshualittaa2f6582015-07-29 10:14:58 -070031 SkStreamAsset* onOpenStream(int* ttcIndex) const override;
32 void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const override;
33
34 int onCharsToGlyphs(const void* chars, Encoding encoding,
35 uint16_t glyphs[], int glyphCount) const override;
36 int onCountGlyphs() const override;
37 int onGetUPEM() const override;
38
39 void onGetFamilyName(SkString* familyName) const override;
40 SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
41
Ben Wagnerfc497342017-02-24 11:15:26 -050042 int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],
43 int coordinateCount) const override;
joshualittaa2f6582015-07-29 10:14:58 -070044 int onGetTableTags(SkFontTableTag tags[]) const override;
45 size_t onGetTableData(SkFontTableTag, size_t offset,
46 size_t length, void* data) const override;
47
48private:
bungeman13b9c952016-05-12 10:09:30 -070049 sk_sp<SkTypeface> fProxy;
50 SkPaint fPaint;
51 bool fFakeIt;
joshualittaa2f6582015-07-29 10:14:58 -070052};
53
54#endif