| OLD | NEW |
| 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 <EGL/egl.h> | 5 #include <EGL/egl.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "gpu/gles2_conform_support/egl/display.h" | 8 #include "gpu/gles2_conform_support/egl/display.h" |
| 9 #include "ui/gl/gl_context.h" | 9 #include "ui/gl/gl_context.h" |
| 10 #include "ui/gl/gl_surface.h" | 10 #include "ui/gl/gl_surface.h" |
| 11 | 11 |
| 12 #if REGAL_STATIC_EGL |
| 13 extern "C" { |
| 14 |
| 15 typedef EGLContext RegalSystemContext; |
| 16 #define REGAL_DECL |
| 17 REGAL_DECL void RegalMakeCurrent( RegalSystemContext ctx ); |
| 18 |
| 19 } // extern "C" |
| 20 #endif |
| 21 |
| 12 namespace { | 22 namespace { |
| 13 void SetCurrentError(EGLint error_code) { | 23 void SetCurrentError(EGLint error_code) { |
| 14 } | 24 } |
| 15 | 25 |
| 16 template<typename T> | 26 template<typename T> |
| 17 T EglError(EGLint error_code, T return_value) { | 27 T EglError(EGLint error_code, T return_value) { |
| 18 SetCurrentError(error_code); | 28 SetCurrentError(error_code); |
| 19 return return_value; | 29 return return_value; |
| 20 } | 30 } |
| 21 | 31 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 return EglSuccess(""); | 136 return EglSuccess(""); |
| 127 case EGL_VENDOR: | 137 case EGL_VENDOR: |
| 128 return EglSuccess("Google Inc."); | 138 return EglSuccess("Google Inc."); |
| 129 case EGL_VERSION: | 139 case EGL_VERSION: |
| 130 return EglSuccess("1.4"); | 140 return EglSuccess("1.4"); |
| 131 default: | 141 default: |
| 132 return EglError(EGL_BAD_PARAMETER, static_cast<const char*>(NULL)); | 142 return EglError(EGL_BAD_PARAMETER, static_cast<const char*>(NULL)); |
| 133 } | 143 } |
| 134 } | 144 } |
| 135 | 145 |
| 146 EGLBoolean eglChooseConfig(EGLDisplay dpy, |
| 147 const EGLint* attrib_list, |
| 148 EGLConfig* configs, |
| 149 EGLint config_size, |
| 150 EGLint* num_config) { |
| 151 EGLint error_code = ValidateDisplay(dpy); |
| 152 if (error_code != EGL_SUCCESS) |
| 153 return EglError(error_code, EGL_FALSE); |
| 154 |
| 155 if (num_config == NULL) |
| 156 return EglError(EGL_BAD_PARAMETER, EGL_FALSE); |
| 157 |
| 158 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 159 if (!display->ChooseConfigs(configs, config_size, num_config)) |
| 160 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); |
| 161 |
| 162 return EglSuccess(EGL_TRUE); |
| 163 } |
| 164 |
| 136 EGLBoolean eglGetConfigs(EGLDisplay dpy, | 165 EGLBoolean eglGetConfigs(EGLDisplay dpy, |
| 137 EGLConfig* configs, | 166 EGLConfig* configs, |
| 138 EGLint config_size, | 167 EGLint config_size, |
| 139 EGLint* num_config) { | 168 EGLint* num_config) { |
| 140 EGLint error_code = ValidateDisplay(dpy); | 169 EGLint error_code = ValidateDisplay(dpy); |
| 141 if (error_code != EGL_SUCCESS) | 170 if (error_code != EGL_SUCCESS) |
| 142 return EglError(error_code, EGL_FALSE); | 171 return EglError(error_code, EGL_FALSE); |
| 143 | 172 |
| 144 if (num_config == NULL) | 173 if (num_config == NULL) |
| 145 return EglError(EGL_BAD_PARAMETER, EGL_FALSE); | 174 return EglError(EGL_BAD_PARAMETER, EGL_FALSE); |
| 146 | 175 |
| 147 egl::Display* display = static_cast<egl::Display*>(dpy); | 176 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 148 if (!display->GetConfigs(configs, config_size, num_config)) | 177 if (!display->GetConfigs(configs, config_size, num_config)) |
| 149 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); | 178 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); |
| 150 | 179 |
| 151 return EglSuccess(EGL_TRUE); | 180 return EglSuccess(EGL_TRUE); |
| 152 } | 181 } |
| 153 | 182 |
| 154 EGLBoolean eglChooseConfig(EGLDisplay dpy, | |
| 155 const EGLint* attrib_list, | |
| 156 EGLConfig* configs, | |
| 157 EGLint config_size, | |
| 158 EGLint* num_config) { | |
| 159 return EGL_FALSE; | |
| 160 } | |
| 161 | |
| 162 EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, | 183 EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, |
| 163 EGLConfig config, | 184 EGLConfig config, |
| 164 EGLint attribute, | 185 EGLint attribute, |
| 165 EGLint* value) { | 186 EGLint* value) { |
| 166 EGLint error_code = ValidateDisplayConfig(dpy, config); | 187 EGLint error_code = ValidateDisplayConfig(dpy, config); |
| 167 if (error_code != EGL_SUCCESS) | 188 if (error_code != EGL_SUCCESS) |
| 168 return EglError(error_code, EGL_FALSE); | 189 return EglError(error_code, EGL_FALSE); |
| 169 | 190 |
| 170 egl::Display* display = static_cast<egl::Display*>(dpy); | 191 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 171 if (!display->GetConfigAttrib(config, attribute, value)) | 192 if (!display->GetConfigAttrib(config, attribute, value)) |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 if (error_code != EGL_SUCCESS) | 337 if (error_code != EGL_SUCCESS) |
| 317 return EglError(error_code, EGL_FALSE); | 338 return EglError(error_code, EGL_FALSE); |
| 318 error_code = ValidateDisplayContext(dpy, ctx); | 339 error_code = ValidateDisplayContext(dpy, ctx); |
| 319 if (error_code != EGL_SUCCESS) | 340 if (error_code != EGL_SUCCESS) |
| 320 return EglError(error_code, EGL_FALSE); | 341 return EglError(error_code, EGL_FALSE); |
| 321 } | 342 } |
| 322 | 343 |
| 323 egl::Display* display = static_cast<egl::Display*>(dpy); | 344 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 324 if (!display->MakeCurrent(draw, read, ctx)) | 345 if (!display->MakeCurrent(draw, read, ctx)) |
| 325 return EglError(EGL_CONTEXT_LOST, EGL_FALSE); | 346 return EglError(EGL_CONTEXT_LOST, EGL_FALSE); |
| 347 |
| 348 #if REGAL_STATIC_EGL |
| 349 RegalMakeCurrent(ctx); |
| 350 #endif |
| 351 |
| 326 return EGL_TRUE; | 352 return EGL_TRUE; |
| 327 } | 353 } |
| 328 | 354 |
| 329 EGLContext eglGetCurrentContext() { | 355 EGLContext eglGetCurrentContext() { |
| 330 return EGL_NO_CONTEXT; | 356 return EGL_NO_CONTEXT; |
| 331 } | 357 } |
| 332 | 358 |
| 333 EGLSurface eglGetCurrentSurface(EGLint readdraw) { | 359 EGLSurface eglGetCurrentSurface(EGLint readdraw) { |
| 334 return EGL_NO_SURFACE; | 360 return EGL_NO_SURFACE; |
| 335 } | 361 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 EGLNativePixmapType target) { | 394 EGLNativePixmapType target) { |
| 369 return EGL_FALSE; | 395 return EGL_FALSE; |
| 370 } | 396 } |
| 371 | 397 |
| 372 /* Now, define eglGetProcAddress using the generic function ptr. type */ | 398 /* Now, define eglGetProcAddress using the generic function ptr. type */ |
| 373 __eglMustCastToProperFunctionPointerType | 399 __eglMustCastToProperFunctionPointerType |
| 374 eglGetProcAddress(const char* procname) { | 400 eglGetProcAddress(const char* procname) { |
| 375 return NULL; | 401 return NULL; |
| 376 } | 402 } |
| 377 } // extern "C" | 403 } // extern "C" |
| OLD | NEW |