| 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/command_buffer/client/gles2_lib.h" | 8 #include "gpu/command_buffer/client/gles2_lib.h" |
| 9 #include "gpu/gles2_conform_support/egl/display.h" | 9 #include "gpu/gles2_conform_support/egl/display.h" |
| 10 #include "ui/gl/gl_context.h" | 10 #include "ui/gl/gl_context.h" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 egl::Display* display = static_cast<egl::Display*>(dpy); | 79 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 80 if (!display->IsValidContext(context)) | 80 if (!display->IsValidContext(context)) |
| 81 return EGL_BAD_CONTEXT; | 81 return EGL_BAD_CONTEXT; |
| 82 | 82 |
| 83 return EGL_SUCCESS; | 83 return EGL_SUCCESS; |
| 84 } | 84 } |
| 85 } // namespace | 85 } // namespace |
| 86 | 86 |
| 87 extern "C" { | 87 extern "C" { |
| 88 EGLAPI EGLint EGLAPIENTRY eglGetError() { | 88 EGLint eglGetError() { |
| 89 // TODO(alokp): Fix me. | 89 // TODO(alokp): Fix me. |
| 90 return EGL_SUCCESS; | 90 return EGL_SUCCESS; |
| 91 } | 91 } |
| 92 | 92 |
| 93 EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id) { | 93 EGLDisplay eglGetDisplay(EGLNativeDisplayType display_id) { |
| 94 return new egl::Display(display_id); | 94 return new egl::Display(display_id); |
| 95 } | 95 } |
| 96 | 96 |
| 97 EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, | 97 EGLBoolean eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor) { |
| 98 EGLint* major, | |
| 99 EGLint* minor) { | |
| 100 if (dpy == EGL_NO_DISPLAY) | 98 if (dpy == EGL_NO_DISPLAY) |
| 101 return EglError(EGL_BAD_DISPLAY, EGL_FALSE); | 99 return EglError(EGL_BAD_DISPLAY, EGL_FALSE); |
| 102 | 100 |
| 103 egl::Display* display = static_cast<egl::Display*>(dpy); | 101 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 104 if (!display->Initialize()) | 102 if (!display->Initialize()) |
| 105 return EglError(EGL_NOT_INITIALIZED, EGL_FALSE); | 103 return EglError(EGL_NOT_INITIALIZED, EGL_FALSE); |
| 106 | 104 |
| 107 // eglInitialize can be called multiple times, prevent InitializeOneOff from | 105 int argc = 1; |
| 108 // being called multiple times. | 106 const char* const argv[] = { |
| 109 if (gfx::GetGLImplementation() == gfx::kGLImplementationNone) { | 107 "dummy" |
| 110 int argc = 1; | 108 }; |
| 111 const char* const argv[] = {"dummy"}; | 109 base::CommandLine::Init(argc, argv); |
| 112 base::CommandLine::Init(argc, argv); | 110 gfx::GLSurface::InitializeOneOff(); |
| 113 gfx::GLSurface::InitializeOneOff(); | |
| 114 } | |
| 115 | 111 |
| 116 *major = 1; | 112 *major = 1; |
| 117 *minor = 4; | 113 *minor = 4; |
| 118 return EglSuccess(EGL_TRUE); | 114 return EglSuccess(EGL_TRUE); |
| 119 } | 115 } |
| 120 | 116 |
| 121 EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy) { | 117 EGLBoolean eglTerminate(EGLDisplay dpy) { |
| 122 EGLint error_code = ValidateDisplay(dpy); | 118 EGLint error_code = ValidateDisplay(dpy); |
| 123 if (error_code != EGL_SUCCESS) | 119 if (error_code != EGL_SUCCESS) |
| 124 return EglError(error_code, EGL_FALSE); | 120 return EglError(error_code, EGL_FALSE); |
| 125 | 121 |
| 126 egl::Display* display = static_cast<egl::Display*>(dpy); | 122 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 127 delete display; | 123 delete display; |
| 128 | 124 |
| 129 return EglSuccess(EGL_TRUE); | 125 return EglSuccess(EGL_TRUE); |
| 130 } | 126 } |
| 131 | 127 |
| 132 EGLAPI const char* EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name) { | 128 const char* eglQueryString(EGLDisplay dpy, EGLint name) { |
| 133 EGLint error_code = ValidateDisplay(dpy); | 129 EGLint error_code = ValidateDisplay(dpy); |
| 134 if (error_code != EGL_SUCCESS) | 130 if (error_code != EGL_SUCCESS) |
| 135 return EglError(error_code, static_cast<const char*>(NULL)); | 131 return EglError(error_code, static_cast<const char*>(NULL)); |
| 136 | 132 |
| 137 switch (name) { | 133 switch (name) { |
| 138 case EGL_CLIENT_APIS: | 134 case EGL_CLIENT_APIS: |
| 139 return EglSuccess("OpenGL_ES"); | 135 return EglSuccess("OpenGL_ES"); |
| 140 case EGL_EXTENSIONS: | 136 case EGL_EXTENSIONS: |
| 141 return EglSuccess(""); | 137 return EglSuccess(""); |
| 142 case EGL_VENDOR: | 138 case EGL_VENDOR: |
| 143 return EglSuccess("Google Inc."); | 139 return EglSuccess("Google Inc."); |
| 144 case EGL_VERSION: | 140 case EGL_VERSION: |
| 145 return EglSuccess("1.4"); | 141 return EglSuccess("1.4"); |
| 146 default: | 142 default: |
| 147 return EglError(EGL_BAD_PARAMETER, static_cast<const char*>(NULL)); | 143 return EglError(EGL_BAD_PARAMETER, static_cast<const char*>(NULL)); |
| 148 } | 144 } |
| 149 } | 145 } |
| 150 | 146 |
| 151 EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, | 147 EGLBoolean eglChooseConfig(EGLDisplay dpy, |
| 152 const EGLint* attrib_list, | 148 const EGLint* attrib_list, |
| 153 EGLConfig* configs, | 149 EGLConfig* configs, |
| 154 EGLint config_size, | 150 EGLint config_size, |
| 155 EGLint* num_config) { | 151 EGLint* num_config) { |
| 156 EGLint error_code = ValidateDisplay(dpy); | 152 EGLint error_code = ValidateDisplay(dpy); |
| 157 if (error_code != EGL_SUCCESS) | 153 if (error_code != EGL_SUCCESS) |
| 158 return EglError(error_code, EGL_FALSE); | 154 return EglError(error_code, EGL_FALSE); |
| 159 | 155 |
| 160 if (num_config == NULL) | 156 if (num_config == NULL) |
| 161 return EglError(EGL_BAD_PARAMETER, EGL_FALSE); | 157 return EglError(EGL_BAD_PARAMETER, EGL_FALSE); |
| 162 | 158 |
| 163 egl::Display* display = static_cast<egl::Display*>(dpy); | 159 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 164 if (!display->ChooseConfigs(configs, config_size, num_config)) | 160 if (!display->ChooseConfigs(configs, config_size, num_config)) |
| 165 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); | 161 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); |
| 166 | 162 |
| 167 return EglSuccess(EGL_TRUE); | 163 return EglSuccess(EGL_TRUE); |
| 168 } | 164 } |
| 169 | 165 |
| 170 EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, | 166 EGLBoolean eglGetConfigs(EGLDisplay dpy, |
| 171 EGLConfig* configs, | 167 EGLConfig* configs, |
| 172 EGLint config_size, | 168 EGLint config_size, |
| 173 EGLint* num_config) { | 169 EGLint* num_config) { |
| 174 EGLint error_code = ValidateDisplay(dpy); | 170 EGLint error_code = ValidateDisplay(dpy); |
| 175 if (error_code != EGL_SUCCESS) | 171 if (error_code != EGL_SUCCESS) |
| 176 return EglError(error_code, EGL_FALSE); | 172 return EglError(error_code, EGL_FALSE); |
| 177 | 173 |
| 178 if (num_config == NULL) | 174 if (num_config == NULL) |
| 179 return EglError(EGL_BAD_PARAMETER, EGL_FALSE); | 175 return EglError(EGL_BAD_PARAMETER, EGL_FALSE); |
| 180 | 176 |
| 181 egl::Display* display = static_cast<egl::Display*>(dpy); | 177 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 182 if (!display->GetConfigs(configs, config_size, num_config)) | 178 if (!display->GetConfigs(configs, config_size, num_config)) |
| 183 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); | 179 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); |
| 184 | 180 |
| 185 return EglSuccess(EGL_TRUE); | 181 return EglSuccess(EGL_TRUE); |
| 186 } | 182 } |
| 187 | 183 |
| 188 EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, | 184 EGLBoolean eglGetConfigAttrib(EGLDisplay dpy, |
| 189 EGLConfig config, | 185 EGLConfig config, |
| 190 EGLint attribute, | 186 EGLint attribute, |
| 191 EGLint* value) { | 187 EGLint* value) { |
| 192 EGLint error_code = ValidateDisplayConfig(dpy, config); | 188 EGLint error_code = ValidateDisplayConfig(dpy, config); |
| 193 if (error_code != EGL_SUCCESS) | 189 if (error_code != EGL_SUCCESS) |
| 194 return EglError(error_code, EGL_FALSE); | 190 return EglError(error_code, EGL_FALSE); |
| 195 | 191 |
| 196 egl::Display* display = static_cast<egl::Display*>(dpy); | 192 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 197 if (!display->GetConfigAttrib(config, attribute, value)) | 193 if (!display->GetConfigAttrib(config, attribute, value)) |
| 198 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); | 194 return EglError(EGL_BAD_ATTRIBUTE, EGL_FALSE); |
| 199 | 195 |
| 200 return EglSuccess(EGL_TRUE); | 196 return EglSuccess(EGL_TRUE); |
| 201 } | 197 } |
| 202 | 198 |
| 203 EGLAPI EGLSurface EGLAPIENTRY | 199 EGLSurface eglCreateWindowSurface(EGLDisplay dpy, |
| 204 eglCreateWindowSurface(EGLDisplay dpy, | 200 EGLConfig config, |
| 205 EGLConfig config, | 201 EGLNativeWindowType win, |
| 206 EGLNativeWindowType win, | 202 const EGLint* attrib_list) { |
| 207 const EGLint* attrib_list) { | |
| 208 EGLint error_code = ValidateDisplayConfig(dpy, config); | 203 EGLint error_code = ValidateDisplayConfig(dpy, config); |
| 209 if (error_code != EGL_SUCCESS) | 204 if (error_code != EGL_SUCCESS) |
| 210 return EglError(error_code, EGL_NO_SURFACE); | 205 return EglError(error_code, EGL_NO_SURFACE); |
| 211 | 206 |
| 212 egl::Display* display = static_cast<egl::Display*>(dpy); | 207 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 213 if (!display->IsValidNativeWindow(win)) | 208 if (!display->IsValidNativeWindow(win)) |
| 214 return EglError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); | 209 return EglError(EGL_BAD_NATIVE_WINDOW, EGL_NO_SURFACE); |
| 215 | 210 |
| 216 EGLSurface surface = display->CreateWindowSurface(config, win, attrib_list); | 211 EGLSurface surface = display->CreateWindowSurface(config, win, attrib_list); |
| 217 if (surface == EGL_NO_SURFACE) | 212 if (surface == EGL_NO_SURFACE) |
| 218 return EglError(EGL_BAD_ALLOC, EGL_NO_SURFACE); | 213 return EglError(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
| 219 | 214 |
| 220 return EglSuccess(surface); | 215 return EglSuccess(surface); |
| 221 } | 216 } |
| 222 | 217 |
| 223 EGLAPI EGLSurface EGLAPIENTRY | 218 EGLSurface eglCreatePbufferSurface(EGLDisplay dpy, |
| 224 eglCreatePbufferSurface(EGLDisplay dpy, | 219 EGLConfig config, |
| 225 EGLConfig config, | 220 const EGLint* attrib_list) { |
| 226 const EGLint* attrib_list) { | |
| 227 EGLint error_code = ValidateDisplayConfig(dpy, config); | 221 EGLint error_code = ValidateDisplayConfig(dpy, config); |
| 228 if (error_code != EGL_SUCCESS) | 222 if (error_code != EGL_SUCCESS) |
| 229 return EglError(error_code, EGL_NO_SURFACE); | 223 return EglError(error_code, EGL_NO_SURFACE); |
| 230 | 224 |
| 231 egl::Display* display = static_cast<egl::Display*>(dpy); | 225 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 232 int width = 1; | 226 int width = 1; |
| 233 int height = 1; | 227 int height = 1; |
| 234 if (attrib_list) { | 228 if (attrib_list) { |
| 235 for (const int32_t* attr = attrib_list; attr[0] != EGL_NONE; attr += 2) { | 229 for (const int32_t* attr = attrib_list; attr[0] != EGL_NONE; attr += 2) { |
| 236 switch (attr[0]) { | 230 switch (attr[0]) { |
| 237 case EGL_WIDTH: | 231 case EGL_WIDTH: |
| 238 width = attr[1]; | 232 width = attr[1]; |
| 239 break; | 233 break; |
| 240 case EGL_HEIGHT: | 234 case EGL_HEIGHT: |
| 241 height = attr[1]; | 235 height = attr[1]; |
| 242 break; | 236 break; |
| 243 } | 237 } |
| 244 } | 238 } |
| 245 } | 239 } |
| 246 display->SetCreateOffscreen(width, height); | 240 display->SetCreateOffscreen(width, height); |
| 247 | 241 |
| 248 EGLSurface surface = display->CreateWindowSurface(config, 0, attrib_list); | 242 EGLSurface surface = display->CreateWindowSurface(config, 0, attrib_list); |
| 249 if (surface == EGL_NO_SURFACE) | 243 if (surface == EGL_NO_SURFACE) |
| 250 return EglError(EGL_BAD_ALLOC, EGL_NO_SURFACE); | 244 return EglError(EGL_BAD_ALLOC, EGL_NO_SURFACE); |
| 251 | 245 |
| 252 return EglSuccess(surface); | 246 return EglSuccess(surface); |
| 253 } | 247 } |
| 254 | 248 |
| 255 EGLAPI EGLSurface EGLAPIENTRY | 249 EGLSurface eglCreatePixmapSurface(EGLDisplay dpy, |
| 256 eglCreatePixmapSurface(EGLDisplay dpy, | 250 EGLConfig config, |
| 257 EGLConfig config, | 251 EGLNativePixmapType pixmap, |
| 258 EGLNativePixmapType pixmap, | 252 const EGLint* attrib_list) { |
| 259 const EGLint* attrib_list) { | |
| 260 return EGL_NO_SURFACE; | 253 return EGL_NO_SURFACE; |
| 261 } | 254 } |
| 262 | 255 |
| 263 EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, | 256 EGLBoolean eglDestroySurface(EGLDisplay dpy, |
| 264 EGLSurface surface) { | 257 EGLSurface surface) { |
| 265 EGLint error_code = ValidateDisplaySurface(dpy, surface); | 258 EGLint error_code = ValidateDisplaySurface(dpy, surface); |
| 266 if (error_code != EGL_SUCCESS) | 259 if (error_code != EGL_SUCCESS) |
| 267 return EglError(error_code, EGL_FALSE); | 260 return EglError(error_code, EGL_FALSE); |
| 268 | 261 |
| 269 egl::Display* display = static_cast<egl::Display*>(dpy); | 262 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 270 display->DestroySurface(surface); | 263 display->DestroySurface(surface); |
| 271 return EglSuccess(EGL_TRUE); | 264 return EglSuccess(EGL_TRUE); |
| 272 } | 265 } |
| 273 | 266 |
| 274 EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, | 267 EGLBoolean eglQuerySurface(EGLDisplay dpy, |
| 275 EGLSurface surface, | 268 EGLSurface surface, |
| 276 EGLint attribute, | 269 EGLint attribute, |
| 277 EGLint* value) { | 270 EGLint* value) { |
| 278 return EGL_FALSE; | 271 return EGL_FALSE; |
| 279 } | 272 } |
| 280 | 273 |
| 281 EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api) { | 274 EGLBoolean eglBindAPI(EGLenum api) { |
| 282 return EGL_FALSE; | 275 return EGL_FALSE; |
| 283 } | 276 } |
| 284 | 277 |
| 285 EGLAPI EGLenum EGLAPIENTRY eglQueryAPI() { | 278 EGLenum eglQueryAPI() { |
| 286 return EGL_OPENGL_ES_API; | 279 return EGL_OPENGL_ES_API; |
| 287 } | 280 } |
| 288 | 281 |
| 289 EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void) { | 282 EGLBoolean eglWaitClient(void) { |
| 290 return EGL_FALSE; | 283 return EGL_FALSE; |
| 291 } | 284 } |
| 292 | 285 |
| 293 EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void) { | 286 EGLBoolean eglReleaseThread(void) { |
| 294 return EGL_FALSE; | 287 return EGL_FALSE; |
| 295 } | 288 } |
| 296 | 289 |
| 297 EGLAPI EGLSurface EGLAPIENTRY | 290 EGLSurface eglCreatePbufferFromClientBuffer(EGLDisplay dpy, |
| 298 eglCreatePbufferFromClientBuffer(EGLDisplay dpy, | 291 EGLenum buftype, |
| 299 EGLenum buftype, | 292 EGLClientBuffer buffer, |
| 300 EGLClientBuffer buffer, | 293 EGLConfig config, |
| 301 EGLConfig config, | 294 const EGLint* attrib_list) { |
| 302 const EGLint* attrib_list) { | |
| 303 return EGL_NO_SURFACE; | 295 return EGL_NO_SURFACE; |
| 304 } | 296 } |
| 305 | 297 |
| 306 EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, | 298 EGLBoolean eglSurfaceAttrib(EGLDisplay dpy, |
| 307 EGLSurface surface, | 299 EGLSurface surface, |
| 308 EGLint attribute, | 300 EGLint attribute, |
| 309 EGLint value) { | 301 EGLint value) { |
| 310 return EGL_FALSE; | 302 return EGL_FALSE; |
| 311 } | 303 } |
| 312 | 304 |
| 313 EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, | 305 EGLBoolean eglBindTexImage(EGLDisplay dpy, |
| 314 EGLSurface surface, | 306 EGLSurface surface, |
| 315 EGLint buffer) { | 307 EGLint buffer) { |
| 316 return EGL_FALSE; | 308 return EGL_FALSE; |
| 317 } | 309 } |
| 318 | 310 |
| 319 EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, | 311 EGLBoolean eglReleaseTexImage(EGLDisplay dpy, |
| 320 EGLSurface surface, | 312 EGLSurface surface, |
| 321 EGLint buffer) { | 313 EGLint buffer) { |
| 322 return EGL_FALSE; | 314 return EGL_FALSE; |
| 323 } | 315 } |
| 324 | 316 |
| 325 EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval) { | 317 EGLBoolean eglSwapInterval(EGLDisplay dpy, EGLint interval) { |
| 326 return EGL_FALSE; | 318 return EGL_FALSE; |
| 327 } | 319 } |
| 328 | 320 |
| 329 EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, | 321 EGLContext eglCreateContext(EGLDisplay dpy, |
| 330 EGLConfig config, | 322 EGLConfig config, |
| 331 EGLContext share_context, | 323 EGLContext share_context, |
| 332 const EGLint* attrib_list) { | 324 const EGLint* attrib_list) { |
| 333 EGLint error_code = ValidateDisplayConfig(dpy, config); | 325 EGLint error_code = ValidateDisplayConfig(dpy, config); |
| 334 if (error_code != EGL_SUCCESS) | 326 if (error_code != EGL_SUCCESS) |
| 335 return EglError(error_code, EGL_NO_CONTEXT); | 327 return EglError(error_code, EGL_NO_CONTEXT); |
| 336 | 328 |
| 337 if (share_context != EGL_NO_CONTEXT) { | 329 if (share_context != EGL_NO_CONTEXT) { |
| 338 error_code = ValidateDisplayContext(dpy, share_context); | 330 error_code = ValidateDisplayContext(dpy, share_context); |
| 339 if (error_code != EGL_SUCCESS) | 331 if (error_code != EGL_SUCCESS) |
| 340 return EglError(error_code, EGL_NO_CONTEXT); | 332 return EglError(error_code, EGL_NO_CONTEXT); |
| 341 } | 333 } |
| 342 | 334 |
| 343 egl::Display* display = static_cast<egl::Display*>(dpy); | 335 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 344 EGLContext context = display->CreateContext( | 336 EGLContext context = display->CreateContext( |
| 345 config, share_context, attrib_list); | 337 config, share_context, attrib_list); |
| 346 if (context == EGL_NO_CONTEXT) | 338 if (context == EGL_NO_CONTEXT) |
| 347 return EglError(EGL_BAD_ALLOC, EGL_NO_CONTEXT); | 339 return EglError(EGL_BAD_ALLOC, EGL_NO_CONTEXT); |
| 348 | 340 |
| 349 return EglSuccess(context); | 341 return EglSuccess(context); |
| 350 } | 342 } |
| 351 | 343 |
| 352 EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, | 344 EGLBoolean eglDestroyContext(EGLDisplay dpy, EGLContext ctx) { |
| 353 EGLContext ctx) { | |
| 354 EGLint error_code = ValidateDisplayContext(dpy, ctx); | 345 EGLint error_code = ValidateDisplayContext(dpy, ctx); |
| 355 if (error_code != EGL_SUCCESS) | 346 if (error_code != EGL_SUCCESS) |
| 356 return EglError(error_code, EGL_FALSE); | 347 return EglError(error_code, EGL_FALSE); |
| 357 | 348 |
| 358 egl::Display* display = static_cast<egl::Display*>(dpy); | 349 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 359 display->DestroyContext(ctx); | 350 display->DestroyContext(ctx); |
| 360 return EGL_TRUE; | 351 return EGL_TRUE; |
| 361 } | 352 } |
| 362 | 353 |
| 363 EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, | 354 EGLBoolean eglMakeCurrent(EGLDisplay dpy, |
| 364 EGLSurface draw, | 355 EGLSurface draw, |
| 365 EGLSurface read, | 356 EGLSurface read, |
| 366 EGLContext ctx) { | 357 EGLContext ctx) { |
| 367 if (ctx != EGL_NO_CONTEXT) { | 358 if (ctx != EGL_NO_CONTEXT) { |
| 368 EGLint error_code = ValidateDisplaySurface(dpy, draw); | 359 EGLint error_code = ValidateDisplaySurface(dpy, draw); |
| 369 if (error_code != EGL_SUCCESS) | 360 if (error_code != EGL_SUCCESS) |
| 370 return EglError(error_code, EGL_FALSE); | 361 return EglError(error_code, EGL_FALSE); |
| 371 error_code = ValidateDisplaySurface(dpy, read); | 362 error_code = ValidateDisplaySurface(dpy, read); |
| 372 if (error_code != EGL_SUCCESS) | 363 if (error_code != EGL_SUCCESS) |
| 373 return EglError(error_code, EGL_FALSE); | 364 return EglError(error_code, EGL_FALSE); |
| 374 error_code = ValidateDisplayContext(dpy, ctx); | 365 error_code = ValidateDisplayContext(dpy, ctx); |
| 375 if (error_code != EGL_SUCCESS) | 366 if (error_code != EGL_SUCCESS) |
| 376 return EglError(error_code, EGL_FALSE); | 367 return EglError(error_code, EGL_FALSE); |
| 377 } | 368 } |
| 378 | 369 |
| 379 egl::Display* display = static_cast<egl::Display*>(dpy); | 370 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 380 if (!display->MakeCurrent(draw, read, ctx)) | 371 if (!display->MakeCurrent(draw, read, ctx)) |
| 381 return EglError(EGL_CONTEXT_LOST, EGL_FALSE); | 372 return EglError(EGL_CONTEXT_LOST, EGL_FALSE); |
| 382 | 373 |
| 383 #if REGAL_STATIC_EGL | 374 #if REGAL_STATIC_EGL |
| 384 RegalMakeCurrent(ctx); | 375 RegalMakeCurrent(ctx); |
| 385 #endif | 376 #endif |
| 386 | 377 |
| 387 return EGL_TRUE; | 378 return EGL_TRUE; |
| 388 } | 379 } |
| 389 | 380 |
| 390 EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext() { | 381 EGLContext eglGetCurrentContext() { |
| 391 return EGL_NO_CONTEXT; | 382 return EGL_NO_CONTEXT; |
| 392 } | 383 } |
| 393 | 384 |
| 394 EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) { | 385 EGLSurface eglGetCurrentSurface(EGLint readdraw) { |
| 395 return EGL_NO_SURFACE; | 386 return EGL_NO_SURFACE; |
| 396 } | 387 } |
| 397 | 388 |
| 398 EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay() { | 389 EGLDisplay eglGetCurrentDisplay() { |
| 399 return EGL_NO_DISPLAY; | 390 return EGL_NO_DISPLAY; |
| 400 } | 391 } |
| 401 | 392 |
| 402 EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, | 393 EGLBoolean eglQueryContext(EGLDisplay dpy, |
| 403 EGLContext ctx, | 394 EGLContext ctx, |
| 404 EGLint attribute, | 395 EGLint attribute, |
| 405 EGLint* value) { | 396 EGLint* value) { |
| 406 return EGL_FALSE; | 397 return EGL_FALSE; |
| 407 } | 398 } |
| 408 | 399 |
| 409 EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL() { | 400 EGLBoolean eglWaitGL() { |
| 410 return EGL_FALSE; | 401 return EGL_FALSE; |
| 411 } | 402 } |
| 412 | 403 |
| 413 EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) { | 404 EGLBoolean eglWaitNative(EGLint engine) { |
| 414 return EGL_FALSE; | 405 return EGL_FALSE; |
| 415 } | 406 } |
| 416 | 407 |
| 417 EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, | 408 EGLBoolean eglSwapBuffers(EGLDisplay dpy, EGLSurface surface) { |
| 418 EGLSurface surface) { | |
| 419 EGLint error_code = ValidateDisplaySurface(dpy, surface); | 409 EGLint error_code = ValidateDisplaySurface(dpy, surface); |
| 420 if (error_code != EGL_SUCCESS) | 410 if (error_code != EGL_SUCCESS) |
| 421 return EglError(error_code, EGL_FALSE); | 411 return EglError(error_code, EGL_FALSE); |
| 422 | 412 |
| 423 egl::Display* display = static_cast<egl::Display*>(dpy); | 413 egl::Display* display = static_cast<egl::Display*>(dpy); |
| 424 display->SwapBuffers(surface); | 414 display->SwapBuffers(surface); |
| 425 return EglSuccess(EGL_TRUE); | 415 return EglSuccess(EGL_TRUE); |
| 426 } | 416 } |
| 427 | 417 |
| 428 EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, | 418 EGLBoolean eglCopyBuffers(EGLDisplay dpy, |
| 429 EGLSurface surface, | 419 EGLSurface surface, |
| 430 EGLNativePixmapType target) { | 420 EGLNativePixmapType target) { |
| 431 return EGL_FALSE; | 421 return EGL_FALSE; |
| 432 } | 422 } |
| 433 | 423 |
| 434 /* Now, define eglGetProcAddress using the generic function ptr. type */ | 424 /* Now, define eglGetProcAddress using the generic function ptr. type */ |
| 435 EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY | 425 __eglMustCastToProperFunctionPointerType |
| 436 eglGetProcAddress(const char* procname) { | 426 eglGetProcAddress(const char* procname) { |
| 437 return reinterpret_cast<__eglMustCastToProperFunctionPointerType>( | 427 return reinterpret_cast<__eglMustCastToProperFunctionPointerType>( |
| 438 gles2::GetGLFunctionPointer(procname)); | 428 gles2::GetGLFunctionPointer(procname)); |
| 439 } | 429 } |
| 440 } // extern "C" | 430 } // extern "C" |
| OLD | NEW |