Flutter Engine
The Flutter Engine
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
19GeometryResult FillPathGeometry::GetPositionBuffer(
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 = renderer.GetTessellator()->TessellateConvex(
40 path_, host_buffer, entity.GetTransform().GetMaxBasisLength());
41
42 return GeometryResult{
44 .vertex_buffer = vertex_buffer,
45 .transform = entity.GetShaderTransform(pass),
46 .mode = GetResultMode(),
47 };
48}
49
50GeometryResult::Mode FillPathGeometry::GetResultMode() const {
51 const auto& bounding_box = path_.GetBoundingBox();
52 if (path_.IsConvex() ||
53 (bounding_box.has_value() && bounding_box->IsEmpty())) {
55 }
56
57 switch (path_.GetFillType()) {
60 case FillType::kOdd:
62 }
63
65}
66
67std::optional<Rect> FillPathGeometry::GetCoverage(
68 const Matrix& transform) const {
70}
71
73 const Rect& rect) const {
74 if (!inner_rect_.has_value()) {
75 return false;
76 }
77 if (!transform.IsTranslationScaleOnly()) {
78 return false;
79 }
80 Rect coverage = inner_rect_->TransformBounds(transform);
81 return coverage.Contains(rect);
82}
83
84} // namespace impeller
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
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...
FillPathGeometry(const Path &path, std::optional< Rect > inner_rect=std::nullopt)
Paths are lightweight objects that describe a collection of linear, quadratic, or cubic segments....
Definition: path.h:52
FillType GetFillType() const
Definition: path.cc:51
std::optional< Rect > GetTransformedBoundingBox(const Matrix &transform) const
Definition: path.cc:409
bool IsConvex() const
Definition: path.cc:55
std::optional< Rect > GetBoundingBox() const
Definition: path.cc:405
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
const Matrix & GetOrthographicTransform() const
Definition: render_pass.cc:47
#define FML_UNREACHABLE()
Definition: logging.h:109
sk_sp< SkBlender > blender SkRect rect
Definition: SkRecords.h:350
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
Definition: switches.h:57
SK_API sk_sp< PrecompileColorFilter > Matrix()
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