• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2002 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.cpp: Implements the egl::Sync class.
8 
9 #include "libANGLE/EGLSync.h"
10 
11 #include "angle_gl.h"
12 
13 #include "common/utilities.h"
14 #include "libANGLE/renderer/EGLImplFactory.h"
15 #include "libANGLE/renderer/EGLSyncImpl.h"
16 
17 namespace egl
18 {
19 
Sync(rx::EGLImplFactory * factory,EGLenum type,const AttributeMap & attribs)20 Sync::Sync(rx::EGLImplFactory *factory, EGLenum type, const AttributeMap &attribs)
21     : mFence(factory->createSync(attribs)),
22       mLabel(nullptr),
23       mType(type),
24       mCondition(EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR),
25       mNativeFenceFD(
26           attribs.getAsInt(EGL_SYNC_NATIVE_FENCE_FD_ANDROID, EGL_NO_NATIVE_FENCE_FD_ANDROID))
27 {
28     // Per extension spec: Signaling Condition.
29     // "If the EGL_SYNC_NATIVE_FENCE_FD_ANDROID attribute is not
30     // EGL_NO_NATIVE_FENCE_FD_ANDROID then the EGL_SYNC_CONDITION_KHR attribute
31     // is set to EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID and the EGL_SYNC_STATUS_KHR
32     // attribute is set to reflect the signal status of the native fence object.
33     if ((mType == EGL_SYNC_NATIVE_FENCE_ANDROID) &&
34         (mNativeFenceFD != EGL_NO_NATIVE_FENCE_FD_ANDROID))
35     {
36         mCondition = EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID;
37     }
38 }
39 
onDestroy(const Display * display)40 void Sync::onDestroy(const Display *display)
41 {
42     ASSERT(mFence);
43     mFence->onDestroy(display);
44     mFence.reset();
45 }
46 
~Sync()47 Sync::~Sync() {}
48 
initialize(const Display * display,const gl::Context * context)49 Error Sync::initialize(const Display *display, const gl::Context *context)
50 {
51     return mFence->initialize(display, context, mType);
52 }
53 
setLabel(EGLLabelKHR label)54 void Sync::setLabel(EGLLabelKHR label)
55 {
56     mLabel = label;
57 }
58 
getLabel() const59 EGLLabelKHR Sync::getLabel() const
60 {
61     return mLabel;
62 }
63 
clientWait(const Display * display,const gl::Context * context,EGLint flags,EGLTime timeout,EGLint * outResult)64 Error Sync::clientWait(const Display *display,
65                        const gl::Context *context,
66                        EGLint flags,
67                        EGLTime timeout,
68                        EGLint *outResult)
69 {
70     return mFence->clientWait(display, context, flags, timeout, outResult);
71 }
72 
serverWait(const Display * display,const gl::Context * context,EGLint flags)73 Error Sync::serverWait(const Display *display, const gl::Context *context, EGLint flags)
74 {
75     return mFence->serverWait(display, context, flags);
76 }
77 
getStatus(const Display * display,EGLint * outStatus) const78 Error Sync::getStatus(const Display *display, EGLint *outStatus) const
79 {
80     return mFence->getStatus(display, outStatus);
81 }
82 
dupNativeFenceFD(const Display * display,EGLint * result) const83 Error Sync::dupNativeFenceFD(const Display *display, EGLint *result) const
84 {
85     return mFence->dupNativeFenceFD(display, result);
86 }
87 
88 }  // namespace egl
89