1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/gpu/gl/SkNativeGLContext.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2011 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 +#ifndef SkNativeGLContext_DEFINED 1.12 +#define SkNativeGLContext_DEFINED 1.13 + 1.14 +#include "SkGLContextHelper.h" 1.15 + 1.16 +#if defined(SK_BUILD_FOR_MAC) 1.17 + #include <OpenGL/OpenGL.h> 1.18 +#elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) 1.19 + #include <GLES2/gl2.h> 1.20 + #include <EGL/egl.h> 1.21 +#elif defined(SK_BUILD_FOR_UNIX) 1.22 + #include <X11/Xlib.h> 1.23 + #include <GL/glx.h> 1.24 +#elif defined(SK_BUILD_FOR_WIN32) 1.25 + #include <windows.h> 1.26 + #include <GL/GL.h> 1.27 +#endif 1.28 + 1.29 +class SkNativeGLContext : public SkGLContextHelper { 1.30 +public: 1.31 + SkNativeGLContext(); 1.32 + 1.33 + virtual ~SkNativeGLContext(); 1.34 + 1.35 + virtual void makeCurrent() const SK_OVERRIDE; 1.36 + virtual void swapBuffers() const SK_OVERRIDE; 1.37 + 1.38 + class AutoContextRestore { 1.39 + public: 1.40 + AutoContextRestore(); 1.41 + ~AutoContextRestore(); 1.42 + 1.43 + private: 1.44 + #if defined(SK_BUILD_FOR_MAC) 1.45 + CGLContextObj fOldCGLContext; 1.46 + #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) 1.47 + EGLContext fOldEGLContext; 1.48 + EGLDisplay fOldDisplay; 1.49 + EGLSurface fOldSurface; 1.50 + #elif defined(SK_BUILD_FOR_UNIX) 1.51 + GLXContext fOldGLXContext; 1.52 + Display* fOldDisplay; 1.53 + GLXDrawable fOldDrawable; 1.54 + #elif defined(SK_BUILD_FOR_WIN32) 1.55 + HDC fOldHDC; 1.56 + HGLRC fOldHGLRC; 1.57 + 1.58 + #elif defined(SK_BUILD_FOR_IOS) 1.59 + void* fEAGLContext; 1.60 + #endif 1.61 + }; 1.62 + 1.63 +protected: 1.64 + virtual const GrGLInterface* createGLContext() SK_OVERRIDE; 1.65 + virtual void destroyGLContext() SK_OVERRIDE; 1.66 + 1.67 +private: 1.68 +#if defined(SK_BUILD_FOR_MAC) 1.69 + CGLContextObj fContext; 1.70 +#elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) 1.71 + EGLContext fContext; 1.72 + EGLDisplay fDisplay; 1.73 + EGLSurface fSurface; 1.74 +#elif defined(SK_BUILD_FOR_UNIX) 1.75 + GLXContext fContext; 1.76 + Display* fDisplay; 1.77 + Pixmap fPixmap; 1.78 + GLXPixmap fGlxPixmap; 1.79 +#elif defined(SK_BUILD_FOR_WIN32) 1.80 + HWND fWindow; 1.81 + HDC fDeviceContext; 1.82 + HGLRC fGlRenderContext; 1.83 + static ATOM gWC; 1.84 +#elif defined(SK_BUILD_FOR_IOS) 1.85 + void* fEAGLContext; 1.86 +#endif 1.87 +}; 1.88 + 1.89 +#endif