forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontext.h
More file actions
56 lines (39 loc) · 1.26 KB
/
context.h
File metadata and controls
56 lines (39 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include <functional>
#include "flutter/fml/macros.h"
#include "impeller/base/comparable.h"
#include "impeller/base/thread.h"
#include "impeller/toolkit/egl/egl.h"
namespace impeller {
namespace egl {
class Surface;
class Context {
public:
Context(EGLDisplay display, EGLContext context);
~Context();
bool IsValid() const;
const EGLContext& GetHandle() const;
bool MakeCurrent(const Surface& surface) const;
bool ClearCurrent() const;
enum class LifecycleEvent {
kDidMakeCurrent,
kWillClearCurrent,
};
using LifecycleListener = std::function<void(LifecycleEvent)>;
std::optional<UniqueID> AddLifecycleListener(
const LifecycleListener& listener);
bool RemoveLifecycleListener(UniqueID id);
private:
EGLDisplay display_ = EGL_NO_DISPLAY;
EGLContext context_ = EGL_NO_CONTEXT;
mutable RWMutex listeners_mutex_;
std::map<UniqueID, LifecycleListener> listeners_
IPLR_GUARDED_BY(listeners_mutex_);
void DispatchLifecyleEvent(LifecycleEvent event) const;
FML_DISALLOW_COPY_AND_ASSIGN(Context);
};
} // namespace egl
} // namespace impeller