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

Side by Side Diff: ui/gl/gl_context_egl.cc

Issue 221433004: gpu: Bind dummy GL API when no context is current (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix two gpu unittests Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/gl/gl_context_cgl.cc ('k') | ui/gl/gl_context_glx.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gl/gl_context_egl.h" 5 #include "ui/gl/gl_context_egl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 86
87 context_ = NULL; 87 context_ = NULL;
88 } 88 }
89 } 89 }
90 90
91 bool GLContextEGL::MakeCurrent(GLSurface* surface) { 91 bool GLContextEGL::MakeCurrent(GLSurface* surface) {
92 DCHECK(context_); 92 DCHECK(context_);
93 if (IsCurrent(surface)) 93 if (IsCurrent(surface))
94 return true; 94 return true;
95 95
96 ScopedReleaseCurrent release_current;
96 TRACE_EVENT2("gpu", "GLContextEGL::MakeCurrent", 97 TRACE_EVENT2("gpu", "GLContextEGL::MakeCurrent",
97 "context", context_, 98 "context", context_,
98 "surface", surface); 99 "surface", surface);
99 100
100 if (unbind_fbo_on_makecurrent_ && 101 if (unbind_fbo_on_makecurrent_ &&
101 eglGetCurrentContext() != EGL_NO_CONTEXT) { 102 eglGetCurrentContext() != EGL_NO_CONTEXT) {
102 glBindFramebufferEXT(GL_FRAMEBUFFER, 0); 103 glBindFramebufferEXT(GL_FRAMEBUFFER, 0);
103 } 104 }
104 105
105 if (!eglMakeCurrent(display_, 106 if (!eglMakeCurrent(display_,
106 surface->GetHandle(), 107 surface->GetHandle(),
107 surface->GetHandle(), 108 surface->GetHandle(),
108 context_)) { 109 context_)) {
109 DVLOG(1) << "eglMakeCurrent failed with error " 110 DVLOG(1) << "eglMakeCurrent failed with error "
110 << GetLastEGLErrorString(); 111 << GetLastEGLErrorString();
111 return false; 112 return false;
112 } 113 }
113 114
114 // Set this as soon as the context is current, since we might call into GL. 115 // Set this as soon as the context is current, since we might call into GL.
115 SetRealGLApi(); 116 SetRealGLApi();
116 117
117 SetCurrent(surface); 118 SetCurrent(surface);
118 if (!InitializeDynamicBindings()) { 119 if (!InitializeDynamicBindings()) {
119 ReleaseCurrent(surface);
120 return false; 120 return false;
121 } 121 }
122 122
123 if (!surface->OnMakeCurrent(this)) { 123 if (!surface->OnMakeCurrent(this)) {
124 LOG(ERROR) << "Could not make current."; 124 LOG(ERROR) << "Could not make current.";
125 return false; 125 return false;
126 } 126 }
127 127
128 release_current.Cancel();
128 return true; 129 return true;
129 } 130 }
130 131
131 void GLContextEGL::SetUnbindFboOnMakeCurrent() { 132 void GLContextEGL::SetUnbindFboOnMakeCurrent() {
132 unbind_fbo_on_makecurrent_ = true; 133 unbind_fbo_on_makecurrent_ = true;
133 } 134 }
134 135
135 void GLContextEGL::ReleaseCurrent(GLSurface* surface) { 136 void GLContextEGL::ReleaseCurrent(GLSurface* surface) {
136 if (!IsCurrent(surface)) 137 if (!IsCurrent(surface))
137 return; 138 return;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 199
199 #if !defined(OS_ANDROID) 200 #if !defined(OS_ANDROID)
200 bool GLContextEGL::GetTotalGpuMemory(size_t* bytes) { 201 bool GLContextEGL::GetTotalGpuMemory(size_t* bytes) {
201 DCHECK(bytes); 202 DCHECK(bytes);
202 *bytes = 0; 203 *bytes = 0;
203 return false; 204 return false;
204 } 205 }
205 #endif 206 #endif
206 207
207 } // namespace gfx 208 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context_cgl.cc ('k') | ui/gl/gl_context_glx.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698