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_
impeller::AtlasGeometry::ShouldUseBlend
virtual bool ShouldUseBlend() const =0
contents.h
impeller::Scalar
float Scalar
Definition: scalar.h:18
entity.h
impeller::BlendMode
BlendMode
Definition: color.h:58
impeller::AtlasGeometry::GetBlendMode
virtual BlendMode GetBlendMode() const =0
impeller::HostBuffer
Definition: host_buffer.h:28
impeller::VertexBuffer
Definition: vertex_buffer.h:13
impeller::AtlasGeometry::GetSamplerDescriptor
virtual const SamplerDescriptor & GetSamplerDescriptor() const =0
impeller::AtlasGeometry::ShouldSkip
virtual bool ShouldSkip() const =0
impeller::SamplerDescriptor
Definition: sampler_descriptor.h:15
impeller::Entity
Definition: entity.h:20
impeller::AtlasGeometry
Definition: atlas_contents.h:19
impeller::AtlasGeometry::GetAtlas
virtual std::shared_ptr< Texture > GetAtlas() const =0
impeller::AtlasContents::~AtlasContents
~AtlasContents() override
impeller::AtlasContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: atlas_contents.cc:38
impeller::AtlasGeometry::CreateSimpleVertexBuffer
virtual VertexBuffer CreateSimpleVertexBuffer(HostBuffer &host_buffer) const =0
impeller::AtlasContents
Definition: atlas_contents.h:40
impeller::AtlasContents::AtlasContents
AtlasContents()
impeller::AtlasGeometry::ComputeBoundingBox
virtual Rect ComputeBoundingBox() const =0
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:23
sampler_descriptor.h
impeller::AtlasContents::SetGeometry
void SetGeometry(AtlasGeometry *geometry)
Definition: atlas_contents.cc:30
impeller::AtlasGeometry::CreateBlendVertexBuffer
virtual VertexBuffer CreateBlendVertexBuffer(HostBuffer &host_buffer) const =0
impeller::AtlasContents::SetAlpha
void SetAlpha(Scalar alpha)
Definition: atlas_contents.cc:34
color.h
impeller::Contents
Definition: contents.h:31
impeller
Definition: allocation.cc:12
impeller::ContentContext
Definition: content_context.h:366
impeller::TRect< Scalar >