Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
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]
uint32_t GrColor
Definition GrColor.h:25
SkColor4f color
static SkPath clip(const SkPath &path, const SkHalfPlane &plane)
Definition SkPath.cpp:3824
constexpr int SkCount(const Container &c)
Definition SkTLogic.h:54
Type::kYUV Type::kRGBA() int(0.7 *637)
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
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
void fillInstanceData(skgpu::graphite::DrawWriter *dw, int offset, int count, unsigned short flags, skvx::ushort2 ssboIndex, SkSpan< const Glyph * > glyphs, SkScalar depth) const
float SkScalar
Definition extension.cpp:12
FlutterSemanticsFlag flags
static const uint8_t buffer[]
TRect< Scalar > Rect
Definition rect.h:746
skgpu::graphite::Transform Transform
Point offset