summaryrefslogtreecommitdiffstats
path: root/ui/gfx/gl
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-08 22:30:14 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-08 22:30:14 +0000
commitf189b2527518a5a507eb764b2777a008e7528dcb (patch)
tree4ef970d5432e8c5622db14480e05dad4f75be2a0 /ui/gfx/gl
parent207ff6675717b341d3c78d305762cd6d7a9888e1 (diff)
downloadchromium_src-f189b2527518a5a507eb764b2777a008e7528dcb.zip
chromium_src-f189b2527518a5a507eb764b2777a008e7528dcb.tar.gz
chromium_src-f189b2527518a5a507eb764b2777a008e7528dcb.tar.bz2
GLSurface::Resize implementations release the current context if they are current before resize.
This is because, if the newly allocated surface happens to have the same handle / address, a subsequent MakeCurrent will think that the surface has not changed and early out. Review URL: http://codereview.chromium.org/8869007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/gl')
-rw-r--r--ui/gfx/gl/gl_surface_egl.cc16
-rw-r--r--ui/gfx/gl/gl_surface_osmesa.cc10
2 files changed, 25 insertions, 1 deletions
diff --git a/ui/gfx/gl/gl_surface_egl.cc b/ui/gfx/gl/gl_surface_egl.cc
index f1d0750..1e32cc0 100644
--- a/ui/gfx/gl/gl_surface_egl.cc
+++ b/ui/gfx/gl/gl_surface_egl.cc
@@ -12,6 +12,7 @@
#include "third_party/angle/include/EGL/eglext.h"
#endif
#include "ui/gfx/gl/egl_util.h"
+#include "ui/gfx/gl/gl_context.h"
#if defined(OS_ANDROID)
#include <EGL/egl.h>
@@ -357,9 +358,22 @@ bool PbufferGLSurfaceEGL::Resize(const gfx::Size& size) {
if (size == size_)
return true;
+ GLContext* current_context = GLContext::GetCurrent();
+ bool was_current = current_context && current_context->IsCurrent(this);
+ if (was_current)
+ current_context->ReleaseCurrent(this);
+
Destroy();
+
size_ = size;
- return Initialize();
+
+ if (!Initialize())
+ return false;
+
+ if (was_current)
+ return current_context->MakeCurrent(this);
+
+ return true;
}
EGLSurface PbufferGLSurfaceEGL::GetHandle() {
diff --git a/ui/gfx/gl/gl_surface_osmesa.cc b/ui/gfx/gl/gl_surface_osmesa.cc
index 2fe5e38..a6d4b4c 100644
--- a/ui/gfx/gl/gl_surface_osmesa.cc
+++ b/ui/gfx/gl/gl_surface_osmesa.cc
@@ -5,6 +5,7 @@
#include "ui/gfx/gl/gl_surface_osmesa.h"
#include "base/logging.h"
#include "ui/gfx/gl/gl_bindings.h"
+#include "ui/gfx/gl/gl_context.h"
namespace gfx {
@@ -21,6 +22,11 @@ bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size) {
if (new_size == size_)
return true;
+ GLContext* current_context = GLContext::GetCurrent();
+ bool was_current = current_context && current_context->IsCurrent(this);
+ if (was_current)
+ current_context->ReleaseCurrent(this);
+
// Preserve the old buffer.
scoped_array<int32> old_buffer(buffer_.release());
@@ -37,6 +43,10 @@ bool GLSurfaceOSMesa::Resize(const gfx::Size& new_size) {
}
size_ = new_size;
+
+ if (was_current)
+ return current_context->MakeCurrent(this);
+
return true;
}