Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
SDFTControl.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 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 sktext_gpu_SDFTControl_DEFINED
9#define sktext_gpu_SDFTControl_DEFINED
10
13
14#include <tuple>
15
16class SkFont;
17class SkMatrix;
18class SkPaint;
19class SkReadBuffer;
20class SkWriteBuffer;
21struct SkPoint;
22
23namespace sktext::gpu {
24
25#if !defined(SK_DISABLE_SDF_TEXT)
26// Two numbers fMatrixMin and fMatrixMax such that if viewMatrix.getMaxScale() is between them then
27// this SDFT size can be reused.
29public:
30 SDFTMatrixRange(SkScalar min, SkScalar max) : fMatrixMin{min}, fMatrixMax{max} {}
31 bool matrixInRange(const SkMatrix& matrix) const;
32 void flatten(SkWriteBuffer& buffer) const;
34
35private:
36 const SkScalar fMatrixMin,
37 fMatrixMax;
38};
39#endif
40
42public:
43#if !defined(SK_DISABLE_SDF_TEXT)
44 SDFTControl(bool ableToUseSDFT, bool useSDFTForSmallText, bool useSDFTForPerspectiveText,
46
47 // Produce a font, a scale factor from the nominal size to the source space size, and matrix
48 // range where this font can be reused.
49 std::tuple<SkFont, SkScalar, SDFTMatrixRange>
50 getSDFFont(const SkFont& font, const SkMatrix& viewMatrix, const SkPoint& textLocation) const;
51
52 bool isSDFT(SkScalar approximateDeviceTextSize, const SkPaint& paint,
53 const SkMatrix& matrix) const;
54 SkScalar maxSize() const { return fMaxDistanceFieldFontSize; }
55#else
56 SDFTControl() {}
57#endif
58 bool isDirect(SkScalar approximateDeviceTextSize, const SkPaint& paint,
59 const SkMatrix& matrix) const;
60
61
62private:
63#if !defined(SK_DISABLE_SDF_TEXT)
64 static SkScalar MinSDFTRange(bool useSDFTForSmallText, SkScalar min);
65
66 // Below this size (in device space) distance field text will not be used.
67 const SkScalar fMinDistanceFieldFontSize;
68
69 // Above this size (in device space) distance field text will not be used and glyphs will
70 // be rendered from outline as individual paths.
71 const SkScalar fMaxDistanceFieldFontSize;
72
73 const bool fAbleToUseSDFT;
74 const bool fAbleToUsePerspectiveSDFT;
75#endif
76};
77
78} // namespace sktext::gpu
79
80#endif // sktext_SDFTControl_DEFINED
std::tuple< SkFont, SkScalar, SDFTMatrixRange > getSDFFont(const SkFont &font, const SkMatrix &viewMatrix, const SkPoint &textLocation) const
bool isSDFT(SkScalar approximateDeviceTextSize, const SkPaint &paint, const SkMatrix &matrix) const
SkScalar maxSize() const
Definition SDFTControl.h:54
bool isDirect(SkScalar approximateDeviceTextSize, const SkPaint &paint, const SkMatrix &matrix) const
SDFTMatrixRange(SkScalar min, SkScalar max)
Definition SDFTControl.h:30
static SDFTMatrixRange MakeFromBuffer(SkReadBuffer &buffer)
bool matrixInRange(const SkMatrix &matrix) const
void flatten(SkWriteBuffer &buffer) const
const Paint & paint
float SkScalar
Definition extension.cpp:12
static const uint8_t buffer[]
static float max(float r, float g, float b)
Definition hsl.cpp:49
static float min(float r, float g, float b)
Definition hsl.cpp:48