aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-20 21:09:45 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-10-20 21:09:45 +0000
commitd47fafe05743d61958397bcf7a4b2bf66d778e1d (patch)
treefac9722ac2921f86840813c7d0792be28851a7ca /src
parentffa11bbbedd201899eb93bf05089c511f53d5c2a (diff)
Add test that validates GrGLInterfaces
Review URL: http://codereview.appspot.com/5304048/ git-svn-id: http://skia.googlecode.com/svn/trunk@2510 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r--src/gpu/mac/SkNativeGLContext_mac.cpp10
-rw-r--r--src/gpu/mesa/SkMesaGLContext.cpp17
-rw-r--r--src/gpu/unix/SkNativeGLContext_unix.cpp13
-rw-r--r--src/gpu/win/SkNativeGLContext_win.cpp17
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() {