Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
fill_path_geometry.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
6
7#include "fml/logging.h"
12
13namespace impeller {
14
16 std::optional<Rect> inner_rect)
17 : path_(path), inner_rect_(inner_rect) {}
18
20 const ContentContext& renderer,
21 const Entity& entity,
22 RenderPass& pass) const {
23 auto& host_buffer = renderer.GetTransientsBuffer();
24
25 const auto& bounding_box = path_.GetBoundingBox();
26 if (bounding_box.has_value() && bounding_box->IsEmpty()) {
27 return GeometryResult{
29 .vertex_buffer =
31 .vertex_buffer = {},
32 .vertex_count = 0,
33 .index_type = IndexType::k16bit,
34 },
35 .transform = pass.GetOrthographicTransform() * entity.GetTransform(),
36 };
37 }
38
39 VertexBuffer vertex_buffer;
40
41 auto points = renderer.GetTessellator()->TessellateConvex(
42 path_, entity.GetTransform().GetMaxBasisLength());
43
44 vertex_buffer.vertex_buffer = host_buffer.Emplace(
45 points.data(), points.size() * sizeof(Point), alignof(Point));
46 vertex_buffer.index_buffer = {}, vertex_buffer.vertex_count = points.size();
47 vertex_buffer.index_type = IndexType::kNone;
48
49 return GeometryResult{
51 .vertex_buffer = vertex_buffer,
52 .transform = entity.GetShaderTransform(pass),
53 .mode = GetResultMode(),
54 };
55}
56
58 const auto& bounding_box = path_.GetBoundingBox();
59 if (path_.IsConvex() ||
60 (bounding_box.has_value() && bounding_box->IsEmpty())) {
62 }
63
64 switch (path_.GetFillType()) {
67 case FillType::kOdd:
69 }
70
72}
73
75 const Matrix& transform) const {
77}
78
80 const Rect& rect) const {
81 if (!inner_rect_.has_value()) {
82 return false;
83 }
84 if (!transform.IsTranslationScaleOnly()) {
85 return false;
86 }
87 Rect coverage = inner_rect_->TransformBounds(transform);
88 return coverage.Contains(rect);
89}
90
91} // namespace impeller
static const int points[]
Matrix GetShaderTransform(const RenderPass &pass) const
Get the vertex shader transform used for drawing this Entity.
Definition entity.cc:50
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
Definition entity.cc:46
std::optional< Rect > GetCoverage(const Matrix &transform) const override
bool CoversArea(const Matrix &transform, const Rect &rect) const override
Determines if this geometry, transformed by the given transform, will completely cover all surface ar...
GeometryResult::Mode GetResultMode() const override
FillPathGeometry(const Path &path, std::optional< Rect > inner_rect=std::nullopt)
GeometryResult GetPositionBuffer(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
Definition path.h:51
FillType GetFillType() const
Definition path.cc:51
std::optional< Rect > GetTransformedBoundingBox(const Matrix &transform) const
Definition path.cc:343
bool IsConvex() const
Definition path.cc:55
std::optional< Rect > GetBoundingBox() const
Definition path.cc:339
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:33
const Matrix & GetOrthographicTransform() const
#define FML_UNREACHABLE()
Definition logging.h:109
@ kNone
Does not use the index buffer.
static SkColor4f transform(SkColor4f c, SkColorSpace *src, SkColorSpace *dst)
Definition p3.cpp:47
PrimitiveType type
Definition geometry.h:35
@ kNormal
The geometry has no overlapping triangles.
A 4x4 matrix using column-major storage.
Definition matrix.h:37
Scalar GetMaxBasisLength() const
Definition matrix.cc:196
BufferView index_buffer
The index buffer binding used by the vertex shader stage.