2015-07-29 17:14:58 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-03-20 16:08:46 +00:00
|
|
|
#ifndef RandomScalerContext_DEFINED
|
|
|
|
#define RandomScalerContext_DEFINED
|
2015-07-29 17:14:58 +00:00
|
|
|
|
|
|
|
#include "SkScalerContext.h"
|
|
|
|
#include "SkTypeface.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This scaler context is for debug only purposes. It will 'randomly' but deterministically return
|
|
|
|
* LCD / A8 / BW / RBGA masks based off of the Glyph ID
|
|
|
|
*/
|
|
|
|
|
|
|
|
class SkRandomTypeface : public SkTypeface {
|
|
|
|
public:
|
2016-05-12 17:09:30 +00:00
|
|
|
SkRandomTypeface(sk_sp<SkTypeface> proxy, const SkPaint&, bool fakeit);
|
2015-07-29 17:14:58 +00:00
|
|
|
|
2019-03-20 16:08:46 +00:00
|
|
|
SkTypeface* proxy() const { return fProxy.get(); }
|
2015-07-29 17:14:58 +00:00
|
|
|
const SkPaint& paint() const { return fPaint; }
|
|
|
|
|
|
|
|
protected:
|
2019-03-20 16:08:46 +00:00
|
|
|
SkScalerContext* onCreateScalerContext(const SkScalerContextEffects&,
|
|
|
|
const SkDescriptor*) const override;
|
|
|
|
void onFilterRec(SkScalerContextRec*) const override;
|
|
|
|
void getGlyphToUnicodeMap(SkUnichar*) const override;
|
2017-05-04 18:23:55 +00:00
|
|
|
std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override;
|
2019-03-20 16:08:46 +00:00
|
|
|
std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override;
|
2018-06-25 15:37:25 +00:00
|
|
|
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override;
|
2019-03-20 16:08:46 +00:00
|
|
|
void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const override;
|
2015-07-29 17:14:58 +00:00
|
|
|
|
2019-03-20 16:08:46 +00:00
|
|
|
int onCharsToGlyphs(const void* chars,
|
|
|
|
Encoding encoding,
|
|
|
|
uint16_t glyphs[],
|
|
|
|
int glyphCount) const override;
|
2015-07-29 17:14:58 +00:00
|
|
|
int onCountGlyphs() const override;
|
|
|
|
int onGetUPEM() const override;
|
|
|
|
|
2019-03-20 16:08:46 +00:00
|
|
|
void onGetFamilyName(SkString* familyName) const override;
|
2015-07-29 17:14:58 +00:00
|
|
|
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
|
|
|
|
|
2017-02-24 16:15:26 +00:00
|
|
|
int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],
|
|
|
|
int coordinateCount) const override;
|
2018-06-26 15:22:37 +00:00
|
|
|
int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],
|
|
|
|
int parameterCount) const override;
|
2015-07-29 17:14:58 +00:00
|
|
|
int onGetTableTags(SkFontTableTag tags[]) const override;
|
2019-03-20 16:08:46 +00:00
|
|
|
size_t onGetTableData(SkFontTableTag, size_t offset, size_t length, void* data) const override;
|
2015-07-29 17:14:58 +00:00
|
|
|
|
|
|
|
private:
|
2019-03-20 16:08:46 +00:00
|
|
|
sk_sp<SkTypeface> fProxy;
|
|
|
|
SkPaint fPaint;
|
|
|
|
bool fFakeIt;
|
2015-07-29 17:14:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|