#include "src/core/SkScalerContext.h"
#include "include/core/SkColorType.h"
#include "include/core/SkDrawable.h"
#include "include/core/SkFont.h"
#include "include/core/SkFontMetrics.h"
#include "include/core/SkImageInfo.h"
#include "include/core/SkMaskFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkPath.h"
#include "include/core/SkPathEffect.h"
#include "include/core/SkPixmap.h"
#include "include/core/SkStrokeRec.h"
#include "include/private/SkColorData.h"
#include "include/private/base/SkAlign.h"
#include "include/private/base/SkCPUTypes.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkFixed.h"
#include "include/private/base/SkMalloc.h"
#include "include/private/base/SkMutex.h"
#include "include/private/base/SkTo.h"
#include "src/base/SkArenaAlloc.h"
#include "src/base/SkAutoMalloc.h"
#include "src/core/SkAutoPixmapStorage.h"
#include "src/core/SkBlitter_A8.h"
#include "src/core/SkDescriptor.h"
#include "src/core/SkDrawBase.h"
#include "src/core/SkFontPriv.h"
#include "src/core/SkGlyph.h"
#include "src/core/SkMaskFilterBase.h"
#include "src/core/SkPaintPriv.h"
#include "src/core/SkRasterClip.h"
#include "src/core/SkTextFormatParams.h"
#include "src/core/SkWriteBuffer.h"
#include "src/utils/SkMatrix22.h"
#include <algorithm>
#include <cstring>
#include <limits>
#include <new>
#include <utility>
namespace {
static inline const constexpr bool kSkShowTextBlitCoverage = …;
static inline const constexpr bool kSkScalerContextDumpRec = …;
}
SkScalerContextRec SkScalerContext::PreprocessRec(const SkTypeface& typeface,
const SkScalerContextEffects& effects,
const SkDescriptor& desc) { … }
SkScalerContext::SkScalerContext(sk_sp<SkTypeface> typeface, const SkScalerContextEffects& effects,
const SkDescriptor* desc)
: … { … }
SkScalerContext::~SkScalerContext() { … }
static SkMutex& mask_gamma_cache_mutex() { … }
static const SkMaskGamma& linear_gamma() { … }
static SkMaskGamma* gDefaultMaskGamma = …;
static SkMaskGamma* gMaskGamma = …;
static uint8_t gContrast = …;
static uint8_t gGamma = …;
const SkMaskGamma& SkScalerContextRec::CachedMaskGamma(uint8_t contrast, uint8_t gamma) { … }
SkMaskGamma::PreBlend SkScalerContext::GetMaskPreBlend(const SkScalerContextRec& rec) { … }
size_t SkScalerContext::GetGammaLUTSize(SkScalar contrast, SkScalar deviceGamma,
int* width, int* height) { … }
bool SkScalerContext::GetGammaLUTData(SkScalar contrast, SkScalar deviceGamma, uint8_t* data) { … }
SkGlyph SkScalerContext::makeGlyph(SkPackedGlyphID packedID, SkArenaAlloc* alloc) { … }
template <typename D, typename S> static constexpr D sk_saturate_cast(S s) { … }
void SkScalerContext::SaturateGlyphBounds(SkGlyph* glyph, SkRect&& r) { … }
void SkScalerContext::SaturateGlyphBounds(SkGlyph* glyph, SkIRect const & r) { … }
void SkScalerContext::GenerateMetricsFromPath(
SkGlyph* glyph, const SkPath& devPath, SkMask::Format format,
const bool verticalLCD, const bool a8FromLCD, const bool hairline)
{ … }
SkGlyph SkScalerContext::internalMakeGlyph(SkPackedGlyphID packedID, SkMask::Format format, SkArenaAlloc* alloc) { … }
static void applyLUTToA8Mask(SkMaskBuilder& mask, const uint8_t* lut) { … }
static void pack4xHToMask(const SkPixmap& src, SkMaskBuilder& dst,
const SkMaskGamma::PreBlend& maskPreBlend,
const bool doBGR, const bool doVert) { … }
static inline int convert_8_to_1(unsigned byte) { … }
static uint8_t pack_8_to_1(const uint8_t alpha[8]) { … }
static void packA8ToA1(SkMaskBuilder& dstMask, const uint8_t* src, size_t srcRB) { … }
void SkScalerContext::GenerateImageFromPath(
SkMaskBuilder& dstMask, const SkPath& path, const SkMaskGamma::PreBlend& maskPreBlend,
const bool doBGR, const bool verticalLCD, const bool a8FromLCD, const bool hairline)
{ … }
void SkScalerContext::getImage(const SkGlyph& origGlyph) { … }
void SkScalerContext::getPath(SkGlyph& glyph, SkArenaAlloc* alloc) { … }
sk_sp<SkDrawable> SkScalerContext::getDrawable(SkGlyph& glyph) { … }
sk_sp<SkDrawable> SkScalerContext::generateDrawable(const SkGlyph&) { … }
void SkScalerContext::getFontMetrics(SkFontMetrics* fm) { … }
void SkScalerContext::internalGetPath(SkGlyph& glyph, SkArenaAlloc* alloc) { … }
void SkScalerContextRec::getMatrixFrom2x2(SkMatrix* dst) const { … }
void SkScalerContextRec::getLocalMatrix(SkMatrix* m) const { … }
void SkScalerContextRec::getSingleMatrix(SkMatrix* m) const { … }
bool SkScalerContextRec::computeMatrices(PreMatrixScale preMatrixScale, SkVector* s, SkMatrix* sA,
SkMatrix* GsA, SkMatrix* G_inv, SkMatrix* A_out)
{ … }
SkAxisAlignment SkScalerContext::computeAxisAlignmentForHText() const { … }
SkAxisAlignment SkScalerContextRec::computeAxisAlignmentForHText() const { … }
void SkScalerContextRec::setLuminanceColor(SkColor c) { … }
void SkScalerContextRec::useStrokeForFakeBold() { … }
static SkScalar sk_relax(SkScalar x) { … }
static SkMask::Format compute_mask_format(const SkFont& font) { … }
#ifndef SK_MAX_SIZE_FOR_LCDTEXT
#define SK_MAX_SIZE_FOR_LCDTEXT …
#endif
const SkScalar gMaxSize2ForLCDText = …;
static bool too_big_for_lcd(const SkScalerContextRec& rec, bool checkPost2x2) { … }
void SkScalerContext::MakeRecAndEffects(const SkFont& font, const SkPaint& paint,
const SkSurfaceProps& surfaceProps,
SkScalerContextFlags scalerContextFlags,
const SkMatrix& deviceMatrix,
SkScalerContextRec* rec,
SkScalerContextEffects* effects) { … }
SkDescriptor* SkScalerContext::CreateDescriptorAndEffectsUsingPaint(
const SkFont& font, const SkPaint& paint, const SkSurfaceProps& surfaceProps,
SkScalerContextFlags scalerContextFlags, const SkMatrix& deviceMatrix, SkAutoDescriptor* ad,
SkScalerContextEffects* effects)
{ … }
static size_t calculate_size_and_flatten(const SkScalerContextRec& rec,
const SkScalerContextEffects& effects,
SkBinaryWriteBuffer* effectBuffer) { … }
static void generate_descriptor(const SkScalerContextRec& rec,
const SkBinaryWriteBuffer& effectBuffer,
SkDescriptor* desc) { … }
SkDescriptor* SkScalerContext::AutoDescriptorGivenRecAndEffects(
const SkScalerContextRec& rec,
const SkScalerContextEffects& effects,
SkAutoDescriptor* ad)
{ … }
std::unique_ptr<SkDescriptor> SkScalerContext::DescriptorGivenRecAndEffects(
const SkScalerContextRec& rec,
const SkScalerContextEffects& effects)
{ … }
void SkScalerContext::DescriptorBufferGiveRec(const SkScalerContextRec& rec, void* buffer) { … }
bool SkScalerContext::CheckBufferSizeForRec(const SkScalerContextRec& rec,
const SkScalerContextEffects& effects,
size_t size) { … }
std::unique_ptr<SkScalerContext> SkScalerContext::MakeEmpty(
sk_sp<SkTypeface> typeface, const SkScalerContextEffects& effects,
const SkDescriptor* desc) { … }