Flutter Engine
The Flutter Engine
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
Definition: SkFont.h:35
std::tuple< SkFont, SkScalar, SDFTMatrixRange > getSDFFont(const SkFont &font, const SkMatrix &viewMatrix, const SkPoint &textLocation) const
Definition: SDFTControl.cpp:83
bool isSDFT(SkScalar approximateDeviceTextSize, const SkPaint &paint, const SkMatrix &matrix) const
Definition: SDFTControl.cpp:69
SkScalar maxSize() const
Definition: SDFTControl.h:54
SDFTControl(bool ableToUseSDFT, bool useSDFTForSmallText, bool useSDFTForPerspectiveText, SkScalar min, SkScalar max)
Definition: SDFTControl.cpp:44
bool isDirect(SkScalar approximateDeviceTextSize, const SkPaint &paint, const SkMatrix &matrix) const
Definition: SDFTControl.cpp:55
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
Definition: color_source.cc:38
float SkScalar
Definition: extension.cpp:12
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
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
font
Font Metadata and Metrics.