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

Side by Side Diff: client/deps/glbench/src/glx_stuff.cc

Issue 1315007: Added tearing tests for plain texture updates and bind pixmap to texture. (Closed)
Patch Set: Created 10 years, 9 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
« no previous file with comments | « client/deps/glbench/src/glx_stuff.h ('k') | client/deps/glbench/src/teartest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium OS 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 <string.h> 5 #include <string.h>
6 #include <GL/glx.h> 6 #include <GL/glx.h>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "main.h" 9 #include "main.h"
10 #include "xlib_window.h" 10 #include "xlib_window.h"
11 11
12 static GLXContext glx_context = NULL; 12 GLXContext g_glx_context = NULL;
13 static GLXFBConfig glx_fbconfig = NULL; 13 GLXFBConfig g_glx_fbconfig = NULL;
14 14
15 #define F(fun, type) type fun = NULL; 15 #define F(fun, type) type fun = NULL;
16 LIST_PROC_FUNCTIONS(F) 16 LIST_PROC_FUNCTIONS(F)
17 #undef F 17 #undef F
18 PFNGLXSWAPINTERVALMESAPROC _glXSwapIntervalMESA = NULL; 18 PFNGLXSWAPINTERVALMESAPROC _glXSwapIntervalMESA = NULL;
19 19
20 bool Init() { 20 bool Init() {
21 return XlibInit(); 21 return XlibInit();
22 } 22 }
23 23
24 XVisualInfo* GetXVisual() { 24 XVisualInfo* GetXVisual() {
25 if (!glx_fbconfig) { 25 if (!g_glx_fbconfig) {
26 int screen = DefaultScreen(g_xlib_display); 26 int screen = DefaultScreen(g_xlib_display);
27 int attrib[] = { 27 int attrib[] = {
28 GLX_DOUBLEBUFFER, True, 28 GLX_DOUBLEBUFFER, True,
29 GLX_RED_SIZE, 1, 29 GLX_RED_SIZE, 1,
30 GLX_GREEN_SIZE, 1, 30 GLX_GREEN_SIZE, 1,
31 GLX_BLUE_SIZE, 1, 31 GLX_BLUE_SIZE, 1,
32 GLX_DEPTH_SIZE, 1, 32 GLX_DEPTH_SIZE, 1,
33 GLX_STENCIL_SIZE, 1, 33 GLX_STENCIL_SIZE, 1,
34 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT, 34 GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
35 None 35 None
36 }; 36 };
37 int nelements; 37 int nelements;
38 GLXFBConfig *fbconfigs = glXChooseFBConfig(g_xlib_display, screen, 38 GLXFBConfig *fbconfigs = glXChooseFBConfig(g_xlib_display, screen,
39 attrib, &nelements); 39 attrib, &nelements);
40 CHECK(nelements >= 1); 40 CHECK(nelements >= 1);
41 glx_fbconfig = fbconfigs[0]; 41 g_glx_fbconfig = fbconfigs[0];
42 XFree(fbconfigs); 42 XFree(fbconfigs);
43 } 43 }
44 44
45 return glXGetVisualFromFBConfig(g_xlib_display, glx_fbconfig); 45 return glXGetVisualFromFBConfig(g_xlib_display, g_glx_fbconfig);
46 } 46 }
47 47
48 bool InitContext() { 48 bool InitContext() {
49 glx_context = glXCreateNewContext(g_xlib_display, glx_fbconfig, 49 g_glx_context = glXCreateNewContext(g_xlib_display, g_glx_fbconfig,
50 GLX_RGBA_TYPE, 0, True); 50 GLX_RGBA_TYPE, 0, True);
51 if (!glx_context) 51 if (!g_glx_context)
52 return false; 52 return false;
53 53
54 if (!glXMakeCurrent(g_xlib_display, g_xlib_window, glx_context)) { 54 if (!glXMakeCurrent(g_xlib_display, g_xlib_window, g_glx_context)) {
55 glXDestroyContext(g_xlib_display, glx_context); 55 glXDestroyContext(g_xlib_display, g_glx_context);
56 return false; 56 return false;
57 } 57 }
58 58
59 glClearColor(1.f, 0, 0, 1.f); 59 glClearColor(1.f, 0, 0, 1.f);
60 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 60 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
61 SwapBuffers(); 61 SwapBuffers();
62 glClearColor(0, 1.f, 0, 1.f); 62 glClearColor(0, 1.f, 0, 1.f);
63 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); 63 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
64 SwapBuffers(); 64 SwapBuffers();
65 glClearColor(0, 0, 0.f, 0.f); 65 glClearColor(0, 0, 0.f, 0.f);
66 66
67 const GLubyte *str = glGetString(GL_EXTENSIONS); 67 const GLubyte *str = glGetString(GL_EXTENSIONS);
68 if (!str || !strstr(reinterpret_cast<const char *>(str), 68 if (!str || !strstr(reinterpret_cast<const char *>(str),
69 "GL_ARB_vertex_buffer_object")) 69 "GL_ARB_vertex_buffer_object"))
70 return false; 70 return false;
71 71
72 #define F(fun, type) fun = reinterpret_cast<type>( \ 72 #define F(fun, type) fun = reinterpret_cast<type>( \
73 glXGetProcAddress(reinterpret_cast<const GLubyte *>(#fun))); 73 glXGetProcAddress(reinterpret_cast<const GLubyte *>(#fun)));
74 LIST_PROC_FUNCTIONS(F) 74 LIST_PROC_FUNCTIONS(F)
75 #undef F 75 #undef F
76 _glXSwapIntervalMESA = reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>( 76 _glXSwapIntervalMESA = reinterpret_cast<PFNGLXSWAPINTERVALMESAPROC>(
77 glXGetProcAddress(reinterpret_cast<const GLubyte *>( 77 glXGetProcAddress(reinterpret_cast<const GLubyte *>(
78 "glXSwapIntervalMESA"))); 78 "glXSwapIntervalMESA")));
79 79
80 return true; 80 return true;
81 } 81 }
82 82
83 void DestroyContext() { 83 void DestroyContext() {
84 glXMakeCurrent(g_xlib_display, 0, NULL); 84 glXMakeCurrent(g_xlib_display, 0, NULL);
85 glXDestroyContext(g_xlib_display, glx_context); 85 glXDestroyContext(g_xlib_display, g_glx_context);
86 } 86 }
87 87
88 void SwapBuffers() { 88 void SwapBuffers() {
89 glXSwapBuffers(g_xlib_display, g_xlib_window); 89 glXSwapBuffers(g_xlib_display, g_xlib_window);
90 } 90 }
91 91
92 bool SwapInterval(int interval) { 92 bool SwapInterval(int interval) {
93 // Strictly, glXSwapIntervalSGI only allows interval > 0, whereas 93 // Strictly, glXSwapIntervalSGI only allows interval > 0, whereas
94 // glXSwapIntervalMESA allow 0 with the same semantics as eglSwapInterval. 94 // glXSwapIntervalMESA allow 0 with the same semantics as eglSwapInterval.
95 if (_glXSwapIntervalMESA) { 95 if (_glXSwapIntervalMESA) {
96 return _glXSwapIntervalMESA(interval) == 0; 96 return _glXSwapIntervalMESA(interval) == 0;
97 } else { 97 } else {
98 return glXSwapIntervalSGI(interval) == 0; 98 return glXSwapIntervalSGI(interval) == 0;
99 } 99 }
100 } 100 }
OLDNEW
« no previous file with comments | « client/deps/glbench/src/glx_stuff.h ('k') | client/deps/glbench/src/teartest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698