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 |
(...skipping 24 matching lines...) Expand all Loading... |
35 GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext)); | 35 GR_STATIC_ASSERT(sizeof(Context) == sizeof(OSMesaContext)); |
36 } | 36 } |
37 | 37 |
38 SkMesaGLContext::~SkMesaGLContext() { | 38 SkMesaGLContext::~SkMesaGLContext() { |
39 this->destroyGLContext(); | 39 this->destroyGLContext(); |
40 } | 40 } |
41 | 41 |
42 void SkMesaGLContext::destroyGLContext() { | 42 void SkMesaGLContext::destroyGLContext() { |
43 if (fImage) { | 43 if (fImage) { |
44 sk_free(fImage); | 44 sk_free(fImage); |
| 45 fImage = NULL; |
45 } | 46 } |
46 | 47 |
47 if (fContext) { | 48 if (fContext) { |
48 OSMesaDestroyContext((OSMesaContext)fContext); | 49 OSMesaDestroyContext((OSMesaContext)fContext); |
| 50 fContext = static_cast<Context>(NULL); |
49 } | 51 } |
50 } | 52 } |
51 | 53 |
52 static const GrGLint gBOGUS_SIZE = 16; | 54 static const GrGLint gBOGUS_SIZE = 16; |
53 | 55 |
54 const GrGLInterface* SkMesaGLContext::createGLContext() { | 56 const GrGLInterface* SkMesaGLContext::createGLContext() { |
55 /* Create an RGBA-mode context */ | 57 /* Create an RGBA-mode context */ |
56 #if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 | 58 #if OSMESA_MAJOR_VERSION * 100 + OSMESA_MINOR_VERSION >= 305 |
57 /* specify Z, stencil, accum sizes */ | 59 /* specify Z, stencil, accum sizes */ |
58 fContext = (Context)OSMesaCreateContextExt(OSMESA_BGRA, 0, 0, 0, NULL); | 60 fContext = (Context)OSMesaCreateContextExt(OSMESA_BGRA, 0, 0, 0, NULL); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 97 } |
96 | 98 |
97 void SkMesaGLContext::makeCurrent() const { | 99 void SkMesaGLContext::makeCurrent() const { |
98 if (fContext) { | 100 if (fContext) { |
99 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage, | 101 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage, |
100 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) { | 102 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) { |
101 SkDebugf("Could not make MESA context current."); | 103 SkDebugf("Could not make MESA context current."); |
102 } | 104 } |
103 } | 105 } |
104 } | 106 } |
OLD | NEW |