OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 #ifndef SkNativeGLContext_DEFINED | 8 #ifndef SkNativeGLContext_DEFINED |
9 #define SkNativeGLContext_DEFINED | 9 #define SkNativeGLContext_DEFINED |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 {4, 1}, | 28 {4, 1}, |
29 {4, 2}, | 29 {4, 2}, |
30 {4, 3}, | 30 {4, 3}, |
31 {4, 4}, | 31 {4, 4}, |
32 {0, 0} /* end of list */ | 32 {0, 0} /* end of list */ |
33 }; | 33 }; |
34 #define NUM_GL_VERSIONS SK_ARRAY_COUNT(gl_versions) | 34 #define NUM_GL_VERSIONS SK_ARRAY_COUNT(gl_versions) |
35 | 35 |
36 #if defined(SK_BUILD_FOR_MAC) | 36 #if defined(SK_BUILD_FOR_MAC) |
37 #include <OpenGL/OpenGL.h> | 37 #include <OpenGL/OpenGL.h> |
38 #elif defined(SK_EGL) | 38 #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) |
39 #include <GLES2/gl2.h> | 39 #include <GLES2/gl2.h> |
40 #include <EGL/egl.h> | 40 #include <EGL/egl.h> |
41 #elif defined(SK_BUILD_FOR_UNIX) | 41 #elif defined(SK_BUILD_FOR_UNIX) |
42 #include <X11/Xlib.h> | 42 #include <X11/Xlib.h> |
43 #include <GL/glx.h> | 43 #include <GL/glx.h> |
44 #elif defined(SK_BUILD_FOR_WIN32) | 44 #elif defined(SK_BUILD_FOR_WIN32) |
45 #include <windows.h> | 45 #include <windows.h> |
46 #include <GL/GL.h> | 46 #include <GL/GL.h> |
47 #include "SkWGL.h" | 47 #include "SkWGL.h" |
48 #endif | 48 #endif |
49 | 49 |
50 class SkNativeGLContext : public SkGLContextHelper { | 50 class SkNativeGLContext : public SkGLContextHelper { |
51 public: | 51 public: |
52 SkNativeGLContext(); | 52 SkNativeGLContext(); |
53 | 53 |
54 virtual ~SkNativeGLContext(); | 54 virtual ~SkNativeGLContext(); |
55 | 55 |
56 virtual void makeCurrent() const SK_OVERRIDE; | 56 virtual void makeCurrent() const SK_OVERRIDE; |
57 virtual void swapBuffers() const SK_OVERRIDE; | 57 virtual void swapBuffers() const SK_OVERRIDE; |
58 | 58 |
59 class AutoContextRestore { | 59 class AutoContextRestore { |
60 public: | 60 public: |
61 AutoContextRestore(); | 61 AutoContextRestore(); |
62 ~AutoContextRestore(); | 62 ~AutoContextRestore(); |
63 | 63 |
64 private: | 64 private: |
65 #if defined(SK_BUILD_FOR_MAC) | 65 #if defined(SK_BUILD_FOR_MAC) |
66 CGLContextObj fOldCGLContext; | 66 CGLContextObj fOldCGLContext; |
67 #elif defined(SK_EGL) | 67 #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) |
68 EGLContext fOldEGLContext; | 68 EGLContext fOldEGLContext; |
69 EGLDisplay fOldDisplay; | 69 EGLDisplay fOldDisplay; |
70 EGLSurface fOldSurface; | 70 EGLSurface fOldSurface; |
71 #elif defined(SK_BUILD_FOR_UNIX) | 71 #elif defined(SK_BUILD_FOR_UNIX) |
72 GLXContext fOldGLXContext; | 72 GLXContext fOldGLXContext; |
73 Display* fOldDisplay; | 73 Display* fOldDisplay; |
74 GLXDrawable fOldDrawable; | 74 GLXDrawable fOldDrawable; |
75 #elif defined(SK_BUILD_FOR_WIN32) | 75 #elif defined(SK_BUILD_FOR_WIN32) |
76 HDC fOldHDC; | 76 HDC fOldHDC; |
77 HGLRC fOldHGLRC; | 77 HGLRC fOldHGLRC; |
78 | 78 |
79 #elif defined(SK_BUILD_FOR_IOS) | 79 #elif defined(SK_BUILD_FOR_IOS) |
80 void* fEAGLContext; | 80 void* fEAGLContext; |
81 #endif | 81 #endif |
82 }; | 82 }; |
83 | 83 |
84 protected: | 84 protected: |
85 virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_O
VERRIDE; | 85 virtual const GrGLInterface* createGLContext(GrGLStandard forcedGpuAPI) SK_O
VERRIDE; |
86 virtual void destroyGLContext() SK_OVERRIDE; | 86 virtual void destroyGLContext() SK_OVERRIDE; |
87 | 87 |
88 private: | 88 private: |
89 #if defined(SK_BUILD_FOR_MAC) | 89 #if defined(SK_BUILD_FOR_MAC) |
90 CGLContextObj fContext; | 90 CGLContextObj fContext; |
91 #elif defined(SK_EGL) | 91 #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) |
92 EGLContext fContext; | 92 EGLContext fContext; |
93 EGLDisplay fDisplay; | 93 EGLDisplay fDisplay; |
94 EGLSurface fSurface; | 94 EGLSurface fSurface; |
95 #elif defined(SK_BUILD_FOR_UNIX) | 95 #elif defined(SK_BUILD_FOR_UNIX) |
96 GLXContext fContext; | 96 GLXContext fContext; |
97 Display* fDisplay; | 97 Display* fDisplay; |
98 Pixmap fPixmap; | 98 Pixmap fPixmap; |
99 GLXPixmap fGlxPixmap; | 99 GLXPixmap fGlxPixmap; |
100 #elif defined(SK_BUILD_FOR_WIN32) | 100 #elif defined(SK_BUILD_FOR_WIN32) |
101 HWND fWindow; | 101 HWND fWindow; |
102 HDC fDeviceContext; | 102 HDC fDeviceContext; |
103 HGLRC fGlRenderContext; | 103 HGLRC fGlRenderContext; |
104 static ATOM gWC; | 104 static ATOM gWC; |
105 SkWGLPbufferContext* fPbufferContext; | 105 SkWGLPbufferContext* fPbufferContext; |
106 #elif defined(SK_BUILD_FOR_IOS) | 106 #elif defined(SK_BUILD_FOR_IOS) |
107 void* fEAGLContext; | 107 void* fEAGLContext; |
108 #endif | 108 #endif |
109 }; | 109 }; |
110 | 110 |
111 #endif | 111 #endif |
OLD | NEW |