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

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

Issue 13886018: Add a factory and defines for native Linux surfaces. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: vsync provider, better transport_dib, etc. Created 7 years, 7 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
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_surface_egl.h" 5 #include "ui/gl/gl_surface_egl.h"
6 6
7 #if defined(OS_ANDROID) 7 #if defined(OS_ANDROID)
8 #include <android/native_window_jni.h> 8 #include <android/native_window_jni.h>
9 #endif 9 #endif
10 10
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
140 140
141 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS); 141 g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS);
142 g_egl_create_context_robustness_supported = 142 g_egl_create_context_robustness_supported =
143 HasEGLExtension("EGL_EXT_create_context_robustness"); 143 HasEGLExtension("EGL_EXT_create_context_robustness");
144 g_egl_sync_control_supported = 144 g_egl_sync_control_supported =
145 HasEGLExtension("EGL_CHROMIUM_sync_control"); 145 HasEGLExtension("EGL_CHROMIUM_sync_control");
146 146
147 initialized = true; 147 initialized = true;
148 148
149 #if defined(USE_X11) || defined(OS_ANDROID) 149 #if defined(USE_X11) || defined(OS_ANDROID) \
150 || defined(USE_OZONE)
150 return true; 151 return true;
151 #else 152 #else
152 g_software_native_display = EGL_SOFTWARE_DISPLAY_ANGLE; 153 g_software_native_display = EGL_SOFTWARE_DISPLAY_ANGLE;
153 #endif 154 #endif
154 g_software_display = eglGetDisplay(g_software_native_display); 155 g_software_display = eglGetDisplay(g_software_native_display);
155 if (!g_software_display) { 156 if (!g_software_display) {
156 return true; 157 return true;
157 } 158 }
158 159
159 if (!eglInitialize(g_software_display, NULL, NULL)) { 160 if (!eglInitialize(g_software_display, NULL, NULL)) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 } 208 }
208 209
209 bool GLSurfaceEGL::HasEGLExtension(const char* name) { 210 bool GLSurfaceEGL::HasEGLExtension(const char* name) {
210 return ExtensionsContain(GetEGLExtensions(), name); 211 return ExtensionsContain(GetEGLExtensions(), name);
211 } 212 }
212 213
213 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() { 214 bool GLSurfaceEGL::IsCreateContextRobustnessSupported() {
214 return g_egl_create_context_robustness_supported; 215 return g_egl_create_context_robustness_supported;
215 } 216 }
216 217
218 bool GLSurfaceEGL::IsSyncControlSupported() {
219 return g_egl_sync_control_supported;
220 }
221
217 GLSurfaceEGL::~GLSurfaceEGL() {} 222 GLSurfaceEGL::~GLSurfaceEGL() {}
218 223
219 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software, 224 NativeViewGLSurfaceEGL::NativeViewGLSurfaceEGL(bool software,
220 gfx::AcceleratedWidget window) 225 gfx::AcceleratedWidget window)
221 : window_(window), 226 : window_(window),
222 surface_(NULL), 227 surface_(NULL),
223 supports_post_sub_buffer_(false), 228 supports_post_sub_buffer_(false),
224 config_(NULL) { 229 config_(NULL) {
225 software_ = software; 230 software_ = software;
226 #if defined(OS_ANDROID) 231 #if defined(OS_ANDROID)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 270
266 EGLint surfaceVal; 271 EGLint surfaceVal;
267 EGLBoolean retVal = eglQuerySurface(GetDisplay(), 272 EGLBoolean retVal = eglQuerySurface(GetDisplay(),
268 surface_, 273 surface_,
269 EGL_POST_SUB_BUFFER_SUPPORTED_NV, 274 EGL_POST_SUB_BUFFER_SUPPORTED_NV,
270 &surfaceVal); 275 &surfaceVal);
271 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE; 276 supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE;
272 277
273 if (g_egl_sync_control_supported) 278 if (g_egl_sync_control_supported)
274 vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_)); 279 vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_));
280 return true;
281 }
275 282
276 return true; 283 bool NativeViewGLSurfaceEGL::Initialize(VSyncProvider* syncProvider) {
284 bool retval = Initialize();
285 if (retval)
286 vsync_provider_.reset(syncProvider);
287 return retval;
277 } 288 }
278 289
279 void NativeViewGLSurfaceEGL::Destroy() { 290 void NativeViewGLSurfaceEGL::Destroy() {
280 if (surface_) { 291 if (surface_) {
281 if (!eglDestroySurface(GetDisplay(), surface_)) { 292 if (!eglDestroySurface(GetDisplay(), surface_)) {
282 LOG(ERROR) << "eglDestroySurface failed with error " 293 LOG(ERROR) << "eglDestroySurface failed with error "
283 << GetLastEGLErrorString(); 294 << GetLastEGLErrorString();
284 } 295 }
285 surface_ = NULL; 296 surface_ = NULL;
286 } 297 }
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 590
580 return handle; 591 return handle;
581 #endif 592 #endif
582 } 593 }
583 594
584 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() { 595 PbufferGLSurfaceEGL::~PbufferGLSurfaceEGL() {
585 Destroy(); 596 Destroy();
586 } 597 }
587 598
588 } // namespace gfx 599 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698