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 | 8 |
9 #include <GL/osmesa.h> | 9 #include <GL/osmesa.h> |
10 | 10 |
11 #include "gl/SkMesaGLContext.h" | 11 #include "gl/SkMesaGLContext.h" |
12 #include "gl/GrGLDefines.h" | 12 #include "gl/GrGLDefines.h" |
13 | 13 |
| 14 SkMesaGLContext::AutoContextRestore::AutoContextRestore() { |
| 15 fOldContext = (Context)OSMesaGetCurrentContext(); |
| 16 if (fOldContext) { |
| 17 OSMesaGetColorBuffer((OSMesaContext)fOldContext, |
| 18 &fOldWidth, &fOldHeight, |
| 19 &fOldFormat, &fOldImage); |
| 20 } |
| 21 } |
| 22 |
| 23 SkMesaGLContext::AutoContextRestore::~AutoContextRestore() { |
| 24 if (fOldContext) { |
| 25 OSMesaMakeCurrent((OSMesaContext)fOldContext, fOldImage, |
| 26 fOldFormat, fOldWidth, fOldHeight); |
| 27 } |
| 28 } |
| 29 |
| 30 /////////////////////////////////////////////////////////////////////////////// |
| 31 |
14 SkMesaGLContext::SkMesaGLContext() | 32 SkMesaGLContext::SkMesaGLContext() |
15 : fContext(static_cast<Context>(NULL)) | 33 : fContext(static_cast<Context>(NULL)) |
16 , fImage(NULL) { | 34 , fImage(NULL) { |
17 GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext)); | 35 GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext)); |
18 } | 36 } |
19 | 37 |
20 SkMesaGLContext::~SkMesaGLContext() { | 38 SkMesaGLContext::~SkMesaGLContext() { |
21 this->destroyGLContext(); | 39 this->destroyGLContext(); |
22 } | 40 } |
23 | 41 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 void SkMesaGLContext::makeCurrent() const { | 103 void SkMesaGLContext::makeCurrent() const { |
86 if (fContext) { | 104 if (fContext) { |
87 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage, | 105 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage, |
88 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) { | 106 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) { |
89 SkDebugf("Could not make MESA context current."); | 107 SkDebugf("Could not make MESA context current."); |
90 } | 108 } |
91 } | 109 } |
92 } | 110 } |
93 | 111 |
94 void SkMesaGLContext::swapBuffers() const { } | 112 void SkMesaGLContext::swapBuffers() const { } |
OLD | NEW |