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

Unified 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, 8 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/teartest_glx.cc
diff --git a/client/deps/glbench/src/teartest_glx.cc b/client/deps/glbench/src/teartest_glx.cc
index 50a478cd4435583ec116538f56c0c4bffc0a6a1b..27f576795474c7b2599d74652d7ea8d8f67b5ccd 100644
--- a/client/deps/glbench/src/teartest_glx.cc
+++ b/client/deps/glbench/src/teartest_glx.cc
@@ -12,22 +12,44 @@
#include "teartest.h"
-PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT = NULL;
-PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT = NULL;
+class PixmapToTextureTest : public Test {
+ public:
+ PixmapToTextureTest();
+ virtual bool Start();
+ virtual bool Loop(int shift);
+ virtual void Stop();
+ private:
+ bool InitNative();
-static GLXPixmap glxpixmap = 0;
+ GLXPixmap glxpixmap_;
+ Pixmap pixmap_;
+ bool init_succeeded;
+};
+Test* GetPixmapToTextureTest() {
+ return new PixmapToTextureTest();
+}
+
+
+PixmapToTextureTest::PixmapToTextureTest() :
+ glxpixmap_(0),
+ pixmap_(0),
+ init_succeeded(false) {}
-void InitNative(Pixmap pixmap) {
- glXBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(
- glXGetProcAddress(
- reinterpret_cast<const GLubyte *>("glXBindTexImageEXT")));
- glXReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(
- glXGetProcAddress(
- reinterpret_cast<const GLubyte *>("glXReleaseTexImageEXT")));
+
+bool PixmapToTextureTest::InitNative() {
+ int major = 0;
+ int minor = 0;
+ if (!glXQueryVersion(g_xlib_display, &major, &minor))
+ return false;
+
+ if (major < 1 || (major == 1 && minor < 3))
+ return false;
if (!glXBindTexImageEXT)
- return;
+ return false;
+
+ pixmap_ = AllocatePixmap();
int rgba, rgb;
glXGetFBConfigAttrib(g_xlib_display, g_glx_fbconfig,
@@ -42,33 +64,34 @@ void InitNative(Pixmap pixmap) {
None
};
- glxpixmap = glXCreatePixmap(g_xlib_display, g_glx_fbconfig,
- pixmap, pixmapAttribs);
+ glxpixmap_ = glXCreatePixmap(g_xlib_display, g_glx_fbconfig,
+ pixmap_, pixmapAttribs);
+ return true;
+}
+
+
+bool PixmapToTextureTest::Start() {
+ init_succeeded = InitNative();
+ printf("# Update pixmap bound to texture.\n");
+ CopyPixmapToTexture(pixmap_);
+ glXBindTexImageEXT(g_xlib_display, glxpixmap_, GLX_FRONT_LEFT_EXT, NULL);
+ return true;
}
-bool UpdateBindTexImage(TestState state, int shift) {
- if (!glXBindTexImageEXT) {
- printf("# Could not load glXBindTexImageEXT\n");
+
+bool PixmapToTextureTest::Loop(int shift) {
+ if (!init_succeeded)
return false;
- }
-
- switch (state) {
- case TestStart:
- printf("# Update pixmap bound to texture.\n");
- InitializePixmap();
- CopyPixmapToTexture();
- glXBindTexImageEXT(g_xlib_display, glxpixmap, GLX_FRONT_LEFT_EXT, NULL);
- break;
-
- case TestLoop:
- glXReleaseTexImageEXT(g_xlib_display, glxpixmap, GLX_FRONT_LEFT_EXT);
- UpdatePixmap(shift);
- glXBindTexImageEXT(g_xlib_display, glxpixmap, GLX_FRONT_LEFT_EXT, NULL);
- break;
-
- case TestStop:
- glXReleaseTexImageEXT(g_xlib_display, glxpixmap, GLX_FRONT_LEFT_EXT);
- break;
- }
+ glXReleaseTexImageEXT(g_xlib_display, glxpixmap_, GLX_FRONT_LEFT_EXT);
+ UpdatePixmap(pixmap_, shift);
+ glXBindTexImageEXT(g_xlib_display, glxpixmap_, GLX_FRONT_LEFT_EXT, NULL);
return true;
}
+
+
+void PixmapToTextureTest::Stop() {
+ glXReleaseTexImageEXT(g_xlib_display, glxpixmap_, GLX_FRONT_LEFT_EXT);
+ glFinish();
+ glXDestroyPixmap(g_xlib_display, glxpixmap_);
+ XFreePixmap(g_xlib_display, pixmap_);
+}
« 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