Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Unified Diff: ui/gl/gl_context_egl.cc

Issue 14189031: Merge 195349 "Reland "gpu: Fix Vivante's "hisilicon" GPUs"" (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1453/src/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_context_egl.h ('k') | ui/gl/gl_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_context_egl.cc
===================================================================
--- ui/gl/gl_context_egl.cc (revision 195901)
+++ ui/gl/gl_context_egl.cc (working copy)
@@ -28,7 +28,8 @@
: GLContext(share_group),
context_(NULL),
display_(NULL),
- config_(NULL) {
+ config_(NULL),
+ recreate_surface_on_makecurrent_(false) {
}
bool GLContextEGL::Initialize(
@@ -112,6 +113,11 @@
return false;
}
+#if defined(OS_ANDROID)
+ if (!RecreateSurfaceIfNeeded(surface))
+ return false;
+#endif
+
if (!surface->OnMakeCurrent(this)) {
LOG(ERROR) << "Could not make current.";
return false;
@@ -121,6 +127,46 @@
return true;
}
+void GLContextEGL::SetRecreateSurfaceOnMakeCurrent() {
+ recreate_surface_on_makecurrent_ = true;
+}
+
+bool GLContextEGL::RecreateSurfaceIfNeeded(GLSurface* surface) {
+ if (!recreate_surface_on_makecurrent_ ||
+ !surface ||
+ surface->IsOffscreen() ||
+ surface->GetBackingFrameBufferObject())
+ return true;
+
+ // This is specifically needed for Vivante GPU's on Android.
+ // A native view surface will not be configured correctly
+ // unless we do all of the following steps after making the
+ // surface current.
+ GLint fbo = 0;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo);
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
+
+ eglMakeCurrent(display_,
+ EGL_NO_SURFACE,
+ EGL_NO_SURFACE,
+ EGL_NO_CONTEXT);
+ if (!surface->Recreate()) {
+ LOG(ERROR) << "Failed to recreate surface";
+ return false;
+ }
+ if (!eglMakeCurrent(display_,
+ surface->GetHandle(),
+ surface->GetHandle(),
+ context_)) {
+ LOG(ERROR) << "eglMakeCurrent failed with error "
+ << GetLastEGLErrorString();
+ return false;
+ }
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER, fbo);
+ return true;
+}
+
void GLContextEGL::ReleaseCurrent(GLSurface* surface) {
if (!IsCurrent(surface))
return;
« no previous file with comments | « ui/gl/gl_context_egl.h ('k') | ui/gl/gl_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698