| Flutter Impeller |

device_buffer_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_DEVICE_BUFFER_GLES_H_
6 #define FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_DEVICE_BUFFER_GLES_H_
7
8 #include <cstdint>
9 #include <memory>
10
11 #include "impeller/base/allocation.h"
12 #include "impeller/base/backend_cast.h"
13 #include "impeller/core/device_buffer.h"
14 #include "impeller/renderer/backend/gles/reactor_gles.h"
15
16 namespace impeller {
17
18 class DeviceBufferGLES final
19 : public DeviceBuffer,
20 public BackendCast<DeviceBufferGLES, DeviceBuffer> {
21 public:
22 DeviceBufferGLES(DeviceBufferDescriptor desc,
23 std::shared_ptr<ReactorGLES> reactor,
24 std::shared_ptr<Allocation> backing_store);
25
26 // |DeviceBuffer|
27 ~DeviceBufferGLES() override;
28
29 const uint8_t* GetBufferData() const;
30
31 void UpdateBufferData(
32 const std::function<void(uint8_t*, size_t length)>& update_buffer_data);
33
34 enum class BindingType {
35 kArrayBuffer,
36 kElementArrayBuffer,
37 kUniformBuffer,
38 };
39
40 [[nodiscard]] bool BindAndUploadDataIfNecessary(BindingType type) const;
41
42 void Flush(std::optional<Range> range = std::nullopt) const override;
43
44 std::optional<GLuint> GetHandle() const;
45
46 private:
47 std::shared_ptr<ReactorGLES> reactor_;
48 std::optional<std::string> label_;
49 // Mutable for lazy evaluation.
50 mutable std::optional<HandleGLES> handle_;
51 mutable std::shared_ptr<Allocation> backing_store_;
52 mutable std::optional<Range> dirty_range_ = std::nullopt;
53 mutable bool initialized_ = false;
54
55 // |DeviceBuffer|
56 uint8_t* OnGetContents() const override;
57
58 // |DeviceBuffer|
59 bool OnCopyHostBuffer(const uint8_t* source,
60 Range source_range,
61 size_t offset) override;
62
63 // |DeviceBuffer|
64 bool SetLabel(std::string_view label) override;
65
66 // |DeviceBuffer|
67 bool SetLabel(std::string_view label, Range range) override;
68
69 DeviceBufferGLES(const DeviceBufferGLES&) = delete;
70
71 DeviceBufferGLES& operator=(const DeviceBufferGLES&) = delete;
72 };
73
74 } // namespace impeller
75
76 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_DEVICE_BUFFER_GLES_H_
allocation.h
backend_cast.h
type
GLenum type
Definition: blit_command_gles.cc:151
impeller::BackendCast
Definition: backend_cast.h:11
impeller::DeviceBufferGLES
Definition: device_buffer_gles.h:20
impeller::DeviceBufferGLES::Flush
void Flush(std::optional< Range > range=std::nullopt) const override
Definition: device_buffer_gles.cc:65
impeller::DeviceBufferGLES::UpdateBufferData
void UpdateBufferData(const std::function< void(uint8_t *, size_t length)> &update_buffer_data)
Definition: device_buffer_gles.cc:151
impeller::DeviceBufferGLES::DeviceBufferGLES
DeviceBufferGLES(DeviceBufferDescriptor desc, std::shared_ptr< ReactorGLES > reactor, std::shared_ptr< Allocation > backing_store)
Definition: device_buffer_gles.cc:15
impeller::DeviceBufferGLES::BindAndUploadDataIfNecessary
bool BindAndUploadDataIfNecessary(BindingType type) const
Definition: device_buffer_gles.cc:90
impeller::DeviceBufferGLES::~DeviceBufferGLES
~DeviceBufferGLES() override
Definition: device_buffer_gles.cc:23
impeller::DeviceBufferGLES::GetBufferData
const uint8_t * GetBufferData() const
Definition: device_buffer_gles.cc:147
impeller::DeviceBufferGLES::GetHandle
std::optional< GLuint > GetHandle() const
Definition: device_buffer_gles.cc:57
impeller::DeviceBufferGLES::BindingType
BindingType
Definition: device_buffer_gles.h:34
impeller::DeviceBufferGLES::BindingType::kArrayBuffer
@ kArrayBuffer
impeller::DeviceBufferGLES::BindingType::kElementArrayBuffer
@ kElementArrayBuffer
impeller::DeviceBufferGLES::BindingType::kUniformBuffer
@ kUniformBuffer
impeller::DeviceBuffer
Definition: device_buffer.h:18
device_buffer.h
impeller
Definition: allocation.cc:12
reactor_gles.h
offset
SeparatedVector2 offset
Definition: stroke_path_geometry.cc:319
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
impeller::Range
Definition: range.h:13