Flutter Impeller
texture_gles.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_RENDERER_BACKEND_GLES_TEXTURE_GLES_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEXTURE_GLES_H_
7 
12 
13 namespace impeller {
14 
15 class TextureGLES final : public Texture,
16  public BackendCast<TextureGLES, Texture> {
17  public:
18  enum class Type {
19  kTexture,
23  };
24 
25  enum class IsWrapped {
26  kWrapped,
27  };
28 
30 
32  TextureDescriptor desc,
33  IsWrapped wrapped);
34 
35  // |Texture|
36  ~TextureGLES() override;
37 
38  std::optional<GLuint> GetGLHandle() const;
39 
40  [[nodiscard]] bool Bind() const;
41 
42  [[nodiscard]] bool GenerateMipmap();
43 
44  enum class AttachmentType {
45  kColor0,
46  kDepth,
47  kStencil,
48  };
49  [[nodiscard]] bool SetAsFramebufferAttachment(
50  GLenum target,
51  AttachmentType attachment_type) const;
52 
53  Type GetType() const;
54 
55  bool IsWrapped() const { return is_wrapped_; }
56 
57  private:
58  friend class AllocatorMTL;
59 
60  ReactorGLES::Ref reactor_;
61  const Type type_;
62  HandleGLES handle_;
63  mutable bool contents_initialized_ = false;
64  const bool is_wrapped_;
65  bool is_valid_ = false;
66 
67  TextureGLES(std::shared_ptr<ReactorGLES> reactor,
68  TextureDescriptor desc,
69  bool is_wrapped);
70 
71  // |Texture|
72  void SetLabel(std::string_view label) override;
73 
74  // |Texture|
75  bool OnSetContents(const uint8_t* contents,
76  size_t length,
77  size_t slice) override;
78 
79  // |Texture|
80  bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
81  size_t slice) override;
82 
83  // |Texture|
84  bool IsValid() const override;
85 
86  // |Texture|
87  ISize GetSize() const override;
88 
89  // |Texture|
90  Scalar GetYCoordScale() const override;
91 
92  void InitializeContentsIfNecessary() const;
93 
94  TextureGLES(const TextureGLES&) = delete;
95 
96  TextureGLES& operator=(const TextureGLES&) = delete;
97 };
98 
99 } // namespace impeller
100 
101 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEXTURE_GLES_H_
impeller::TextureGLES::Type
Type
Definition: texture_gles.h:18
impeller::TextureGLES::Type::kTextureMultisampled
@ kTextureMultisampled
impeller::AllocatorMTL
Definition: allocator_mtl.h:15
impeller::Scalar
float Scalar
Definition: scalar.h:18
impeller::TextureGLES::GenerateMipmap
bool GenerateMipmap()
Definition: texture_gles.cc:450
impeller::TextureGLES::AttachmentType::kDepth
@ kDepth
impeller::ReactorGLES::Ref
std::shared_ptr< ReactorGLES > Ref
Definition: reactor_gles.h:87
impeller::TextureGLES::GetGLHandle
std::optional< GLuint > GetGLHandle() const
Definition: texture_gles.cc:418
impeller::TextureGLES::Type::kRenderBufferMultisampled
@ kRenderBufferMultisampled
impeller::TextureGLES::AttachmentType::kColor0
@ kColor0
impeller::Texture
Definition: texture.h:17
impeller::TextureGLES::IsWrapped
bool IsWrapped() const
Definition: texture_gles.h:55
impeller::TSize< int64_t >
impeller::TextureGLES::Type::kRenderBuffer
@ kRenderBuffer
impeller::TextureGLES::TextureGLES
TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc)
Definition: texture_gles.cc:70
backend_cast.h
impeller::HandleGLES
Definition: handle_gles.h:35
impeller::TextureGLES::AttachmentType::kStencil
@ kStencil
impeller::TextureGLES::GetType
Type GetType() const
Definition: texture_gles.cc:484
reactor_gles.h
impeller::TextureGLES::~TextureGLES
~TextureGLES() override
Definition: texture_gles.cc:105
handle_gles.h
impeller::TextureGLES::AttachmentType
AttachmentType
Definition: texture_gles.h:44
impeller::BackendCast
Definition: backend_cast.h:11
texture.h
impeller::TextureGLES::IsWrapped::kWrapped
@ kWrapped
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
impeller::TextureGLES::IsWrapped
IsWrapped
Definition: texture_gles.h:25
impeller::TextureGLES
Definition: texture_gles.h:15
impeller::TextureGLES::Bind
bool Bind() const
Definition: texture_gles.cc:425
impeller::TextureGLES::Type::kTexture
@ kTexture
impeller
Definition: aiks_blur_unittests.cc:20
impeller::TextureGLES::SetAsFramebufferAttachment
bool SetAsFramebufferAttachment(GLenum target, AttachmentType attachment_type) const
Definition: texture_gles.cc:499