Flutter Engine
 
Loading...
Searching...
No Matches
device_buffer.cc
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
6
7namespace impeller {
8
10
12
13void DeviceBuffer::Flush(std::optional<Range> range) const {}
14
15void DeviceBuffer::Invalidate(std::optional<Range> range) const {}
16
17// static
18BufferView DeviceBuffer::AsBufferView(std::shared_ptr<DeviceBuffer> buffer) {
19 Range range = {0u, buffer->desc_.size};
20 return BufferView(std::move(buffer), range);
21}
22
26
27[[nodiscard]] bool DeviceBuffer::CopyHostBuffer(const uint8_t* source,
28 Range source_range,
29 size_t offset) {
30 if (source_range.length == 0u) {
31 // Nothing to copy. Bail.
32 return true;
33 }
34
35 if (source == nullptr) {
36 // Attempted to copy data from a null buffer.
37 return false;
38 }
39
41 // One of the storage modes where a transfer queue must be used.
42 return false;
43 }
44
45 if (offset + source_range.length > desc_.size) {
46 // Out of bounds of this buffer.
47 return false;
48 }
49
50 return OnCopyHostBuffer(source, source_range, offset);
51}
52
53} // namespace impeller
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_
virtual void Invalidate(std::optional< Range > range=std::nullopt) const
const DeviceBufferDescriptor & GetDeviceBufferDescriptor() const
DeviceBuffer(DeviceBufferDescriptor desc)
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)
std::optional< PipelineDescriptor > desc_
size_t length
Definition range.h:15