85 lines
2.1 KiB
C++
85 lines
2.1 KiB
C++
#include "Present_Surface_Lease.h"
|
|
|
|
namespace renderive {
|
|
|
|
Present_Surface_Lease::Present_Surface_Lease() = default;
|
|
|
|
Present_Surface_Lease::Present_Surface_Lease(Present_Surface_Lease&& other) noexcept {
|
|
move_from(std::move(other));
|
|
}
|
|
|
|
Present_Surface_Lease& Present_Surface_Lease::operator=(Present_Surface_Lease&& other) noexcept {
|
|
if (this == &other)
|
|
return *this;
|
|
reset();
|
|
move_from(std::move(other));
|
|
return *this;
|
|
}
|
|
|
|
Present_Surface_Lease::~Present_Surface_Lease() {
|
|
reset();
|
|
}
|
|
|
|
Present_Surface_Lease::operator bool() const {
|
|
return output() != nullptr;
|
|
}
|
|
|
|
bool Present_Surface_Lease::new_frame() const {
|
|
return is_new_frame;
|
|
}
|
|
|
|
bool Present_Surface_Lease::request_was_pending() const {
|
|
return update_was_pending;
|
|
}
|
|
|
|
Image_View Present_Surface_Lease::image() const {
|
|
Render_Output* current = output();
|
|
if (!current)
|
|
return {};
|
|
return current->image.view();
|
|
}
|
|
|
|
Present_Surface_Lease Present_Surface_Lease::empty(bool is_new_frame, bool update_was_pending) {
|
|
Present_Surface_Lease lease;
|
|
lease.is_new_frame = is_new_frame;
|
|
lease.update_was_pending = update_was_pending;
|
|
return lease;
|
|
}
|
|
|
|
Render_Output* Present_Surface_Lease::output() const {
|
|
return output_ ? output_(&storage_) : nullptr;
|
|
}
|
|
|
|
void Present_Surface_Lease::reset() {
|
|
if (destroy_)
|
|
destroy_(&storage_);
|
|
output_ = nullptr;
|
|
destroy_ = nullptr;
|
|
move_ = nullptr;
|
|
is_new_frame = false;
|
|
update_was_pending = false;
|
|
}
|
|
|
|
void Present_Surface_Lease::move_from(Present_Surface_Lease&& other) noexcept {
|
|
if (!other.move_) {
|
|
is_new_frame = other.is_new_frame;
|
|
update_was_pending = other.update_was_pending;
|
|
other.is_new_frame = false;
|
|
other.update_was_pending = false;
|
|
return;
|
|
}
|
|
other.move_(&storage_, &other.storage_);
|
|
output_ = other.output_;
|
|
destroy_ = other.destroy_;
|
|
move_ = other.move_;
|
|
is_new_frame = other.is_new_frame;
|
|
update_was_pending = other.update_was_pending;
|
|
other.output_ = nullptr;
|
|
other.destroy_ = nullptr;
|
|
other.move_ = nullptr;
|
|
other.is_new_frame = false;
|
|
other.update_was_pending = false;
|
|
}
|
|
|
|
} // namespace renderive
|