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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 if (!OSMesaMakeCurrent((OSMesaContext)fContext, | 43 if (!OSMesaMakeCurrent((OSMesaContext)fContext, |
44 fImage, | 44 fImage, |
45 GR_GL_UNSIGNED_BYTE, | 45 GR_GL_UNSIGNED_BYTE, |
46 gBOGUS_SIZE, | 46 gBOGUS_SIZE, |
47 gBOGUS_SIZE)) { | 47 gBOGUS_SIZE)) { |
48 SkDebugf("OSMesaMakeCurrent failed!\n"); | 48 SkDebugf("OSMesaMakeCurrent failed!\n"); |
49 this->destroyGLContext(); | 49 this->destroyGLContext(); |
50 return; | 50 return; |
51 } | 51 } |
52 | 52 |
53 fGL.reset(GrGLCreateMesaInterface()); | 53 SkAutoTUnref<const GrGLInterface> gl(GrGLCreateMesaInterface()); |
54 if (NULL == fGL.get()) { | 54 if (NULL == gl.get()) { |
55 SkDebugf("Could not create GL interface!\n"); | 55 SkDebugf("Could not create GL interface!\n"); |
56 this->destroyGLContext(); | 56 this->destroyGLContext(); |
57 return; | 57 return; |
58 } | 58 } |
59 | 59 |
60 if (!fGL->validate()) { | 60 if (!gl->validate()) { |
61 SkDebugf("Could not validate GL interface!\n"); | 61 SkDebugf("Could not validate GL interface!\n"); |
62 this->destroyGLContext(); | 62 this->destroyGLContext(); |
63 return; | 63 return; |
64 } | 64 } |
| 65 |
| 66 this->init(gl.detach()); |
65 } | 67 } |
66 | 68 |
67 SkMesaGLContext::~SkMesaGLContext() { | 69 SkMesaGLContext::~SkMesaGLContext() { |
| 70 this->teardown(); |
68 this->destroyGLContext(); | 71 this->destroyGLContext(); |
69 } | 72 } |
70 | 73 |
71 void SkMesaGLContext::destroyGLContext() { | 74 void SkMesaGLContext::destroyGLContext() { |
72 fGL.reset(NULL); | |
73 if (fImage) { | 75 if (fImage) { |
74 sk_free(fImage); | 76 sk_free(fImage); |
75 fImage = NULL; | 77 fImage = NULL; |
76 } | 78 } |
77 | 79 |
78 if (fContext) { | 80 if (fContext) { |
79 OSMesaDestroyContext((OSMesaContext)fContext); | 81 OSMesaDestroyContext((OSMesaContext)fContext); |
80 fContext = static_cast<Context>(NULL); | 82 fContext = static_cast<Context>(NULL); |
81 } | 83 } |
82 } | 84 } |
83 | 85 |
84 | 86 |
85 | 87 |
86 void SkMesaGLContext::makeCurrent() const { | 88 void SkMesaGLContext::onPlatformMakeCurrent() const { |
87 if (fContext) { | 89 if (fContext) { |
88 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage, | 90 if (!OSMesaMakeCurrent((OSMesaContext)fContext, fImage, |
89 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) { | 91 GR_GL_UNSIGNED_BYTE, gBOGUS_SIZE, gBOGUS_SIZE)) { |
90 SkDebugf("Could not make MESA context current."); | 92 SkDebugf("Could not make MESA context current."); |
91 } | 93 } |
92 } | 94 } |
93 } | 95 } |
94 | 96 |
95 void SkMesaGLContext::swapBuffers() const { } | 97 void SkMesaGLContext::onPlatformSwapBuffers() const { } |
| 98 |
| 99 GrGLFuncPtr SkMesaGLContext::onPlatformGetProcAddress(const char* procName) cons
t { |
| 100 return OSMesaGetProcAddress(procName); |
| 101 } |
OLD | NEW |