| Flutter Impeller |

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
11 #include "impeller/core/allocator.h"
12 #include "impeller/core/buffer.h"
13 #include "impeller/core/buffer_view.h"
14 #include "impeller/core/device_buffer_descriptor.h"
15 #include "impeller/core/range.h"
16 #include "impeller/core/texture.h"
17
18 namespace impeller {
19
20 class DeviceBuffer : public Buffer,
21 public std::enable_shared_from_this<DeviceBuffer> {
22 public:
23 virtual ~DeviceBuffer();
24
25 [[nodiscard]] bool CopyHostBuffer(const uint8_t* source,
26 Range source_range,
27 size_t offset = 0u);
28
29 virtual bool SetLabel(const std::string& label) = 0;
30
31 virtual bool SetLabel(const std::string& label, Range range) = 0;
32
33 BufferView AsBufferView() const;
34
35 virtual std::shared_ptr<Texture> AsTexture(
36 Allocator& allocator,
37 const TextureDescriptor& descriptor,
38 uint16_t row_bytes) const;
39
40 // |Buffer|
41 std::shared_ptr<const DeviceBuffer> GetDeviceBuffer(
42 Allocator& allocator) const;
43
44 const DeviceBufferDescriptor& GetDeviceBufferDescriptor() const;
45
46 virtual uint8_t* OnGetContents() const = 0;
47
48 protected:
49 const DeviceBufferDescriptor desc_;
50
51 explicit DeviceBuffer(DeviceBufferDescriptor desc);
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_
impeller::DeviceBuffer::OnGetContents
virtual uint8_t * OnGetContents() const =0
impeller::DeviceBuffer::DeviceBuffer
DeviceBuffer(DeviceBufferDescriptor desc)
Definition: device_buffer.cc:9
impeller::DeviceBuffer
Definition: device_buffer.h:20
impeller::DeviceBufferDescriptor
Definition: device_buffer_descriptor.h:14
impeller::DeviceBuffer::~DeviceBuffer
virtual ~DeviceBuffer()
impeller::DeviceBuffer::AsTexture
virtual std::shared_ptr< Texture > AsTexture(Allocator &allocator, const TextureDescriptor &descriptor, uint16_t row_bytes) const
Definition: device_buffer.cc:27
impeller::DeviceBuffer::CopyHostBuffer
bool CopyHostBuffer(const uint8_t *source, Range source_range, size_t offset=0u)
Definition: device_buffer.cc:46
impeller::Buffer
Definition: buffer.h:15
impeller::Allocator
An object that allocates device memory.
Definition: allocator.h:22
impeller::DeviceBuffer::GetDeviceBufferDescriptor
const DeviceBufferDescriptor & GetDeviceBufferDescriptor() const
Definition: device_buffer.cc:42
range.h
buffer.h
impeller::DeviceBuffer::SetLabel
virtual bool SetLabel(const std::string &label)=0
allocator.h
impeller::BufferView
Definition: buffer_view.h:13
impeller::Range
Definition: range.h:14
buffer_view.h
impeller::DeviceBuffer::desc_
const DeviceBufferDescriptor desc_
Definition: device_buffer.h:49
texture.h
impeller::DeviceBuffer::OnCopyHostBuffer
virtual bool OnCopyHostBuffer(const uint8_t *source, Range source_range, size_t offset)=0
device_buffer_descriptor.h
impeller::TextureDescriptor
A lightweight object that describes the attributes of a texture that can then used an allocator to cr...
Definition: texture_descriptor.h:37
impeller::DeviceBuffer::GetDeviceBuffer
std::shared_ptr< const DeviceBuffer > GetDeviceBuffer(Allocator &allocator) const
Definition: device_buffer.cc:14
impeller::DeviceBuffer::AsBufferView
BufferView AsBufferView() const
Definition: device_buffer.cc:19
impeller
Definition: aiks_context.cc:10