| Flutter Impeller |

Public Types | Public Member Functions | List of all members
impeller::DeviceBufferGLES Class Referencefinal

`#include <device_buffer_gles.h>`

Inheritance diagram for impeller::DeviceBufferGLES:

## Public Types
enum | BindingType { BindingType::kArrayBuffer, BindingType::kElementArrayBuffer }

## Public Member Functions
| DeviceBufferGLES (DeviceBufferDescriptor desc, ReactorGLES::Ref reactor, std::shared_ptr< Allocation > backing_store)
| ~DeviceBufferGLES () override
const uint8_t * | GetBufferData () const
void | UpdateBufferData (const std::function< void(uint8_t *, size_t length)> &update_buffer_data)
bool | BindAndUploadDataIfNecessary (BindingType type) const
void | Flush (std::optional< Range > range=std::nullopt) const override
Public Member Functions inherited from impeller::DeviceBuffer
virtual | ~DeviceBuffer ()
bool | CopyHostBuffer (const uint8_t *source, Range source_range, size_t offset=0u)
const DeviceBufferDescriptor & | GetDeviceBufferDescriptor () const
virtual void | Invalidate (std::optional< Range > range=std::nullopt) const

## Additional Inherited Members
Static Public Member Functions inherited from impeller::DeviceBuffer
static BufferView | AsBufferView (std::shared_ptr< DeviceBuffer > buffer)
| Create a buffer view of this entire buffer. More...
Static Public Member Functions inherited from impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >
static DeviceBufferGLES & | Cast (DeviceBuffer &base)
static const DeviceBufferGLES & | Cast (const DeviceBuffer &base)
static DeviceBufferGLES * | Cast (DeviceBuffer *base)
static const DeviceBufferGLES * | Cast (const DeviceBuffer *base)
Protected Member Functions inherited from impeller::DeviceBuffer
| DeviceBuffer (DeviceBufferDescriptor desc)
Protected Attributes inherited from impeller::DeviceBuffer
const DeviceBufferDescriptor | desc_

## Detailed Description

Definition at line 18 of file device_buffer_gles.h.

## Member Enumeration Documentation

## ◆ BindingType

enum impeller::DeviceBufferGLES::BindingType
| strong

Enumerator
kArrayBuffer |
kElementArrayBuffer |

Definition at line 34 of file device_buffer_gles.h.

34 {
35 kArrayBuffer,
36 kElementArrayBuffer,
37 };

## Constructor & Destructor Documentation

## ◆ DeviceBufferGLES()

impeller::DeviceBufferGLES::DeviceBufferGLES | ( | DeviceBufferDescriptor | desc,
|  | ReactorGLES::Ref | reactor,
|  | std::shared_ptr< Allocation > | backing_store
| ) |  |

Definition at line 15 of file device_buffer_gles.cc.

18 : DeviceBuffer(desc),
19 reactor_(std::move(reactor)),
20 handle_(reactor_ ? reactor_->CreateHandle(HandleType::kBuffer)
21 : HandleGLES::DeadHandle()),
22 backing_store_(std::move(backing_store)) {}

References impeller::kBuffer.

## ◆ ~DeviceBufferGLES()

impeller::DeviceBufferGLES::~DeviceBufferGLES | ( |  | ) |
| override

Definition at line 25 of file device_buffer_gles.cc.

25 {
26 if (!handle_.IsDead()) {
27 reactor_->CollectHandle(handle_);
28 }
29 }

References impeller::HandleGLES::IsDead().

## Member Function Documentation

## ◆ BindAndUploadDataIfNecessary()

bool impeller::DeviceBufferGLES::BindAndUploadDataIfNecessary | ( | BindingType | type | ) | const

Definition at line 82 of file device_buffer_gles.cc.

82 {
83 if (!reactor_) {
84 return false;
85 }
86
87 auto buffer = reactor_->GetGLHandle(handle_);
88 if (!buffer.has_value()) {
89 return false;
90 }
91
92 const auto target_type = ToTarget(type);
93 const auto& gl = reactor_->GetProcTable();
94
95 gl.BindBuffer(target_type, buffer.value());
96 if (!initialized_) {
97 gl.BufferData(target_type, backing_store_->GetLength().GetByteSize(),
98 nullptr, GL_DYNAMIC_DRAW);
99 initialized_ = true;
100 }
101
102 if (dirty_range_.has_value()) {
103 auto range = dirty_range_.value();
104 gl.BufferSubData(target_type, range.offset, range.length,
105 backing_store_->GetBuffer() + range.offset);
106 dirty_range_ = std::nullopt;
107 }
108
109 return true;
110 }

References impeller::ToTarget(), and type.

## ◆ Flush()

void impeller::DeviceBufferGLES::Flush | ( | std::optional< Range > | range = `std::nullopt` | ) | const
| override virtual

Make any pending writes visible to the GPU.

This method must be called if the device pointer provided by [OnGetContents] is written to without using [CopyHostBuffer]. On Devices with coherent host memory, this method will not perform extra work.

If the range is not provided, the entire buffer is flushed.

Reimplemented from impeller::DeviceBuffer.

Definition at line 59 of file device_buffer_gles.cc.

59 {
60 if (!range.has_value()) {
61 dirty_range_ = Range{
62 0, static_cast<size_t>(backing_store_->GetLength().GetByteSize())};
63 } else {
64 if (dirty_range_.has_value()) {
65 dirty_range_ = dirty_range_->Merge(range.value());
66 } else {
67 dirty_range_ = range.value();
68 }
69 }
70 }

Referenced by UpdateBufferData().

## ◆ GetBufferData()

const uint8_t * impeller::DeviceBufferGLES::GetBufferData | ( |  | ) | const

Definition at line 125 of file device_buffer_gles.cc.

125 {
126 return backing_store_->GetBuffer();
127 }

## ◆ UpdateBufferData()

void impeller::DeviceBufferGLES::UpdateBufferData | ( | const std::function< void(uint8_t *, size_t length)> & | update_buffer_data | ) |

Definition at line 129 of file device_buffer_gles.cc.

131 {
132 if (update_buffer_data) {
133 update_buffer_data(backing_store_->GetBuffer(),
134 backing_store_->GetLength().GetByteSize());
135 Flush(Range{
136 0, static_cast<size_t>(backing_store_->GetLength().GetByteSize())});
137 }
138 }

References Flush().

Referenced by impeller::BlitCopyTextureToBufferCommandGLES::Encode().

The documentation for this class was generated from the following files:

- impeller/renderer/backend/gles/device_buffer_gles.h
- impeller/renderer/backend/gles/device_buffer_gles.cc

impeller::HandleGLES::DeadHandle
static HandleGLES DeadHandle()
Creates a dead handle.
Definition: handle_gles.h:45
impeller::DeviceBuffer::DeviceBuffer
DeviceBuffer(DeviceBufferDescriptor desc)
Definition: device_buffer.cc:9
impeller::HandleGLES::IsDead
constexpr bool IsDead() const
Determines if the handle is dead.
Definition: handle_gles.h:54
type
GLenum type
Definition: blit_command_gles.cc:127
impeller::ToTarget
static GLenum ToTarget(DeviceBufferGLES::BindingType type)
Definition: device_buffer_gles.cc:72
impeller::HandleType::kBuffer
@ kBuffer
impeller::DeviceBufferGLES::Flush
void Flush(std::optional< Range > range=std::nullopt) const override
Definition: device_buffer_gles.cc:59