| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/osmesa.h> | 5 #include <GL/osmesa.h> |
| 6 | 6 |
| 7 #include "ui/gfx/gl/gl_context_osmesa.h" | 7 #include "ui/gfx/gl/gl_context_osmesa.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/gfx/gl/gl_bindings.h" | 10 #include "ui/gfx/gl/gl_bindings.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool GLContextOSMesa::Initialize(GLSurface* compatible_surface) { | 24 bool GLContextOSMesa::Initialize(GLSurface* compatible_surface) { |
| 25 DCHECK(!context_); | 25 DCHECK(!context_); |
| 26 | 26 |
| 27 OSMesaContext share_handle = static_cast<OSMesaContext>( | 27 OSMesaContext share_handle = static_cast<OSMesaContext>( |
| 28 share_group() ? share_group()->GetHandle() : NULL); | 28 share_group() ? share_group()->GetHandle() : NULL); |
| 29 | 29 |
| 30 GLuint format = | 30 GLuint format = |
| 31 static_cast<GLSurfaceOSMesa*>(compatible_surface)->GetFormat(); | 31 static_cast<GLSurfaceOSMesa*>(compatible_surface)->GetFormat(); |
| 32 DCHECK_NE(format, (unsigned)0); |
| 32 context_ = OSMesaCreateContextExt(format, | 33 context_ = OSMesaCreateContextExt(format, |
| 33 0, // depth bits | 34 0, // depth bits |
| 34 0, // stencil bits | 35 0, // stencil bits |
| 35 0, // accum bits | 36 0, // accum bits |
| 36 share_handle); | 37 share_handle); |
| 37 if (!context_) { | 38 if (!context_) { |
| 38 LOG(ERROR) << "OSMesaCreateContextExt failed."; | 39 LOG(ERROR) << "OSMesaCreateContextExt failed."; |
| 39 return false; | 40 return false; |
| 40 } | 41 } |
| 41 | 42 |
| 42 return true; | 43 return true; |
| 43 } | 44 } |
| 44 | 45 |
| 45 void GLContextOSMesa::Destroy() { | 46 void GLContextOSMesa::Destroy() { |
| 46 if (context_) { | 47 if (context_) { |
| 47 OSMesaDestroyContext(static_cast<OSMesaContext>(context_)); | 48 OSMesaDestroyContext(static_cast<OSMesaContext>(context_)); |
| 48 context_ = NULL; | 49 context_ = NULL; |
| 49 } | 50 } |
| 50 } | 51 } |
| 51 | 52 |
| 52 bool GLContextOSMesa::MakeCurrent(GLSurface* surface) { | 53 bool GLContextOSMesa::MakeCurrent(GLSurface* surface) { |
| 53 DCHECK(context_); | 54 DCHECK(context_); |
| 54 | 55 |
| 55 gfx::Size size = surface->GetSize(); | 56 gfx::Size size = surface->GetSize(); |
| 56 | 57 |
| 57 if (!OSMesaMakeCurrent(static_cast<OSMesaContext>(context_), | 58 if (!OSMesaMakeCurrent(context_, |
| 58 surface->GetHandle(), | 59 surface->GetHandle(), |
| 59 GL_UNSIGNED_BYTE, | 60 GL_UNSIGNED_BYTE, |
| 60 size.width(), | 61 size.width(), |
| 61 size.height())) { | 62 size.height())) { |
| 62 LOG(ERROR) << "OSMesaMakeCurrent failed."; | 63 LOG(ERROR) << "OSMesaMakeCurrent failed."; |
| 63 Destroy(); | 64 Destroy(); |
| 64 return false; | 65 return false; |
| 65 } | 66 } |
| 66 | 67 |
| 67 // Row 0 is at the top. | 68 // Row 0 is at the top. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void* GLContextOSMesa::GetHandle() { | 108 void* GLContextOSMesa::GetHandle() { |
| 108 return context_; | 109 return context_; |
| 109 } | 110 } |
| 110 | 111 |
| 111 void GLContextOSMesa::SetSwapInterval(int interval) { | 112 void GLContextOSMesa::SetSwapInterval(int interval) { |
| 112 DCHECK(IsCurrent(NULL)); | 113 DCHECK(IsCurrent(NULL)); |
| 113 LOG(WARNING) << "GLContextOSMesa::SetSwapInterval is ignored."; | 114 LOG(WARNING) << "GLContextOSMesa::SetSwapInterval is ignored."; |
| 114 } | 115 } |
| 115 | 116 |
| 116 } // namespace gfx | 117 } // namespace gfx |
| OLD | NEW |