| 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 17 of file device_buffer_gles.cc.

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

References impeller::kBuffer.

## ◆ ~DeviceBufferGLES()

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

Definition at line 27 of file device_buffer_gles.cc.

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

References impeller::HandleGLES::IsDead().

## Member Function Documentation

## ◆ BindAndUploadDataIfNecessary()

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

Definition at line 74 of file device_buffer_gles.cc.

74 {
75 if (!reactor_) {
76 return false;
77 }
78
79 auto buffer = reactor_->GetGLHandle(handle_);
80 if (!buffer.has_value()) {
81 return false;
82 }
83
84 const auto target_type = ToTarget(type);
85 const auto& gl = reactor_->GetProcTable();
86
87 gl.BindBuffer(target_type, buffer.value());
88
89 if (upload_generation_ != generation_) {
90 TRACE_EVENT1("impeller", "BufferData", "Bytes",
91 std::to_string(backing_store_->GetLength()).c_str());
92 gl.BufferData(target_type, backing_store_->GetLength(),
93 backing_store_->GetBuffer(), GL_STATIC_DRAW);
94 upload_generation_ = generation_;
95 }
96
97 return true;
98 }

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 60 of file device_buffer_gles.cc.

60 {
61 generation_++;
62 }

## ◆ GetBufferData()

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

Definition at line 113 of file device_buffer_gles.cc.

113 {
114 return backing_store_->GetBuffer();
115 }

## ◆ UpdateBufferData()

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

Definition at line 117 of file device_buffer_gles.cc.

119 {
120 if (update_buffer_data) {
121 update_buffer_data(backing_store_->GetBuffer(),
122 backing_store_->GetLength());
123 ++generation_;
124 }
125 }

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()
Definition: handle_gles.h:35
impeller::DeviceBuffer::DeviceBuffer
DeviceBuffer(DeviceBufferDescriptor desc)
Definition: device_buffer.cc:9
impeller::HandleGLES::IsDead
constexpr bool IsDead() const
Definition: handle_gles.h:39
type
GLenum type
Definition: blit_command_gles.cc:126
impeller::ToTarget
static GLenum ToTarget(DeviceBufferGLES::BindingType type)
Definition: device_buffer_gles.cc:64
impeller::HandleType::kBuffer
@ kBuffer