Flutter Engine
The Flutter Engine
VertexFiller.h
Go to the documentation of this file.
1/*
2* Copyright 2023 Google LLC
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#ifndef sktext_gpu_VertexFiller_DEFINED
8#define sktext_gpu_VertexFiller_DEFINED
9
12#include "include/core/SkRect.h"
14#include "include/core/SkSpan.h"
17#include "src/base/SkVx.h"
18
19#include <cstddef>
20#include <optional>
21#include <tuple>
22
23class SkReadBuffer;
24class SkWriteBuffer;
25
26#if defined(SK_GANESH) || defined(SK_USE_LEGACY_GANESH_TEXT_APIS)
29#endif // defined(SK_GANESH) || defined(SK_USE_LEGACY_GANESH_TEXT_APIS)
30
31namespace skgpu {
32enum class MaskFormat : int;
33
34namespace graphite {
35class DrawWriter;
36class Rect;
37class Transform;
38}
39}
40
41namespace sktext::gpu {
42class Glyph;
43class SubRunAllocator;
44
48};
49
50// -- VertexFiller ---------------------------------------------------------------------------------
51// The VertexFiller assumes that all points, glyph atlas entries, and bounds are created with
52// respect to the CreationMatrix. This assumes that mapping any point, mask or bounds through the
53// CreationMatrix will result in the proper device position. In order to draw using an arbitrary
54// PositionMatrix, calculate a
55//
56// viewDifference = [PositionMatrix] * [CreationMatrix] ^ -1.
57//
58// The viewDifference is used to map all points, masks and bounds to position to the device
59// respecting the PositionMatrix.
61public:
63 const SkMatrix &creationMatrix,
64 SkRect creationBounds,
66 bool canDrawDirect);
67
68 static VertexFiller Make(skgpu::MaskFormat maskType,
69 const SkMatrix &creationMatrix,
70 SkRect creationBounds,
71 SkSpan<const SkPoint> positions,
72 SubRunAllocator *alloc,
73 FillerType fillerType);
74
75 static std::optional<VertexFiller> MakeFromBuffer(SkReadBuffer &buffer,
76 SubRunAllocator *alloc);
77
78 int unflattenSize() const { return fLeftTop.size_bytes(); }
79
80 void flatten(SkWriteBuffer &buffer) const;
81
82#if defined(SK_GANESH) || defined(SK_USE_LEGACY_GANESH_TEXT_APIS)
83 size_t vertexStride(const SkMatrix &matrix) const;
84
85 void fillVertexData(int offset, int count,
88 const SkMatrix& positionMatrix,
90 void* vertexBuffer) const;
91
92 skgpu::ganesh::AtlasTextOp::MaskType opMaskType() const;
93#endif // defined(SK_GANESH) || defined(SK_USE_LEGACY_GANESH_TEXT_APIS)
94
95 // This is only available if the graphite backend is compiled in (see GraphiteVertexFiller.cpp)
97 int offset, int count,
98 unsigned short flags,
99 skvx::ushort2 ssboIndex,
101 SkScalar depth) const;
102
103 std::tuple<skgpu::graphite::Rect, skgpu::graphite::Transform> boundsAndDeviceMatrix(
104 const skgpu::graphite::Transform& localToDevice, SkPoint drawOrigin) const;
105
106 // Return true if the positionMatrix represents an integer translation. Return the device
107 // bounding box of all the glyphs. If the bounding box is empty, then something went singular
108 // and this operation should be dropped.
109 std::tuple<bool, SkRect> deviceRectAndCheckTransform(const SkMatrix &positionMatrix) const;
110
111 skgpu::MaskFormat grMaskType() const { return fMaskType; }
112 bool isLCD() const;
113
114 int count() const { return SkCount(fLeftTop); }
115
116private:
117 SkMatrix viewDifference(const SkMatrix &positionMatrix) const;
118
119 const skgpu::MaskFormat fMaskType;
120 const bool fCanDrawDirect;
121 const SkMatrix fCreationMatrix;
122 const SkRect fCreationBounds;
123 const SkSpan<const SkPoint> fLeftTop;
124};
125
126} // namespace sktext::gpu
127
128#endif
uint16_t glyphs[5]
Definition: FontMgrTest.cpp:46
uint32_t GrColor
Definition: GrColor.h:25
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition: SkPath.cpp:3892
constexpr int SkCount(const Container &c)
Definition: SkTLogic.h:54
static std::optional< VertexFiller > MakeFromBuffer(SkReadBuffer &buffer, SubRunAllocator *alloc)
static VertexFiller Make(skgpu::MaskFormat maskType, const SkMatrix &creationMatrix, SkRect creationBounds, SkSpan< const SkPoint > positions, SubRunAllocator *alloc, FillerType fillerType)
skgpu::MaskFormat grMaskType() const
Definition: VertexFiller.h:111
std::tuple< bool, SkRect > deviceRectAndCheckTransform(const SkMatrix &positionMatrix) const
void flatten(SkWriteBuffer &buffer) const
std::tuple< skgpu::graphite::Rect, skgpu::graphite::Transform > boundsAndDeviceMatrix(const skgpu::graphite::Transform &localToDevice, SkPoint drawOrigin) const
VertexFiller(skgpu::MaskFormat maskFormat, const SkMatrix &creationMatrix, SkRect creationBounds, SkSpan< const SkPoint > leftTop, bool canDrawDirect)
void fillInstanceData(skgpu::graphite::DrawWriter *dw, int offset, int count, unsigned short flags, skvx::ushort2 ssboIndex, SkSpan< const Glyph * > glyphs, SkScalar depth) const
DlColor color
float SkScalar
Definition: extension.cpp:12
FlutterSemanticsFlag flags
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
TRect< Scalar > Rect
Definition: rect.h:769
Definition: GpuTools.h:21
MaskFormat
Definition: AtlasTypes.h:98
skgpu::graphite::Transform Transform
SeparatedVector2 offset
Definition: SkRect.h:32
Definition: SkVx.h:83