• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //    http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 // Sync.hpp: Defines sync objects for the EGL_KHR_fence_sync extension.
16 
17 #ifndef LIBEGL_SYNC_H_
18 #define LIBEGL_SYNC_H_
19 
20 #include "Context.hpp"
21 
22 #include <EGL/eglext.h>
23 
24 namespace egl
25 {
26 
27 class FenceSync
28 {
29 public:
FenceSync(Context * context)30 	explicit FenceSync(Context *context) : context(context)
31 	{
32 		status = EGL_UNSIGNALED_KHR;
33 		context->addRef();
34 	}
35 
~FenceSync()36 	~FenceSync()
37 	{
38 		context->release();
39 		context = nullptr;
40 	}
41 
wait()42 	void wait() { context->finish(); signal(); }
signal()43 	void signal() { status = EGL_SIGNALED_KHR; }
isSignaled() const44 	bool isSignaled() const { return status == EGL_SIGNALED_KHR; }
45 
46 private:
47 	EGLint status;
48 	Context *context;
49 };
50 
51 }
52 
53 #endif   // LIBEGL_SYNC_H_
54