| 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 "flutter/fml/macros.h"
12 #include "impeller/base/allocation.h"
13 #include "impeller/base/backend_cast.h"
14 #include "impeller/core/device_buffer.h"
15 #include "impeller/renderer/backend/gles/reactor_gles.h"
16
17 namespace impeller {
18
19 class DeviceBufferGLES final
20 : public DeviceBuffer,
21 public BackendCast<DeviceBufferGLES, DeviceBuffer> {
22 public:
23 DeviceBufferGLES(DeviceBufferDescriptor desc,
24 ReactorGLES::Ref reactor,
25 std::shared_ptr<Allocation> backing_store);
26
27 // |DeviceBuffer|
28 ~DeviceBufferGLES() override;
29
30 const uint8_t* GetBufferData() const;
31
32 void UpdateBufferData(
33 const std::function<void(uint8_t*, size_t length)>& update_buffer_data);
34
35 enum class BindingType {
36 kArrayBuffer,
37 kElementArrayBuffer,
38 };
39
40 [[nodiscard]] bool BindAndUploadDataIfNecessary(BindingType type) const;
41
42 private:
43 ReactorGLES::Ref reactor_;
44 HandleGLES handle_;
45 mutable std::shared_ptr<Allocation> backing_store_;
46 mutable uint32_t generation_ = 0;
47 mutable uint32_t upload_generation_ = 0;
48
49 // |DeviceBuffer|
50 uint8_t* OnGetContents() const override;
51
52 // |DeviceBuffer|
53 bool OnCopyHostBuffer(const uint8_t* source,
54 Range source_range,
55 size_t offset) override;
56
57 // |DeviceBuffer|
58 bool SetLabel(const std::string& label) override;
59
60 // |DeviceBuffer|
61 bool SetLabel(const std::string& label, Range range) override;
62
63 DeviceBufferGLES(const DeviceBufferGLES&) = delete;
64
65 DeviceBufferGLES& operator=(const DeviceBufferGLES&) = delete;
66 };
67
68 } // namespace impeller
69
70 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_DEVICE_BUFFER_GLES_H_
impeller::DeviceBufferGLES::BindingType::kArrayBuffer
@ kArrayBuffer
impeller::DeviceBuffer
Definition: device_buffer.h:20
allocation.h
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
device_buffer.h
impeller::ReactorGLES::Ref
std::shared_ptr< ReactorGLES > Ref
Definition: reactor_gles.h:87
impeller::DeviceBufferGLES
Definition: device_buffer_gles.h:19
impeller::DeviceBufferGLES::GetBufferData
const uint8_t * GetBufferData() const
Definition: device_buffer_gles.cc:109
impeller::DeviceBufferGLES::BindingType::kElementArrayBuffer
@ kElementArrayBuffer
impeller::DeviceBufferGLES::BindAndUploadDataIfNecessary
bool BindAndUploadDataIfNecessary(BindingType type) const
Definition: device_buffer_gles.cc:70
backend_cast.h
impeller::HandleGLES
Definition: handle_gles.h:35
impeller::DeviceBufferGLES::~DeviceBufferGLES
~DeviceBufferGLES() override
Definition: device_buffer_gles.cc:27
impeller::DeviceBufferGLES::UpdateBufferData
void UpdateBufferData(const std::function< void(uint8_t *, size_t length)> &update_buffer_data)
Definition: device_buffer_gles.cc:113
impeller::DeviceBufferGLES::DeviceBufferGLES
DeviceBufferGLES(DeviceBufferDescriptor desc, ReactorGLES::Ref reactor, std::shared_ptr< Allocation > backing_store)
Definition: device_buffer_gles.cc:17
impeller::DeviceBufferGLES::BindingType
BindingType
Definition: device_buffer_gles.h:35
reactor_gles.h
impeller::Range
Definition: range.h:14
impeller::BackendCast
Definition: backend_cast.h:13
impeller
Definition: aiks_context.cc:10