Flutter Engine
The Flutter Engine
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 <bitset>
9
14
15namespace impeller {
16
17class TextureGLES final : public Texture,
18 public BackendCast<TextureGLES, Texture> {
19 public:
20 enum class Type {
22 kTextureMultisampled,
24 kRenderBufferMultisampled,
25 };
26
27 enum class IsWrapped {
28 kWrapped,
29 };
30
32
36
37 static std::shared_ptr<TextureGLES> WrapFBO(ReactorGLES::Ref reactor,
39 GLuint fbo);
40
41 // |Texture|
42 ~TextureGLES() override;
43
44 std::optional<GLuint> GetGLHandle() const;
45
46 [[nodiscard]] bool Bind() const;
47
48 [[nodiscard]] bool GenerateMipmap();
49
50 enum class AttachmentType {
51 kColor0,
52 kDepth,
53 kStencil,
54 };
55 [[nodiscard]] bool SetAsFramebufferAttachment(
56 GLenum target,
57 AttachmentType attachment_type) const;
58
59 Type GetType() const;
60
61 bool IsWrapped() const { return is_wrapped_; }
62
63 std::optional<GLuint> GetFBO() const { return wrapped_fbo_; }
64
65 // For non cubemap textures, 0 indicates uninitialized and 1 indicates
66 // initialized. For cubemap textures, each face is initialized separately with
67 // each bit tracking the initialization of the corresponding slice.
68 void MarkSliceInitialized(size_t slice) const;
69
70 bool IsSliceInitialized(size_t slice) const;
71
72 private:
73 ReactorGLES::Ref reactor_;
74 const Type type_;
75 HandleGLES handle_;
76 mutable std::bitset<6> slices_initialized_ = 0;
77 const bool is_wrapped_;
78 const std::optional<GLuint> wrapped_fbo_;
79 bool is_valid_ = false;
80
81 TextureGLES(std::shared_ptr<ReactorGLES> reactor,
83 bool is_wrapped,
84 std::optional<GLuint> fbo);
85
86 // |Texture|
87 void SetLabel(std::string_view label) override;
88
89 // |Texture|
90 bool OnSetContents(const uint8_t* contents,
91 size_t length,
92 size_t slice) override;
93
94 // |Texture|
95 bool OnSetContents(std::shared_ptr<const fml::Mapping> mapping,
96 size_t slice) override;
97
98 // |Texture|
99 bool IsValid() const override;
100
101 // |Texture|
102 ISize GetSize() const override;
103
104 // |Texture|
105 Scalar GetYCoordScale() const override;
106
107 void InitializeContentsIfNecessary() const;
108
109 TextureGLES(const TextureGLES&) = delete;
110
111 TextureGLES& operator=(const TextureGLES&) = delete;
112};
113
114} // namespace impeller
115
116#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_TEXTURE_GLES_H_
static sk_sp< GrTextureProxy > wrapped(skiatest::Reporter *reporter, GrRecordingContext *rContext, GrProxyProvider *proxyProvider, SkBackingFit fit)
std::shared_ptr< ReactorGLES > Ref
Definition: reactor_gles.h:86
bool IsSliceInitialized(size_t slice) const
TextureGLES(ReactorGLES::Ref reactor, TextureDescriptor desc)
bool SetAsFramebufferAttachment(GLenum target, AttachmentType attachment_type) const
std::optional< GLuint > GetFBO() const
Definition: texture_gles.h:63
void MarkSliceInitialized(size_t slice) const
static std::shared_ptr< TextureGLES > WrapFBO(ReactorGLES::Ref reactor, TextureDescriptor desc, GLuint fbo)
std::optional< GLuint > GetGLHandle() const
bool IsWrapped() const
Definition: texture_gles.h:61
uint32_t * target
size_t length
float Scalar
Definition: scalar.h:18
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...