Flutter Engine
 
Loading...
Searching...
No Matches
buffer_view.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_BUFFER_VIEW_H_
6#define FLUTTER_IMPELLER_CORE_BUFFER_VIEW_H_
7
8#include <memory>
10
11namespace impeller {
12
13class DeviceBuffer;
14
15/// A specific range in a DeviceBuffer.
16///
17/// BufferView can maintain ownership over the DeviceBuffer or not depending on
18/// if it is created with a std::shared_ptr or a raw pointer.
19struct BufferView {
20 public:
21 BufferView();
22
23 BufferView(DeviceBuffer* buffer, Range range);
24
25 BufferView(std::shared_ptr<const DeviceBuffer> buffer, Range range);
26
27 Range GetRange() const { return range_; }
28
29 const DeviceBuffer* GetBuffer() const;
30
31 std::shared_ptr<const DeviceBuffer> TakeBuffer();
32
33 explicit operator bool() const;
34
35 private:
36 std::shared_ptr<const DeviceBuffer> buffer_;
37 /// This is a non-owned DeviceBuffer. Steps should be taken to make sure this
38 /// lives for the duration of the BufferView's life. Usually this is done
39 /// automatically by the graphics API or in the case of Vulkan the HostBuffer
40 /// or TrackedObjectsVK keeps it alive.
41 const DeviceBuffer* raw_buffer_;
42 Range range_;
43};
44
45} // namespace impeller
46
47#endif // FLUTTER_IMPELLER_CORE_BUFFER_VIEW_H_
Range GetRange() const
Definition buffer_view.h:27
std::shared_ptr< const DeviceBuffer > TakeBuffer()
const DeviceBuffer * GetBuffer() const