1 // Copyright (c) 2012 The Chromium OS 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. 4 5 #ifndef BENCH_GL_GLINTERFACE_H_ 6 #define BENCH_GL_GLINTERFACE_H_ 7 8 #include "base/memory/scoped_ptr.h" 9 10 //TODO: Remove cases where PLATFORM is not defined, when no longer needed. 11 // Only synccontroltest and teartest get compiled that way, and we plan 12 // to remove them. 13 #ifdef PLATFORM 14 15 typedef struct waffle_context *GLContext; // Forward declaration from waffle.h. 16 17 #else 18 19 #include <X11/Xutil.h> 20 21 #if defined(USE_OPENGL) 22 23 struct __GLXcontextRec; // Forward declaration from GLX.h. 24 typedef struct __GLXcontextRec *GLXContext; 25 typedef GLXContext GLContext; 26 27 #elif defined(USE_OPENGLES) 28 29 typedef void *EGLContext; // Forward declaration from EGL.h. 30 typedef EGLContext GLContext; 31 32 #endif 33 #endif 34 35 //TODO: Once synccontroltest and teartest are removed, only the waffle 36 // implementation of this interface will remain. At that time consider 37 // removing this class as waffle itself provides platform-independence. 38 class GLInterface { 39 public: GLInterface()40 GLInterface() {} ~GLInterface()41 virtual ~GLInterface() {} 42 virtual bool Init() = 0; 43 virtual void Cleanup() = 0; 44 #ifndef PLATFORM 45 virtual XVisualInfo* GetXVisual() = 0; 46 #endif 47 48 virtual void SwapBuffers() = 0; 49 //TODO: Remove this when it is no longer used. 50 // Only teartest calls this, and we plan to remove that. 51 virtual bool SwapInterval(int interval) = 0; 52 53 //TODO: Remove this when it is no longer used. 54 // Only synccontroltest_egl calls this, and we plan to remove that. 55 virtual void CheckError() = 0; 56 57 virtual bool MakeCurrent(const GLContext& context) = 0; 58 virtual const GLContext CreateContext() = 0; 59 virtual void DeleteContext(const GLContext& context) = 0; 60 virtual const GLContext& GetMainContext() = 0; 61 62 static GLInterface* Create(); 63 }; 64 65 extern scoped_ptr<GLInterface> g_main_gl_interface; 66 67 #endif // BENCH_GL_GLINTERFACE_H_ 68