| 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 <memory>
9
10 #include "impeller/core/sampler_descriptor.h"
11 #include "impeller/entity/contents/contents.h"
12 #include "impeller/entity/entity.h"
13 #include "impeller/entity/geometry/vertices_geometry.h"
14 #include "impeller/geometry/color.h"
15
16 namespace impeller {
17
18 /// A vertices contents for (optional) per-color vertices + texture and any
19 /// blend mode.
20 class VerticesSimpleBlendContents final : public Contents {
21 public:
22 VerticesSimpleBlendContents();
23
24 ~VerticesSimpleBlendContents() override;
25
26 using LazyTexture =
27 std::function<std::shared_ptr<Texture>(const ContentContext& renderer)>;
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 SetTexture(std::shared_ptr<Texture> texture);
36
37 void SetLazyTexture(const LazyTexture& lazy_texture);
38
39 void SetSamplerDescriptor(const SamplerDescriptor& descriptor);
40
41 void SetTileMode(Entity::TileMode tile_mode_x, Entity::TileMode tile_mode_y);
42
43 void SetEffectTransform(Matrix transform);
44
45 void SetLazyTextureCoverage(Rect rect);
46
47 // |Contents|
48 std::optional<Rect> GetCoverage(const Entity& entity) const override;
49
50 // |Contents|
51 bool Render(const ContentContext& renderer,
52 const Entity& entity,
53 RenderPass& pass) const override;
54
55 private:
56 Scalar alpha_ = 1.0;
57 std::shared_ptr<VerticesGeometry> geometry_;
58 std::shared_ptr<Texture> texture_;
59 BlendMode blend_mode_ = BlendMode::kSrc;
60 SamplerDescriptor descriptor_ = {};
61 Entity::TileMode tile_mode_x_ = Entity::TileMode::kClamp;
62 Entity::TileMode tile_mode_y_ = Entity::TileMode::kClamp;
63 Matrix inverse_matrix_ = {};
64 std::optional<Rect> lazy_texture_coverage_;
65 LazyTexture lazy_texture_;
66
67 VerticesSimpleBlendContents(const VerticesSimpleBlendContents&) = delete;
68
69 VerticesSimpleBlendContents& operator=(const VerticesSimpleBlendContents&) =
70 delete;
71 };
72
73 } // namespace impeller
74
75 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_VERTICES_CONTENTS_H_
impeller::ContentContext
Definition: content_context.h:138
impeller::Contents
Definition: contents.h:31
impeller::Entity
Definition: entity.h:20
impeller::Entity::TileMode
TileMode
Definition: entity.h:42
impeller::Entity::TileMode::kClamp
@ kClamp
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
impeller::VerticesSimpleBlendContents
Definition: vertices_contents.h:20
impeller::VerticesSimpleBlendContents::SetSamplerDescriptor
void SetSamplerDescriptor(const SamplerDescriptor &descriptor)
Definition: vertices_contents.cc:73
impeller::VerticesSimpleBlendContents::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:68
impeller::VerticesSimpleBlendContents::SetBlendMode
void SetBlendMode(BlendMode blend_mode)
Definition: vertices_contents.cc:60
impeller::VerticesSimpleBlendContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: vertices_contents.cc:97
impeller::VerticesSimpleBlendContents::SetTileMode
void SetTileMode(Entity::TileMode tile_mode_x, Entity::TileMode tile_mode_y)
Definition: vertices_contents.cc:78
impeller::VerticesSimpleBlendContents::SetLazyTexture
void SetLazyTexture(const LazyTexture &lazy_texture)
Definition: vertices_contents.cc:88
impeller::VerticesSimpleBlendContents::SetLazyTextureCoverage
void SetLazyTextureCoverage(Rect rect)
Definition: vertices_contents.cc:93
impeller::VerticesSimpleBlendContents::~VerticesSimpleBlendContents
~VerticesSimpleBlendContents() override
Definition: vertices_contents.cc:49
impeller::VerticesSimpleBlendContents::LazyTexture
std::function< std::shared_ptr< Texture >(const ContentContext &renderer)> LazyTexture
Definition: vertices_contents.h:27
impeller::VerticesSimpleBlendContents::SetEffectTransform
void SetEffectTransform(Matrix transform)
Definition: vertices_contents.cc:84
impeller::VerticesSimpleBlendContents::SetTexture
void SetTexture(std::shared_ptr< Texture > texture)
Definition: vertices_contents.cc:64
impeller::VerticesSimpleBlendContents::SetGeometry
void SetGeometry(std::shared_ptr< VerticesGeometry > geometry)
Definition: vertices_contents.cc:51
impeller::VerticesSimpleBlendContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: vertices_contents.cc:56
impeller::VerticesSimpleBlendContents::VerticesSimpleBlendContents
VerticesSimpleBlendContents()
Definition: vertices_contents.cc:47
color.h
contents.h
entity.h
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:214
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::BlendMode::kSrc
@ kSrc
sampler_descriptor.h
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14
impeller::TRect< Scalar >
vertices_geometry.h