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