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

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

Issue 1732030: Replaced funky state machines with classes. This is in preparation of doing the same to gl_Bench. (Closed) Base URL: ssh://git@chromiumos-git//autotest.git
Patch Set: Got rid of static test list initialization, fixed USE_EGL. Created 10 years, 7 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/teartest_egl.cc ('k') | client/deps/glbench/src/utils.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 <stdio.h> 5 #include <stdio.h>
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 #include "main.h" 9 #include "main.h"
10 #include "xlib_window.h" 10 #include "xlib_window.h"
11 #include "glx_stuff.h" 11 #include "glx_stuff.h"
12 #include "teartest.h" 12 #include "teartest.h"
13 13
14 14
15 PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT = NULL; 15 class PixmapToTextureTest : public Test {
16 PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT = NULL; 16 public:
17 PixmapToTextureTest();
18 virtual bool Start();
19 virtual bool Loop(int shift);
20 virtual void Stop();
21 private:
22 bool InitNative();
17 23
18 static GLXPixmap glxpixmap = 0; 24 GLXPixmap glxpixmap_;
25 Pixmap pixmap_;
26 bool init_succeeded;
27 };
28
29 Test* GetPixmapToTextureTest() {
30 return new PixmapToTextureTest();
31 }
19 32
20 33
21 void InitNative(Pixmap pixmap) { 34 PixmapToTextureTest::PixmapToTextureTest() :
22 glXBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>( 35 glxpixmap_(0),
23 glXGetProcAddress( 36 pixmap_(0),
24 reinterpret_cast<const GLubyte *>("glXBindTexImageEXT"))); 37 init_succeeded(false) {}
25 glXReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>( 38
26 glXGetProcAddress( 39
27 reinterpret_cast<const GLubyte *>("glXReleaseTexImageEXT"))); 40 bool PixmapToTextureTest::InitNative() {
41 int major = 0;
42 int minor = 0;
43 if (!glXQueryVersion(g_xlib_display, &major, &minor))
44 return false;
45
46 if (major < 1 || (major == 1 && minor < 3))
47 return false;
28 48
29 if (!glXBindTexImageEXT) 49 if (!glXBindTexImageEXT)
30 return; 50 return false;
51
52 pixmap_ = AllocatePixmap();
31 53
32 int rgba, rgb; 54 int rgba, rgb;
33 glXGetFBConfigAttrib(g_xlib_display, g_glx_fbconfig, 55 glXGetFBConfigAttrib(g_xlib_display, g_glx_fbconfig,
34 GLX_BIND_TO_TEXTURE_RGBA_EXT, &rgba); 56 GLX_BIND_TO_TEXTURE_RGBA_EXT, &rgba);
35 glXGetFBConfigAttrib(g_xlib_display, g_glx_fbconfig, 57 glXGetFBConfigAttrib(g_xlib_display, g_glx_fbconfig,
36 GLX_BIND_TO_TEXTURE_RGB_EXT, &rgb); 58 GLX_BIND_TO_TEXTURE_RGB_EXT, &rgb);
37 CHECK(rgba || rgb); 59 CHECK(rgba || rgb);
38 const int pixmapAttribs[] = { 60 const int pixmapAttribs[] = {
39 GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT, 61 GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
40 GLX_TEXTURE_FORMAT_EXT, 62 GLX_TEXTURE_FORMAT_EXT,
41 rgba ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT, 63 rgba ? GLX_TEXTURE_FORMAT_RGBA_EXT : GLX_TEXTURE_FORMAT_RGB_EXT,
42 None 64 None
43 }; 65 };
44 66
45 glxpixmap = glXCreatePixmap(g_xlib_display, g_glx_fbconfig, 67 glxpixmap_ = glXCreatePixmap(g_xlib_display, g_glx_fbconfig,
46 pixmap, pixmapAttribs); 68 pixmap_, pixmapAttribs);
69 return true;
47 } 70 }
48 71
49 bool UpdateBindTexImage(TestState state, int shift) {
50 if (!glXBindTexImageEXT) {
51 printf("# Could not load glXBindTexImageEXT\n");
52 return false;
53 }
54 72
55 switch (state) { 73 bool PixmapToTextureTest::Start() {
56 case TestStart: 74 init_succeeded = InitNative();
57 printf("# Update pixmap bound to texture.\n"); 75 printf("# Update pixmap bound to texture.\n");
58 InitializePixmap(); 76 CopyPixmapToTexture(pixmap_);
59 CopyPixmapToTexture(); 77 glXBindTexImageEXT(g_xlib_display, glxpixmap_, GLX_FRONT_LEFT_EXT, NULL);
60 glXBindTexImageEXT(g_xlib_display, glxpixmap, GLX_FRONT_LEFT_EXT, NULL);
61 break;
62
63 case TestLoop:
64 glXReleaseTexImageEXT(g_xlib_display, glxpixmap, GLX_FRONT_LEFT_EXT);
65 UpdatePixmap(shift);
66 glXBindTexImageEXT(g_xlib_display, glxpixmap, GLX_FRONT_LEFT_EXT, NULL);
67 break;
68
69 case TestStop:
70 glXReleaseTexImageEXT(g_xlib_display, glxpixmap, GLX_FRONT_LEFT_EXT);
71 break;
72 }
73 return true; 78 return true;
74 } 79 }
80
81
82 bool PixmapToTextureTest::Loop(int shift) {
83 if (!init_succeeded)
84 return false;
85 glXReleaseTexImageEXT(g_xlib_display, glxpixmap_, GLX_FRONT_LEFT_EXT);
86 UpdatePixmap(pixmap_, shift);
87 glXBindTexImageEXT(g_xlib_display, glxpixmap_, GLX_FRONT_LEFT_EXT, NULL);
88 return true;
89 }
90
91
92 void PixmapToTextureTest::Stop() {
93 glXReleaseTexImageEXT(g_xlib_display, glxpixmap_, GLX_FRONT_LEFT_EXT);
94 glFinish();
95 glXDestroyPixmap(g_xlib_display, glxpixmap_);
96 XFreePixmap(g_xlib_display, pixmap_);
97 }
OLDNEW
« no previous file with comments | « client/deps/glbench/src/teartest_egl.cc ('k') | client/deps/glbench/src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698