| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 <GL/glew.h> | |
| 6 #include <GL/osmew.h> | |
| 7 | |
| 8 #include <algorithm> | 5 #include <algorithm> |
| 9 | 6 |
| 7 #include "app/gfx/gl/gl_bindings.h" |
| 10 #include "app/gfx/gl/gl_context_osmesa.h" | 8 #include "app/gfx/gl/gl_context_osmesa.h" |
| 11 | 9 |
| 12 namespace gfx { | 10 namespace gfx { |
| 13 | 11 |
| 14 OSMesaGLContext::OSMesaGLContext() : context_(NULL) | 12 OSMesaGLContext::OSMesaGLContext() : context_(NULL) |
| 15 { | 13 { |
| 16 } | 14 } |
| 17 | 15 |
| 18 OSMesaGLContext::~OSMesaGLContext() { | 16 OSMesaGLContext::~OSMesaGLContext() { |
| 19 } | 17 } |
| 20 | 18 |
| 21 bool OSMesaGLContext::Initialize(void* shared_handle) { | 19 bool OSMesaGLContext::Initialize(GLContext* shared_context) { |
| 22 DCHECK(!context_); | 20 DCHECK(!context_); |
| 23 | 21 |
| 24 size_ = gfx::Size(1, 1); | 22 size_ = gfx::Size(1, 1); |
| 25 buffer_.reset(new int32[1]); | 23 buffer_.reset(new int32[1]); |
| 26 | 24 |
| 27 context_ = OSMesaCreateContext(GL_RGBA, | 25 OSMesaContext shared_handle = NULL; |
| 28 static_cast<OSMesaContext>(shared_handle)); | 26 if (shared_context) |
| 27 shared_handle = static_cast<OSMesaContext>(shared_context->GetHandle()); |
| 28 |
| 29 context_ = OSMesaCreateContext(GL_RGBA, shared_handle); |
| 29 if (!context_) | 30 if (!context_) |
| 30 return false; | 31 return false; |
| 31 | 32 |
| 32 if (!MakeCurrent()) { | 33 if (!MakeCurrent()) { |
| 33 Destroy(); | 34 Destroy(); |
| 34 return false; | 35 return false; |
| 35 } | 36 } |
| 36 | 37 |
| 37 if (!InitializeGLEW()) { | |
| 38 Destroy(); | |
| 39 return false; | |
| 40 } | |
| 41 | |
| 42 if (!InitializeCommon()) { | 38 if (!InitializeCommon()) { |
| 43 Destroy(); | 39 Destroy(); |
| 44 return false; | 40 return false; |
| 45 } | 41 } |
| 46 | 42 |
| 47 return true; | 43 return true; |
| 48 } | 44 } |
| 49 | 45 |
| 50 void OSMesaGLContext::Destroy() { | 46 void OSMesaGLContext::Destroy() { |
| 51 if (context_) { | 47 if (context_) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 buffer_.reset(new_buffer.release()); | 102 buffer_.reset(new_buffer.release()); |
| 107 size_ = new_size; | 103 size_ = new_size; |
| 108 | 104 |
| 109 // If this context is current, need to call MakeCurrent again so OSMesa uses | 105 // If this context is current, need to call MakeCurrent again so OSMesa uses |
| 110 // the new buffer. | 106 // the new buffer. |
| 111 if (IsCurrent()) | 107 if (IsCurrent()) |
| 112 MakeCurrent(); | 108 MakeCurrent(); |
| 113 } | 109 } |
| 114 | 110 |
| 115 } // namespace gfx | 111 } // namespace gfx |
| OLD | NEW |