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

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

Issue 693313002: Dont set SwapInterval with Surfaceless. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing Changes Created 6 years, 1 month 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
« no previous file with comments | « ui/gl/gl_context_egl.h ('k') | ui/gl/gl_surface_egl.h » ('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 11 matching lines...) Expand all
22 22
23 using ui::GetLastEGLErrorString; 23 using ui::GetLastEGLErrorString;
24 24
25 namespace gfx { 25 namespace gfx {
26 26
27 GLContextEGL::GLContextEGL(GLShareGroup* share_group) 27 GLContextEGL::GLContextEGL(GLShareGroup* share_group)
28 : GLContextReal(share_group), 28 : GLContextReal(share_group),
29 context_(NULL), 29 context_(NULL),
30 display_(NULL), 30 display_(NULL),
31 config_(NULL), 31 config_(NULL),
32 unbind_fbo_on_makecurrent_(false) { 32 unbind_fbo_on_makecurrent_(false),
33 is_surfaceless_context_(false) {
33 } 34 }
34 35
35 bool GLContextEGL::Initialize( 36 bool GLContextEGL::Initialize(
36 GLSurface* compatible_surface, GpuPreference gpu_preference) { 37 GLSurface* compatible_surface, GpuPreference gpu_preference) {
37 DCHECK(compatible_surface); 38 DCHECK(compatible_surface);
38 DCHECK(!context_); 39 DCHECK(!context_);
39 40
40 static const EGLint kContextAttributes[] = { 41 static const EGLint kContextAttributes[] = {
41 EGL_CONTEXT_CLIENT_VERSION, 2, 42 EGL_CONTEXT_CLIENT_VERSION, 2,
42 EGL_NONE 43 EGL_NONE
(...skipping 24 matching lines...) Expand all
67 config_, 68 config_,
68 share_group() ? share_group()->GetHandle() : NULL, 69 share_group() ? share_group()->GetHandle() : NULL,
69 context_attributes); 70 context_attributes);
70 71
71 if (!context_) { 72 if (!context_) {
72 LOG(ERROR) << "eglCreateContext failed with error " 73 LOG(ERROR) << "eglCreateContext failed with error "
73 << GetLastEGLErrorString(); 74 << GetLastEGLErrorString();
74 return false; 75 return false;
75 } 76 }
76 77
78 is_surfaceless_context_ = compatible_surface->IsSurfaceless();
79
77 return true; 80 return true;
78 } 81 }
79 82
80 void GLContextEGL::Destroy() { 83 void GLContextEGL::Destroy() {
81 if (context_) { 84 if (context_) {
82 if (!eglDestroyContext(display_, context_)) { 85 if (!eglDestroyContext(display_, context_)) {
83 LOG(ERROR) << "eglDestroyContext failed with error " 86 LOG(ERROR) << "eglDestroyContext failed with error "
84 << GetLastEGLErrorString(); 87 << GetLastEGLErrorString();
85 } 88 }
86 89
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 SetCurrent(surface); 121 SetCurrent(surface);
119 if (!InitializeDynamicBindings()) { 122 if (!InitializeDynamicBindings()) {
120 return false; 123 return false;
121 } 124 }
122 125
123 if (!surface->OnMakeCurrent(this)) { 126 if (!surface->OnMakeCurrent(this)) {
124 LOG(ERROR) << "Could not make current."; 127 LOG(ERROR) << "Could not make current.";
125 return false; 128 return false;
126 } 129 }
127 130
131 is_surfaceless_context_ = surface->IsSurfaceless();
128 release_current.Cancel(); 132 release_current.Cancel();
129 return true; 133 return true;
130 } 134 }
131 135
132 void GLContextEGL::SetUnbindFboOnMakeCurrent() { 136 void GLContextEGL::SetUnbindFboOnMakeCurrent() {
133 unbind_fbo_on_makecurrent_ = true; 137 unbind_fbo_on_makecurrent_ = true;
134 } 138 }
135 139
136 void GLContextEGL::ReleaseCurrent(GLSurface* surface) { 140 void GLContextEGL::ReleaseCurrent(GLSurface* surface) {
137 if (!IsCurrent(surface)) 141 if (!IsCurrent(surface))
(...skipping 29 matching lines...) Expand all
167 171
168 return true; 172 return true;
169 } 173 }
170 174
171 void* GLContextEGL::GetHandle() { 175 void* GLContextEGL::GetHandle() {
172 return context_; 176 return context_;
173 } 177 }
174 178
175 void GLContextEGL::SetSwapInterval(int interval) { 179 void GLContextEGL::SetSwapInterval(int interval) {
176 DCHECK(IsCurrent(NULL)); 180 DCHECK(IsCurrent(NULL));
181
182 // This is a surfaceless context. eglSwapInterval doesn't take any effect in
183 // this case and will just return EGL_BAD_SURFACE.
184 if (is_surfaceless_context_)
piman 2014/11/03 19:43:13 Rather than stashing a bool, you can simply use GL
kalyank 2014/11/03 20:04:53 Didn't realize that, thanks. Will do that.
kalyank 2014/11/03 20:46:11 Done.
185 return;
186
177 if (!eglSwapInterval(display_, interval)) { 187 if (!eglSwapInterval(display_, interval)) {
178 LOG(ERROR) << "eglSwapInterval failed with error " 188 LOG(ERROR) << "eglSwapInterval failed with error "
179 << GetLastEGLErrorString(); 189 << GetLastEGLErrorString();
180 } 190 }
181 } 191 }
182 192
183 std::string GLContextEGL::GetExtensions() { 193 std::string GLContextEGL::GetExtensions() {
184 const char* extensions = eglQueryString(display_, 194 const char* extensions = eglQueryString(display_,
185 EGL_EXTENSIONS); 195 EGL_EXTENSIONS);
186 if (!extensions) 196 if (!extensions)
(...skipping 12 matching lines...) Expand all
199 209
200 #if !defined(OS_ANDROID) 210 #if !defined(OS_ANDROID)
201 bool GLContextEGL::GetTotalGpuMemory(size_t* bytes) { 211 bool GLContextEGL::GetTotalGpuMemory(size_t* bytes) {
202 DCHECK(bytes); 212 DCHECK(bytes);
203 *bytes = 0; 213 *bytes = 0;
204 return false; 214 return false;
205 } 215 }
206 #endif 216 #endif
207 217
208 } // namespace gfx 218 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context_egl.h ('k') | ui/gl/gl_surface_egl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698