• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
24 void PthreadKeyDestructorCallback(void *ptr);
25 }  // namespace angle
26 
27 namespace gl
28 {
29 class Context;
30 }  // namespace gl
31 
32 namespace egl
33 {
34 class Error;
35 class Debug;
36 class Display;
37 class Surface;
38 
39 class Thread : public LabeledObject
40 {
41   public:
42     Thread();
43 
44     void setLabel(EGLLabelKHR label) override;
45     EGLLabelKHR getLabel() const override;
46 
47     void setSuccess();
48 
49     void setError(EGLint error,
50                   const char *command,
51                   const LabeledObject *object,
52                   const char *message);
53 
54     // TODO: Remove egl::Error. http://anglebug.com/3041
55     void setError(const Error &error, const char *command, const LabeledObject *object);
56     EGLint getError() const;
57 
58     void setAPI(EGLenum api);
59     EGLenum getAPI() const;
60 
61     void setCurrent(gl::Context *context);
62     Surface *getCurrentDrawSurface() const;
63     Surface *getCurrentReadSurface() const;
64     gl::Context *getContext() const;
65     Display *getDisplay() const;
66 
67   private:
68     EGLLabelKHR mLabel;
69     EGLint mError;
70     EGLenum mAPI;
71     gl::Context *mContext;
72 };
73 
74 void EnsureDebugAllocated();
75 void DeallocateDebug();
76 Debug *GetDebug();
77 
78 }  // namespace egl
79 
80 #endif  // LIBANGLE_THREAD_H_
81