| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/gl/gl_context_osmesa.h" | 5 #include "ui/gl/gl_context_osmesa.h" |
| 6 | 6 |
| 7 #include <GL/osmesa.h> | 7 #include <GL/osmesa.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/gfx/size.h" | 10 #include "ui/gfx/size.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 if (!OSMesaMakeCurrent(context_, | 55 if (!OSMesaMakeCurrent(context_, |
| 56 surface->GetHandle(), | 56 surface->GetHandle(), |
| 57 GL_UNSIGNED_BYTE, | 57 GL_UNSIGNED_BYTE, |
| 58 size.width(), | 58 size.width(), |
| 59 size.height())) { | 59 size.height())) { |
| 60 LOG(ERROR) << "OSMesaMakeCurrent failed."; | 60 LOG(ERROR) << "OSMesaMakeCurrent failed."; |
| 61 Destroy(); | 61 Destroy(); |
| 62 return false; | 62 return false; |
| 63 } | 63 } |
| 64 | 64 |
| 65 // Set this as soon as the context is current, since we might call into GL. |
| 66 SetRealGLApi(); |
| 67 |
| 65 // Row 0 is at the top. | 68 // Row 0 is at the top. |
| 66 OSMesaPixelStore(OSMESA_Y_UP, 0); | 69 OSMesaPixelStore(OSMESA_Y_UP, 0); |
| 67 | 70 |
| 68 SetCurrent(surface); | 71 SetCurrent(surface); |
| 69 if (!InitializeExtensionBindings()) { | 72 if (!InitializeExtensionBindings()) { |
| 70 ReleaseCurrent(surface); | 73 ReleaseCurrent(surface); |
| 71 return false; | 74 return false; |
| 72 } | 75 } |
| 73 | 76 |
| 74 if (!surface->OnMakeCurrent(this)) { | 77 if (!surface->OnMakeCurrent(this)) { |
| 75 LOG(ERROR) << "Could not make current."; | 78 LOG(ERROR) << "Could not make current."; |
| 76 return false; | 79 return false; |
| 77 } | 80 } |
| 78 | 81 |
| 79 SetRealGLApi(); | |
| 80 return true; | 82 return true; |
| 81 } | 83 } |
| 82 | 84 |
| 83 void GLContextOSMesa::ReleaseCurrent(GLSurface* surface) { | 85 void GLContextOSMesa::ReleaseCurrent(GLSurface* surface) { |
| 84 if (!IsCurrent(surface)) | 86 if (!IsCurrent(surface)) |
| 85 return; | 87 return; |
| 86 | 88 |
| 87 SetCurrent(NULL); | 89 SetCurrent(NULL); |
| 88 OSMesaMakeCurrent(NULL, NULL, GL_UNSIGNED_BYTE, 0, 0); | 90 OSMesaMakeCurrent(NULL, NULL, GL_UNSIGNED_BYTE, 0, 0); |
| 89 } | 91 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 123 |
| 122 void GLContextOSMesa::SetSwapInterval(int interval) { | 124 void GLContextOSMesa::SetSwapInterval(int interval) { |
| 123 DCHECK(IsCurrent(NULL)); | 125 DCHECK(IsCurrent(NULL)); |
| 124 } | 126 } |
| 125 | 127 |
| 126 GLContextOSMesa::~GLContextOSMesa() { | 128 GLContextOSMesa::~GLContextOSMesa() { |
| 127 Destroy(); | 129 Destroy(); |
| 128 } | 130 } |
| 129 | 131 |
| 130 } // namespace gfx | 132 } // namespace gfx |
| OLD | NEW |