1 // 2 // Copyright 2019 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 // EGLSync.h: Defines the egl::Sync classes, which support the EGL_KHR_fence_sync, 8 // EGL_KHR_wait_sync and EGL 1.5 sync objects. 9 10 #ifndef LIBANGLE_EGLSYNC_H_ 11 #define LIBANGLE_EGLSYNC_H_ 12 13 #include "libANGLE/Debug.h" 14 #include "libANGLE/Error.h" 15 #include "libANGLE/RefCountObject.h" 16 17 #include "common/angleutils.h" 18 19 namespace rx 20 { 21 class EGLImplFactory; 22 class EGLSyncImpl; 23 } // namespace rx 24 25 namespace gl 26 { 27 class Context; 28 } // namespace gl 29 30 namespace egl 31 { 32 class Sync final : public LabeledObject 33 { 34 public: 35 Sync(rx::EGLImplFactory *factory, EGLenum type); 36 ~Sync() override; 37 38 void setLabel(EGLLabelKHR label) override; 39 EGLLabelKHR getLabel() const override; 40 id()41 const SyncID &id() const { return mId; } 42 43 void onDestroy(const Display *display); 44 45 Error initialize(const Display *display, 46 const gl::Context *context, 47 const SyncID &id, 48 const AttributeMap &attribs); 49 Error clientWait(const Display *display, 50 const gl::Context *context, 51 EGLint flags, 52 EGLTime timeout, 53 EGLint *outResult); 54 Error serverWait(const Display *display, const gl::Context *context, EGLint flags); 55 Error signal(const Display *display, const gl::Context *context, EGLint mode); 56 Error getStatus(const Display *display, EGLint *outStatus) const; 57 58 Error copyMetalSharedEventANGLE(const Display *display, void **result) const; 59 Error dupNativeFenceFD(const Display *display, EGLint *result) const; 60 getType()61 EGLenum getType() const { return mType; } getAttributeMap()62 const AttributeMap &getAttributeMap() const { return mAttributeMap; } getCondition()63 EGLint getCondition() const { return mCondition; } getNativeFenceFD()64 EGLint getNativeFenceFD() const { return mNativeFenceFD; } 65 66 private: 67 std::unique_ptr<rx::EGLSyncImpl> mFence; 68 69 EGLLabelKHR mLabel; 70 71 SyncID mId; 72 EGLenum mType; 73 AttributeMap mAttributeMap; 74 EGLint mCondition; 75 EGLint mNativeFenceFD; 76 }; 77 78 } // namespace egl 79 80 #endif // LIBANGLE_FENCE_H_ 81