Qt 4.8
qmeegoextensions.cpp
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #include "qmeegoextensions.h"
43 #include <private/qeglcontext_p.h>
44 #include <private/qpixmapdata_gl_p.h>
45 
51 
52 /* Extension funcs */
53 
54 typedef EGLBoolean (EGLAPIENTRY *eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint, EGLint*);
57 typedef EGLBoolean (EGLAPIENTRY *eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint);
58 typedef EGLBoolean (EGLAPIENTRY *eglLockSurfaceKHRFunc)(EGLDisplay, EGLSurface, const EGLint*);
59 typedef EGLBoolean (EGLAPIENTRY *eglUnlockSurfaceKHRFunc)(EGLDisplay, EGLSurface);
60 typedef EGLSyncKHR (EGLAPIENTRY *eglCreateSyncKHRFunc)(EGLDisplay, EGLenum, const EGLint*);
61 typedef EGLBoolean (EGLAPIENTRY *eglDestroySyncKHRFunc)(EGLDisplay, EGLSyncKHR);
62 typedef EGLint (EGLAPIENTRY *eglClientWaitSyncKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR);
63 typedef EGLBoolean (EGLAPIENTRY *eglGetSyncAttribKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLint*);
64 
75 
76 /* Public */
77 
79 {
80  if (!initialized)
81  initialize();
82 
83  initialized = true;
84 }
85 
87 {
88  if (!hasImageShared)
89  qFatal("EGL_NOK_image_shared not found but trying to use capability!");
90 
91  return _eglCreateSharedImageNOK(dpy, image, props);
92 }
93 
94 bool QMeeGoExtensions::eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v)
95 {
96  if (!hasImageShared)
97  qFatal("EGL_NOK_image_shared not found but trying to use capability!");
98 
99  return _eglQueryImageNOK(dpy, image, prop, v);
100 }
101 
103 {
104  if (!hasImageShared)
105  qFatal("EGL_NOK_image_shared not found but trying to use capability!");
106 
107  return _eglDestroySharedImageNOK(dpy, img);
108 }
109 
110 bool QMeeGoExtensions::eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height)
111 {
112  if (!hasSurfaceScaling)
113  qFatal("EGL_NOK_surface_scaling not found but trying to use capability!");
114 
115  return _eglSetSurfaceScalingNOK(dpy, surface, x, y, width, height);
116 }
117 
118 bool QMeeGoExtensions::eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
119 {
120  if (!hasLockSurface)
121  qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!");
122 
123  return _eglLockSurfaceKHR(display, surface, attrib_list);
124 }
125 
126 bool QMeeGoExtensions::eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
127 {
128  if (!hasLockSurface)
129  qFatal("EGL_KHR_lock_surface2 not found but trying to use capability!");
130 
131  return _eglUnlockSurfaceKHR(display, surface);
132 }
133 
134 EGLSyncKHR QMeeGoExtensions::eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
135 {
136  if (!hasFenceSync)
137  qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
138 
139  return _eglCreateSyncKHR(dpy, type, attrib_list);
140 }
141 
143 {
144  if (!hasFenceSync)
145  qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
146 
147  return _eglDestroySyncKHR(dpy, sync);
148 }
149 
150 EGLint QMeeGoExtensions::eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
151 {
152  if (!hasFenceSync)
153  qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
154 
155  return _eglClientWaitSyncKHR(dpy, sync, flags, timeout);
156 }
157 
158 EGLBoolean QMeeGoExtensions::eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
159 {
160  if (!hasFenceSync)
161  qFatal("EGL_KHR_fence_sync not found but trying to use capability!");
162 
163  return _eglGetSyncAttribKHR(dpy, sync, attribute, value);
164 }
165 
166 /* Private */
167 
169 {
172 
173  if (QEgl::hasExtension("EGL_NOK_image_shared")) {
174  qDebug("MeegoGraphics: found EGL_NOK_image_shared");
175  _eglQueryImageNOK = (eglQueryImageNOKFunc) eglGetProcAddress("eglQueryImageNOK");
176  _eglCreateSharedImageNOK = (eglCreateSharedImageNOKFunc) eglGetProcAddress("eglCreateSharedImageNOK");
177  _eglDestroySharedImageNOK = (eglDestroySharedImageNOKFunc) eglGetProcAddress("eglDestroySharedImageNOK");
178  _eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR");
179  _eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR");
180 
182  hasImageShared = true;
183  }
184 
185  if (QEgl::hasExtension("EGL_NOK_surface_scaling")) {
186  qDebug("MeegoGraphics: found EGL_NOK_surface_scaling");
187  _eglSetSurfaceScalingNOK = (eglSetSurfaceScalingNOKFunc) eglGetProcAddress("eglSetSurfaceScalingNOK");
188 
190  hasSurfaceScaling = true;
191  }
192 
193  if (QEgl::hasExtension("EGL_KHR_lock_surface2")) {
194  qDebug("MeegoGraphics: found EGL_KHR_lock_surface2");
195  _eglLockSurfaceKHR = (eglLockSurfaceKHRFunc) eglGetProcAddress("eglLockSurfaceKHR");
196  _eglUnlockSurfaceKHR = (eglUnlockSurfaceKHRFunc) eglGetProcAddress("eglUnlockSurfaceKHR");
197 
199  hasLockSurface = true;
200  }
201 
202  if (QEgl::hasExtension("EGL_KHR_fence_sync")) {
203  qDebug("MeegoGraphics: found EGL_KHR_fence_sync");
204  _eglCreateSyncKHR = (eglCreateSyncKHRFunc) eglGetProcAddress("eglCreateSyncKHR");
205  _eglDestroySyncKHR = (eglDestroySyncKHRFunc) eglGetProcAddress("eglDestroySyncKHR");
206  _eglClientWaitSyncKHR = (eglClientWaitSyncKHRFunc) eglGetProcAddress("eglClientWaitSyncKHR");
207  _eglGetSyncAttribKHR = (eglGetSyncAttribKHRFunc) eglGetProcAddress("eglGetSyncAttribKHR");
208 
210  hasFenceSync = true;
211  }
212 }
213 
static bool eglSetSurfaceScalingNOK(EGLDisplay dpy, EGLSurface surface, int x, int y, int width, int height)
static EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value)
static bool hasImageShared
EGLBoolean(EGLAPIENTRY * eglGetSyncAttribKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLint *)
static void initialize()
int type
Definition: qmetatype.cpp:239
khronos_utime_nanoseconds_t EGLTimeKHR
EGLBoolean(EGLAPIENTRY * eglUnlockSurfaceKHRFunc)(EGLDisplay, EGLSurface)
static bool eglDestroySharedImageNOK(EGLDisplay dpy, EGLNativeSharedImageTypeNOK img)
static eglDestroySyncKHRFunc _eglDestroySyncKHR
static eglCreateSharedImageNOKFunc _eglCreateSharedImageNOK
static eglCreateSyncKHRFunc _eglCreateSyncKHR
static eglUnlockSurfaceKHRFunc _eglUnlockSurfaceKHR
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static bool eglUnlockSurfaceKHR(EGLDisplay display, EGLSurface surface)
static const QGLContext * currentContext()
Returns the current context, i.e.
Definition: qgl.cpp:3545
Q_CORE_EXPORT void qDebug(const char *,...)
void * EGLNativeSharedImageTypeNOK
Q_GUI_EXPORT EGLDisplay display()
Definition: qegl.cpp:589
static bool initialized
static bool eglQueryImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint prop, EGLint *v)
The QGLContext class encapsulates an OpenGL rendering context.
Definition: qgl.h:310
EGLSyncKHR(EGLAPIENTRY * eglCreateSyncKHRFunc)(EGLDisplay, EGLenum, const EGLint *)
static bool hasLockSurface
unsigned int EGLenum
Definition: qegl_p.h:69
static eglDestroySharedImageNOKFunc _eglDestroySharedImageNOK
static EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list)
Q_GUI_EXPORT bool hasExtension(const char *extensionName)
Definition: qegl.cpp:791
static eglSetSurfaceScalingNOKFunc _eglSetSurfaceScalingNOK
void * EGLImageKHR
Definition: qegl_p.h:165
EGLBoolean(EGLAPIENTRY * eglSetSurfaceScalingNOKFunc)(EGLDisplay, EGLSurface, EGLint, EGLint, EGLint, EGLint)
EGLNativeSharedImageTypeNOK(EGLAPIENTRY * eglCreateSharedImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint *)
Q_CORE_EXPORT void qFatal(const char *,...)
EGLBoolean(EGLAPIENTRY * eglLockSurfaceKHRFunc)(EGLDisplay, EGLSurface, const EGLint *)
static EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout)
static void ensureInitialized()
static eglQueryImageNOKFunc _eglQueryImageNOK
EGLint(EGLAPIENTRY * eglClientWaitSyncKHRFunc)(EGLDisplay, EGLSyncKHR, EGLint, EGLTimeKHR)
static eglGetSyncAttribKHRFunc _eglGetSyncAttribKHR
static bool eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
static eglClientWaitSyncKHRFunc _eglClientWaitSyncKHR
#define ctx
Definition: qgl.cpp:6094
EGLBoolean(EGLAPIENTRY * eglQueryImageNOKFunc)(EGLDisplay, EGLImageKHR, EGLint, EGLint *)
bool qt_resolve_eglimage_gl_extensions(QGLContext *ctx)
#define EGLAPIENTRY
Definition: qegl_p.h:132
void * EGLSyncKHR
static bool hasSurfaceScaling
static bool eglLockSurfaceKHR(EGLDisplay display, EGLSurface surface, const EGLint *attrib_list)
static EGLNativeSharedImageTypeNOK eglCreateSharedImageNOK(EGLDisplay dpy, EGLImageKHR image, EGLint *props)
static eglLockSurfaceKHRFunc _eglLockSurfaceKHR
EGLBoolean(EGLAPIENTRY * eglDestroySharedImageNOKFunc)(EGLDisplay, EGLNativeSharedImageTypeNOK)
static bool hasFenceSync
EGLBoolean(EGLAPIENTRY * eglDestroySyncKHRFunc)(EGLDisplay, EGLSyncKHR)