~oxide-developers/oxide/1.1

« back to all changes in this revision

Viewing changes to patches/use-gles-api.patch

  • Committer: Chris Coulson
  • Date: 2014-06-06 16:07:21 UTC
  • Revision ID: chris.coulson@canonical.com-20140606160721-k06nhuyqjoun8vsm
Select GLES when binding and creating EGL contexts. The Ubuntu QPA plugin selects OpenGL on desktop, but we depend on GLES for surfaceless contexts

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Description: Set the API to GLES rather than OpenGL when binding and
 
2
#  creating contexts. The Ubuntu QPA plugin explicitly selects OpenGL on
 
3
#  desktop, but we depend on GLES for surfaceless contexts
 
4
# Author: Chris Coulson <chris.coulson@canonical.com>
 
5
 
 
6
diff --git a/ui/gl/gl_context_egl.cc b/ui/gl/gl_context_egl.cc
 
7
--- a/ui/gl/gl_context_egl.cc
 
8
+++ b/ui/gl/gl_context_egl.cc
 
9
@@ -57,16 +57,18 @@ bool GLContextEGL::Initialize(
 
10
     context_attributes = kContextRobustnessAttributes;
 
11
   } else {
 
12
     // At some point we should require the presence of the robustness
 
13
     // extension and remove this code path.
 
14
     DVLOG(1) << "EGL_EXT_create_context_robustness NOT supported.";
 
15
     context_attributes = kContextAttributes;
 
16
   }
 
17
 
 
18
+  eglBindAPI(EGL_OPENGL_ES_API);
 
19
+
 
20
   context_ = eglCreateContext(
 
21
       display_,
 
22
       config_,
 
23
       share_group() ? share_group()->GetHandle() : NULL,
 
24
       context_attributes);
 
25
 
 
26
   if (!context_) {
 
27
     LOG(ERROR) << "eglCreateContext failed with error "
 
28
@@ -88,16 +90,18 @@ void GLContextEGL::Destroy() {
 
29
   }
 
30
 }
 
31
 
 
32
 bool GLContextEGL::MakeCurrent(GLSurface* surface) {
 
33
   DCHECK(context_);
 
34
   if (IsCurrent(surface))
 
35
       return true;
 
36
 
 
37
+  eglBindAPI(EGL_OPENGL_ES_API);
 
38
+
 
39
   ScopedReleaseCurrent release_current;
 
40
   TRACE_EVENT2("gpu", "GLContextEGL::MakeCurrent",
 
41
                "context", context_,
 
42
                "surface", surface);
 
43
 
 
44
   if (unbind_fbo_on_makecurrent_ &&
 
45
       eglGetCurrentContext() != EGL_NO_CONTEXT) {
 
46
     glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
 
47
@@ -132,29 +136,33 @@ bool GLContextEGL::MakeCurrent(GLSurface
 
48
 void GLContextEGL::SetUnbindFboOnMakeCurrent() {
 
49
   unbind_fbo_on_makecurrent_ = true;
 
50
 }
 
51
 
 
52
 void GLContextEGL::ReleaseCurrent(GLSurface* surface) {
 
53
   if (!IsCurrent(surface))
 
54
     return;
 
55
 
 
56
+  eglBindAPI(EGL_OPENGL_ES_API);
 
57
+
 
58
   if (unbind_fbo_on_makecurrent_)
 
59
     glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
 
60
 
 
61
   SetCurrent(NULL);
 
62
   eglMakeCurrent(display_,
 
63
                  EGL_NO_SURFACE,
 
64
                  EGL_NO_SURFACE,
 
65
                  EGL_NO_CONTEXT);
 
66
 }
 
67
 
 
68
 bool GLContextEGL::IsCurrent(GLSurface* surface) {
 
69
   DCHECK(context_);
 
70
 
 
71
+  eglBindAPI(EGL_OPENGL_ES_API);
 
72
+
 
73
   bool native_context_is_current = context_ == eglGetCurrentContext();
 
74
 
 
75
   // If our context is current then our notion of which GLContext is
 
76
   // current must be correct. On the other hand, third-party code
 
77
   // using OpenGL might change the current context.
 
78
   DCHECK(!native_context_is_current || (GetRealCurrent() == this));
 
79
 
 
80
   if (!native_context_is_current)