xref: /aosp_15_r20/external/angle/src/libANGLE/Thread.h (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1 //
2 // Copyright 2016 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 // Thread.h : Defines the Thread class which represents a global EGL thread.
8 
9 #ifndef LIBANGLE_THREAD_H_
10 #define LIBANGLE_THREAD_H_
11 
12 #include <EGL/egl.h>
13 
14 #include "libANGLE/Debug.h"
15 
16 #include <atomic>
17 
18 namespace angle
19 {
20 #if defined(ANGLE_USE_ANDROID_TLS_SLOT)
21 extern bool gUseAndroidOpenGLTlsSlot;
22 #endif
23 }  // namespace angle
24 
25 namespace gl
26 {
27 class Context;
28 }  // namespace gl
29 
30 namespace egl
31 {
32 class Error;
33 class Debug;
34 class Display;
35 class Surface;
36 
37 class Thread : public LabeledObject
38 {
39   public:
40     Thread();
41 
42     void setLabel(EGLLabelKHR label) override;
43     EGLLabelKHR getLabel() const override;
44 
45     void setSuccess();
46 
47     void setError(EGLint error,
48                   const char *command,
49                   const LabeledObject *object,
50                   const char *message);
51 
52     // TODO: Remove egl::Error. http://anglebug.com/42261727
53     void setError(const Error &error, const char *command, const LabeledObject *object);
54     EGLint getError() const;
55 
56     void setAPI(EGLenum api);
57     EGLenum getAPI() const;
58 
59     void setCurrent(gl::Context *context);
60     Surface *getCurrentDrawSurface() const;
61     Surface *getCurrentReadSurface() const;
62     gl::Context *getContext() const;
63     Display *getDisplay() const;
64 
65   private:
66     EGLLabelKHR mLabel;
67     EGLint mError;
68     EGLenum mAPI;
69     gl::Context *mContext;
70 };
71 
72 void EnsureDebugAllocated();
73 void DeallocateDebug();
74 Debug *GetDebug();
75 
76 }  // namespace egl
77 
78 #endif  // LIBANGLE_THREAD_H_
79