| 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
8 #include "impeller/base/backend_cast.h"
9 #include "impeller/core/texture.h"
10 #include "impeller/renderer/backend/gles/handle_gles.h"
11 #include "impeller/renderer/backend/gles/reactor_gles.h"
12
13 namespace impeller {
14
15 class TextureGLES final : public Texture,
16 public BackendCast<TextureGLES, Texture> {
17 public:
18 enum class Type {
19 kTexture,
20 kTextureMultisampled,
21 kRenderBuffer,
22 kRenderBufferMultisampled,
23 };
24
25 enum class IsWrapped {
26 kWrapped,
27 };
28
29 TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc);
30
31 TextureGLES(ReactorGLES::Ref reactor,
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 AttachmentPoint {
45 kColor0,
46 kDepth,
47 kStencil,
48 };
49 [[nodiscard]] bool SetAsFramebufferAttachment(GLenum target,
50 AttachmentPoint point) const;
51
52 Type GetType() const;
53
54 bool IsWrapped() const { return is_wrapped_; }
55
56 private:
57 friend class AllocatorMTL;
58
59 ReactorGLES::Ref reactor_;
60 const Type type_;
61 HandleGLES handle_;
62 mutable bool contents_initialized_ = false;
63 const bool is_wrapped_;
64 bool is_valid_ = false;
65
66 TextureGLES(std::shared_ptr<ReactorGLES> reactor,
67 TextureDescriptor desc,
68 bool is_wrapped);
69
70 // |Texture|
71 void SetLabel(std::string_view label) override;
72
73 // |Texture|
74 bool OnSetContents(const uint8_t* contents,
75 size_t length,
76 size_t slice) override;
77
78 // |Texture|
79 bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
80 size_t slice) override;
81
82 // |Texture|
83 bool IsValid() const override;
84
85 // |Texture|
86 ISize GetSize() const override;
87
88 // |Texture|
89 Scalar GetYCoordScale() const override;
90
91 void InitializeContentsIfNecessary() const;
92
93 TextureGLES(const TextureGLES&) = delete;
94
95 TextureGLES& operator=(const TextureGLES&) = delete;
96 };
97
98 } // namespace impeller
99
100 #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::AttachmentPoint::kDepth
@ kDepth
impeller::TextureGLES::GenerateMipmap
bool GenerateMipmap()
Definition: texture_gles.cc:422
impeller::TextureGLES::AttachmentPoint
AttachmentPoint
Definition: texture_gles.h:44
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:390
impeller::TextureGLES::Type::kRenderBufferMultisampled
@ kRenderBufferMultisampled
impeller::TextureGLES::AttachmentPoint::kColor0
@ kColor0
impeller::Texture
Definition: texture.h:17
impeller::TextureGLES::IsWrapped
bool IsWrapped() const
Definition: texture_gles.h:54
impeller::TSize< int64_t >
impeller::TextureGLES::Type::kRenderBuffer
@ kRenderBuffer
impeller::TextureGLES::TextureGLES
TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc)
Definition: texture_gles.cc:46
impeller::TextureGLES::SetAsFramebufferAttachment
bool SetAsFramebufferAttachment(GLenum target, AttachmentPoint point) const
Definition: texture_gles.cc:471
backend_cast.h
impeller::HandleGLES
Definition: handle_gles.h:35
impeller::TextureGLES::AttachmentPoint::kStencil
@ kStencil
impeller::TextureGLES::GetType
Type GetType() const
Definition: texture_gles.cc:456
reactor_gles.h
impeller::TextureGLES::~TextureGLES
~TextureGLES() override
Definition: texture_gles.cc:81
handle_gles.h
impeller::BackendCast
Definition: backend_cast.h:13
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:397
impeller::TextureGLES::Type::kTexture
@ kTexture
impeller
Definition: aiks_context.cc:10