| Flutter Impeller |

unique_handle_gles.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/renderer/backend/gles/unique_handle_gles.h"
6
7 #include <utility>
8
9 namespace impeller {
10
11 UniqueHandleGLES::UniqueHandleGLES(std::shared_ptr<ReactorGLES> reactor,
12 HandleType type)
13 : reactor_(std::move(reactor)) {
14 if (reactor_) {
15 handle_ = reactor_->CreateHandle(type);
16 }
17 }
18
19 // static
20 UniqueHandleGLES UniqueHandleGLES::MakeUntracked(
21 std::shared_ptr<ReactorGLES> reactor,
22 HandleType type) {
23 FML_DCHECK(reactor);
24 HandleGLES handle = reactor->CreateUntrackedHandle(type);
25 return UniqueHandleGLES(std::move(reactor), handle);
26 }
27
28 UniqueHandleGLES::UniqueHandleGLES(std::shared_ptr<ReactorGLES> reactor,
29 HandleGLES handle)
30 : reactor_(std::move(reactor)), handle_(handle) {}
31
32 UniqueHandleGLES::~UniqueHandleGLES() {
33 if (!handle_.IsDead() && reactor_) {
34 reactor_->CollectHandle(handle_);
35 }
36 }
37
38 const HandleGLES& UniqueHandleGLES::Get() const {
39 return handle_;
40 }
41
42 bool UniqueHandleGLES::IsValid() const {
43 return !handle_.IsDead();
44 }
45
46 UniqueHandleGLES::UniqueHandleGLES(UniqueHandleGLES&& other) {
47 std::swap(reactor_, other.reactor_);
48 std::swap(handle_, other.handle_);
49 }
50
51 } // namespace impeller
type
GLenum type
Definition: blit_command_gles.cc:153
impeller::HandleGLES
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
Definition: handle_gles.h:37
impeller::HandleGLES::IsDead
constexpr bool IsDead() const
Determines if the handle is dead.
Definition: handle_gles.h:53
impeller::UniqueHandleGLES
A unique handle to an OpenGL object. The collection of this handle scheduled the destruction of the a...
Definition: unique_handle_gles.h:18
impeller::UniqueHandleGLES::MakeUntracked
static UniqueHandleGLES MakeUntracked(std::shared_ptr< ReactorGLES > reactor, HandleType type)
Definition: unique_handle_gles.cc:20
impeller::UniqueHandleGLES::UniqueHandleGLES
UniqueHandleGLES(std::shared_ptr< ReactorGLES > reactor, HandleType type)
Definition: unique_handle_gles.cc:11
impeller::UniqueHandleGLES::Get
const HandleGLES & Get() const
Definition: unique_handle_gles.cc:38
impeller::UniqueHandleGLES::IsValid
bool IsValid() const
Definition: unique_handle_gles.cc:42
impeller::UniqueHandleGLES::~UniqueHandleGLES
~UniqueHandleGLES()
Definition: unique_handle_gles.cc:32
impeller
Definition: allocation.cc:12
impeller::HandleType
HandleType
Definition: handle_gles.h:18
std
Definition: comparable.h:95
unique_handle_gles.h