| Flutter Impeller |

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>
9 #include "impeller/core/range.h"
10
11 namespace impeller {
12
13 class 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.
19 struct 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_
impeller::DeviceBuffer
Definition: device_buffer.h:18
impeller
Definition: allocation.cc:12
range.h
impeller::BufferView
Definition: buffer_view.h:19
impeller::BufferView::GetRange
Range GetRange() const
Definition: buffer_view.h:27
impeller::BufferView::TakeBuffer
std::shared_ptr< const DeviceBuffer > TakeBuffer()
Definition: buffer_view.cc:21
impeller::BufferView::BufferView
BufferView()
Definition: buffer_view.cc:9
impeller::BufferView::GetBuffer
const DeviceBuffer * GetBuffer() const
Definition: buffer_view.cc:17
impeller::Range
Definition: range.h:13