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