Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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
15
16namespace impeller {
17
18class 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
39
40 void SetAlpha(Scalar alpha);
41
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_
const SamplerDescriptor & GetSamplerDescriptor() const
const std::vector< Rect > & GetTextureCoordinates() const
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
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 SetTransforms(std::vector< Matrix > transforms)
const std::vector< Color > & GetColors() const
void SetAlpha(Scalar alpha)
void SetTexture(std::shared_ptr< Texture > texture)
void SetSamplerDescriptor(SamplerDescriptor desc)
void SetBlendMode(BlendMode blend_mode)
void SetCullRect(std::optional< Rect > cull_rect)
const std::vector< Matrix > & GetTransforms() const
void SetColors(std::vector< Color > colors)
std::shared_ptr< Texture > GetTexture() const
void SetTextureCoordinates(std::vector< Rect > texture_coords)
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition render_pass.h:33
FlTexture * texture
float Scalar
Definition scalar.h:18
BlendMode
Definition color.h:59