| Index: ui/gfx/gl/gl_context_osmesa.cc
|
| ===================================================================
|
| --- ui/gfx/gl/gl_context_osmesa.cc (revision 85357)
|
| +++ ui/gfx/gl/gl_context_osmesa.cc (working copy)
|
| @@ -4,17 +4,16 @@
|
|
|
| #include <GL/osmesa.h>
|
|
|
| -#include <algorithm>
|
| +#include "ui/gfx/gl/gl_context_osmesa.h"
|
|
|
| #include "base/logging.h"
|
| #include "ui/gfx/gl/gl_bindings.h"
|
| -#include "ui/gfx/gl/gl_context_osmesa.h"
|
| +#include "ui/gfx/gl/gl_surface_osmesa.h"
|
|
|
| namespace gfx {
|
|
|
| -GLContextOSMesa::GLContextOSMesa(GLSurfaceOSMesa* surface)
|
| - : surface_(surface),
|
| - context_(NULL)
|
| +GLContextOSMesa::GLContextOSMesa()
|
| + : context_(NULL)
|
| {
|
| }
|
|
|
| @@ -47,22 +46,20 @@
|
| OSMesaDestroyContext(static_cast<OSMesaContext>(context_));
|
| context_ = NULL;
|
| }
|
| -
|
| - if (surface_.get()) {
|
| - surface_->Destroy();
|
| - surface_.reset();
|
| - }
|
| }
|
|
|
| -bool GLContextOSMesa::MakeCurrent() {
|
| +bool GLContextOSMesa::MakeCurrent(GLSurface* surface) {
|
| DCHECK(context_);
|
|
|
| - gfx::Size size = surface_->GetSize();
|
| + gfx::Size size = surface->GetSize();
|
|
|
| if (!OSMesaMakeCurrent(static_cast<OSMesaContext>(context_),
|
| - surface_->GetHandle(),
|
| + surface->GetHandle(),
|
| GL_UNSIGNED_BYTE,
|
| - size.width(), size.height())) {
|
| + size.width(),
|
| + size.height())) {
|
| + LOG(ERROR) << "OSMesaMakeCurrent failed.";
|
| + Destroy();
|
| return false;
|
| }
|
|
|
| @@ -72,24 +69,29 @@
|
| return true;
|
| }
|
|
|
| -bool GLContextOSMesa::IsCurrent() {
|
| - DCHECK(context_);
|
| - return context_ == OSMesaGetCurrentContext();
|
| -}
|
| +void GLContextOSMesa::ReleaseCurrent(GLSurface* surface) {
|
| + if (!IsCurrent(surface))
|
| + return;
|
|
|
| -bool GLContextOSMesa::IsOffscreen() {
|
| - // TODO(apatrick): remove this from GLContext interface.
|
| - return surface_->IsOffscreen();
|
| + OSMesaMakeCurrent(NULL, NULL, GL_UNSIGNED_BYTE, 0, 0);
|
| }
|
|
|
| -bool GLContextOSMesa::SwapBuffers() {
|
| - // TODO(apatrick): remove this from GLContext interface.
|
| - return surface_->SwapBuffers();
|
| -}
|
| +bool GLContextOSMesa::IsCurrent(GLSurface* surface) {
|
| + DCHECK(context_);
|
| + if (context_ != OSMesaGetCurrentContext())
|
| + return false;
|
|
|
| -gfx::Size GLContextOSMesa::GetSize() {
|
| - // TODO(apatrick): remove this from GLContext interface.
|
| - return surface_->GetSize();
|
| + if (surface) {
|
| + GLint width;
|
| + GLint height;
|
| + GLint format;
|
| + void* buffer = NULL;
|
| + OSMesaGetColorBuffer(context_, &width, &height, &format, &buffer);
|
| + if (buffer != surface->GetHandle())
|
| + return false;
|
| + }
|
| +
|
| + return true;
|
| }
|
|
|
| void* GLContextOSMesa::GetHandle() {
|
| @@ -97,7 +99,7 @@
|
| }
|
|
|
| void GLContextOSMesa::SetSwapInterval(int interval) {
|
| - DCHECK(IsCurrent());
|
| + DCHECK(IsCurrent(NULL));
|
| NOTREACHED() << "Attempt to call SetSwapInterval on an GLContextOSMesa.";
|
| }
|
|
|
|
|