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 
6 
7 #include <utility>
8 
9 namespace impeller {
10 
11 UniqueHandleGLES::UniqueHandleGLES(std::shared_ptr<ReactorGLES> reactor,
13  : reactor_(std::move(reactor)) {
14  if (reactor_) {
15  handle_ = reactor_->CreateHandle(type);
16  }
17 }
18 
19 // static
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 
33  if (!handle_.IsDead() && reactor_) {
34  reactor_->CollectHandle(handle_);
35  }
36 }
37 
39  return handle_;
40 }
41 
43  return !handle_.IsDead();
44 }
45 
47  std::swap(reactor_, other.reactor_);
48  std::swap(handle_, other.handle_);
49 }
50 
51 } // namespace impeller
GLenum type
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
Definition: handle_gles.h:37
constexpr bool IsDead() const
Determines if the handle is dead.
Definition: handle_gles.h:53
A unique handle to an OpenGL object. The collection of this handle scheduled the destruction of the a...
static UniqueHandleGLES MakeUntracked(std::shared_ptr< ReactorGLES > reactor, HandleType type)
UniqueHandleGLES(std::shared_ptr< ReactorGLES > reactor, HandleType type)
const HandleGLES & Get() const
Definition: comparable.h:95