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