Skip to content

Commit

Permalink
move egl macro
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Sep 27, 2015
1 parent b189cae commit f1cf56e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 21 deletions.
9 changes: 0 additions & 9 deletions src/codec/video/SurfaceInteropCUDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,6 @@ void SurfaceInteropCUDA::unmap(void *handle)
} //namespace QtAV

#if QTAV_HAVE(CUDA_EGL)
#define EGL_ENSURE(x, ...) \
do { \
if (!(x)) { \
EGLint err = eglGetError(); \
qWarning("EGL error@%d<<%s. " #x ": %#x %s", __LINE__, __FILE__, err, eglQueryString(eglGetCurrentDisplay(), err)); \
return __VA_ARGS__; \
} \
} while(0)

#if QTAV_HAVE(GUI_PRIVATE)
#include <qpa/qplatformnativeinterface.h>
#include <QtGui/QGuiApplication>
Expand Down
10 changes: 1 addition & 9 deletions src/codec/video/SurfaceInteropDXVA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,6 @@ void* SurfaceInteropDXVA::mapToHost(const VideoFormat &format, void *handle, int
} //namespace QtAV

#if QTAV_HAVE(DXVA_EGL)
#define EGL_ENSURE(x, ...) \
do { \
if (!(x)) { \
EGLint err = eglGetError(); \
qWarning("EGL error@%d<<%s. " #x ": %#x %s", __LINE__, __FILE__, err, eglQueryString(eglGetCurrentDisplay(), err)); \
return __VA_ARGS__; \
} \
} while(0)

#if QTAV_HAVE(GUI_PRIVATE)
#include <qpa/qplatformnativeinterface.h>
#include <QtGui/QGuiApplication>
Expand Down Expand Up @@ -239,6 +230,7 @@ bool EGLInteropResource::ensureSurface(int w, int h) {
// check extensions
QList<QByteArray> extensions = QByteArray(eglQueryString(egl->dpy, EGL_EXTENSIONS)).split(' ');
// ANGLE_d3d_share_handle_client_buffer will be used if possible
// TODO: strstr is enough
const bool kEGL_ANGLE_d3d_share_handle_client_buffer = extensions.contains("EGL_ANGLE_d3d_share_handle_client_buffer");
const bool kEGL_ANGLE_query_surface_pointer = extensions.contains("EGL_ANGLE_query_surface_pointer");
if (!kEGL_ANGLE_d3d_share_handle_client_buffer && !kEGL_ANGLE_query_surface_pointer) {
Expand Down
16 changes: 16 additions & 0 deletions src/utils/OpenGLHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ typedef QGLBuffer QOpenGLBuffer;
#define GL_TEXTURE_RECTANGLE 0x84F5
#endif

#define EGL_ENSURE(x, ...) \
do { \
if (!(x)) { \
EGLint err = eglGetError(); \
qWarning("EGL error@%d<<%s. " #x ": %#x %s", __LINE__, __FILE__, err, eglQueryString(eglGetCurrentDisplay(), err)); \
return __VA_ARGS__; \
} \
} while(0)
#define EGL_WARN(x, ...) \
do { \
if (!(x)) { \
EGLint err = eglGetError(); \
qWarning("EGL error@%d<<%s. " #x ": %#x %s", __LINE__, __FILE__, err, eglQueryString(eglGetCurrentDisplay(), err)); \
} \
} while(0)

class QMatrix4x4;
namespace QtAV {
namespace OpenGLHelper {
Expand Down
5 changes: 2 additions & 3 deletions src/vaapi/SurfaceInteropVAAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class EGL Q_DECL_FINAL: public X11 {
~EGL() {
for (unsigned i = 0; i < sizeof(image)/sizeof(image[0]); ++i) {
if (image[i] != EGL_NO_IMAGE_KHR) {
eglDestroyImageKHR(dpy, image[i]);
EGL_WARN(eglDestroyImageKHR(dpy, image[i]));
}
}
}
Expand All @@ -258,7 +258,7 @@ class EGL Q_DECL_FINAL: public X11 {
qDebug("eglGetCurrentDisplay");
dpy = eglGetCurrentDisplay();
}
image[0] = eglCreateImageKHR(dpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)pixmap, NULL);
EGL_ENSURE(image[0] = eglCreateImageKHR(dpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, (EGLClientBuffer)pixmap, NULL), false);
if (!image[0]) {
qWarning("eglCreateImageKHR error %#X, image: %p", eglGetError(), image[0]);
return false;
Expand Down Expand Up @@ -428,7 +428,6 @@ bool X11InteropResource::unmap(GLuint tex)
// can not call glXReleaseTexImageEXT otherwise the texture will containts no image data
return true;
}

#endif //VA_X11_INTEROP
} //namespace QtAV
} //namespace vaapi

0 comments on commit f1cf56e

Please sign in to comment.