| Flutter Impeller |

vertices_contents.h
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
5 #ifndef FLUTTER_IMPELLER_ENTITY_CONTENTS_VERTICES_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_VERTICES_CONTENTS_H_
7
8 #include <functional>
9 #include <memory>
10 #include <vector>
11
12 #include "flutter/fml/macros.h"
13 #include "impeller/core/sampler_descriptor.h"
14 #include "impeller/entity/contents/contents.h"
15 #include "impeller/entity/entity.h"
16 #include "impeller/entity/geometry/geometry.h"
17 #include "impeller/entity/geometry/vertices_geometry.h"
18 #include "impeller/geometry/color.h"
19 #include "impeller/geometry/path.h"
20 #include "impeller/geometry/point.h"
21
22 namespace impeller {
23
24 class VerticesContents final : public Contents {
25 public:
26 VerticesContents();
27
28 ~VerticesContents() override;
29
30 void SetGeometry(std::shared_ptr<VerticesGeometry> geometry);
31
32 void SetAlpha(Scalar alpha);
33
34 void SetBlendMode(BlendMode blend_mode);
35
36 void SetSourceContents(std::shared_ptr<Contents> contents);
37
38 std::shared_ptr<VerticesGeometry> GetGeometry() const;
39
40 const std::shared_ptr<Contents>& GetSourceContents() const;
41
42 // |Contents|
43 std::optional<Rect> GetCoverage(const Entity& entity) const override;
44
45 // |Contents|
46 bool Render(const ContentContext& renderer,
47 const Entity& entity,
48 RenderPass& pass) const override;
49
50 private:
51 Scalar alpha_;
52 std::shared_ptr<VerticesGeometry> geometry_;
53 BlendMode blend_mode_ = BlendMode::kSource;
54 std::shared_ptr<Contents> src_contents_;
55
56 VerticesContents(const VerticesContents&) = delete;
57
58 VerticesContents& operator=(const VerticesContents&) = delete;
59 };
60
61 class VerticesColorContents final : public Contents {
62 public:
63 explicit VerticesColorContents(const VerticesContents& parent);
64
65 ~VerticesColorContents() override;
66
67 // |Contents|
68 std::optional<Rect> GetCoverage(const Entity& entity) const override;
69
70 // |Contents|
71 bool Render(const ContentContext& renderer,
72 const Entity& entity,
73 RenderPass& pass) const override;
74
75 void SetAlpha(Scalar alpha);
76
77 private:
78 const VerticesContents& parent_;
79 Scalar alpha_ = 1.0;
80
81 VerticesColorContents(const VerticesColorContents&) = delete;
82
83 VerticesColorContents& operator=(const VerticesColorContents&) = delete;
84 };
85
86 class VerticesUVContents final : public Contents {
87 public:
88 explicit VerticesUVContents(const VerticesContents& parent);
89
90 ~VerticesUVContents() override;
91
92 // |Contents|
93 std::optional<Rect> GetCoverage(const Entity& entity) const override;
94
95 // |Contents|
96 bool Render(const ContentContext& renderer,
97 const Entity& entity,
98 RenderPass& pass) const override;
99
100 void SetAlpha(Scalar alpha);
101
102 private:
103 const VerticesContents& parent_;
104 Scalar alpha_ = 1.0;
105
106 VerticesUVContents(const VerticesUVContents&) = delete;
107
108 VerticesUVContents& operator=(const VerticesUVContents&) = delete;
109 };
110
111 } // namespace impeller
112
113 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_VERTICES_CONTENTS_H_
impeller::VerticesContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: vertices_contents.cc:48
impeller::VerticesColorContents::~VerticesColorContents
~VerticesColorContents() override
Definition: vertices_contents.cc:159
impeller::VerticesContents::SetBlendMode
void SetBlendMode(BlendMode blend_mode)
Definition: vertices_contents.cc:40
path.h
impeller::VerticesUVContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: vertices_contents.cc:99
impeller::VerticesColorContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: vertices_contents.cc:170
contents.h
point.h
impeller::Scalar
float Scalar
Definition: scalar.h:18
entity.h
impeller::BlendMode
BlendMode
Definition: color.h:59
impeller::VerticesUVContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: vertices_contents.cc:103
impeller::BlendMode::kSource
@ kSource
impeller::VerticesColorContents::VerticesColorContents
VerticesColorContents(const VerticesContents &parent)
Definition: vertices_contents.cc:156
impeller::VerticesContents::SetGeometry
void SetGeometry(std::shared_ptr< VerticesGeometry > geometry)
Definition: vertices_contents.cc:24
impeller::VerticesContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: vertices_contents.cc:36
impeller::VerticesContents
Definition: vertices_contents.h:24
impeller::Entity
Definition: entity.h:21
impeller::VerticesContents::~VerticesContents
~VerticesContents() override
impeller::VerticesUVContents::VerticesUVContents
VerticesUVContents(const VerticesContents &parent)
Definition: vertices_contents.cc:89
impeller::VerticesContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
Definition: vertices_contents.cc:20
geometry.h
impeller::VerticesContents::SetSourceContents
void SetSourceContents(std::shared_ptr< Contents > contents)
Definition: vertices_contents.cc:28
impeller::VerticesColorContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
Definition: vertices_contents.cc:161
vertices_geometry.h
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:29
impeller::VerticesColorContents
Definition: vertices_contents.h:61
sampler_descriptor.h
impeller::VerticesContents::VerticesContents
VerticesContents()
impeller::VerticesUVContents::~VerticesUVContents
~VerticesUVContents() override
Definition: vertices_contents.cc:92
color.h
impeller::Contents
Definition: contents.h:34
impeller
Definition: aiks_context.cc:10
impeller::VerticesContents::GetSourceContents
const std::shared_ptr< Contents > & GetSourceContents() const
Definition: vertices_contents.cc:44
impeller::VerticesContents::GetGeometry
std::shared_ptr< VerticesGeometry > GetGeometry() const
Definition: vertices_contents.cc:32
impeller::ContentContext
Definition: content_context.h:332
impeller::VerticesColorContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: vertices_contents.cc:166
impeller::VerticesUVContents::GetCoverage
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
Definition: vertices_contents.cc:94
impeller::VerticesUVContents
Definition: vertices_contents.h:86