Disable flaky tests in --site-per-process mode:
[chromium-blink-merge.git] / gpu / gles2_conform_support / native / egl_native_x11.cc
blob3cb6895c880415155263433e0d5014c7f5b73fef
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include <EGL/egl.h>
6 #include <EGL/eglext.h>
8 extern "C" {
9 #if defined(GLES2_CONFORM_SUPPORT_ONLY)
10 #include "gpu/gles2_conform_support/gtf/gtf_stubs.h"
11 #else
12 #include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/eglNative.h"
13 #endif
15 EGLImageKHR GTFCreateEGLImage(int width, int height,
16 GLenum format, GLenum type) {
17 PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr_;
18 egl_create_image_khr_ = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>
19 (eglGetProcAddress("eglCreateImageKHR"));
21 static const EGLint attrib[] = {
22 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
23 EGL_GL_TEXTURE_LEVEL_KHR, 0,
24 EGL_NONE
27 if (format != GL_RGBA && format != GL_RGB)
28 return static_cast<EGLImageKHR>(NULL);
30 if (type != GL_UNSIGNED_BYTE)
31 return static_cast<EGLImageKHR>(NULL);
33 GLuint texture;
34 glGenTextures(1, &texture);
35 glBindTexture(GL_TEXTURE_2D, texture);
36 glTexImage2D(GL_TEXTURE_2D,
38 format,
39 width,
40 height,
42 format,
43 type,
44 NULL);
46 // Disable mip-maps because we do not require it.
47 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
48 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
50 if(glGetError() != GL_NO_ERROR)
51 return static_cast<EGLImageKHR>(NULL);
53 EGLImageKHR egl_image =
54 egl_create_image_khr_(eglGetCurrentDisplay(),
55 eglGetCurrentContext(),
56 EGL_GL_TEXTURE_2D_KHR,
57 reinterpret_cast<EGLClientBuffer>(texture),
58 attrib);
60 if (eglGetError() == EGL_SUCCESS)
61 return egl_image;
62 else
63 return static_cast<EGLImageKHR>(NULL);
66 void GTFDestroyEGLImage(EGLImageKHR image) {
67 PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr_;
68 egl_destroy_image_khr_ = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>
69 (eglGetProcAddress("eglDestroyImageKHR"));
71 egl_destroy_image_khr_(eglGetCurrentDisplay(), image);
74 } // extern "C"