Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
context.h
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#ifndef FLUTTER_IMPELLER_TOOLKIT_EGL_CONTEXT_H_
6#define FLUTTER_IMPELLER_TOOLKIT_EGL_CONTEXT_H_
7
8#include <functional>
9
10#include "flutter/fml/macros.h"
14
15namespace impeller {
16namespace egl {
17
18class Surface;
19
20class Context {
21 public:
22 Context(EGLDisplay display, EGLContext context);
23
24 ~Context();
25
26 bool IsValid() const;
27
28 const EGLContext& GetHandle() const;
29
30 bool MakeCurrent(const Surface& surface) const;
31
32 bool ClearCurrent() const;
33
38 using LifecycleListener = std::function<void(LifecycleEvent)>;
39 std::optional<UniqueID> AddLifecycleListener(
40 const LifecycleListener& listener);
41
43
44 private:
45 EGLDisplay display_ = EGL_NO_DISPLAY;
46 EGLContext context_ = EGL_NO_CONTEXT;
47 mutable RWMutex listeners_mutex_;
48 std::map<UniqueID, LifecycleListener> listeners_ IPLR_GUARDED_BY(
49 listeners_mutex_);
50
51 void DispatchLifecyleEvent(LifecycleEvent event) const;
52
53 Context(const Context&) = delete;
54
55 Context& operator=(const Context&) = delete;
56};
57
58} // namespace egl
59} // namespace impeller
60
61#endif // FLUTTER_IMPELLER_TOOLKIT_EGL_CONTEXT_H_
std::function< void(LifecycleEvent)> LifecycleListener
Definition context.h:38
bool ClearCurrent() const
Definition context.cc:61
std::optional< UniqueID > AddLifecycleListener(const LifecycleListener &listener)
Definition context.cc:74
const EGLContext & GetHandle() const
Definition context.cc:27
bool RemoveLifecycleListener(UniqueID id)
Definition context.cc:85
bool IsValid() const
Definition context.cc:23
bool MakeCurrent(const Surface &surface) const
Definition context.cc:45
VkSurfaceKHR surface
Definition main.cc:49
FlKeyEvent * event
#define IPLR_GUARDED_BY(x)