3 * Copyright 2011 Google Inc.
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
8 #ifndef SkNativeGLContext_DEFINED
9 #define SkNativeGLContext_DEFINED
11 #include "SkGLContextHelper.h"
13 /* This struct is taken from a mesa demo. Please update as required */
14 static const struct { int major, minor; } gl_versions[] = {
32 {0, 0} /* end of list */
34 #define NUM_GL_VERSIONS SK_ARRAY_COUNT(gl_versions)
36 #if defined(SK_BUILD_FOR_MAC)
37 #include <OpenGL/OpenGL.h>
38 #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL)
39 #include <GLES2/gl2.h>
41 #elif defined(SK_BUILD_FOR_UNIX)
44 #elif defined(SK_BUILD_FOR_WIN32)
50 class SkNativeGLContext : public SkGLContextHelper {
54 virtual ~SkNativeGLContext();
56 virtual void makeCurrent() const SK_OVERRIDE;
57 virtual void swapBuffers() const SK_OVERRIDE;
59 class AutoContextRestore {
62 ~AutoContextRestore();
65 #if defined(SK_BUILD_FOR_MAC)
66 CGLContextObj fOldCGLContext;
67 #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL)
68 EGLContext fOldEGLContext;
69 EGLDisplay fOldDisplay;
70 EGLSurface fOldSurface;
71 #elif defined(SK_BUILD_FOR_UNIX)
72 GLXContext fOldGLXContext;
74 GLXDrawable fOldDrawable;
75 #elif defined(SK_BUILD_FOR_WIN32)
79 #elif defined(SK_BUILD_FOR_IOS)
85 virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_OVERRIDE;
86 virtual void destroyGLContext() SK_OVERRIDE;
89 #if defined(SK_BUILD_FOR_MAC)
90 CGLContextObj fContext;
91 #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL)
95 #elif defined(SK_BUILD_FOR_UNIX)
100 #elif defined(SK_BUILD_FOR_WIN32)
103 HGLRC fGlRenderContext;
105 SkWGLPbufferContext* fPbufferContext;
106 #elif defined(SK_BUILD_FOR_IOS)