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 
12 #include "impeller/entity/entity.h"
14 
15 namespace impeller {
16 
17 // Interface wrapper to allow usage of DL pointer data without copying (or
18 // circular imports).
20  public:
21  virtual bool ShouldUseBlend() const = 0;
22 
23  virtual bool ShouldSkip() const = 0;
24 
26  HostBuffer& host_buffer) const = 0;
27 
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_
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
void SetGeometry(AtlasGeometry *geometry)
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 SetAlpha(Scalar alpha)
virtual VertexBuffer CreateSimpleVertexBuffer(HostBuffer &host_buffer) const =0
virtual Rect ComputeBoundingBox() const =0
virtual bool ShouldUseBlend() const =0
virtual std::shared_ptr< Texture > GetAtlas() const =0
virtual const SamplerDescriptor & GetSamplerDescriptor() const =0
virtual bool ShouldSkip() const =0
virtual VertexBuffer CreateBlendVertexBuffer(HostBuffer &host_buffer) const =0
virtual BlendMode GetBlendMode() const =0
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
float Scalar
Definition: scalar.h:18
BlendMode
Definition: color.h:58