xref: /aosp_15_r20/external/angle/src/libANGLE/renderer/EGLReusableSync.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2020 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 // EGL_KHR_reusable_sync
8 
9 #ifndef LIBANGLE_RENDERER_EGLREUSABLESYNC_H_
10 #define LIBANGLE_RENDERER_EGLREUSABLESYNC_H_
11 
12 #include "libANGLE/AttributeMap.h"
13 #include "libANGLE/renderer/EGLSyncImpl.h"
14 
15 #include "common/angleutils.h"
16 
17 #include <condition_variable>
18 
19 namespace rx
20 {
21 
22 class ReusableSync final : public EGLSyncImpl
23 {
24   public:
25     ReusableSync();
26     ~ReusableSync() override;
27 
28     void onDestroy(const egl::Display *display) override;
29 
30     egl::Error initialize(const egl::Display *display,
31                           const gl::Context *context,
32                           EGLenum type,
33                           const egl::AttributeMap &attribs) override;
34     egl::Error clientWait(const egl::Display *display,
35                           const gl::Context *context,
36                           EGLint flags,
37                           EGLTime timeout,
38                           EGLint *outResult) override;
39     egl::Error serverWait(const egl::Display *display,
40                           const gl::Context *context,
41                           EGLint flags) override;
42     egl::Error signal(const egl::Display *display,
43                       const gl::Context *context,
44                       EGLint mode) override;
45     egl::Error getStatus(const egl::Display *display, EGLint *outStatus) override;
46 
47   private:
48     EGLint mStatus;
49     std::condition_variable mCondVar;
50     std::unique_lock<std::mutex> mMutex;
51 };
52 
53 }  // namespace rx
54 
55 #endif  // LIBANGLE_RENDERER_EGLREUSABLESYNC_H_
56