| Flutter Impeller |

atlas_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_ATLAS_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_ATLAS_CONTENTS_H_
7
8 #include <functional>
9 #include <memory>
10 #include <vector>
11
12 #include "impeller/core/sampler_descriptor.h"
13 #include "impeller/entity/contents/contents.h"
14 #include "impeller/entity/entity.h"
15
16 namespace impeller {
17
18 class AtlasContents final : public Contents {
19 public:
20 explicit AtlasContents();
21
22 ~AtlasContents() override;
23
24 void SetTexture(std::shared_ptr<Texture> texture);
25
26 std::shared_ptr<Texture> GetTexture() const;
27
28 void SetTransforms(std::vector<Matrix> transforms);
29
30 void SetBlendMode(BlendMode blend_mode);
31
32 void SetTextureCoordinates(std::vector<Rect> texture_coords);
33
34 void SetColors(std::vector<Color> colors);
35
36 void SetCullRect(std::optional<Rect> cull_rect);
37
38 void SetSamplerDescriptor(SamplerDescriptor desc);
39
40 void SetAlpha(Scalar alpha);
41
42 const SamplerDescriptor& GetSamplerDescriptor() const;
43
44 const std::vector<Matrix>& GetTransforms() const;
45
46 const std::vector<Rect>& GetTextureCoordinates() const;
47
48 const std::vector<Color>& GetColors() const;
49
50 // |Contents|
51 std::optional<Rect> GetCoverage(const Entity& entity) const override;
52
53 // |Contents|
54 bool Render(const ContentContext& renderer,
55 const Entity& entity,
56 RenderPass& pass) const override;
57
58 private:
59 Rect ComputeBoundingBox() const;
60
61 std::shared_ptr<Texture> texture_;
62 std::vector<Rect> texture_coords_;
63 std::vector<Color> colors_;
64 std::vector<Matrix> transforms_;
65 BlendMode blend_mode_;
66 std::optional<Rect> cull_rect_;
67 Scalar alpha_ = 1.0;
68 SamplerDescriptor sampler_descriptor_ = {};
69 mutable std::optional<Rect> bounding_box_cache_;
70
71 AtlasContents(const AtlasContents&) = delete;
72
73 AtlasContents& operator=(const AtlasContents&) = delete;
74 };
75
76 } // namespace impeller
77
78 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_ATLAS_CONTENTS_H_
impeller::AtlasContents::SetTextureCoordinates
void SetTextureCoordinates(std::vector< Rect > texture_coords)
Definition: atlas_contents.cc:37
contents.h
impeller::Scalar
float Scalar
Definition: scalar.h:18
entity.h
impeller::AtlasContents::SetSamplerDescriptor
void SetSamplerDescriptor(SamplerDescriptor desc)
Definition: atlas_contents.cc:80
impeller::BlendMode
BlendMode
Definition: color.h:59
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:15
impeller::Entity
Definition: entity.h:20
impeller::AtlasContents::SetBlendMode
void SetBlendMode(BlendMode blend_mode)
Definition: atlas_contents.cc:50
impeller::AtlasContents::~AtlasContents
~AtlasContents() override
impeller::AtlasContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: atlas_contents.cc:100
impeller::AtlasContents::GetTransforms
const std::vector< Matrix > & GetTransforms() const
Definition: atlas_contents.cc:88
impeller::AtlasContents::GetTextureCoordinates
const std::vector< Rect > & GetTextureCoordinates() const
Definition: atlas_contents.cc:92
impeller::AtlasContents::GetTexture
std::shared_ptr< Texture > GetTexture() const
Definition: atlas_contents.cc:28
impeller::AtlasContents
Definition: atlas_contents.h:18
impeller::AtlasContents::AtlasContents
AtlasContents()
impeller::AtlasContents::SetColors
void SetColors(std::vector< Color > colors)
Definition: atlas_contents.cc:42
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:33
impeller::AtlasContents::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: atlas_contents.cc:58
sampler_descriptor.h
impeller::AtlasContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:46
impeller::AtlasContents::SetCullRect
void SetCullRect(std::optional< Rect > cull_rect)
Definition: atlas_contents.cc:54
impeller::AtlasContents::SetTexture
void SetTexture(std::shared_ptr< Texture > texture)
Definition: atlas_contents.cc:24
impeller::Contents
Definition: contents.h:31
impeller::AtlasContents::SetTransforms
void SetTransforms(std::vector< Matrix > transforms)
Definition: atlas_contents.cc:32
impeller
Definition: aiks_blend_unittests.cc:18
impeller::AtlasContents::GetSamplerDescriptor
const SamplerDescriptor & GetSamplerDescriptor() const
Definition: atlas_contents.cc:84
impeller::ContentContext
Definition: content_context.h:366
impeller::TRect< Scalar >
impeller::AtlasContents::GetColors
const std::vector< Color > & GetColors() const
Definition: atlas_contents.cc:96