Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(927)

Side by Side Diff: gpu/gles2_conform_support/native/egl_native_x11.cc

Issue 2196923002: Make ash::DisplayMode more like ui::DisplayMode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more tests fixed Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <EGL/egl.h> 5 #include <EGL/egl.h>
6 #include <EGL/eglext.h> 6 #include <EGL/eglext.h>
7 7
8 extern "C" { 8 extern "C" {
9 #if defined(GLES2_CONFORM_SUPPORT_ONLY) 9 #if defined(GLES2_CONFORM_SUPPORT_ONLY)
10 #include "gpu/gles2_conform_support/gtf/gtf_stubs.h" 10 #include "gpu/gles2_conform_support/gtf/gtf_stubs.h"
11 #else 11 #else
12 #include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/eglNative.h" // nogn check 12 #include "third_party/gles2_conform/GTF_ES/glsl/GTF/Source/eglNative.h" // nogn check
13 #endif 13 #endif
14 14
15 EGLImageKHR GTFCreateEGLImage(int width, int height, 15 EGLImageKHR GTFCreateEGLImage(int width, int height,
16 GLenum format, GLenum type) { 16 GLenum format, GLenum type) {
17 PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr_; 17 PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr_;
18 egl_create_image_khr_ = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC> 18 egl_create_image_khr_ = reinterpret_cast<PFNEGLCREATEIMAGEKHRPROC>
19 (eglGetProcAddress("eglCreateImageKHR")); 19 (eglGetProcAddress("eglCreateImageKHR"));
20 20
21 static const EGLint attrib[] = { 21 static const EGLint attrib[] = {
22 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE, 22 EGL_IMAGE_PRESERVED_KHR, EGL_TRUE,
23 EGL_GL_TEXTURE_LEVEL_KHR, 0, 23 EGL_GL_TEXTURE_LEVEL_KHR, 0,
24 EGL_NONE 24 EGL_NONE
25 }; 25 };
26 26
27 if (format != GL_RGBA && format != GL_RGB) 27 if (format != GL_RGBA && format != GL_RGB)
28 return static_cast<EGLImageKHR>(NULL); 28 return static_cast<EGLImageKHR>(nullptr);
oshima 2016/08/02 19:44:57 unrelated changes?
rjkroege 2016/08/04 00:12:05 yes. pulled out into different CL.
29 29
30 if (type != GL_UNSIGNED_BYTE) 30 if (type != GL_UNSIGNED_BYTE)
31 return static_cast<EGLImageKHR>(NULL); 31 return static_cast<EGLImageKHR>(nullptr);
32 32
33 GLuint texture; 33 GLuint texture;
34 glGenTextures(1, &texture); 34 glGenTextures(1, &texture);
35 glBindTexture(GL_TEXTURE_2D, texture); 35 glBindTexture(GL_TEXTURE_2D, texture);
36 glTexImage2D(GL_TEXTURE_2D, 36 glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, type,
37 0, 37 nullptr);
38 format,
39 width,
40 height,
41 0,
42 format,
43 type,
44 NULL);
45 38
46 // Disable mip-maps because we do not require it. 39 // Disable mip-maps because we do not require it.
47 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 40 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
48 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 41 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
49 42
50 if(glGetError() != GL_NO_ERROR) 43 if(glGetError() != GL_NO_ERROR)
51 return static_cast<EGLImageKHR>(NULL); 44 return static_cast<EGLImageKHR>(nullptr);
52 45
53 EGLImageKHR egl_image = 46 EGLImageKHR egl_image =
54 egl_create_image_khr_(eglGetCurrentDisplay(), 47 egl_create_image_khr_(eglGetCurrentDisplay(),
55 eglGetCurrentContext(), 48 eglGetCurrentContext(),
56 EGL_GL_TEXTURE_2D_KHR, 49 EGL_GL_TEXTURE_2D_KHR,
57 reinterpret_cast<EGLClientBuffer>(texture), 50 reinterpret_cast<EGLClientBuffer>(texture),
58 attrib); 51 attrib);
59 52
60 if (eglGetError() == EGL_SUCCESS) 53 if (eglGetError() == EGL_SUCCESS)
61 return egl_image; 54 return egl_image;
62 else 55 else
63 return static_cast<EGLImageKHR>(NULL); 56 return static_cast<EGLImageKHR>(nullptr);
64 } 57 }
65 58
66 void GTFDestroyEGLImage(EGLImageKHR image) { 59 void GTFDestroyEGLImage(EGLImageKHR image) {
67 PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr_; 60 PFNEGLDESTROYIMAGEKHRPROC egl_destroy_image_khr_;
68 egl_destroy_image_khr_ = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC> 61 egl_destroy_image_khr_ = reinterpret_cast<PFNEGLDESTROYIMAGEKHRPROC>
69 (eglGetProcAddress("eglDestroyImageKHR")); 62 (eglGetProcAddress("eglDestroyImageKHR"));
70 63
71 egl_destroy_image_khr_(eglGetCurrentDisplay(), image); 64 egl_destroy_image_khr_(eglGetCurrentDisplay(), image);
72 } 65 }
73 66
74 } // extern "C" 67 } // extern "C"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698