skia2/tools/fonts/RandomScalerContext.h
Dominik Röttsches 8be6332748 Serialize foreground color caching requirement specialisation
Add a getter to SkTypeface to provide information on whether it
needs access to the foreground color (in COLR fonts) so that the
strike cache can determine caching requirements.

Since remote SkTypefaces do not have access to table information,
implement this as a serializable flag, with font-blob backed
implementations being able to return this based on whether they
have a COLR table or not, starting with FreeType.

Preparation for supporting foreground color in FreeType COLR
rasterisation.

Bug: skia:12576
Change-Id: I7e71b0ec12e17f652ab7b43adffc43bc780ce2e7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/466936
Reviewed-by: Ben Wagner <bungeman@google.com>
Reviewed-by: Derek Sollenberger <djsollen@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Ben Wagner <bungeman@google.com>
2021-11-03 19:56:47 +00:00

61 lines
2.4 KiB
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef RandomScalerContext_DEFINED
#define RandomScalerContext_DEFINED
#include "include/core/SkTypeface.h"
#include "src/core/SkScalerContext.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:
SkRandomTypeface(sk_sp<SkTypeface> proxy, const SkPaint&, bool fakeit);
SkTypeface* proxy() const { return fProxy.get(); }
const SkPaint& paint() const { return fPaint; }
protected:
std::unique_ptr<SkScalerContext> onCreateScalerContext(const SkScalerContextEffects&,
const SkDescriptor*) const override;
void onFilterRec(SkScalerContextRec*) const override;
void getGlyphToUnicodeMap(SkUnichar*) const override;
std::unique_ptr<SkAdvancedTypefaceMetrics> onGetAdvancedMetrics() const override;
std::unique_ptr<SkStreamAsset> onOpenStream(int* ttcIndex) const override;
sk_sp<SkTypeface> onMakeClone(const SkFontArguments& args) const override;
void onGetFontDescriptor(SkFontDescriptor*, bool* isLocal) const override;
void onCharsToGlyphs(const SkUnichar* chars, int count, SkGlyphID glyphs[]) const override;
int onCountGlyphs() const override;
int onGetUPEM() const override;
void onGetFamilyName(SkString* familyName) const override;
bool onGetPostScriptName(SkString*) const override;
SkTypeface::LocalizedStrings* onCreateFamilyNameIterator() const override;
void getPostScriptGlyphNames(SkString*) const override;
bool onGlyphMaskNeedsCurrentColor() const override { return false; }
int onGetVariationDesignPosition(SkFontArguments::VariationPosition::Coordinate coordinates[],
int coordinateCount) const override;
int onGetVariationDesignParameters(SkFontParameters::Variation::Axis parameters[],
int parameterCount) const override;
int onGetTableTags(SkFontTableTag tags[]) const override;
size_t onGetTableData(SkFontTableTag, size_t offset, size_t length, void* data) const override;
private:
sk_sp<SkTypeface> fProxy;
SkPaint fPaint;
bool fFakeIt;
};
#endif