| 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 #pragma once
6
7 #include "flutter/fml/macros.h"
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 kRenderBuffer,
21 kRenderBufferMultisampled,
22 };
23
24 enum class IsWrapped {
25 kWrapped,
26 };
27
28 TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc);
29
30 TextureGLES(ReactorGLES::Ref reactor,
31 TextureDescriptor desc,
32 IsWrapped wrapped);
33
34 // |Texture|
35 ~TextureGLES() override;
36
37 std::optional<GLuint> GetGLHandle() const;
38
39 [[nodiscard]] bool Bind() const;
40
41 [[nodiscard]] bool GenerateMipmap();
42
43 enum class AttachmentPoint {
44 kColor0,
45 kDepth,
46 kStencil,
47 };
48 [[nodiscard]] bool SetAsFramebufferAttachment(GLenum target,
49 GLuint fbo,
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 FML_DISALLOW_COPY_AND_ASSIGN(TextureGLES);
94 };
95
96 } // namespace impeller
impeller::TextureGLES::Type
Type
Definition: texture_gles.h:18
impeller::AllocatorMTL
Definition: allocator_mtl.h:14
impeller::Scalar
float Scalar
Definition: scalar.h:15
impeller::TextureGLES::AttachmentPoint::kDepth
@ kDepth
impeller::TextureGLES::GenerateMipmap
bool GenerateMipmap()
Definition: texture_gles.cc:459
impeller::TextureGLES::AttachmentPoint
AttachmentPoint
Definition: texture_gles.h:43
impeller::ReactorGLES::Ref
std::shared_ptr< ReactorGLES > Ref
Definition: reactor_gles.h:31
impeller::TextureGLES::GetGLHandle
std::optional< GLuint > GetGLHandle() const
Definition: texture_gles.cc:427
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:42
backend_cast.h
impeller::HandleGLES
Definition: handle_gles.h:34
impeller::TextureGLES::AttachmentPoint::kStencil
@ kStencil
impeller::TextureGLES::GetType
Type GetType() const
Definition: texture_gles.cc:493
reactor_gles.h
impeller::TextureGLES::~TextureGLES
~TextureGLES() override
Definition: texture_gles.cc:76
handle_gles.h
impeller::BackendCast
Definition: backend_cast.h:12
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:39
impeller::TextureGLES::IsWrapped
IsWrapped
Definition: texture_gles.h:24
impeller::TextureGLES
Definition: texture_gles.h:15
impeller::TextureGLES::Bind
bool Bind() const
Definition: texture_gles.cc:434
impeller::TextureGLES::Type::kTexture
@ kTexture
impeller
Definition: aiks_context.cc:10
impeller::TextureGLES::SetAsFramebufferAttachment
bool SetAsFramebufferAttachment(GLenum target, GLuint fbo, AttachmentPoint point) const
Definition: texture_gles.cc:508