Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2011 Google Inc. |
michael@0 | 4 | * |
michael@0 | 5 | * Use of this source code is governed by a BSD-style license that can be |
michael@0 | 6 | * found in the LICENSE file. |
michael@0 | 7 | */ |
michael@0 | 8 | #ifndef SkNativeGLContext_DEFINED |
michael@0 | 9 | #define SkNativeGLContext_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkGLContextHelper.h" |
michael@0 | 12 | |
michael@0 | 13 | #if defined(SK_BUILD_FOR_MAC) |
michael@0 | 14 | #include <OpenGL/OpenGL.h> |
michael@0 | 15 | #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) |
michael@0 | 16 | #include <GLES2/gl2.h> |
michael@0 | 17 | #include <EGL/egl.h> |
michael@0 | 18 | #elif defined(SK_BUILD_FOR_UNIX) |
michael@0 | 19 | #include <X11/Xlib.h> |
michael@0 | 20 | #include <GL/glx.h> |
michael@0 | 21 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 22 | #include <windows.h> |
michael@0 | 23 | #include <GL/GL.h> |
michael@0 | 24 | #endif |
michael@0 | 25 | |
michael@0 | 26 | class SkNativeGLContext : public SkGLContextHelper { |
michael@0 | 27 | public: |
michael@0 | 28 | SkNativeGLContext(); |
michael@0 | 29 | |
michael@0 | 30 | virtual ~SkNativeGLContext(); |
michael@0 | 31 | |
michael@0 | 32 | virtual void makeCurrent() const SK_OVERRIDE; |
michael@0 | 33 | virtual void swapBuffers() const SK_OVERRIDE; |
michael@0 | 34 | |
michael@0 | 35 | class AutoContextRestore { |
michael@0 | 36 | public: |
michael@0 | 37 | AutoContextRestore(); |
michael@0 | 38 | ~AutoContextRestore(); |
michael@0 | 39 | |
michael@0 | 40 | private: |
michael@0 | 41 | #if defined(SK_BUILD_FOR_MAC) |
michael@0 | 42 | CGLContextObj fOldCGLContext; |
michael@0 | 43 | #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) |
michael@0 | 44 | EGLContext fOldEGLContext; |
michael@0 | 45 | EGLDisplay fOldDisplay; |
michael@0 | 46 | EGLSurface fOldSurface; |
michael@0 | 47 | #elif defined(SK_BUILD_FOR_UNIX) |
michael@0 | 48 | GLXContext fOldGLXContext; |
michael@0 | 49 | Display* fOldDisplay; |
michael@0 | 50 | GLXDrawable fOldDrawable; |
michael@0 | 51 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 52 | HDC fOldHDC; |
michael@0 | 53 | HGLRC fOldHGLRC; |
michael@0 | 54 | |
michael@0 | 55 | #elif defined(SK_BUILD_FOR_IOS) |
michael@0 | 56 | void* fEAGLContext; |
michael@0 | 57 | #endif |
michael@0 | 58 | }; |
michael@0 | 59 | |
michael@0 | 60 | protected: |
michael@0 | 61 | virtual const GrGLInterface* createGLContext() SK_OVERRIDE; |
michael@0 | 62 | virtual void destroyGLContext() SK_OVERRIDE; |
michael@0 | 63 | |
michael@0 | 64 | private: |
michael@0 | 65 | #if defined(SK_BUILD_FOR_MAC) |
michael@0 | 66 | CGLContextObj fContext; |
michael@0 | 67 | #elif defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_NACL) |
michael@0 | 68 | EGLContext fContext; |
michael@0 | 69 | EGLDisplay fDisplay; |
michael@0 | 70 | EGLSurface fSurface; |
michael@0 | 71 | #elif defined(SK_BUILD_FOR_UNIX) |
michael@0 | 72 | GLXContext fContext; |
michael@0 | 73 | Display* fDisplay; |
michael@0 | 74 | Pixmap fPixmap; |
michael@0 | 75 | GLXPixmap fGlxPixmap; |
michael@0 | 76 | #elif defined(SK_BUILD_FOR_WIN32) |
michael@0 | 77 | HWND fWindow; |
michael@0 | 78 | HDC fDeviceContext; |
michael@0 | 79 | HGLRC fGlRenderContext; |
michael@0 | 80 | static ATOM gWC; |
michael@0 | 81 | #elif defined(SK_BUILD_FOR_IOS) |
michael@0 | 82 | void* fEAGLContext; |
michael@0 | 83 | #endif |
michael@0 | 84 | }; |
michael@0 | 85 | |
michael@0 | 86 | #endif |