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"
15 #include "impeller/entity/entity.h"
19 #include "impeller/geometry/path.h"
21 
22 namespace impeller {
23 
24 class VerticesContents final : public Contents {
25  public:
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 
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:50
impeller::VerticesColorContents::~VerticesColorContents
~VerticesColorContents() override
Definition: vertices_contents.cc:161
impeller::VerticesContents::SetBlendMode
void SetBlendMode(BlendMode blend_mode)
Definition: vertices_contents.cc:42
path.h
impeller::VerticesUVContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: vertices_contents.cc:101
impeller::VerticesColorContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: vertices_contents.cc:172
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:105
impeller::BlendMode::kSource
@ kSource
impeller::VerticesColorContents::VerticesColorContents
VerticesColorContents(const VerticesContents &parent)
Definition: vertices_contents.cc:158
impeller::VerticesContents::SetGeometry
void SetGeometry(std::shared_ptr< VerticesGeometry > geometry)
Definition: vertices_contents.cc:26
impeller::VerticesContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: vertices_contents.cc:38
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:91
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:22
geometry.h
impeller::VerticesContents::SetSourceContents
void SetSourceContents(std::shared_ptr< Contents > contents)
Definition: vertices_contents.cc:30
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:163
vertices_geometry.h
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::VerticesColorContents
Definition: vertices_contents.h:61
sampler_descriptor.h
impeller::VerticesContents::VerticesContents
VerticesContents()
impeller::VerticesUVContents::~VerticesUVContents
~VerticesUVContents() override
Definition: vertices_contents.cc:94
color.h
impeller::Contents
Definition: contents.h:34
impeller
Definition: aiks_blur_unittests.cc:20
impeller::VerticesContents::GetSourceContents
const std::shared_ptr< Contents > & GetSourceContents() const
Definition: vertices_contents.cc:46
impeller::VerticesContents::GetGeometry
std::shared_ptr< VerticesGeometry > GetGeometry() const
Definition: vertices_contents.cc:34
impeller::ContentContext
Definition: content_context.h:392
impeller::VerticesColorContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: vertices_contents.cc:168
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:96
impeller::VerticesUVContents
Definition: vertices_contents.h:86