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 #pragma once
6 
7 #include <memory>
8 #include <string>
9 
10 #include "flutter/fml/macros.h"
12 #include "impeller/core/buffer.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 
45 
46  virtual uint8_t* OnGetContents() const = 0;
47 
48  protected:
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  FML_DISALLOW_COPY_AND_ASSIGN(DeviceBuffer);
59 };
60 
61 } // namespace impeller
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:13
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:14
impeller::Allocator
An object that allocates device memory.
Definition: allocator.h:25
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:13
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:39
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