KWin
Loading...
Searching...
No Matches
src
opengl
eglnativefence.cpp
Go to the documentation of this file.
1
/*
2
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
3
4
SPDX-License-Identifier: GPL-2.0-or-later
5
*/
6
7
#include "
eglnativefence.h
"
8
#include "
egldisplay.h
"
9
10
#include <unistd.h>
11
12
namespace
KWin
13
{
14
15
#ifndef EGL_ANDROID_native_fence_sync
16
#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144
17
#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1
18
#endif
// EGL_ANDROID_native_fence_sync
19
20
EGLNativeFence::EGLNativeFence
(
EglDisplay
*display)
21
:
EGLNativeFence
(display, eglCreateSyncKHR(display->handle(),
EGL_SYNC_NATIVE_FENCE_ANDROID
, nullptr))
22
{
23
if
(m_sync != EGL_NO_SYNC_KHR) {
24
// The native fence will get a valid sync file fd only after a flush.
25
glFlush();
26
m_fileDescriptor =
FileDescriptor
(eglDupNativeFenceFDANDROID(m_display->
handle
(), m_sync));
27
}
28
}
29
30
EGLNativeFence::EGLNativeFence
(
EglDisplay
*display, EGLSyncKHR sync)
31
: m_sync(sync)
32
, m_display(display)
33
{
34
}
35
36
EGLNativeFence::~EGLNativeFence
()
37
{
38
m_fileDescriptor.
reset
();
39
if
(m_sync != EGL_NO_SYNC_KHR) {
40
eglDestroySyncKHR(m_display->
handle
(), m_sync);
41
}
42
}
43
44
bool
EGLNativeFence::isValid
()
const
45
{
46
return
m_sync != EGL_NO_SYNC_KHR && m_fileDescriptor.
isValid
();
47
}
48
49
const
FileDescriptor
&
EGLNativeFence::fileDescriptor
()
const
50
{
51
return
m_fileDescriptor;
52
}
53
54
bool
EGLNativeFence::waitSync
()
const
55
{
56
return
eglWaitSync(m_display->
handle
(), m_sync, 0) == EGL_TRUE;
57
}
58
59
EGLNativeFence
EGLNativeFence::importFence
(
EglDisplay
*display,
FileDescriptor
&&fd)
60
{
61
EGLint attributes[] = {
62
EGL_SYNC_NATIVE_FENCE_FD_ANDROID, fd.take(),
63
EGL_NONE};
64
return
EGLNativeFence
(display, eglCreateSyncKHR(display->
handle
(),
EGL_SYNC_NATIVE_FENCE_ANDROID
, attributes));
65
}
66
67
}
// namespace KWin
KWin::EGLNativeFence
Definition
eglnativefence.h:20
KWin::EGLNativeFence::waitSync
bool waitSync() const
Definition
eglnativefence.cpp:54
KWin::EGLNativeFence::importFence
static EGLNativeFence importFence(EglDisplay *display, FileDescriptor &&fd)
Definition
eglnativefence.cpp:59
KWin::EGLNativeFence::~EGLNativeFence
~EGLNativeFence()
Definition
eglnativefence.cpp:36
KWin::EGLNativeFence::EGLNativeFence
EGLNativeFence(EglDisplay *display)
Definition
eglnativefence.cpp:20
KWin::EGLNativeFence::fileDescriptor
const FileDescriptor & fileDescriptor() const
Definition
eglnativefence.cpp:49
KWin::EGLNativeFence::isValid
bool isValid() const
Definition
eglnativefence.cpp:44
KWin::EglDisplay
Definition
egldisplay.h:26
KWin::EglDisplay::handle
::EGLDisplay handle() const
Definition
egldisplay.cpp:98
KWin::FileDescriptor
Definition
filedescriptor.h:17
KWin::FileDescriptor::reset
void reset()
Definition
filedescriptor.cpp:60
KWin::FileDescriptor::isValid
bool isValid() const
Definition
filedescriptor.cpp:45
egldisplay.h
EGL_SYNC_NATIVE_FENCE_ANDROID
#define EGL_SYNC_NATIVE_FENCE_ANDROID
Definition
eglnativefence.cpp:16
eglnativefence.h
KWin
Definition
activation_test.cpp:20
Generated on Sat Feb 17 2024 01:42:09 for KWin by
1.10.0