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 | |
32 SkMesaGLContext::SkMesaGLContext() | 14 SkMesaGLContext::SkMesaGLContext() |
33 : fContext(static_cast<Context>(NULL)) | 15 : fContext(static_cast<Context>(NULL)) |
34 , fImage(NULL) { | 16 , fImage(NULL) { |
35 GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext)); | 17 GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext)); |
36 } | 18 } |
37 | 19 |
38 SkMesaGLContext::~SkMesaGLContext() { | 20 SkMesaGLContext::~SkMesaGLContext() { |
39 this->destroyGLContext(); | 21 this->destroyGLContext(); |
40 } | 22 } |
41 | 23 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void SkMesaGLContext::makeCurrent() const { | 85 void SkMesaGLContext::makeCurrent() const { |
104 if (fContext) { | 86 if (fContext) { |
105 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage, | 87 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage, |
106 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) { | 88 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) { |
107 SkDebugf("Could not make MESA context current."); | 89 SkDebugf("Could not make MESA context current."); |
108 } | 90 } |
109 } | 91 } |
110 } | 92 } |
111 | 93 |
112 void SkMesaGLContext::swapBuffers() const { } | 94 void SkMesaGLContext::swapBuffers() const { } |
OLD | NEW |