Flutter Engine
The Flutter Engine
device_buffer.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_CORE_DEVICE_BUFFER_H_
6#define FLUTTER_IMPELLER_CORE_DEVICE_BUFFER_H_
7
8#include <memory>
9#include <string>
10
14#include "impeller/core/range.h"
15
16namespace impeller {
17
19 public:
20 virtual ~DeviceBuffer();
21
22 [[nodiscard]] bool CopyHostBuffer(const uint8_t* source,
23 Range source_range,
24 size_t offset = 0u);
25
26 virtual bool SetLabel(const std::string& label) = 0;
27
28 virtual bool SetLabel(const std::string& label, Range range) = 0;
29
30 /// @brief Create a buffer view of this entire buffer.
31 static BufferView AsBufferView(std::shared_ptr<DeviceBuffer> buffer);
32
34
35 virtual uint8_t* OnGetContents() const = 0;
36
37 /// Make any pending writes visible to the GPU.
38 ///
39 /// This method must be called if the device pointer provided by
40 /// [OnGetContents] is written to without using [CopyHostBuffer]. On Devices
41 /// with coherent host memory, this method will not perform extra work.
42 ///
43 /// If the range is not provided, the entire buffer is flushed.
44 virtual void Flush(std::optional<Range> range = std::nullopt) const;
45
46 virtual void Invalidate(std::optional<Range> range = std::nullopt) const;
47
48 protected:
50
52
53 virtual bool OnCopyHostBuffer(const uint8_t* source,
54 Range source_range,
55 size_t offset) = 0;
56
57 private:
58 DeviceBuffer(const DeviceBuffer&) = delete;
59
60 DeviceBuffer& operator=(const DeviceBuffer&) = delete;
61};
62
63} // namespace impeller
64
65#endif // FLUTTER_IMPELLER_CORE_DEVICE_BUFFER_H_
static BufferView AsBufferView(std::shared_ptr< DeviceBuffer > buffer)
Create a buffer view of this entire buffer.
virtual void Flush(std::optional< Range > range=std::nullopt) const
const DeviceBufferDescriptor desc_
Definition: device_buffer.h:49
virtual void Invalidate(std::optional< Range > range=std::nullopt) const
virtual uint8_t * OnGetContents() const =0
virtual bool SetLabel(const std::string &label)=0
const DeviceBufferDescriptor & GetDeviceBufferDescriptor() const
DeviceBuffer(DeviceBufferDescriptor desc)
Definition: device_buffer.cc:9
virtual bool OnCopyHostBuffer(const uint8_t *source, Range source_range, size_t offset)=0
bool CopyHostBuffer(const uint8_t *source, Range source_range, size_t offset=0u)
virtual bool SetLabel(const std::string &label, Range range)=0
SkBitmap source
Definition: examples.cpp:28
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
SeparatedVector2 offset