| 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(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::kSource;
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::Entity::TileMode::kClamp
@ kClamp
contents.h
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::VerticesSimpleBlendContents::SetEffectTransform
void SetEffectTransform(Matrix transform)
Definition: vertices_contents.cc:83
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:67
entity.h
impeller::BlendMode
BlendMode
Definition: color.h:59
impeller::BlendMode::kSource
@ kSource
impeller::VerticesSimpleBlendContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: vertices_contents.cc:55
impeller::VerticesSimpleBlendContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: vertices_contents.cc:96
impeller::VerticesSimpleBlendContents::SetLazyTextureCoverage
void SetLazyTextureCoverage(Rect rect)
Definition: vertices_contents.cc:92
impeller::VerticesSimpleBlendContents::SetTexture
void SetTexture(std::shared_ptr< Texture > texture)
Definition: vertices_contents.cc:63
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:15
impeller::Entity
Definition: entity.h:20
impeller::VerticesSimpleBlendContents::LazyTexture
std::function< std::shared_ptr< Texture >(const ContentContext &renderer)> LazyTexture
Definition: vertices_contents.h:27
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:231
impeller::VerticesSimpleBlendContents::SetLazyTexture
void SetLazyTexture(const LazyTexture &lazy_texture)
Definition: vertices_contents.cc:87
impeller::VerticesSimpleBlendContents::SetGeometry
void SetGeometry(std::shared_ptr< VerticesGeometry > geometry)
Definition: vertices_contents.cc:50
impeller::Entity::TileMode
TileMode
Definition: entity.h:42
vertices_geometry.h
impeller::VerticesSimpleBlendContents
Definition: vertices_contents.h:20
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::VerticesSimpleBlendContents::VerticesSimpleBlendContents
VerticesSimpleBlendContents()
Definition: vertices_contents.cc:46
sampler_descriptor.h
impeller::VerticesSimpleBlendContents::SetTileMode
void SetTileMode(Entity::TileMode tile_mode_x, Entity::TileMode tile_mode_y)
Definition: vertices_contents.cc:77
color.h
impeller::VerticesSimpleBlendContents::SetBlendMode
void SetBlendMode(BlendMode blend_mode)
Definition: vertices_contents.cc:59
impeller::VerticesSimpleBlendContents::~VerticesSimpleBlendContents
~VerticesSimpleBlendContents() override
Definition: vertices_contents.cc:48
impeller::Contents
Definition: contents.h:31
impeller
Definition: aiks_blend_unittests.cc:18
impeller::ContentContext
Definition: content_context.h:366
impeller::TRect< Scalar >
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::VerticesSimpleBlendContents::SetSamplerDescriptor
void SetSamplerDescriptor(SamplerDescriptor descriptor)
Definition: vertices_contents.cc:72