| Flutter Impeller |

buffer_view.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
5 #include "impeller/core/buffer_view.h"
6
7 namespace impeller {
8
9 BufferView::BufferView() : buffer_(nullptr), raw_buffer_(nullptr), range_({}) {}
10
11 BufferView::BufferView(DeviceBuffer* buffer, Range range)
12 : buffer_(), raw_buffer_(buffer), range_(range) {}
13
14 BufferView::BufferView(std::shared_ptr<const DeviceBuffer> buffer, Range range)
15 : buffer_(std::move(buffer)), raw_buffer_(nullptr), range_(range) {}
16
17 const DeviceBuffer* BufferView::GetBuffer() const {
18 return raw_buffer_ ? raw_buffer_ : buffer_.get();
19 }
20
21 std::shared_ptr<const DeviceBuffer> BufferView::TakeBuffer() {
22 if (buffer_) {
23 raw_buffer_ = buffer_.get();
24 return std::move(buffer_);
25 } else {
26 return nullptr;
27 }
28 }
29
30 BufferView::operator bool() const {
31 return buffer_ || raw_buffer_;
32 }
33
34 } // namespace impeller
buffer_view.h
impeller::DeviceBuffer
Definition: device_buffer.h:18
impeller
Definition: allocation.cc:12
std
Definition: comparable.h:95
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