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 
12 #include "impeller/entity/entity.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:
23 
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 
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_ = {};
63  Matrix inverse_matrix_ = {};
64  std::optional<Rect> lazy_texture_coverage_;
65  LazyTexture lazy_texture_;
66 
68 
70  delete;
71 };
72 
73 } // namespace impeller
74 
75 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_VERTICES_CONTENTS_H_
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
void SetSamplerDescriptor(const SamplerDescriptor &descriptor)
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.
void SetBlendMode(BlendMode blend_mode)
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
void SetTileMode(Entity::TileMode tile_mode_x, Entity::TileMode tile_mode_y)
void SetLazyTexture(const LazyTexture &lazy_texture)
std::function< std::shared_ptr< Texture >(const ContentContext &renderer)> LazyTexture
void SetTexture(std::shared_ptr< Texture > texture)
void SetGeometry(std::shared_ptr< VerticesGeometry > geometry)
float Scalar
Definition: scalar.h:19
BlendMode
Definition: color.h:58
A 4x4 matrix using column-major storage.
Definition: matrix.h:37