 |
Flutter Impeller
|
|
Go to the documentation of this file.
10 #include "fml/status.h"
30 using VT = SolidFillVertexShader::PerVertexData;
39 count *
sizeof(VT),
alignof(VT),
40 [&generator](uint8_t* buffer) {
41 auto vertices =
reinterpret_cast<VT*
>(buffer);
47 FML_DCHECK(vertices ==
reinterpret_cast<VT*
>(buffer) +
50 .vertex_count = count,
60 const Matrix& uv_transform,
63 using VT = TextureFillVertexShader::PerVertexData;
72 count *
sizeof(VT),
alignof(VT),
73 [&generator, &uv_transform](uint8_t* buffer) {
74 auto vertices =
reinterpret_cast<VT*
>(buffer);
76 [&vertices, &uv_transform](
const Point& p) {
79 .texture_coords = uv_transform * p,
82 FML_DCHECK(vertices ==
reinterpret_cast<VT*
>(buffer) +
85 .vertex_count = count,
96 Size texture_coverage,
101 [&vertex_builder, &texture_coverage, &effect_transform,
102 &texture_origin](SolidFillVertexShader::PerVertexData old_vtx) {
103 TextureFillVertexShader::PerVertexData data;
104 data.position = old_vtx.position;
105 data.texture_coords = effect_transform *
106 (old_vtx.position - texture_origin) /
110 return vertex_builder;
140 for (
auto i = 0u, j = 0u; i < 8; i += 2, j++) {
145 data[i + 1] = uv_transform * points[j];
152 .vertex_buffer = host_buffer.Emplace(
177 std::optional<Rect> inner_rect) {
178 return std::make_shared<FillPathGeometry>(path, inner_rect);
184 return std::make_shared<PointFieldGeometry>(std::move(points), radius, round);
193 if (miter_limit < 0) {
196 return std::make_shared<StrokePathGeometry>(path,
stroke_width, miter_limit,
197 stroke_cap, stroke_join);
201 return std::make_shared<CoverGeometry>();
205 return std::make_shared<RectGeometry>(rect);
209 return std::make_shared<EllipseGeometry>(rect);
216 return std::make_shared<LineGeometry>(p0, p1, width, cap);
221 return std::make_shared<CircleGeometry>(center, radius);
227 return std::make_shared<CircleGeometry>(center, radius,
stroke_width);
232 return std::make_shared<RoundRectGeometry>(rect, radii);
@ kNormal
The geometry has no overlapping triangles.
Matrix GetShaderTransform(const RenderPass &pass) const
Get the vertex shader transform used for drawing this Entity.
static std::shared_ptr< Geometry > MakePointField(std::vector< Point > points, Scalar radius, bool round)
static std::shared_ptr< Geometry > MakeStrokedCircle(const Point ¢er, Scalar radius, Scalar stroke_width)
static std::shared_ptr< Geometry > MakeStrokePath(const Path &path, Scalar stroke_width=0.0, Scalar miter_limit=4.0, Cap stroke_cap=Cap::kButt, Join stroke_join=Join::kMiter)
static std::shared_ptr< Geometry > MakeRoundRect(const Rect &rect, const Size &radii)
size_t GetVertexCount() const
virtual bool CanApplyMaskFilter() const
BufferView Emplace(const BufferType &buffer)
Emplace non-uniform data (like contiguous vertices) onto the host buffer.
constexpr Matrix GetNormalizingTransform() const
Constructs a Matrix that will map all points in the coordinate space of the rectangle into a new norm...
virtual bool IsAxisAlignedRect() const
virtual GeometryResult::Mode GetResultMode() const
virtual bool CoversArea(const Matrix &transform, const Rect &rect) const
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
virtual void GenerateVertices(const TessellatedVertexProc &proc) const =0
Generate the vertices and deliver them in the necessary order (as required by the PrimitiveType) to t...
const Scalar stroke_width
VertexBufferBuilder< TextureFillVertexShader::PerVertexData > ComputeUVGeometryCPU(VertexBufferBuilder< SolidFillVertexShader::PerVertexData > &input, Point texture_origin, Size texture_coverage, Matrix effect_transform)
Compute UV geometry for a VBB that contains only position geometry.
constexpr std::array< TPoint< T >, 4 > GetPoints() const
Get the points that represent the 4 corners of this rectangle in a Z order that is compatible with tr...
static std::shared_ptr< Geometry > MakeOval(const Rect &rect)
static GeometryResult ComputePositionGeometry(const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Entity &entity, RenderPass &pass)
static std::shared_ptr< Geometry > MakeFillPath(const Path &path, std::optional< Rect > inner_rect=std::nullopt)
An object which produces a list of vertices as |Point|s that tessellate a previously provided shape a...
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
static GeometryResult ComputePositionUVGeometry(const ContentContext &renderer, const Tessellator::VertexGenerator &generator, const Matrix &uv_transform, const Entity &entity, RenderPass &pass)
virtual GeometryResult GetPositionUVBuffer(Rect texture_coverage, Matrix effect_transform, const ContentContext &renderer, const Entity &entity, RenderPass &pass) const =0
@ kNone
Does not use the index buffer.
void IterateVertices(const std::function< void(VertexType &)> &iterator)
Render passes encode render commands directed as one specific render target into an underlying comman...
static std::shared_ptr< Geometry > MakeRect(const Rect &rect)
virtual PrimitiveType GetTriangleType() const =0
Returns the |PrimitiveType| that describes the relationship among the list of vertices produced by th...
VertexBufferBuilder & AppendVertex(VertexType_ vertex)
virtual size_t GetVertexCount() const =0
Returns the number of vertices that the generator plans to produce, if known.
GeometryResult ComputeUVGeometryForRect(Rect source_rect, Rect texture_bounds, Matrix effect_transform, const ContentContext &renderer, const Entity &entity, RenderPass &pass)
Computes geometry and UV coordinates for a rectangle to be rendered.
static std::shared_ptr< Geometry > MakeCircle(const Point ¢er, Scalar radius)
void Reserve(size_t count)
A 4x4 matrix using column-major storage.
HostBuffer & GetTransientsBuffer() const
Retrieve the currnent host buffer for transient storage.
static std::shared_ptr< Geometry > MakeCover()
static std::shared_ptr< Geometry > MakeLine(const Point &p0, const Point &p1, Scalar width, Cap cap)