| 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 #include "gl/SkNativeGLContext.h" | 8 #include "gl/SkNativeGLContext.h" |
| 9 | 9 |
| 10 #include <GL/glu.h> | 10 #include <GL/glu.h> |
| 11 | 11 |
| 12 /* Note: Skia requires glx 1.3 or newer */ | 12 /* Note: Skia requires glx 1.3 or newer */ |
| 13 | 13 |
| 14 SkNativeGLContext::AutoContextRestore::AutoContextRestore() { | 14 SkNativeGLContext::AutoContextRestore::AutoContextRestore() { |
| 15 fOldGLXContext = glXGetCurrentContext(); | 15 fOldGLXContext = glXGetCurrentContext(); |
| 16 fOldDisplay = glXGetCurrentDisplay(); | 16 fOldDisplay = glXGetCurrentDisplay(); |
| 17 fOldDrawable = glXGetCurrentDrawable(); | 17 fOldDrawable = glXGetCurrentDrawable(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { | 20 SkNativeGLContext::AutoContextRestore::~AutoContextRestore() { |
| 21 if (NULL != fOldDisplay) { | 21 if (fOldDisplay) { |
| 22 glXMakeCurrent(fOldDisplay, fOldDrawable, fOldGLXContext); | 22 glXMakeCurrent(fOldDisplay, fOldDrawable, fOldGLXContext); |
| 23 } | 23 } |
| 24 } | 24 } |
| 25 | 25 |
| 26 /////////////////////////////////////////////////////////////////////////////// | 26 /////////////////////////////////////////////////////////////////////////////// |
| 27 | 27 |
| 28 static bool ctxErrorOccurred = false; | 28 static bool ctxErrorOccurred = false; |
| 29 static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) { | 29 static int ctxErrorHandler(Display *dpy, XErrorEvent *ev) { |
| 30 ctxErrorOccurred = true; | 30 ctxErrorOccurred = true; |
| 31 return 0; | 31 return 0; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 void SkNativeGLContext::makeCurrent() const { | 280 void SkNativeGLContext::makeCurrent() const { |
| 281 if (!glXMakeCurrent(fDisplay, fGlxPixmap, fContext)) { | 281 if (!glXMakeCurrent(fDisplay, fGlxPixmap, fContext)) { |
| 282 SkDebugf("Could not set the context.\n"); | 282 SkDebugf("Could not set the context.\n"); |
| 283 } | 283 } |
| 284 } | 284 } |
| 285 | 285 |
| 286 void SkNativeGLContext::swapBuffers() const { | 286 void SkNativeGLContext::swapBuffers() const { |
| 287 glXSwapBuffers(fDisplay, fGlxPixmap); | 287 glXSwapBuffers(fDisplay, fGlxPixmap); |
| 288 } | 288 } |
| OLD | NEW |