Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
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
9namespace impeller {
10
11UniqueHandleGLES::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,
24 HandleGLES handle = reactor->CreateUntrackedHandle(type);
25 return UniqueHandleGLES(std::move(reactor), handle);
26}
27
28UniqueHandleGLES::UniqueHandleGLES(std::shared_ptr<ReactorGLES> reactor,
29 HandleGLES handle)
30 : reactor_(std::move(reactor)), handle_(handle) {}
31
33 CollectHandle();
34}
35
36void UniqueHandleGLES::CollectHandle() {
37 if (!handle_.IsDead() && reactor_) {
38 reactor_->CollectHandle(handle_);
39 }
40}
41
43 return handle_;
44}
45
47 return !handle_.IsDead();
48}
49
51 CollectHandle();
52 reactor_.reset();
53 handle_ = HandleGLES::DeadHandle();
54}
55
57 reactor_.reset();
58 HandleGLES old_handle = handle_;
59 handle_ = HandleGLES::DeadHandle();
60 return old_handle;
61}
62
64 std::swap(reactor_, other.reactor_);
65 std::swap(handle_, other.handle_);
66}
67
69 if (this != &other) {
70 Reset();
71 std::swap(reactor_, other.reactor_);
72 std::swap(handle_, other.handle_);
73 }
74 return *this;
75}
76
77} // namespace impeller
Represents a handle to an underlying OpenGL object. Unlike OpenGL object handles, these handles can b...
Definition handle_gles.h:42
constexpr bool IsDead() const
Determines if the handle is dead.
Definition handle_gles.h:58
static HandleGLES DeadHandle()
Creates a dead handle.
Definition handle_gles.h:49
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)
const HandleGLES & Get() const
void Reset()
Collect the managed handle and replace it with a dead handle.
UniqueHandleGLES & operator=(UniqueHandleGLES &&)
HandleGLES Release()
Release ownership of the handle.
#define FML_DCHECK(condition)
Definition logging.h:122
Definition ref_ptr.h:261
fuchsia::ui::composition::ParentViewportWatcherHandle handle_
std::shared_ptr< ReactorGLES > reactor
impeller::ShaderType type