| 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 <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/geometry/color.h"
14
15 namespace impeller {
16
17 // Interface wrapper to allow usage of DL pointer data without copying (or
18 // circular imports).
19 class AtlasGeometry {
20 public:
21 virtual bool ShouldUseBlend() const = 0;
22
23 virtual bool ShouldSkip() const = 0;
24
25 virtual VertexBuffer CreateSimpleVertexBuffer(
26 HostBuffer& host_buffer) const = 0;
27
28 virtual VertexBuffer CreateBlendVertexBuffer(
29 HostBuffer& host_buffer) const = 0;
30
31 virtual Rect ComputeBoundingBox() const = 0;
32
33 virtual std::shared_ptr<Texture> GetAtlas() const = 0;
34
35 virtual const SamplerDescriptor& GetSamplerDescriptor() const = 0;
36
37 virtual BlendMode GetBlendMode() const = 0;
38 };
39
40 class AtlasContents final : public Contents {
41 public:
42 explicit AtlasContents();
43
44 ~AtlasContents() override;
45
46 void SetGeometry(AtlasGeometry* geometry);
47
48 void SetAlpha(Scalar alpha);
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 AtlasGeometry* geometry_ = nullptr;
60 Scalar alpha_ = 1.0;
61
62 AtlasContents(const AtlasContents&) = delete;
63
64 AtlasContents& operator=(const AtlasContents&) = delete;
65 };
66
67 } // namespace impeller
68
69 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_ATLAS_CONTENTS_H_
impeller::AtlasContents
Definition: atlas_contents.h:40
impeller::AtlasContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: atlas_contents.cc:38
impeller::AtlasContents::SetGeometry
void SetGeometry(AtlasGeometry *geometry)
Definition: atlas_contents.cc:30
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:23
impeller::AtlasContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:34
impeller::AtlasContents::~AtlasContents
~AtlasContents() override
impeller::AtlasContents::AtlasContents
AtlasContents()
impeller::AtlasGeometry
Definition: atlas_contents.h:19
impeller::AtlasGeometry::CreateSimpleVertexBuffer
virtual VertexBuffer CreateSimpleVertexBuffer(HostBuffer &host_buffer) const =0
impeller::AtlasGeometry::ComputeBoundingBox
virtual Rect ComputeBoundingBox() const =0
impeller::AtlasGeometry::ShouldUseBlend
virtual bool ShouldUseBlend() const =0
impeller::AtlasGeometry::GetAtlas
virtual std::shared_ptr< Texture > GetAtlas() const =0
impeller::AtlasGeometry::GetSamplerDescriptor
virtual const SamplerDescriptor & GetSamplerDescriptor() const =0
impeller::AtlasGeometry::ShouldSkip
virtual bool ShouldSkip() const =0
impeller::AtlasGeometry::CreateBlendVertexBuffer
virtual VertexBuffer CreateBlendVertexBuffer(HostBuffer &host_buffer) const =0
impeller::AtlasGeometry::GetBlendMode
virtual BlendMode GetBlendMode() const =0
impeller::ContentContext
Definition: content_context.h:371
impeller::Contents
Definition: contents.h:31
impeller::Entity
Definition: entity.h:20
impeller::HostBuffer
Definition: host_buffer.h:28
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
color.h
contents.h
entity.h
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::BlendMode
BlendMode
Definition: color.h:58
sampler_descriptor.h
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:14
impeller::TRect< Scalar >
impeller::VertexBuffer
Definition: vertex_buffer.h:15