diff options
author | 2011-10-24 21:17:53 +0000 | |
---|---|---|
committer | 2011-10-24 21:17:53 +0000 | |
commit | 57f5d9854bfc78c347cb587e044fb3950f9ad298 (patch) | |
tree | 91c75b0a9a4555e29ea40dc057948c5520eeabaa /src/gpu | |
parent | 820e80ad6390e120d4991a5280d0452ec87beaeb (diff) |
Recommit r2510 now that mac build bot issue has been fixed.
git-svn-id: http://skia.googlecode.com/svn/trunk@2521 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/mac/SkNativeGLContext_mac.cpp | 10 | ||||
-rw-r--r-- | src/gpu/mesa/SkMesaGLContext.cpp | 17 | ||||
-rw-r--r-- | src/gpu/unix/SkNativeGLContext_unix.cpp | 13 | ||||
-rw-r--r-- | src/gpu/win/SkNativeGLContext_win.cpp | 17 |
4 files changed, 54 insertions, 3 deletions
diff --git a/src/gpu/mac/SkNativeGLContext_mac.cpp b/src/gpu/mac/SkNativeGLContext_mac.cpp index 3f864c2e01..ad68c40f57 100644 --- a/src/gpu/mac/SkNativeGLContext_mac.cpp +++ b/src/gpu/mac/SkNativeGLContext_mac.cpp @@ -7,6 +7,16 @@ */ #include "SkNativeGLContext.h" +SkNativeGLContext::AutoContextRestore::AutoContextRestore() { + fOldAGLContext = aglGetCurrentContext(); +} + +SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { + aglSetCurrentContext(fOldAGLContext); +} + +/////////////////////////////////////////////////////////////////////////////// + SkNativeGLContext::SkNativeGLContext() : fContext(NULL) { } diff --git a/src/gpu/mesa/SkMesaGLContext.cpp b/src/gpu/mesa/SkMesaGLContext.cpp index 23ccc9593e..5440a90569 100644 --- a/src/gpu/mesa/SkMesaGLContext.cpp +++ b/src/gpu/mesa/SkMesaGLContext.cpp @@ -10,6 +10,23 @@ #include "SkMesaGLContext.h" +SkMesaGLContext::AutoContextRestore::AutoContextRestore() { + fOldContext = (Context)OSMesaGetCurrentContext(); + if (NULL != (OSMesaContext)fOldContext) { + OSMesaGetColorBuffer((OSMesaContext)fOldContext, + &fOldWidth, &fOldHeight, + &fOldFormat, &fOldImage); + } +} + +SkMesaGLContext::AutoContextRestore::~AutoContextRestore() { + if (NULL != fOldContext) { + OSMesaMakeCurrent((OSMesaContext)fOldContext, fOldImage, + fOldFormat, fOldWidth, fOldHeight); + } +} + +/////////////////////////////////////////////////////////////////////////////// SkMesaGLContext::SkMesaGLContext() : fContext(NULL) diff --git a/src/gpu/unix/SkNativeGLContext_unix.cpp b/src/gpu/unix/SkNativeGLContext_unix.cpp index 870ff45a4f..907e2b8238 100644 --- a/src/gpu/unix/SkNativeGLContext_unix.cpp +++ b/src/gpu/unix/SkNativeGLContext_unix.cpp @@ -9,6 +9,19 @@ #include <GL/glu.h> +SkNativeGLContext::AutoContextRestore::AutoContextRestore() { + fOldGLXContext = glXGetCurrentContext(); + fOldDisplay = glXGetCurrentDisplay(); + fOldDrawable = glXGetCurrentDrawable(); +} + +SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { + if (NULL != fOldDisplay) { + glXMakeCurrent(fOldDisplay, fOldDrawable, fOldGLXContext); + } +} + +/////////////////////////////////////////////////////////////////////////////// static bool ctxErrorOccurred = false; static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) { diff --git a/src/gpu/win/SkNativeGLContext_win.cpp b/src/gpu/win/SkNativeGLContext_win.cpp index c19f7cca45..5d518dd138 100644 --- a/src/gpu/win/SkNativeGLContext_win.cpp +++ b/src/gpu/win/SkNativeGLContext_win.cpp @@ -11,12 +11,23 @@ #define WIN32_LEAN_AND_MEAN #include <Windows.h> +SkNativeGLContext::AutoContextRestore::AutoContextRestore() { + fOldHGLRC = wglGetCurrentContext(); + fOldHDC = wglGetCurrentDC(); +} + +SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { + wglMakeCurrent(fOldHDC, fOldHGLRC); +} + +/////////////////////////////////////////////////////////////////////////////// + ATOM SkNativeGLContext::gWC = 0; SkNativeGLContext::SkNativeGLContext() - : fWindow(NULL) - , fDeviceContext(NULL) - , fGlRenderContext(0) { + : fWindow(NULL) + , fDeviceContext(NULL) + , fGlRenderContext(0) { } SkNativeGLContext::~SkNativeGLContext() { |