OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "third_party/mesa/MesaLib/src/egl/main/egldriver.h" |
| 6 |
| 7 #include "third_party/mesa/MesaLib/src/egl/main/eglconfig.h" |
| 8 #include "third_party/mesa/MesaLib/src/egl/main/eglcontext.h" |
| 9 #include "third_party/mesa/MesaLib/src/egl/main/egldisplay.h" |
| 10 #include "third_party/mesa/MesaLib/src/egl/main/eglmisc.h" |
| 11 #include "third_party/mesa/MesaLib/src/egl/main/eglsurface.h" |
| 12 |
| 13 /** |
| 14 * Functions for choosing and opening/loading device drivers. |
| 15 */ |
| 16 |
| 17 static _EGLDriver *_eglDriver; |
| 18 |
| 19 static EGLBoolean _eglLoadDriver() { |
| 20 assert(!_eglDriver); |
| 21 |
| 22 _eglDriver = _eglMain(NULL); |
| 23 return _eglDriver ? EGL_TRUE : EGL_FALSE; |
| 24 } |
| 25 |
| 26 /** |
| 27 * Match a display to a driver. The display is initialized unless use_probe is |
| 28 * true. |
| 29 */ |
| 30 |
| 31 _EGLDriver * _eglMatchDriver(_EGLDisplay *dpy, EGLBoolean use_probe) { |
| 32 _EGLDriver * drv = NULL; |
| 33 EGLint major = 0, minor = 0; |
| 34 |
| 35 if (!_eglDriver && !_eglLoadDriver()) |
| 36 return NULL; |
| 37 |
| 38 if (use_probe) { |
| 39 if (_eglDriver->Probe) |
| 40 _eglDriver->Probe(_eglDriver, dpy); |
| 41 drv = _eglDriver; |
| 42 } else { |
| 43 if (_eglDriver->API.Initialize(_eglDriver, dpy, &major, &minor)) { |
| 44 drv = _eglDriver; |
| 45 dpy->Driver = drv; |
| 46 dpy->Initialized = EGL_TRUE; |
| 47 dpy->APImajor = major; |
| 48 dpy->APIminor = minor; |
| 49 } |
| 50 } |
| 51 |
| 52 return drv; |
| 53 } |
| 54 |
| 55 __eglMustCastToProperFunctionPointerType _eglGetDriverProc( |
| 56 const char *procname) { |
| 57 _EGLProc proc = NULL; |
| 58 |
| 59 return proc; |
| 60 } |
| 61 |
| 62 /** |
| 63 * Unload all drivers. |
| 64 */ |
| 65 void _eglUnloadDrivers(void) { |
| 66 if (_eglDriver && _eglDriver->Unload) |
| 67 _eglDriver->Unload(_eglDriver); |
| 68 |
| 69 _eglDriver = NULL; |
| 70 } |
| 71 |
| 72 /** |
| 73 * Plug all the available fallback routines into the given driver's |
| 74 * dispatch table. |
| 75 */ |
| 76 void _eglInitDriverFallbacks(_EGLDriver *drv) { |
| 77 /* If a pointer is set to NULL, then the device driver _really_ has |
| 78 * to implement it. |
| 79 */ |
| 80 drv->API.Initialize = NULL; |
| 81 drv->API.Terminate = NULL; |
| 82 |
| 83 drv->API.GetConfigs = _eglGetConfigs; |
| 84 drv->API.ChooseConfig = _eglChooseConfig; |
| 85 drv->API.GetConfigAttrib = _eglGetConfigAttrib; |
| 86 |
| 87 drv->API.CreateContext = _eglCreateContext; |
| 88 drv->API.DestroyContext = _eglDestroyContext; |
| 89 drv->API.MakeCurrent = _eglMakeCurrent; |
| 90 drv->API.QueryContext = _eglQueryContext; |
| 91 |
| 92 drv->API.CreateWindowSurface = _eglCreateWindowSurface; |
| 93 drv->API.CreatePixmapSurface = _eglCreatePixmapSurface; |
| 94 drv->API.CreatePbufferSurface = _eglCreatePbufferSurface; |
| 95 drv->API.DestroySurface = _eglDestroySurface; |
| 96 drv->API.QuerySurface = _eglQuerySurface; |
| 97 drv->API.SurfaceAttrib = _eglSurfaceAttrib; |
| 98 drv->API.BindTexImage = _eglBindTexImage; |
| 99 drv->API.ReleaseTexImage = _eglReleaseTexImage; |
| 100 drv->API.SwapInterval = _eglSwapInterval; |
| 101 drv->API.SwapBuffers = _eglSwapBuffers; |
| 102 drv->API.CopyBuffers = _eglCopyBuffers; |
| 103 |
| 104 drv->API.QueryString = _eglQueryString; |
| 105 drv->API.WaitClient = _eglWaitClient; |
| 106 drv->API.WaitNative = _eglWaitNative; |
| 107 } |
| 108 |
OLD | NEW |