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 std::optional<Range> dirty_range_ = std::nullopt;
48  mutable bool initialized_ = false;
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:18
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:86
impeller::DeviceBufferGLES
Definition: device_buffer_gles.h:18
offset
SeparatedVector2 offset
Definition: stroke_path_geometry.cc:304
impeller::DeviceBufferGLES::GetBufferData
const uint8_t * GetBufferData() const
Definition: device_buffer_gles.cc:125
impeller::DeviceBufferGLES::BindingType::kElementArrayBuffer
@ kElementArrayBuffer
impeller::DeviceBufferGLES::BindAndUploadDataIfNecessary
bool BindAndUploadDataIfNecessary(BindingType type) const
Definition: device_buffer_gles.cc:82
backend_cast.h
type
GLenum type
Definition: blit_command_gles.cc:127
impeller::HandleGLES
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
Definition: handle_gles.h:36
impeller::DeviceBufferGLES::~DeviceBufferGLES
~DeviceBufferGLES() override
Definition: device_buffer_gles.cc:25
impeller::DeviceBufferGLES::UpdateBufferData
void UpdateBufferData(const std::function< void(uint8_t *, size_t length)> &update_buffer_data)
Definition: device_buffer_gles.cc:129
impeller::DeviceBufferGLES::DeviceBufferGLES
DeviceBufferGLES(DeviceBufferDescriptor desc, ReactorGLES::Ref reactor, std::shared_ptr< Allocation > backing_store)
Definition: device_buffer_gles.cc:15
impeller::DeviceBufferGLES::BindingType
BindingType
Definition: device_buffer_gles.h:34
reactor_gles.h
impeller::Range
Definition: range.h:13
impeller::BackendCast
Definition: backend_cast.h:11
impeller
Definition: allocation.cc:12
impeller::DeviceBufferGLES::Flush
void Flush(std::optional< Range > range=std::nullopt) const override
Definition: device_buffer_gles.cc:59