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

#include <device_buffer_gles.h>

Inheritance diagram for impeller::DeviceBufferGLES:
impeller::DeviceBuffer impeller::BackendCast< DeviceBufferGLES, DeviceBuffer >

Public Types

enum class  BindingType { kArrayBuffer , 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)
 
virtual bool SetLabel (const std::string &label)=0
 
virtual bool SetLabel (const std::string &label, Range range)=0
 
const DeviceBufferDescriptorGetDeviceBufferDescriptor () const
 
virtual uint8_t * OnGetContents () const =0
 
virtual void Flush (std::optional< Range > range=std::nullopt) 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 DeviceBufferGLESCast (DeviceBuffer &base)
 
static const DeviceBufferGLESCast (const DeviceBuffer &base)
 
static DeviceBufferGLESCast (DeviceBuffer *base)
 
static const DeviceBufferGLESCast (const DeviceBuffer *base)
 
- Protected Member Functions inherited from impeller::DeviceBuffer
 DeviceBuffer (DeviceBufferDescriptor desc)
 
virtual bool OnCopyHostBuffer (const uint8_t *source, Range source_range, size_t offset)=0
 
- 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

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.

21 reactor_(std::move(reactor)),
22 handle_(reactor_ ? reactor_->CreateHandle(HandleType::kBuffer)
24 backing_store_(std::move(backing_store)) {}
DeviceBuffer(DeviceBufferDescriptor desc)
Definition: device_buffer.cc:9
static HandleGLES DeadHandle()
Definition: handle_gles.h:35

◆ ~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}
constexpr bool IsDead() const
Definition: handle_gles.h:39

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}
GLenum type
const char * c_str() const
Definition: SkString.h:133
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126
static GLenum ToTarget(DeviceBufferGLES::BindingType type)
gl
Definition: malisc.py:41
static SkString to_string(int n)
Definition: nanobench.cpp:119
#define TRACE_EVENT1(category_group, name, arg1_name, arg1_val)
Definition: trace_event.h:141

◆ Flush()

void impeller::DeviceBufferGLES::Flush ( std::optional< Range range = std::nullopt) const
overridevirtual

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}

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