Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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
16
17namespace impeller {
18
20 : public DeviceBuffer,
21 public BackendCast<DeviceBufferGLES, DeviceBuffer> {
22 public:
24 std::shared_ptr<ReactorGLES> reactor,
25 std::unique_ptr<Allocation> backing_store);
26
27 // |DeviceBuffer|
28 ~DeviceBufferGLES() override;
29
30 const uint8_t* GetBufferData() const;
31
33 const std::function<void(uint8_t*, size_t length)>& update_buffer_data);
34
40
41 [[nodiscard]] bool BindAndUploadDataIfNecessary(BindingType type) const;
42
43 void Flush(std::optional<Range> range = std::nullopt) const override;
44
45 std::optional<GLuint> GetHandle() const;
46
47 private:
48 std::shared_ptr<ReactorGLES> reactor_;
49 std::optional<std::string> label_;
50 // Mutable for lazy evaluation.
51 mutable std::optional<HandleGLES> handle_;
52 mutable std::unique_ptr<Allocation> backing_store_;
53 // Guards dirty_range_. Flush() merges ranges from writer threads (e.g. the
54 // UI thread for flutter_gpu host-visible buffers) while
55 // BindAndUploadDataIfNecessary() consumes the range on a reactor thread.
56 mutable Mutex dirty_range_mutex_;
57 mutable std::optional<Range> dirty_range_
58 IPLR_GUARDED_BY(dirty_range_mutex_) = std::nullopt;
59 mutable bool initialized_ = false;
60
61 // |DeviceBuffer|
62 uint8_t* OnGetContents() const override;
63
64 // |DeviceBuffer|
65 bool OnCopyHostBuffer(const uint8_t* source,
66 Range source_range,
67 size_t offset) override;
68
69 // |DeviceBuffer|
70 bool SetLabel(std::string_view label) override;
71
72 // |DeviceBuffer|
73 bool SetLabel(std::string_view label, Range range) override;
74
75 DeviceBufferGLES(const DeviceBufferGLES&) = delete;
76
77 DeviceBufferGLES& operator=(const DeviceBufferGLES&) = delete;
78};
79
80} // namespace impeller
81
82#endif // FLUTTER_IMPELLER_RENDERER_BACKEND_GLES_DEVICE_BUFFER_GLES_H_
void Flush(std::optional< Range > range=std::nullopt) const override
void UpdateBufferData(const std::function< void(uint8_t *, size_t length)> &update_buffer_data)
bool BindAndUploadDataIfNecessary(BindingType type) const
const uint8_t * GetBufferData() const
std::optional< GLuint > GetHandle() const
size_t length
std::shared_ptr< ReactorGLES > reactor
impeller::ShaderType type
#define IPLR_GUARDED_BY(x)