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 
15 
16 namespace impeller {
17 
18 class DeviceBufferGLES final
19  : public DeviceBuffer,
20  public BackendCast<DeviceBufferGLES, DeviceBuffer> {
21  public:
23  ReactorGLES::Ref 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 {
37  };
38 
39  [[nodiscard]] bool BindAndUploadDataIfNecessary(BindingType type) const;
40 
41  void Flush(std::optional<Range> range = std::nullopt) const override;
42 
43  private:
44  ReactorGLES::Ref reactor_;
45  HandleGLES handle_;
46  mutable std::shared_ptr<Allocation> backing_store_;
47  mutable uint32_t generation_ = 0;
48  mutable uint32_t upload_generation_ = 0;
49 
50  // |DeviceBuffer|
51  uint8_t* OnGetContents() const override;
52 
53  // |DeviceBuffer|
54  bool OnCopyHostBuffer(const uint8_t* source,
55  Range source_range,
56  size_t offset) override;
57 
58  // |DeviceBuffer|
59  bool SetLabel(const std::string& label) override;
60 
61  // |DeviceBuffer|
62  bool SetLabel(const std::string& label, Range range) override;
63 
64  DeviceBufferGLES(const DeviceBufferGLES&) = delete;
65 
66  DeviceBufferGLES& operator=(const DeviceBufferGLES&) = delete;
67 };
68 
69 } // namespace impeller
70 
71 #endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_DEVICE_BUFFER_GLES_H_
impeller::DeviceBufferGLES::BindingType::kArrayBuffer
@ kArrayBuffer
impeller::DeviceBuffer
Definition: device_buffer.h:19
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:18
impeller::DeviceBufferGLES::GetBufferData
const uint8_t * GetBufferData() const
Definition: device_buffer_gles.cc:113
impeller::DeviceBufferGLES::BindingType::kElementArrayBuffer
@ kElementArrayBuffer
impeller::DeviceBufferGLES::BindAndUploadDataIfNecessary
bool BindAndUploadDataIfNecessary(BindingType type) const
Definition: device_buffer_gles.cc:74
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:117
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:34
reactor_gles.h
impeller::Range
Definition: range.h:14
impeller::BackendCast
Definition: backend_cast.h:11
offset
Point offset
Definition: stroke_path_geometry.cc:300
impeller
Definition: aiks_blur_unittests.cc:20
impeller::DeviceBufferGLES::Flush
void Flush(std::optional< Range > range=std::nullopt) const override
Definition: device_buffer_gles.cc:60