1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 #include "egl_wrapper_entry.h"
16
17 #include <map>
18 #include <string>
19
20 #include <EGL/egl.h>
21 #include <EGL/eglext.h>
22
23 #include "egl_defs.h"
24 #include "egl_wrapper_context.h"
25 #include "egl_wrapper_display.h"
26 #include "egl_wrapper_loader.h"
27 #include "../thread_private_data_ctl.h"
28 #include "../wrapper_log.h"
29
30 using namespace OHOS;
31 namespace OHOS {
ValidateDisplay(EGLDisplay dpy)32 static EglWrapperDisplay *ValidateDisplay(EGLDisplay dpy)
33 {
34 EglWrapperDisplay *display = EglWrapperDisplay::GetWrapperDisplay(dpy);
35 if (!display) {
36 WLOGE("EGLDislay is invalid.");
37 ThreadPrivateDataCtl::SetError(EGL_BAD_DISPLAY);
38 return nullptr;
39 }
40
41 if (!display->IsReady()) {
42 WLOGE("display is not ready.");
43 ThreadPrivateDataCtl::SetError(EGL_NOT_INITIALIZED);
44 return nullptr;
45 }
46 return display;
47 }
48
EglChooseConfigImpl(EGLDisplay dpy,const EGLint * attribList,EGLConfig * configs,EGLint configSize,EGLint * numConfig)49 EGLBoolean EglChooseConfigImpl(EGLDisplay dpy, const EGLint *attribList,
50 EGLConfig *configs, EGLint configSize, EGLint *numConfig)
51 {
52 WLOGD("");
53 EglWrapperDisplay *display = ValidateDisplay(dpy);
54 if (!display) {
55 return EGL_FALSE;
56 }
57
58 if (numConfig == nullptr) {
59 WLOGE("EGLint *numConfig is nullptr.");
60 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
61 return EGL_FALSE;
62 }
63
64 EGLBoolean ret = EGL_FALSE;
65 *numConfig = 0;
66
67 EglWrapperDispatchTablePtr table = &gWrapperHook;
68 if (table->isLoad && table->egl.eglChooseConfig) {
69 ret = table->egl.eglChooseConfig(display->GetEglDisplay(),
70 attribList, configs, configSize, numConfig);
71 } else {
72 WLOGE("eglChooseConfig is invalid.");
73 }
74
75 return ret;
76 }
77
EglCopyBuffersImpl(EGLDisplay dpy,EGLSurface surf,NativePixmapType target)78 EGLBoolean EglCopyBuffersImpl(EGLDisplay dpy, EGLSurface surf, NativePixmapType target)
79 {
80 WLOGD("");
81 EglWrapperDisplay *display = ValidateDisplay(dpy);
82 if (!display) {
83 return EGL_FALSE;
84 }
85
86 return display->CopyBuffers(surf, target);
87 }
88
EglCreateContextImpl(EGLDisplay dpy,EGLConfig config,EGLContext shareList,const EGLint * attribList)89 EGLContext EglCreateContextImpl(EGLDisplay dpy, EGLConfig config,
90 EGLContext shareList, const EGLint *attribList)
91 {
92 WLOGD("");
93 EglWrapperDisplay *display = ValidateDisplay(dpy);
94 if (!display) {
95 return EGL_NO_CONTEXT;
96 }
97
98 return display->CreateEglContext(config, shareList, attribList);
99 }
100
EglCreatePbufferSurfaceImpl(EGLDisplay dpy,EGLConfig config,const EGLint * attribList)101 EGLSurface EglCreatePbufferSurfaceImpl(EGLDisplay dpy, EGLConfig config,
102 const EGLint* attribList)
103 {
104 WLOGD("");
105 EglWrapperDisplay *display = ValidateDisplay(dpy);
106 if (!display) {
107 return EGL_NO_CONTEXT;
108 }
109
110 return display->CreatePbufferSurface(config, attribList);
111 }
112
EglCreatePixmapSurfaceImpl(EGLDisplay dpy,EGLConfig config,EGLNativePixmapType pixmap,const EGLint * attribList)113 EGLSurface EglCreatePixmapSurfaceImpl(EGLDisplay dpy, EGLConfig config,
114 EGLNativePixmapType pixmap, const EGLint* attribList)
115 {
116 WLOGD("");
117 EglWrapperDisplay *display = ValidateDisplay(dpy);
118 if (!display) {
119 return EGL_NO_CONTEXT;
120 }
121
122 return display->CreatePixmapSurface(config, pixmap, attribList);
123 }
124
EglCreateWindowSurfaceImpl(EGLDisplay dpy,EGLConfig config,NativeWindowType window,const EGLint * attribList)125 EGLSurface EglCreateWindowSurfaceImpl(EGLDisplay dpy,
126 EGLConfig config, NativeWindowType window, const EGLint* attribList)
127 {
128 WLOGD("");
129 EglWrapperDisplay *display = ValidateDisplay(dpy);
130 if (!display) {
131 return EGL_NO_SURFACE;
132 }
133
134 return display->CreateEglSurface(config, window, attribList);
135 }
136
EglDestroyContextImpl(EGLDisplay dpy,EGLContext ctx)137 EGLBoolean EglDestroyContextImpl(EGLDisplay dpy, EGLContext ctx)
138 {
139 WLOGD("");
140 EglWrapperDisplay *display = ValidateDisplay(dpy);
141 if (!display) {
142 return EGL_FALSE;
143 }
144
145 return display->DestroyEglContext(ctx);
146 }
147
EglDestroySurfaceImpl(EGLDisplay dpy,EGLSurface surf)148 EGLBoolean EglDestroySurfaceImpl(EGLDisplay dpy, EGLSurface surf)
149 {
150 WLOGD("");
151 EglWrapperDisplay *display = ValidateDisplay(dpy);
152 if (!display) {
153 return EGL_FALSE;
154 }
155
156 return display->DestroyEglSurface(surf);
157 }
158
EglGetConfigAttribImpl(EGLDisplay dpy,EGLConfig config,EGLint attribute,EGLint * value)159 EGLBoolean EglGetConfigAttribImpl(EGLDisplay dpy, EGLConfig config,
160 EGLint attribute, EGLint *value)
161 {
162 WLOGD("");
163 EglWrapperDisplay *display = ValidateDisplay(dpy);
164 if (!display) {
165 return EGL_FALSE;
166 }
167
168 EGLBoolean ret = EGL_FALSE;
169 EglWrapperDispatchTablePtr table = &gWrapperHook;
170 if (table->isLoad && table->egl.eglGetConfigAttrib) {
171 ret = table->egl.eglGetConfigAttrib(display->GetEglDisplay(), config, attribute, value);
172 } else {
173 WLOGE("eglGetConfigAttrib is not found.");
174 }
175 return ret;
176 }
177
EglGetConfigsImpl(EGLDisplay dpy,EGLConfig * configs,EGLint configSize,EGLint * numConfig)178 EGLBoolean EglGetConfigsImpl(EGLDisplay dpy, EGLConfig *configs,
179 EGLint configSize, EGLint *numConfig)
180 {
181 WLOGD("");
182 EglWrapperDisplay *display = ValidateDisplay(dpy);
183 if (!display) {
184 return EGL_FALSE;
185 }
186
187 if (numConfig == nullptr) {
188 WLOGE("EGLint *numConfig is nullptr.");
189 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
190 }
191
192 EGLBoolean ret = EGL_FALSE;
193 EglWrapperDispatchTablePtr table = &gWrapperHook;
194 if (table->isLoad && table->egl.eglGetConfigs) {
195 ret = table->egl.eglGetConfigs(display->GetEglDisplay(), configs, configSize, numConfig);
196 } else {
197 WLOGE("eglGetConfigs is not found.");
198 }
199
200 return ret;
201 }
202
EglGetCurrentDisplayImpl(void)203 EGLDisplay EglGetCurrentDisplayImpl(void)
204 {
205 EGLContext ctx = ThreadPrivateDataCtl::GetContext();
206 if (ctx) {
207 EglWrapperContext *ctxPtr = EglWrapperContext::GetWrapperContext(ctx);
208 if (ctxPtr == nullptr) {
209 WLOGE("current is bad context.");
210 ThreadPrivateDataCtl::SetError(EGL_BAD_CONTEXT);
211 return EGL_NO_DISPLAY;
212 }
213 return ctxPtr->GetDisplay();
214 }
215 return EGL_NO_DISPLAY;
216 }
217
EglGetCurrentSurfaceImpl(EGLint type)218 EGLSurface EglGetCurrentSurfaceImpl(EGLint type)
219 {
220 EGLContext ctx = ThreadPrivateDataCtl::GetContext();
221 if (ctx) {
222 EglWrapperContext *ctxPtr = EglWrapperContext::GetWrapperContext(ctx);
223 if (ctxPtr == nullptr) {
224 WLOGE("current is bad context.");
225 ThreadPrivateDataCtl::SetError(EGL_BAD_CONTEXT);
226 return EGL_NO_SURFACE;
227 }
228 return ctxPtr->GetCurrentSurface(type);
229 }
230 return EGL_NO_SURFACE;
231 }
232
EglGetPlatformDisplayInternal(EGLenum platform,EGLNativeDisplayType type,const EGLAttrib * attribList)233 static EGLDisplay EglGetPlatformDisplayInternal(EGLenum platform,
234 EGLNativeDisplayType type, const EGLAttrib *attribList)
235 {
236 WLOGD("");
237 if (type != EGL_DEFAULT_DISPLAY) {
238 WLOGE("EGLNativeDisplayType is invalid.");
239 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
240 return EGL_NO_DISPLAY;
241 }
242
243 if (platform != EGL_PLATFORM_OHOS_KHR) {
244 WLOGE("EGLenum platform is not EGL_PLATFORM_OHOS_KHR.");
245 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
246 return EGL_NO_DISPLAY;
247 }
248
249 return EglWrapperDisplay::GetEglDisplay(platform, type, attribList);
250 }
251
EglGetDisplayImpl(EGLNativeDisplayType type)252 EGLDisplay EglGetDisplayImpl(EGLNativeDisplayType type)
253 {
254 WLOGD("");
255 return EglGetPlatformDisplayInternal(EGL_PLATFORM_OHOS_KHR, type, nullptr);
256 }
257
EglGetErrorImpl(void)258 EGLint EglGetErrorImpl(void)
259 {
260 WLOGD("");
261 EGLint ret = EGL_SUCCESS;
262 EglWrapperDispatchTablePtr table = &gWrapperHook;
263 if (table->isLoad && table->egl.eglGetError) {
264 ret = table->egl.eglGetError();
265 } else {
266 WLOGE("eglGetError is not found.");
267 }
268
269 if (ret == EGL_SUCCESS) {
270 ret = ThreadPrivateDataCtl::GetError();
271 }
272
273 return ret;
274 }
275
EglGetProcAddressImpl(const char * procname)276 __eglMustCastToProperFunctionPointerType EglGetProcAddressImpl(const char *procname)
277 {
278 WLOGD("");
279 if (gExtensionMap.find(procname) != gExtensionMap.end()) {
280 return gExtensionMap.at(procname);
281 }
282
283 EglWrapperLoader& loader(EglWrapperLoader::GetInstance());
284 void *func = loader.GetProcAddrFromDriver(procname);
285
286 if (!func) {
287 EglWrapperDispatchTablePtr table = &gWrapperHook;
288 if (table->isLoad && table->egl.eglGetProcAddress) {
289 func = reinterpret_cast<void *>(table->egl.eglGetProcAddress(procname));
290 }
291 }
292
293 if (func) {
294 return __eglMustCastToProperFunctionPointerType(func);
295 }
296
297 WLOGW("FindEglExtApi did not find an entry for %{public}s", procname);
298 return nullptr;
299 }
300
EglInitializeImpl(EGLDisplay dpy,EGLint * major,EGLint * minor)301 EGLBoolean EglInitializeImpl(EGLDisplay dpy, EGLint *major, EGLint *minor)
302 {
303 WLOGD("");
304 EglWrapperDisplay *display = EglWrapperDisplay::GetWrapperDisplay(dpy);
305 if (!display) {
306 WLOGE("EGLDislay is invalid.");
307 ThreadPrivateDataCtl::SetError(EGL_BAD_DISPLAY);
308 return EGL_FALSE;
309 }
310
311 return display->Init(major, minor);
312 }
313
EglMakeCurrentImpl(EGLDisplay dpy,EGLSurface draw,EGLSurface read,EGLContext ctx)314 EGLBoolean EglMakeCurrentImpl(EGLDisplay dpy, EGLSurface draw,
315 EGLSurface read, EGLContext ctx)
316 {
317 WLOGD("");
318 EglWrapperDisplay *display = ValidateDisplay(dpy);
319 if (!display) {
320 return EGL_FALSE;
321 }
322
323 return display->MakeCurrent(draw, read, ctx);
324 }
325
EglQueryContextImpl(EGLDisplay dpy,EGLContext ctx,EGLint attribute,EGLint * value)326 EGLBoolean EglQueryContextImpl(EGLDisplay dpy, EGLContext ctx,
327 EGLint attribute, EGLint *value)
328 {
329 WLOGD("");
330 EglWrapperDisplay *display = ValidateDisplay(dpy);
331 if (!display) {
332 return EGL_FALSE;
333 }
334
335 if (value == nullptr) {
336 WLOGE("EGLint *value is nullptr.");
337 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
338 return EGL_FALSE;
339 }
340
341 return display->QueryContext(ctx, attribute, value);
342 }
343
EglQueryStringImpl(EGLDisplay dpy,EGLint name)344 const char *EglQueryStringImpl(EGLDisplay dpy, EGLint name)
345 {
346 WLOGD("");
347 EGLDisplay actualDpy = EGL_NO_DISPLAY;
348 if (dpy != EGL_NO_DISPLAY) {
349 EglWrapperDisplay *display = ValidateDisplay(dpy);
350 if (!display) {
351 return nullptr;
352 }
353 actualDpy = display->GetEglDisplay();
354 }
355
356 EglWrapperDispatchTablePtr table = &gWrapperHook;
357 if (table->isLoad && table->egl.eglQueryString) {
358 return table->egl.eglQueryString(actualDpy, name);
359 } else {
360 WLOGE("eglQueryString is not found.");
361 }
362
363 return nullptr;
364 }
365
EglQuerySurfaceImpl(EGLDisplay dpy,EGLSurface surf,EGLint attribute,EGLint * value)366 EGLBoolean EglQuerySurfaceImpl(EGLDisplay dpy, EGLSurface surf,
367 EGLint attribute, EGLint* value)
368 {
369 WLOGD("");
370 EglWrapperDisplay *display = ValidateDisplay(dpy);
371 if (!display) {
372 return EGL_FALSE;
373 }
374
375 if (value == nullptr) {
376 WLOGE("EGLint *value is nullptr.");
377 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
378 return EGL_FALSE;
379 }
380
381 return display->QuerySurface(surf, attribute, value);
382 }
383
EglSwapBuffersImpl(EGLDisplay dpy,EGLSurface surf)384 EGLBoolean EglSwapBuffersImpl(EGLDisplay dpy, EGLSurface surf)
385 {
386 WLOGD("");
387 EglWrapperDisplay *display = ValidateDisplay(dpy);
388 if (!display) {
389 return EGL_FALSE;
390 }
391
392 return display->SwapBuffers(surf);
393 }
394
EglTerminateImpl(EGLDisplay dpy)395 EGLBoolean EglTerminateImpl(EGLDisplay dpy)
396 {
397 WLOGD("");
398 EglWrapperDisplay *display = ValidateDisplay(dpy);
399 if (!display) {
400 return EGL_FALSE;
401 }
402
403 return display->Terminate();
404 }
405
EglWaitGLImpl(void)406 EGLBoolean EglWaitGLImpl(void)
407 {
408 WLOGD("");
409 EGLBoolean ret = EGL_FALSE;
410 EglWrapperDispatchTablePtr table = &gWrapperHook;
411 if (table->isLoad && table->egl.eglWaitGL) {
412 ret = table->egl.eglWaitGL();
413 } else {
414 WLOGE("eglWaitGL is not found.");
415 }
416 return ret;
417 }
418
EglWaitNativeImpl(EGLint engine)419 EGLBoolean EglWaitNativeImpl(EGLint engine)
420 {
421 WLOGD("");
422 EGLBoolean ret = EGL_FALSE;
423 EglWrapperDispatchTablePtr table = &gWrapperHook;
424 if (table->isLoad && table->egl.eglWaitNative) {
425 ret = table->egl.eglWaitNative(engine);
426 } else {
427 WLOGE("eglWaitNative is not found.");
428 }
429 return ret;
430 }
431
EglBindTexImageImpl(EGLDisplay dpy,EGLSurface surf,EGLint buffer)432 EGLBoolean EglBindTexImageImpl(EGLDisplay dpy, EGLSurface surf, EGLint buffer)
433 {
434 WLOGD("");
435 EglWrapperDisplay *display = ValidateDisplay(dpy);
436 if (!display) {
437 return EGL_FALSE;
438 }
439
440 return display->BindTexImage(surf, buffer);
441 }
442
EglReleaseTexImageImpl(EGLDisplay dpy,EGLSurface surf,EGLint buffer)443 EGLBoolean EglReleaseTexImageImpl(EGLDisplay dpy, EGLSurface surf, EGLint buffer)
444 {
445 WLOGD("");
446 EglWrapperDisplay *display = ValidateDisplay(dpy);
447 if (!display) {
448 return EGL_FALSE;
449 }
450
451 return display->ReleaseTexImage(surf, buffer);
452 }
453
EglSurfaceAttribImpl(EGLDisplay dpy,EGLSurface surf,EGLint attribute,EGLint value)454 EGLBoolean EglSurfaceAttribImpl(EGLDisplay dpy, EGLSurface surf,
455 EGLint attribute, EGLint value)
456 {
457 WLOGD("");
458 EglWrapperDisplay *display = ValidateDisplay(dpy);
459 if (!display) {
460 return EGL_FALSE;
461 }
462
463 return display->SurfaceAttrib(surf, attribute, value);
464 }
465
EglSwapIntervalImpl(EGLDisplay dpy,EGLint interval)466 EGLBoolean EglSwapIntervalImpl(EGLDisplay dpy, EGLint interval)
467 {
468 WLOGD("");
469 EglWrapperDisplay *display = ValidateDisplay(dpy);
470 if (!display) {
471 return EGL_FALSE;
472 }
473
474 EGLBoolean ret = EGL_FALSE;
475 EglWrapperDispatchTablePtr table = &gWrapperHook;
476 if (table->isLoad && table->egl.eglSwapInterval) {
477 ret = table->egl.eglSwapInterval(display->GetEglDisplay(), interval);
478 } else {
479 WLOGE("eglQueryString is not found.");
480 }
481
482 return ret;
483 }
484
EglBindAPIImpl(EGLenum api)485 EGLBoolean EglBindAPIImpl(EGLenum api)
486 {
487 WLOGD("");
488 EGLBoolean ret = EGL_FALSE;
489 EglWrapperDispatchTablePtr table = &gWrapperHook;
490 if (table->isLoad && table->egl.eglBindAPI) {
491 ret = table->egl.eglBindAPI(api);
492 } else {
493 WLOGE("eglBindAPI is not found.");
494 }
495 return ret;
496 }
497
EglQueryAPIImpl(void)498 EGLBoolean EglQueryAPIImpl(void)
499 {
500 WLOGD("");
501 EglWrapperDispatchTablePtr table = &gWrapperHook;
502 if (table->isLoad && table->egl.eglQueryAPI) {
503 return table->egl.eglQueryAPI();
504 } else {
505 WLOGE("eglQueryAPI is not found.");
506 }
507
508 return EGL_OPENGL_ES_API;
509 }
510
EglCreatePbufferFromClientBufferImpl(EGLDisplay dpy,EGLenum buftype,EGLClientBuffer buffer,EGLConfig config,const EGLint * attribList)511 EGLSurface EglCreatePbufferFromClientBufferImpl(EGLDisplay dpy,
512 EGLenum buftype, EGLClientBuffer buffer,
513 EGLConfig config, const EGLint *attribList)
514 {
515 WLOGD("");
516 EglWrapperDisplay *display = ValidateDisplay(dpy);
517 if (!display) {
518 return EGL_NO_SURFACE;
519 }
520
521 return display->CreatePbufferFromClientBuffer(buftype, buffer, config, attribList);
522 }
523
EglReleaseThreadImpl(void)524 EGLBoolean EglReleaseThreadImpl(void)
525 {
526 WLOGD("");
527 EglWrapperDispatchTablePtr table = &gWrapperHook;
528 if (table->isLoad && table->egl.eglReleaseThread) {
529 table->egl.eglReleaseThread();
530 } else {
531 WLOGE("eglReleaseThread is not found.");
532 }
533
534 ThreadPrivateDataCtl::ClearPrivateData();
535 return EGL_TRUE;
536 }
537
EglWaitClientImpl(void)538 EGLBoolean EglWaitClientImpl(void)
539 {
540 WLOGD("");
541 EGLBoolean ret = EGL_FALSE;
542 EglWrapperDispatchTablePtr table = &gWrapperHook;
543 if (table->isLoad && table->egl.eglWaitClient) {
544 ret = table->egl.eglWaitClient();
545 } else {
546 WLOGE("eglWaitClient is not found.");
547 }
548 return ret;
549 }
550
EglGetCurrentContextImpl(void)551 EGLContext EglGetCurrentContextImpl(void)
552 {
553 EGLContext ctx = ThreadPrivateDataCtl::GetContext();
554 return ctx;
555 }
556
EglCreateSyncImpl(EGLDisplay dpy,EGLenum type,const EGLAttrib * attribList)557 EGLSync EglCreateSyncImpl(EGLDisplay dpy, EGLenum type, const EGLAttrib *attribList)
558 {
559 WLOGD("");
560 EglWrapperDisplay *display = ValidateDisplay(dpy);
561 if (!display) {
562 return EGL_NO_SYNC;
563 }
564
565 EGLSyncKHR ret = EGL_NO_SYNC;
566 EglWrapperDispatchTablePtr table = &gWrapperHook;
567 if (table->isLoad && table->egl.eglCreateSync) {
568 ret = table->egl.eglCreateSync(display->GetEglDisplay(), type, attribList);
569 } else {
570 WLOGE("eglCreateSync is not found.");
571 }
572
573 return ret;
574 }
575
EglDestroySyncImpl(EGLDisplay dpy,EGLSync sync)576 EGLBoolean EglDestroySyncImpl(EGLDisplay dpy, EGLSync sync)
577 {
578 WLOGD("");
579 EglWrapperDisplay *display = ValidateDisplay(dpy);
580 if (!display) {
581 return EGL_FALSE;
582 }
583
584 EGLBoolean ret = EGL_FALSE;
585 EglWrapperDispatchTablePtr table = &gWrapperHook;
586 if (table->isLoad && table->egl.eglDestroySync) {
587 ret = table->egl.eglDestroySync(display->GetEglDisplay(), sync);
588 } else {
589 WLOGE("eglDestroySync is not found.");
590 }
591
592 return ret;
593 }
594
EglClientWaitSyncImpl(EGLDisplay dpy,EGLSync sync,EGLint flags,EGLTimeKHR timeout)595 EGLint EglClientWaitSyncImpl(EGLDisplay dpy, EGLSync sync,
596 EGLint flags, EGLTimeKHR timeout)
597 {
598 WLOGD("");
599 EglWrapperDisplay *display = ValidateDisplay(dpy);
600 if (!display) {
601 return EGL_FALSE;
602 }
603
604 EGLBoolean ret = EGL_FALSE;
605 EglWrapperDispatchTablePtr table = &gWrapperHook;
606 if (table->isLoad && table->egl.eglClientWaitSync) {
607 ret = table->egl.eglClientWaitSync(display->GetEglDisplay(),
608 sync, flags, timeout);
609 } else {
610 WLOGE("eglClientWaitSync is not found.");
611 }
612
613 return ret;
614 }
615
EglGetSyncAttribImpl(EGLDisplay dpy,EGLSync sync,EGLint attribute,EGLAttrib * value)616 EGLBoolean EglGetSyncAttribImpl(EGLDisplay dpy, EGLSync sync,
617 EGLint attribute, EGLAttrib *value)
618 {
619 WLOGD("");
620 EglWrapperDisplay *display = ValidateDisplay(dpy);
621 if (!display) {
622 return EGL_FALSE;
623 }
624
625 if (value == nullptr) {
626 WLOGE("EGLAttrib *value is nullptr.");
627 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
628 return EGL_FALSE;
629 }
630
631 EGLBoolean ret = EGL_FALSE;
632 EglWrapperDispatchTablePtr table = &gWrapperHook;
633 if (table->isLoad && table->egl.eglGetSyncAttrib) {
634 ret = table->egl.eglGetSyncAttrib(display->GetEglDisplay(),
635 sync, attribute, value);
636 } else {
637 WLOGE("eglGetSyncAttrib is not found.");
638 }
639
640 return ret;
641 }
642
EglCreateImageImpl(EGLDisplay dpy,EGLContext ctx,EGLenum target,EGLClientBuffer buffer,const EGLAttrib * attribList)643 EGLImage EglCreateImageImpl(EGLDisplay dpy, EGLContext ctx,
644 EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attribList)
645 {
646 WLOGD("");
647 EglWrapperDisplay *display = ValidateDisplay(dpy);
648 if (!display) {
649 return EGL_NO_IMAGE;
650 }
651
652 return display->CreateImage(ctx, target, buffer, attribList);
653 }
654
EglDestroyImageImpl(EGLDisplay dpy,EGLImage img)655 EGLBoolean EglDestroyImageImpl(EGLDisplay dpy, EGLImage img)
656 {
657 WLOGD("");
658 EglWrapperDisplay *display = ValidateDisplay(dpy);
659 if (!display) {
660 return EGL_FALSE;
661 }
662
663 return display->DestroyImage(img);
664 }
665
EglGetPlatformDisplayImpl(EGLenum platform,void * nativeDisplay,const EGLAttrib * attribList)666 EGLDisplay EglGetPlatformDisplayImpl(EGLenum platform,
667 void *nativeDisplay, const EGLAttrib *attribList)
668 {
669 return EglGetPlatformDisplayInternal(platform,
670 static_cast<EGLNativeDisplayType>(nativeDisplay), attribList);
671 }
672
EglCreatePlatformWindowSurfaceImpl(EGLDisplay dpy,EGLConfig config,void * nativeWindow,const EGLAttrib * attribList)673 EGLSurface EglCreatePlatformWindowSurfaceImpl(EGLDisplay dpy,
674 EGLConfig config, void *nativeWindow, const EGLAttrib *attribList)
675 {
676 WLOGD("");
677 EglWrapperDisplay *display = ValidateDisplay(dpy);
678 if (!display) {
679 return EGL_NO_SURFACE;
680 }
681
682 return display->CreatePlatformWindowSurface(config, nativeWindow, attribList);
683 }
684
685
EglCreatePlatformPixmapSurfaceImpl(EGLDisplay dpy,EGLConfig config,void * nativePixmap,const EGLAttrib * attribList)686 EGLSurface EglCreatePlatformPixmapSurfaceImpl(EGLDisplay dpy,
687 EGLConfig config, void *nativePixmap, const EGLAttrib *attribList)
688 {
689 WLOGD("");
690 EglWrapperDisplay *display = ValidateDisplay(dpy);
691 if (!display) {
692 return EGL_NO_SURFACE;
693 }
694
695 return display->CreatePlatformPixmapSurface(config, nativePixmap, attribList);
696 }
697
EglWaitSyncImpl(EGLDisplay dpy,EGLSync sync,EGLint flags)698 EGLBoolean EglWaitSyncImpl(EGLDisplay dpy, EGLSync sync, EGLint flags)
699 {
700 WLOGD("");
701 EglWrapperDisplay *display = ValidateDisplay(dpy);
702 if (!display) {
703 return EGL_FALSE;
704 }
705
706 EGLBoolean ret = EGL_FALSE;
707 EglWrapperDispatchTablePtr table = &gWrapperHook;
708 if (table->isLoad && table->egl.eglWaitSync) {
709 ret = table->egl.eglWaitSync(display->GetEglDisplay(), sync, flags);
710 } else {
711 WLOGE("eglWaitSync is not found.");
712 }
713
714 return ret;
715 }
716
EglLockSurfaceKHRImpl(EGLDisplay dpy,EGLSurface surf,const EGLint * attribList)717 EGLBoolean EglLockSurfaceKHRImpl(EGLDisplay dpy, EGLSurface surf,
718 const EGLint *attribList)
719 {
720 WLOGD("");
721 EglWrapperDisplay *display = ValidateDisplay(dpy);
722 if (!display) {
723 return EGL_FALSE;
724 }
725
726 return display->LockSurfaceKHR(surf, attribList);
727 }
728
EglUnlockSurfaceKHRImpl(EGLDisplay dpy,EGLSurface surf)729 EGLBoolean EglUnlockSurfaceKHRImpl(EGLDisplay dpy, EGLSurface surf)
730 {
731 WLOGD("");
732 EglWrapperDisplay *display = ValidateDisplay(dpy);
733 if (!display) {
734 return EGL_FALSE;
735 }
736
737 return display->UnlockSurfaceKHR(surf);
738 }
739
EglCreateImageKHRImpl(EGLDisplay dpy,EGLContext ctx,EGLenum target,EGLClientBuffer buffer,const EGLint * attribList)740 EGLImageKHR EglCreateImageKHRImpl(EGLDisplay dpy, EGLContext ctx,
741 EGLenum target, EGLClientBuffer buffer, const EGLint *attribList)
742 {
743 WLOGD("");
744 EglWrapperDisplay *display = ValidateDisplay(dpy);
745 if (!display) {
746 return EGL_NO_IMAGE_KHR;
747 }
748
749 return display->CreateImageKHR(ctx, target, buffer, attribList);
750 }
751
EglDestroyImageKHRImpl(EGLDisplay dpy,EGLImageKHR img)752 EGLBoolean EglDestroyImageKHRImpl(EGLDisplay dpy, EGLImageKHR img)
753 {
754 WLOGD("");
755 EglWrapperDisplay *display = ValidateDisplay(dpy);
756 if (!display) {
757 return EGL_FALSE;
758 }
759
760 return display->DestroyImageKHR(img);
761 }
762
EglCreateSyncKHRImpl(EGLDisplay dpy,EGLenum type,const EGLint * attribList)763 EGLSyncKHR EglCreateSyncKHRImpl(EGLDisplay dpy, EGLenum type, const EGLint* attribList)
764 {
765 WLOGD("");
766 EglWrapperDisplay *display = ValidateDisplay(dpy);
767 if (!display) {
768 return EGL_NO_SYNC_KHR;
769 }
770
771 EGLSyncKHR ret = EGL_NO_SYNC_KHR;
772 EglWrapperDispatchTablePtr table = &gWrapperHook;
773 if (table->isLoad && table->egl.eglCreateSyncKHR) {
774 ret = table->egl.eglCreateSyncKHR(display->GetEglDisplay(), type, attribList);
775 } else {
776 WLOGE("eglCreateSyncKHR is not found.");
777 }
778
779 return ret;
780 }
781
EglDestroySyncKHRImpl(EGLDisplay dpy,EGLSyncKHR sync)782 EGLBoolean EglDestroySyncKHRImpl(EGLDisplay dpy, EGLSyncKHR sync)
783 {
784 WLOGD("");
785 EglWrapperDisplay *display = ValidateDisplay(dpy);
786 if (!display) {
787 return EGL_FALSE;
788 }
789
790 EGLBoolean ret = EGL_FALSE;
791 EglWrapperDispatchTablePtr table = &gWrapperHook;
792 if (table->isLoad && table->egl.eglDestroySyncKHR) {
793 ret = table->egl.eglDestroySyncKHR(display->GetEglDisplay(), sync);
794 } else {
795 WLOGE("eglDestroySyncKHR is not found.");
796 }
797
798 return ret;
799 }
800
EglClientWaitSyncKHRImpl(EGLDisplay dpy,EGLSyncKHR sync,EGLint flags,EGLTimeKHR timeout)801 EGLint EglClientWaitSyncKHRImpl(EGLDisplay dpy, EGLSyncKHR sync,
802 EGLint flags, EGLTimeKHR timeout)
803 {
804 WLOGD("");
805 EglWrapperDisplay *display = ValidateDisplay(dpy);
806 if (!display) {
807 return EGL_FALSE;
808 }
809
810 EGLBoolean ret = EGL_FALSE;
811 EglWrapperDispatchTablePtr table = &gWrapperHook;
812 if (table->isLoad && table->egl.eglClientWaitSyncKHR) {
813 ret = table->egl.eglClientWaitSyncKHR(display->GetEglDisplay(),
814 sync, flags, timeout);
815 } else {
816 WLOGE("eglClientWaitSyncKHR is not found.");
817 }
818
819 return ret;
820 }
821
EglGetSyncAttribKHRImpl(EGLDisplay dpy,EGLSyncKHR sync,EGLint attribute,EGLint * value)822 EGLBoolean EglGetSyncAttribKHRImpl(EGLDisplay dpy, EGLSyncKHR sync,
823 EGLint attribute, EGLint *value)
824 {
825 WLOGD("");
826 EglWrapperDisplay *display = ValidateDisplay(dpy);
827 if (!display) {
828 return EGL_FALSE;
829 }
830
831 if (value == nullptr) {
832 WLOGE("EGLint *value is nullptr.");
833 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
834 return EGL_FALSE;
835 }
836
837 EGLBoolean ret = EGL_FALSE;
838 EglWrapperDispatchTablePtr table = &gWrapperHook;
839 if (table->isLoad && table->egl.eglGetSyncAttribKHR) {
840 ret = table->egl.eglGetSyncAttribKHR(display->GetEglDisplay(),
841 sync, attribute, value);
842 } else {
843 WLOGE("eglGetSyncAttribKHR is not found.");
844 }
845
846 return ret;
847 }
848
EglSignalSyncKHRImpl(EGLDisplay dpy,EGLSyncKHR sync,EGLenum mode)849 EGLBoolean EglSignalSyncKHRImpl(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode)
850 {
851 WLOGD("");
852 EglWrapperDisplay *display = ValidateDisplay(dpy);
853 if (!display) {
854 return EGL_FALSE;
855 }
856
857 EGLBoolean ret = EGL_FALSE;
858 EglWrapperDispatchTablePtr table = &gWrapperHook;
859 if (table->isLoad && table->egl.eglSignalSyncKHR) {
860 ret = table->egl.eglSignalSyncKHR(display->GetEglDisplay(), sync, mode);
861 } else {
862 WLOGE("eglSignalSyncKHR is not found.");
863 }
864
865 return ret;
866 }
867
EglCreateStreamKHRImpl(EGLDisplay dpy,const EGLint * attribList)868 EGLStreamKHR EglCreateStreamKHRImpl(EGLDisplay dpy, const EGLint *attribList)
869 {
870 WLOGD("");
871 EglWrapperDisplay *display = ValidateDisplay(dpy);
872 if (!display) {
873 return EGL_NO_STREAM_KHR;
874 }
875
876 EGLStreamKHR ret = EGL_NO_STREAM_KHR;
877 EglWrapperDispatchTablePtr table = &gWrapperHook;
878 if (table->isLoad && table->egl.eglCreateStreamKHR) {
879 ret = table->egl.eglCreateStreamKHR(display->GetEglDisplay(), attribList);
880 } else {
881 WLOGE("eglCreateStreamKHR is not found.");
882 }
883
884 return ret;
885 }
886
EglDestroyStreamKHRImpl(EGLDisplay dpy,EGLStreamKHR stream)887 EGLBoolean EglDestroyStreamKHRImpl(EGLDisplay dpy, EGLStreamKHR stream)
888 {
889 WLOGD("");
890 EglWrapperDisplay *display = ValidateDisplay(dpy);
891 if (!display) {
892 return EGL_FALSE;
893 }
894
895 EGLBoolean ret = EGL_FALSE;
896 EglWrapperDispatchTablePtr table = &gWrapperHook;
897 if (table->isLoad && table->egl.eglDestroyStreamKHR) {
898 ret = table->egl.eglDestroyStreamKHR(display->GetEglDisplay(), stream);
899 } else {
900 WLOGE("eglDestroyStreamKHR is not found.");
901 }
902
903 return ret;
904 }
905
EglStreamAttribKHRImpl(EGLDisplay dpy,EGLStreamKHR stream,EGLenum attribute,EGLint value)906 EGLBoolean EglStreamAttribKHRImpl(EGLDisplay dpy, EGLStreamKHR stream,
907 EGLenum attribute, EGLint value)
908 {
909 WLOGD("");
910 EglWrapperDisplay *display = ValidateDisplay(dpy);
911 if (!display) {
912 return EGL_FALSE;
913 }
914
915 EGLBoolean ret = EGL_FALSE;
916 EglWrapperDispatchTablePtr table = &gWrapperHook;
917 if (table->isLoad && table->egl.eglStreamAttribKHR) {
918 ret = table->egl.eglStreamAttribKHR(display->GetEglDisplay(),
919 stream, attribute, value);
920 } else {
921 WLOGE("eglStreamAttribKHR is not found.");
922 }
923
924 return ret;
925 }
926
EglQueryStreamKHRImpl(EGLDisplay dpy,EGLStreamKHR stream,EGLenum attribute,EGLint * value)927 EGLBoolean EglQueryStreamKHRImpl(EGLDisplay dpy, EGLStreamKHR stream,
928 EGLenum attribute, EGLint *value)
929 {
930 WLOGD("");
931 EglWrapperDisplay *display = ValidateDisplay(dpy);
932 if (!display) {
933 return EGL_FALSE;
934 }
935
936 if (value == nullptr) {
937 WLOGE("EGLint *value is nullptr.");
938 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
939 return EGL_FALSE;
940 }
941
942 EGLBoolean ret = EGL_FALSE;
943 EglWrapperDispatchTablePtr table = &gWrapperHook;
944 if (table->isLoad && table->egl.eglQueryStreamKHR) {
945 ret = table->egl.eglQueryStreamKHR(display->GetEglDisplay(),
946 stream, attribute, value);
947 } else {
948 WLOGE("eglQueryStreamKHR is not found.");
949 }
950
951 return ret;
952 }
953
EglQueryStreamu64KHRImpl(EGLDisplay dpy,EGLStreamKHR stream,EGLenum attribute,EGLuint64KHR * value)954 EGLBoolean EglQueryStreamu64KHRImpl(EGLDisplay dpy, EGLStreamKHR stream,
955 EGLenum attribute, EGLuint64KHR *value)
956 {
957 WLOGD("");
958 EglWrapperDisplay *display = ValidateDisplay(dpy);
959 if (!display) {
960 return EGL_FALSE;
961 }
962
963 if (value == nullptr) {
964 WLOGE("EGLint *value is nullptr.");
965 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
966 return EGL_FALSE;
967 }
968
969 EGLBoolean ret = EGL_FALSE;
970 EglWrapperDispatchTablePtr table = &gWrapperHook;
971 if (table->isLoad && table->egl.eglQueryStreamu64KHR) {
972 ret = table->egl.eglQueryStreamu64KHR(display->GetEglDisplay(),
973 stream, attribute, value);
974 } else {
975 WLOGE("eglQueryStreamu64KHR is not found.");
976 }
977
978 return ret;
979 }
980
EglStreamConsumerGLTextureExternalKHRImpl(EGLDisplay dpy,EGLStreamKHR stream)981 EGLBoolean EglStreamConsumerGLTextureExternalKHRImpl(EGLDisplay dpy,
982 EGLStreamKHR stream)
983 {
984 WLOGD("");
985 EglWrapperDisplay *display = ValidateDisplay(dpy);
986 if (!display) {
987 return EGL_FALSE;
988 }
989
990 EGLBoolean ret = EGL_FALSE;
991 EglWrapperDispatchTablePtr table = &gWrapperHook;
992 if (table->isLoad && table->egl.eglStreamConsumerGLTextureExternalKHR) {
993 ret = table->egl.eglStreamConsumerGLTextureExternalKHR(
994 display->GetEglDisplay(), stream);
995 } else {
996 WLOGE("eglStreamConsumerGLTextureExternalKHR is not found.");
997 }
998
999 return ret;
1000 }
1001
EglStreamConsumerAcquireKHRImpl(EGLDisplay dpy,EGLStreamKHR stream)1002 EGLBoolean EglStreamConsumerAcquireKHRImpl(EGLDisplay dpy, EGLStreamKHR stream)
1003 {
1004 WLOGD("");
1005 EglWrapperDisplay *display = ValidateDisplay(dpy);
1006 if (!display) {
1007 return EGL_FALSE;
1008 }
1009
1010 EGLBoolean ret = EGL_FALSE;
1011 EglWrapperDispatchTablePtr table = &gWrapperHook;
1012 if (table->isLoad && table->egl.eglStreamConsumerAcquireKHR) {
1013 ret = table->egl.eglStreamConsumerAcquireKHR(
1014 display->GetEglDisplay(), stream);
1015 } else {
1016 WLOGE("eglStreamConsumerAcquireKHR is not found.");
1017 }
1018
1019 return ret;
1020 }
1021
EglStreamConsumerReleaseKHRImpl(EGLDisplay dpy,EGLStreamKHR stream)1022 EGLBoolean EglStreamConsumerReleaseKHRImpl(EGLDisplay dpy, EGLStreamKHR stream)
1023 {
1024 WLOGD("");
1025 EglWrapperDisplay *display = ValidateDisplay(dpy);
1026 if (!display) {
1027 return EGL_FALSE;
1028 }
1029
1030 EGLBoolean ret = EGL_FALSE;
1031 EglWrapperDispatchTablePtr table = &gWrapperHook;
1032 if (table->isLoad && table->egl.eglStreamConsumerReleaseKHR) {
1033 ret = table->egl.eglStreamConsumerReleaseKHR(
1034 display->GetEglDisplay(), stream);
1035 } else {
1036 WLOGE("eglStreamConsumerReleaseKHR is not found.");
1037 }
1038
1039 return ret;
1040 }
1041
EglCreateStreamProducerSurfaceKHRImpl(EGLDisplay dpy,EGLConfig config,EGLStreamKHR stream,const EGLint * attribList)1042 EGLSurface EglCreateStreamProducerSurfaceKHRImpl(EGLDisplay dpy, EGLConfig config,
1043 EGLStreamKHR stream, const EGLint *attribList)
1044 {
1045 WLOGD("");
1046 EglWrapperDisplay *display = ValidateDisplay(dpy);
1047 if (!display) {
1048 return EGL_NO_SURFACE;
1049 }
1050
1051 return display->CreateStreamProducerSurfaceKHR(config, stream, attribList);
1052 }
1053
EglQueryStreamTimeKHRImpl(EGLDisplay dpy,EGLStreamKHR stream,EGLenum attribute,EGLTimeKHR * value)1054 EGLBoolean EglQueryStreamTimeKHRImpl(EGLDisplay dpy, EGLStreamKHR stream,
1055 EGLenum attribute, EGLTimeKHR *value)
1056 {
1057 WLOGD("");
1058 EglWrapperDisplay *display = ValidateDisplay(dpy);
1059 if (!display) {
1060 return EGL_FALSE;
1061 }
1062
1063 if (value == nullptr) {
1064 WLOGE("EGLint *value is nullptr.");
1065 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
1066 return EGL_FALSE;
1067 }
1068
1069 EGLBoolean ret = EGL_FALSE;
1070 EglWrapperDispatchTablePtr table = &gWrapperHook;
1071 if (table->isLoad && table->egl.eglQueryStreamTimeKHR) {
1072 ret = table->egl.eglQueryStreamTimeKHR(display->GetEglDisplay(),
1073 stream, attribute, value);
1074 } else {
1075 WLOGE("eglQueryStreamTimeKHR is not found.");
1076 }
1077
1078 return ret;
1079 }
1080
EglGetStreamFileDescriptorKHRImpl(EGLDisplay dpy,EGLStreamKHR stream)1081 EGLNativeFileDescriptorKHR EglGetStreamFileDescriptorKHRImpl(
1082 EGLDisplay dpy, EGLStreamKHR stream)
1083 {
1084 WLOGD("");
1085 EglWrapperDisplay *display = ValidateDisplay(dpy);
1086 if (!display) {
1087 return EGL_NO_FILE_DESCRIPTOR_KHR;
1088 }
1089
1090 EGLNativeFileDescriptorKHR ret = EGL_NO_FILE_DESCRIPTOR_KHR;
1091 EglWrapperDispatchTablePtr table = &gWrapperHook;
1092 if (table->isLoad && table->egl.eglGetStreamFileDescriptorKHR) {
1093 ret = table->egl.eglGetStreamFileDescriptorKHR(
1094 display->GetEglDisplay(), stream);
1095 } else {
1096 WLOGE("eglGetStreamFileDescriptorKHR is not found.");
1097 }
1098
1099 return ret;
1100 }
1101
EglCreateStreamFromFileDescriptorKHRImpl(EGLDisplay dpy,EGLNativeFileDescriptorKHR fd)1102 EGLStreamKHR EglCreateStreamFromFileDescriptorKHRImpl(
1103 EGLDisplay dpy, EGLNativeFileDescriptorKHR fd)
1104 {
1105 WLOGD("");
1106 EglWrapperDisplay *display = ValidateDisplay(dpy);
1107 if (!display) {
1108 return EGL_NO_STREAM_KHR;
1109 }
1110
1111 EGLStreamKHR ret = EGL_NO_STREAM_KHR;
1112 EglWrapperDispatchTablePtr table = &gWrapperHook;
1113 if (table->isLoad && table->egl.eglCreateStreamFromFileDescriptorKHR) {
1114 ret = table->egl.eglCreateStreamFromFileDescriptorKHR(
1115 display->GetEglDisplay(), fd);
1116 } else {
1117 WLOGE("eglCreateStreamFromFileDescriptorKHR is not found.");
1118 }
1119
1120 return ret;
1121 }
1122
EglWaitSyncKHRImpl(EGLDisplay dpy,EGLSyncKHR sync,EGLint flags)1123 EGLBoolean EglWaitSyncKHRImpl(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags)
1124 {
1125 WLOGD("");
1126 EglWrapperDisplay *display = ValidateDisplay(dpy);
1127 if (!display) {
1128 return EGL_FALSE;
1129 }
1130
1131 EGLBoolean ret = EGL_FALSE;
1132 EglWrapperDispatchTablePtr table = &gWrapperHook;
1133 if (table->isLoad && table->egl.eglWaitSyncKHR) {
1134 ret = table->egl.eglWaitSyncKHR(display->GetEglDisplay(), sync, flags);
1135 } else {
1136 WLOGE("eglWaitSyncKHR is not found.");
1137 }
1138
1139 return ret;
1140 }
1141
EglGetPlatformDisplayEXTImpl(EGLenum platform,void * nativeDisplay,const EGLint * attribList)1142 EGLDisplay EglGetPlatformDisplayEXTImpl(EGLenum platform,
1143 void *nativeDisplay, const EGLint *attribList)
1144 {
1145 WLOGD("");
1146 if (nativeDisplay != EGL_DEFAULT_DISPLAY) {
1147 WLOGE("nativeDisplay is invalid.");
1148 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
1149 return EGL_NO_DISPLAY;
1150 }
1151
1152 if (platform != EGL_PLATFORM_OHOS_KHR) {
1153 WLOGE("EGLenum platform is not EGL_PLATFORM_OHOS_KHR.");
1154 ThreadPrivateDataCtl::SetError(EGL_BAD_PARAMETER);
1155 return EGL_NO_DISPLAY;
1156 }
1157
1158 return EglWrapperDisplay::GetEglDisplayExt(platform, nativeDisplay, attribList);
1159 }
1160
EglSwapBuffersWithDamageKHRImpl(EGLDisplay dpy,EGLSurface draw,EGLint * rects,EGLint nRects)1161 EGLBoolean EglSwapBuffersWithDamageKHRImpl(EGLDisplay dpy, EGLSurface draw,
1162 EGLint *rects, EGLint nRects)
1163 {
1164 WLOGD("");
1165 EglWrapperDisplay *display = ValidateDisplay(dpy);
1166 if (!display) {
1167 return EGL_FALSE;
1168 }
1169
1170 return display->SwapBuffersWithDamageKHR(draw, rects, nRects);
1171 }
1172
EglSetDamageRegionKHRImpl(EGLDisplay dpy,EGLSurface surf,EGLint * rects,EGLint nRects)1173 EGLBoolean EglSetDamageRegionKHRImpl(EGLDisplay dpy, EGLSurface surf,
1174 EGLint *rects, EGLint nRects)
1175 {
1176 WLOGD("");
1177 EglWrapperDisplay *display = ValidateDisplay(dpy);
1178 if (!display) {
1179 return EGL_FALSE;
1180 }
1181
1182 return display->SetDamageRegionKHR(surf, rects, nRects);
1183 }
1184
1185 static const std::map<std::string, EglWrapperFuncPointer> gEglWrapperMap = {
1186 /* EGL_VERSION_1_0 */
1187 { "eglChooseConfig", (EglWrapperFuncPointer)&EglChooseConfigImpl },
1188 { "eglCopyBuffers", (EglWrapperFuncPointer)&EglCopyBuffersImpl },
1189 { "eglCreateContext", (EglWrapperFuncPointer)&EglCreateContextImpl },
1190 { "eglCreatePbufferSurface", (EglWrapperFuncPointer)&EglCreatePbufferSurfaceImpl },
1191 { "eglCreatePixmapSurface", (EglWrapperFuncPointer)&EglCreatePixmapSurfaceImpl },
1192 { "eglCreateWindowSurface", (EglWrapperFuncPointer)&EglCreateWindowSurfaceImpl },
1193 { "eglDestroyContext", (EglWrapperFuncPointer)&EglDestroyContextImpl },
1194 { "eglDestroySurface", (EglWrapperFuncPointer)&EglDestroySurfaceImpl },
1195 { "eglGetConfigAttrib", (EglWrapperFuncPointer)&EglGetConfigAttribImpl },
1196 { "eglGetConfigs", (EglWrapperFuncPointer)&EglGetConfigsImpl },
1197 { "eglGetCurrentDisplay", (EglWrapperFuncPointer)&EglGetCurrentDisplayImpl },
1198 { "eglGetCurrentSurface", (EglWrapperFuncPointer)&EglGetCurrentSurfaceImpl },
1199 { "eglGetDisplay", (EglWrapperFuncPointer)&EglGetDisplayImpl },
1200 { "eglGetError", (EglWrapperFuncPointer)&EglGetErrorImpl },
1201 { "eglGetProcAddress", (EglWrapperFuncPointer)&EglGetProcAddressImpl },
1202 { "eglInitialize", (EglWrapperFuncPointer)&EglInitializeImpl },
1203 { "eglMakeCurrent", (EglWrapperFuncPointer)&EglMakeCurrentImpl },
1204 { "eglQueryContext", (EglWrapperFuncPointer)&EglQueryContextImpl },
1205 { "eglQueryString", (EglWrapperFuncPointer)&EglQueryStringImpl },
1206 { "eglQuerySurface", (EglWrapperFuncPointer)&EglQuerySurfaceImpl },
1207 { "eglSwapBuffers", (EglWrapperFuncPointer)&EglSwapBuffersImpl },
1208 { "eglTerminate", (EglWrapperFuncPointer)&EglTerminateImpl },
1209 { "eglWaitGL", (EglWrapperFuncPointer)&EglWaitGLImpl },
1210 { "eglWaitNative", (EglWrapperFuncPointer)&EglWaitNativeImpl },
1211
1212 /* EGL_VERSION_1_1 */
1213 { "eglBindTexImage", (EglWrapperFuncPointer)&EglBindTexImageImpl },
1214 { "eglReleaseTexImage", (EglWrapperFuncPointer)&EglReleaseTexImageImpl },
1215 { "eglSurfaceAttrib", (EglWrapperFuncPointer)&EglSurfaceAttribImpl },
1216 { "eglSwapInterval", (EglWrapperFuncPointer)&EglSwapIntervalImpl },
1217
1218 /* EGL_VERSION_1_2 */
1219 { "eglBindAPI", (EglWrapperFuncPointer)&EglBindAPIImpl },
1220 { "eglQueryAPI", (EglWrapperFuncPointer)&EglQueryAPIImpl },
1221 { "eglCreatePbufferFromClientBuffer", (EglWrapperFuncPointer)&EglCreatePbufferFromClientBufferImpl },
1222 { "eglReleaseThread", (EglWrapperFuncPointer)&EglReleaseThreadImpl },
1223 { "eglWaitClient", (EglWrapperFuncPointer)&EglWaitClientImpl },
1224
1225 /* EGL_VERSION_1_3 */
1226 /* EGL_VERSION_1_4 */
1227 { "eglGetCurrentContext", (EglWrapperFuncPointer)&EglGetCurrentContextImpl },
1228
1229 /* EGL_VERSION_1_5 */
1230 { "eglCreateSync", (EglWrapperFuncPointer)&EglCreateSyncImpl },
1231 { "eglDestroySync", (EglWrapperFuncPointer)&EglDestroySyncImpl },
1232 { "eglClientWaitSync", (EglWrapperFuncPointer)&EglClientWaitSyncImpl },
1233 { "eglGetSyncAttrib", (EglWrapperFuncPointer)&EglGetSyncAttribImpl },
1234 { "eglCreateImage", (EglWrapperFuncPointer)&EglCreateImageImpl },
1235 { "eglDestroyImage", (EglWrapperFuncPointer)&EglDestroyImageImpl },
1236 { "eglGetPlatformDisplay", (EglWrapperFuncPointer)&EglGetPlatformDisplayImpl },
1237 { "eglCreatePlatformWindowSurface", (EglWrapperFuncPointer)&EglCreatePlatformWindowSurfaceImpl },
1238 { "eglCreatePlatformPixmapSurface", (EglWrapperFuncPointer)&EglCreatePlatformPixmapSurfaceImpl },
1239 { "eglWaitSync", (EglWrapperFuncPointer)&EglWaitSyncImpl },
1240
1241 /* EGL_EXTENTIONS */
1242 { "eglLockSurfaceKHR", (EglWrapperFuncPointer)&EglLockSurfaceKHRImpl },
1243 { "eglUnlockSurfaceKHR", (EglWrapperFuncPointer)&EglUnlockSurfaceKHRImpl },
1244
1245 { "eglCreateImageKHR", (EglWrapperFuncPointer)&EglCreateImageKHRImpl },
1246 { "eglDestroyImageKHR", (EglWrapperFuncPointer)&EglDestroyImageKHRImpl },
1247
1248 { "eglCreateSyncKHR", (EglWrapperFuncPointer)&EglCreateSyncKHRImpl },
1249 { "eglDestroySyncKHR", (EglWrapperFuncPointer)&EglDestroySyncKHRImpl },
1250 { "eglClientWaitSyncKHR", (EglWrapperFuncPointer)&EglClientWaitSyncKHRImpl },
1251 { "eglGetSyncAttribKHR", (EglWrapperFuncPointer)&EglGetSyncAttribKHRImpl },
1252
1253 { "eglSignalSyncKHR", (EglWrapperFuncPointer)&EglSignalSyncKHRImpl },
1254
1255 { "eglCreateStreamKHR", (EglWrapperFuncPointer)&EglCreateStreamKHRImpl },
1256 { "eglDestroyStreamKHR", (EglWrapperFuncPointer)&EglDestroyStreamKHRImpl },
1257 { "eglStreamAttribKHR", (EglWrapperFuncPointer)&EglStreamAttribKHRImpl },
1258 { "eglQueryStreamKHR", (EglWrapperFuncPointer)&EglQueryStreamKHRImpl },
1259 { "eglQueryStreamu64KHR", (EglWrapperFuncPointer)&EglQueryStreamu64KHRImpl },
1260
1261 { "eglStreamConsumerGLTextureExternalKHR", (EglWrapperFuncPointer)&EglStreamConsumerGLTextureExternalKHRImpl },
1262 { "eglStreamConsumerAcquireKHR", (EglWrapperFuncPointer)&EglStreamConsumerAcquireKHRImpl },
1263 { "eglStreamConsumerReleaseKHR", (EglWrapperFuncPointer)&EglStreamConsumerReleaseKHRImpl },
1264
1265 { "eglCreateStreamProducerSurfaceKHR", (EglWrapperFuncPointer)&EglCreateStreamProducerSurfaceKHRImpl },
1266
1267 { "eglQueryStreamTimeKHR", (EglWrapperFuncPointer)&EglQueryStreamTimeKHRImpl },
1268
1269 { "eglGetStreamFileDescriptorKHR", (EglWrapperFuncPointer)&EglGetStreamFileDescriptorKHRImpl },
1270 { "eglCreateStreamFromFileDescriptorKHR", (EglWrapperFuncPointer)&EglCreateStreamFromFileDescriptorKHRImpl },
1271
1272 { "eglWaitSyncKHR", (EglWrapperFuncPointer)&EglWaitSyncKHRImpl },
1273
1274 { "eglGetPlatformDisplayEXT", (EglWrapperFuncPointer)&EglGetPlatformDisplayEXTImpl },
1275
1276 { "eglSwapBuffersWithDamageKHR", (EglWrapperFuncPointer)&EglSwapBuffersWithDamageKHRImpl },
1277 { "eglSetDamageRegionKHR", (EglWrapperFuncPointer)&EglSetDamageRegionKHRImpl },
1278
1279 };
1280
FindEglWrapperApi(const std::string & name)1281 EglWrapperFuncPointer FindEglWrapperApi(const std::string &name)
1282 {
1283 if (gEglWrapperMap.find(name) != gEglWrapperMap.end()) {
1284 return gEglWrapperMap.at(name);
1285 }
1286
1287 WLOGW("FindEglWrapperApi did not find an entry for %{public}s", name.c_str());
1288 return nullptr;
1289 }
1290
CheckEglWrapperApi(const std::string & name)1291 bool CheckEglWrapperApi(const std::string &name)
1292 {
1293 if (gEglWrapperMap.find(name) != gEglWrapperMap.end()) {
1294 return true;
1295 }
1296 return false;
1297 }
1298 }; // namespace OHOS
1299