1 /*
2 * Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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
16 #include "rosen_context_impl.h"
17
18 #include "ui/rs_surface_extractor.h"
19 #include "backend/rs_surface_ohos_gl.h"
20
21 using namespace OHOS;
22 using namespace Rosen;
23
RosenContextImpl()24 RosenContextImpl::RosenContextImpl()
25 {
26 InitEgl();
27 InitProducer();
28 }
29
30 #define PRINT_EGL_CONFIG(type) \
31 { \
32 int32_t value; \
33 eglGetConfigAttrib(eglDisplay, cfg, type, &value); \
34 printf(" %s: %d\n", #type, value); \
35 }
PrintEglConfig(void * eglDisplay,EGLConfig cfg)36 void PrintEglConfig(void *eglDisplay, EGLConfig cfg)
37 {
38 // 打印颜色缓冲区属性
39 PRINT_EGL_CONFIG(EGL_BUFFER_SIZE)
40 PRINT_EGL_CONFIG(EGL_RED_SIZE)
41 PRINT_EGL_CONFIG(EGL_GREEN_SIZE)
42 PRINT_EGL_CONFIG(EGL_BLUE_SIZE)
43 PRINT_EGL_CONFIG(EGL_ALPHA_SIZE)
44 PRINT_EGL_CONFIG(EGL_DEPTH_SIZE)
45 PRINT_EGL_CONFIG(EGL_STENCIL_SIZE)
46
47 // 打印其他属性
48 PRINT_EGL_CONFIG(EGL_CONFIG_CAVEAT)
49 PRINT_EGL_CONFIG(EGL_CONFIG_ID)
50 PRINT_EGL_CONFIG(EGL_LEVEL)
51 PRINT_EGL_CONFIG(EGL_MAX_PBUFFER_WIDTH)
52 PRINT_EGL_CONFIG(EGL_MAX_PBUFFER_HEIGHT)
53 PRINT_EGL_CONFIG(EGL_MAX_PBUFFER_PIXELS)
54 PRINT_EGL_CONFIG(EGL_NATIVE_VISUAL_ID)
55 PRINT_EGL_CONFIG(EGL_SAMPLES)
56 PRINT_EGL_CONFIG(EGL_SAMPLE_BUFFERS)
57 PRINT_EGL_CONFIG(EGL_SURFACE_TYPE)
58 PRINT_EGL_CONFIG(EGL_RENDERABLE_TYPE)
59 PRINT_EGL_CONFIG(EGL_TRANSPARENT_TYPE)
60 PRINT_EGL_CONFIG(EGL_TRANSPARENT_RED_VALUE)
61 PRINT_EGL_CONFIG(EGL_TRANSPARENT_GREEN_VALUE)
62 PRINT_EGL_CONFIG(EGL_TRANSPARENT_BLUE_VALUE)
63 }
64
ShowConfig(EGLConfig cfg)65 void RosenContextImpl::ShowConfig(EGLConfig cfg)
66 {
67 EGLint red, green, blue, alpha, depth, stencil, samples, sft, rt;
68
69 eglGetConfigAttrib(eglDisplay_, cfg, EGL_RED_SIZE, &red);
70 eglGetConfigAttrib(eglDisplay_, cfg, EGL_GREEN_SIZE, &green);
71 eglGetConfigAttrib(eglDisplay_, cfg, EGL_BLUE_SIZE, &blue);
72 eglGetConfigAttrib(eglDisplay_, cfg, EGL_ALPHA_SIZE, &alpha);
73 eglGetConfigAttrib(eglDisplay_, cfg, EGL_DEPTH_SIZE, &depth);
74 eglGetConfigAttrib(eglDisplay_, cfg, EGL_STENCIL_SIZE, &stencil);
75 eglGetConfigAttrib(eglDisplay_, cfg, EGL_SAMPLES, &samples);
76 eglGetConfigAttrib(eglDisplay_, cfg, EGL_SURFACE_TYPE, &sft);
77 eglGetConfigAttrib(eglDisplay_, cfg, EGL_RENDERABLE_TYPE, &rt);
78
79 printf("%8d%8d%8d%8d%8d%8d%8d%8d%8d\n", red, green, blue, alpha, depth, stencil, samples, sft, rt);
80 }
81
InitProducer()82 void RosenContextImpl::InitProducer()
83 {
84 displayNode_ = RSDisplayNode::Create(RSDisplayNodeConfig());
85 surfaceNode_ = RSSurfaceNode::Create(RSSurfaceNodeConfig());
86 surfaceNode_->SetBounds(0, 0, 512, 512);
87 displayNode_->AddChild(surfaceNode_, -1);
88
89 std::shared_ptr<RSSurface> rsSurface = RSSurfaceExtractor::ExtractRSSurface(surfaceNode_);
90 std::shared_ptr<RSSurfaceOhosGl> rsSurfaceOhosGl = std::static_pointer_cast<RSSurfaceOhosGl>(rsSurface);
91 producer_ = rsSurfaceOhosGl->GetSurface();
92 }
93
InitEgl()94 bool RosenContextImpl::InitEgl()
95 {
96 if (eglInited_)
97 {
98 return true;
99 }
100 eglDisplay_ = eglGetDisplay(EGL_DEFAULT_DISPLAY);
101 if (eglDisplay_ == EGL_NO_DISPLAY)
102 {
103 printf("Failed to create EGLDisplay gl errno : %x", eglGetError());
104 return false;
105 }
106
107 EGLint major, minor;
108 if (eglInitialize(eglDisplay_, &major, &minor) == EGL_FALSE)
109 {
110 printf("Failed to initialize EGLDisplay");
111 return false;
112 }
113
114 glDepthMask(GL_TRUE);
115
116 eglGetConfigs(eglDisplay_, NULL, 0, &configCount_);
117 allConfigs_ = new EGLConfig[configCount_];
118 eglGetConfigs(eglDisplay_, allConfigs_, configCount_, &configCount_);
119
120 printf("config count : %d\n", configCount_);
121 printf("%8s%8s%8s%8s%8s%8s%8s%8s%8s\n", "red", "green", "blue", "alpha", "depth", "stencil", "samples", "sft", "rt");
122 for (int i = 0; i < configCount_; i++)
123 {
124 ShowConfig(allConfigs_[i]);
125 }
126 eglInited_ = true;
127 return true;
128 }
129
SetConfig(int32_t w,int32_t h,RCI_GLES_VERSION ver,RCI_PIXEL_FORMAT pf,RCI_SURFACE_TYPE st,RCI_PROFILE tp,RCI_CONTEXT_FLAG flags)130 bool RosenContextImpl::SetConfig(int32_t w, int32_t h, RCI_GLES_VERSION ver, RCI_PIXEL_FORMAT pf, RCI_SURFACE_TYPE st, RCI_PROFILE tp, RCI_CONTEXT_FLAG flags)
131 {
132 glesVersion_ = ver;
133 typeProfile_ = tp;
134 contextFlags_ = flags;
135 surfaceType_ = st;
136 width_ = w;
137 height_ = h;
138 pixelFormat_ = pf;
139
140 EGLint eglApi;
141 switch (typeProfile_)
142 {
143 case RCI_PROFILE::ES:
144 eglApi = EGL_OPENGL_ES_API;
145 break;
146 case RCI_PROFILE::CORE:
147 eglApi = EGL_OPENGL_API;
148 break;
149 case RCI_PROFILE::COMPATIBILITY:
150 eglApi = EGL_OPENGL_API;
151 break;
152 default:
153 return false;
154 }
155 if (eglBindAPI(EGL_OPENGL_ES_API) == EGL_FALSE)
156 {
157 printf("Failed to bind OpenGL ES API");
158 return false;
159 }
160
161 std::vector<EGLint> frameBufferAttribs;
162 frameBufferAttribs.push_back(EGL_RENDERABLE_TYPE);
163 switch (static_cast<int>(glesVersion_) / 10)
164 {
165 case 3:
166 frameBufferAttribs.push_back(EGL_OPENGL_ES3_BIT);
167 break;
168 case 2:
169 frameBufferAttribs.push_back(EGL_OPENGL_ES2_BIT);
170 break;
171 default:
172 frameBufferAttribs.push_back(EGL_OPENGL_ES_BIT);
173 }
174
175 frameBufferAttribs.push_back(EGL_SURFACE_TYPE);
176 switch (surfaceType_)
177 {
178 case RCI_SURFACE_TYPE::NONE:
179 frameBufferAttribs.push_back(EGL_DONT_CARE);
180 break;
181 case RCI_SURFACE_TYPE::PBUFFER:
182 frameBufferAttribs.push_back(EGL_PBUFFER_BIT);
183 break;
184 case RCI_SURFACE_TYPE::PIXMAP:
185 frameBufferAttribs.push_back(EGL_PIXMAP_BIT);
186 break;
187 case RCI_SURFACE_TYPE::WINDOW:
188 frameBufferAttribs.push_back(EGL_WINDOW_BIT);
189 break;
190 }
191
192 if (pixelFormat_.redBits != -1)
193 {
194 frameBufferAttribs.push_back(EGL_RED_SIZE);
195 frameBufferAttribs.push_back(pixelFormat_.redBits);
196 }
197 if (pixelFormat_.greenBits != -1)
198 {
199 frameBufferAttribs.push_back(EGL_GREEN_SIZE);
200 frameBufferAttribs.push_back(pixelFormat_.greenBits);
201 }
202 if (pixelFormat_.blueBits != -1)
203 {
204 frameBufferAttribs.push_back(EGL_BLUE_SIZE);
205 frameBufferAttribs.push_back(pixelFormat_.blueBits);
206 }
207 if (pixelFormat_.alphaBits != -1)
208 {
209 frameBufferAttribs.push_back(EGL_ALPHA_SIZE);
210 frameBufferAttribs.push_back(pixelFormat_.alphaBits);
211 }
212 if (pixelFormat_.depthBits != -1)
213 {
214 frameBufferAttribs.push_back(EGL_DEPTH_SIZE);
215 frameBufferAttribs.push_back(pixelFormat_.depthBits);
216 }
217 if (pixelFormat_.stencilBits != -1)
218 {
219 frameBufferAttribs.push_back(EGL_STENCIL_SIZE);
220 frameBufferAttribs.push_back(pixelFormat_.stencilBits);
221 }
222 if (pixelFormat_.numSamples != -1)
223 {
224 frameBufferAttribs.push_back(EGL_SAMPLES);
225 frameBufferAttribs.push_back(pixelFormat_.numSamples);
226 }
227 frameBufferAttribs.push_back(EGL_NONE);
228
229 unsigned int ret;
230 EGLint count;
231 ret = eglChooseConfig(eglDisplay_, &frameBufferAttribs[0], &config_, 1, &count);
232 printf("ret=%d,count=%d\n", ret, count);
233 if (!(ret && static_cast<unsigned int>(count) >= 1))
234 {
235 printf("Failed to eglChooseConfig\n");
236 return false;
237 }
238 EGLint red, green, blue, alpha, depth, stencil, samples;
239 eglGetConfigAttrib(eglDisplay_, config_, EGL_RED_SIZE, &red);
240 eglGetConfigAttrib(eglDisplay_, config_, EGL_GREEN_SIZE, &green);
241 eglGetConfigAttrib(eglDisplay_, config_, EGL_BLUE_SIZE, &blue);
242 eglGetConfigAttrib(eglDisplay_, config_, EGL_ALPHA_SIZE, &alpha);
243 eglGetConfigAttrib(eglDisplay_, config_, EGL_DEPTH_SIZE, &depth);
244 eglGetConfigAttrib(eglDisplay_, config_, EGL_STENCIL_SIZE, &stencil);
245 eglGetConfigAttrib(eglDisplay_, config_, EGL_SAMPLES, &samples);
246 ShowConfig(config_);
247 if (pixelFormat_.redBits == -1)
248 {
249 pixelFormat_.redBits = red;
250 }
251 else if (pixelFormat_.redBits != red)
252 {
253 printf("Failed to eglChooseConfig redBits %d != %d\n", pixelFormat_.redBits, red);
254 return false;
255 }
256
257 if (pixelFormat_.greenBits == -1)
258 {
259 pixelFormat_.greenBits = green;
260 }
261 else if (pixelFormat_.greenBits != green)
262 {
263 printf("Failed to eglChooseConfig redBits %d != %d\n", pixelFormat_.greenBits, green);
264 return false;
265 }
266
267 if (pixelFormat_.blueBits != blue)
268 {
269 if (pixelFormat_.blueBits != -1)
270 printf("Failed to eglChooseConfig blueBits %d != %d\n", pixelFormat_.blueBits, blue);
271 pixelFormat_.blueBits = blue;
272 }
273
274 if (pixelFormat_.alphaBits != alpha)
275 {
276 if (pixelFormat_.alphaBits != -1)
277 printf("Failed to eglChooseConfig alphaBits %d != %d\n", pixelFormat_.alphaBits, alpha);
278 pixelFormat_.alphaBits = alpha;
279 }
280
281 if (pixelFormat_.depthBits != depth)
282 {
283 if (pixelFormat_.depthBits != -1)
284 printf("Failed to eglChooseConfig depthBits %d != %d\n", pixelFormat_.depthBits, depth);
285 pixelFormat_.depthBits = depth;
286 }
287
288 if (pixelFormat_.stencilBits != stencil)
289 {
290 if (pixelFormat_.stencilBits != -1)
291 printf("Failed to eglChooseConfig stencilBits %d != %d\n", pixelFormat_.stencilBits, stencil);
292 pixelFormat_.stencilBits = stencil;
293 }
294
295 if (pixelFormat_.numSamples != samples)
296 {
297 if (pixelFormat_.numSamples != -1)
298 printf("Failed to eglChooseConfig numSamples %d != %d\n", pixelFormat_.numSamples, samples);
299 pixelFormat_.numSamples = samples;
300 }
301 printf("config ok\n");
302 return true;
303 }
304
InitNativeWindow()305 bool RosenContextImpl::InitNativeWindow()
306 {
307 if (nativeWindow_ == nullptr)
308 {
309 nativeWindow_ = CreateNativeWindowFromSurface(&producer_);
310 }
311 NativeWindowHandleOpt(nativeWindow_, SET_BUFFER_GEOMETRY, width_, height_);
312 if (pixelFormat_.stencilBits != -1)
313 {
314 NativeWindowHandleOpt(nativeWindow_, SET_STRIDE, pixelFormat_.stencilBits);
315 }
316 if (pixelFormat_.redBits == 8 && pixelFormat_.greenBits == 8 && pixelFormat_.blueBits == 8 && pixelFormat_.alphaBits == 8)
317 {
318 NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGBA_8888);
319 // NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, PIXEL_FMT_RGBA_8888);
320 }
321 else if (pixelFormat_.redBits == 5 && pixelFormat_.greenBits == 6 && pixelFormat_.blueBits == 5 && pixelFormat_.alphaBits == 0)
322 {
323 NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGB_565);
324 // NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, PIXEL_FMT_RGB_565);
325 }
326 else if (pixelFormat_.redBits == 4 && pixelFormat_.greenBits == 4 && pixelFormat_.blueBits == 4 && pixelFormat_.alphaBits == 4)
327 {
328 NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGBA_4444);
329 // NativeWindowHandleOpt(nativeWindow_, SET_FORMAT, PIXEL_FMT_RGBA_4444);
330 }
331 printf("native window ok\n");
332 return true;
333 }
334
InitEglSurface()335 bool RosenContextImpl::InitEglSurface()
336 {
337 if (eglSurface_ != EGL_NO_SURFACE)
338 {
339 eglDestroySurface(eglDisplay_, eglSurface_);
340 eglSurface_ = EGL_NO_SURFACE;
341 }
342
343 eglMakeCurrent(eglDisplay_, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
344
345 std::vector<EGLint> surfaceAttribs;
346
347 switch (surfaceType_)
348 {
349 case RCI_SURFACE_TYPE::NONE:
350 break;
351 case RCI_SURFACE_TYPE::WINDOW:
352 // surfaceAttribs.push_back(EGL_GL_COLORSPACE_KHR);
353 // TODO: EGL_GL_COLORSPACE_LINEAR_KHR, EGL_GL_COLORSPACE_SRGB_KHR
354 // surfaceAttribs.push_back(EGL_GL_COLORSPACE_LINEAR_KHR);
355 surfaceAttribs.push_back(EGL_NONE);
356
357 eglSurface_ = eglCreateWindowSurface(eglDisplay_, config_, nativeWindow_, &surfaceAttribs[0]);
358 if (eglSurface_ == EGL_NO_SURFACE)
359 {
360 printf("Failed to create eglsurface!!! %x\n", eglGetError());
361 return false;
362 }
363 break;
364 case RCI_SURFACE_TYPE::PBUFFER:
365 case RCI_SURFACE_TYPE::PIXMAP:
366 surfaceAttribs.push_back(EGL_WIDTH);
367 surfaceAttribs.push_back(width_);
368 surfaceAttribs.push_back(EGL_HEIGHT);
369 surfaceAttribs.push_back(height_);
370 surfaceAttribs.push_back(EGL_NONE);
371 break;
372 }
373 printf("egl surface ok\n");
374 return true;
375 }
376
InitEglContext()377 bool RosenContextImpl::InitEglContext()
378 {
379 if (eglContext_ != EGL_NO_CONTEXT)
380 {
381 eglDestroyContext(eglDisplay_, eglContext_);
382 eglContext_ = EGL_NO_CONTEXT;
383 }
384
385 std::vector<EGLint> contextAttribs;
386 contextAttribs.push_back(EGL_CONTEXT_MAJOR_VERSION_KHR);
387 contextAttribs.push_back(static_cast<int>(glesVersion_) / 10);
388 contextAttribs.push_back(EGL_CONTEXT_MINOR_VERSION_KHR);
389 contextAttribs.push_back(static_cast<int>(glesVersion_) % 10);
390
391 switch (typeProfile_)
392 {
393 case RCI_PROFILE::ES:
394 break;
395 case RCI_PROFILE::CORE:
396 contextAttribs.push_back(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
397 contextAttribs.push_back(EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR);
398 break;
399 case RCI_PROFILE::COMPATIBILITY:
400 contextAttribs.push_back(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR);
401 contextAttribs.push_back(EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR);
402 break;
403 }
404
405 EGLint flags = 0;
406 if ((static_cast<int>(contextFlags_) & static_cast<int>(RCI_CONTEXT_FLAG::DEBUG)) != 0)
407 flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
408
409 if ((static_cast<int>(contextFlags_) & static_cast<int>(RCI_CONTEXT_FLAG::ROBUST)) != 0)
410 flags |= EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR;
411
412 if ((static_cast<int>(contextFlags_) & static_cast<int>(RCI_CONTEXT_FLAG::FORWARD_COMPATIBLE)) != 0)
413 flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
414
415 contextAttribs.push_back(EGL_CONTEXT_FLAGS_KHR);
416 contextAttribs.push_back(flags);
417
418 contextAttribs.push_back(EGL_NONE);
419
420 eglContext_ = eglCreateContext(eglDisplay_, config_, EGL_NO_CONTEXT, &contextAttribs[0]);
421 if (eglContext_ == EGL_NO_CONTEXT)
422 {
423 printf("Failed to create egl context %x\n", eglGetError());
424 return false;
425 }
426 printf("context ok\n");
427 return true;
428 }
429
MakeCurrent()430 void RosenContextImpl::MakeCurrent()
431 {
432 if (!eglMakeCurrent(eglDisplay_, eglSurface_, eglSurface_, eglContext_))
433 {
434 printf("eglMakeCurrent FAIL\n");
435 }
436 }
437
SwapBuffer()438 void RosenContextImpl::SwapBuffer()
439 {
440 eglSwapBuffers(eglDisplay_, eglSurface_);
441 RSTransactionProxy::GetInstance()->FlushImplicitTransaction();
442 }
443
GetAttrib(int32_t attrType)444 int32_t RosenContextImpl::GetAttrib(int32_t attrType)
445 {
446 int32_t ret;
447 eglGetConfigAttrib(eglDisplay_, config_, attrType, &ret);
448 return ret;
449 }
450
CreateWindow(uint32_t x,uint32_t y,uint32_t width,uint32_t height)451 uint64_t RosenContextImpl::CreateWindow(uint32_t x, uint32_t y, uint32_t width, uint32_t height)
452 {
453 static uint64_t windowId = 1;
454 uint64_t wid = windowId++;
455
456 // printf("impl create window %llu\n",wid);
457 if (displayNode_ == nullptr)
458 {
459 displayNode_ = RSDisplayNode::Create(RSDisplayNodeConfig());
460 }
461 vulkanWindows_[wid].surfaceNode_ = RSSurfaceNode::Create(RSSurfaceNodeConfig());
462 vulkanWindows_[wid].surfaceNode_->SetBounds(x, y, width, height);
463 displayNode_->AddChild(vulkanWindows_[wid].surfaceNode_, -1);
464
465 std::shared_ptr<RSSurface> rsSurface = RSSurfaceExtractor::ExtractRSSurface(vulkanWindows_[wid].surfaceNode_);
466 std::shared_ptr<RSSurfaceOhosGl> rsSurfaceOhosGl = std::static_pointer_cast<RSSurfaceOhosGl>(rsSurface);
467 vulkanWindows_[wid].producer_ = rsSurfaceOhosGl->GetSurface();
468
469 vulkanWindows_[wid].nativeWindow_ = CreateNativeWindowFromSurface(&vulkanWindows_[wid].producer_);
470 NativeWindowHandleOpt(vulkanWindows_[wid].nativeWindow_, SET_BUFFER_GEOMETRY, width, height);
471
472 return wid;
473 }
474
GetNativeWindow(uint64_t windowId)475 void *RosenContextImpl::GetNativeWindow(uint64_t windowId)
476 {
477 // printf("impl get native window %llu\n",windowId);
478 return vulkanWindows_[windowId].nativeWindow_;
479 }
480
DestoryWindow(uint64_t windowId)481 void RosenContextImpl::DestoryWindow(uint64_t windowId)
482 {
483 // printf("impl destory window %llu\n",windowId);
484 displayNode_->RemoveChild(vulkanWindows_[windowId].surfaceNode_);
485 vulkanWindows_.erase(windowId);
486 }
487
OhosWindowResize(int32_t w,int32_t h)488 void RosenContextImpl::OhosWindowResize(int32_t w, int32_t h)
489 {
490 printf("RosenContextImpl::OhosWindowResize %d %d\n", w, h);
491 width_ = w;
492 height_ = h;
493 }
494
GetNativeWindowEx()495 void *RosenContextImpl::GetNativeWindowEx()
496 {
497 printf("RosenContextImpl::GetNativeWindowEx\n");
498 if (nativeWindow_ == nullptr)
499 {
500 nativeWindow_ = CreateNativeWindowFromSurface(&producer_);
501 }
502 if (width_ > 0 && height_ > 0)
503 {
504 NativeWindowHandleOpt(nativeWindow_, SET_BUFFER_GEOMETRY, width_, height_);
505 }
506
507 return nativeWindow_;
508 }
509
510 // implemented2_BEGIN
OH_bindAPI(uint32_t api)511 uint32_t RosenContextImpl::OH_bindAPI(uint32_t api)
512 {
513 auto ret = eglBindAPI(api);
514 // std::cout<<" ! bindAPI("<<"api="<<api<<")" << "=" << ret << std::endl;
515 return ret;
516 }
517
OH_bindTexImage(void * dpy,void * surface,int32_t buffer)518 uint32_t RosenContextImpl::OH_bindTexImage(void* dpy, void* surface, int32_t buffer)
519 {
520 auto ret = eglBindTexImage(dpy, surface, buffer);
521 // std::cout<<" ! bindTexImage("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"buffer="<<buffer<<")" << "=" << ret << std::endl;
522 return ret;
523 }
524
OH_chooseConfig(void * dpy,const int32_t * attrib_list,void ** configs,int32_t config_size,int32_t * num_config)525 uint32_t RosenContextImpl::OH_chooseConfig(void* dpy, const int32_t *attrib_list, void* *configs, int32_t config_size, int32_t *num_config)
526 {
527 auto ret = eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
528 // std::cout<<" ! chooseConfig("<<"dpy="<<dpy<<", "<<"attrib_list="<<attrib_list<<", "<<"configs="<<configs<<", "<<"config_size="<<config_size<<", "<<"num_config="<<num_config<<")" << "=" << ret << std::endl;
529 return ret;
530 }
531
OH_clientWaitSync(void * dpy,void * sync,int32_t flags,uint64_t timeout)532 int32_t RosenContextImpl::OH_clientWaitSync(void* dpy, void* sync, int32_t flags, uint64_t timeout)
533 {
534 auto ret = eglClientWaitSync(dpy, sync, flags, timeout);
535 // std::cout<<" ! clientWaitSync("<<"dpy="<<dpy<<", "<<"sync="<<sync<<", "<<"flags="<<flags<<", "<<"timeout="<<timeout<<")" << "=" << ret << std::endl;
536 return ret;
537 }
538
OH_clientWaitSyncKHR(void * dpy,void * sync,int32_t flags,uint64_t timeout)539 int32_t RosenContextImpl::OH_clientWaitSyncKHR(void* dpy, void* sync, int32_t flags, uint64_t timeout)
540 {
541 printf("eglClientWaitSyncKHR is not declared\n");
542 return 0;
543 }
544
OH_copyBuffers(void * dpy,void * surface,void * target)545 uint32_t RosenContextImpl::OH_copyBuffers(void* dpy, void* surface, void* target)
546 {
547 auto ret = eglCopyBuffers(dpy, surface, target);
548 // std::cout<<" ! copyBuffers("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"target="<<target<<")" << "=" << ret << std::endl;
549 return ret;
550 }
551
OH_createContext(void * dpy,void * config,void * share_context,const int32_t * attrib_list)552 void* RosenContextImpl::OH_createContext(void* dpy, void* config, void* share_context, const int32_t *attrib_list)
553 {
554 auto ret = eglCreateContext(dpy, config, share_context, attrib_list);
555 // std::cout<<" ! createContext("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"share_context="<<share_context<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
556 return ret;
557 }
558
OH_createImage(void * dpy,void * ctx,uint32_t target,void * buffer,const int * attrib_list)559 void* RosenContextImpl::OH_createImage(void* dpy, void* ctx, uint32_t target, void* buffer, const int *attrib_list)
560 {
561 auto ret = eglCreateImage(dpy, ctx, target, buffer, reinterpret_cast<const EGLAttrib *>(attrib_list));
562 // std::cout<<" ! createImage("<<"dpy="<<dpy<<", "<<"ctx="<<ctx<<", "<<"target="<<target<<", "<<"buffer="<<buffer<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
563 return ret;
564 }
565
OH_createImageKHR(void * dpy,void * ctx,uint32_t target,void * buffer,const int32_t * attrib_list)566 void* RosenContextImpl::OH_createImageKHR(void* dpy, void* ctx, uint32_t target, void* buffer, const int32_t *attrib_list)
567 {
568 printf("eglCreateImageKHR is not declared\n");
569 return 0;
570 }
571
OH_createPbufferFromClientBuffer(void * dpy,uint32_t buftype,void * buffer,void * config,const int32_t * attrib_list)572 void* RosenContextImpl::OH_createPbufferFromClientBuffer(void* dpy, uint32_t buftype, void* buffer, void* config, const int32_t *attrib_list)
573 {
574 auto ret = eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
575 // std::cout<<" ! createPbufferFromClientBuffer("<<"dpy="<<dpy<<", "<<"buftype="<<buftype<<", "<<"buffer="<<buffer<<", "<<"config="<<config<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
576 return ret;
577 }
578
OH_createPbufferSurface(void * dpy,void * config,const int32_t * attrib_list)579 void* RosenContextImpl::OH_createPbufferSurface(void* dpy, void* config, const int32_t *attrib_list)
580 {
581 auto ret = eglCreatePbufferSurface(dpy, config, attrib_list);
582 // std::cout<<" ! createPbufferSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
583 return ret;
584 }
585
OH_createPixmapSurface(void * dpy,void * config,void * pixmap,const int32_t * attrib_list)586 void* RosenContextImpl::OH_createPixmapSurface(void* dpy, void* config, void* pixmap, const int32_t *attrib_list)
587 {
588 auto ret = eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
589 // std::cout<<" ! createPixmapSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"pixmap="<<pixmap<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
590 return ret;
591 }
592
OH_createPlatformPixmapSurface(void * dpy,void * config,void * native_pixmap,const int * attrib_list)593 void* RosenContextImpl::OH_createPlatformPixmapSurface(void* dpy, void* config, void *native_pixmap, const int *attrib_list)
594 {
595 auto ret = eglCreatePlatformPixmapSurface(dpy, config, native_pixmap, reinterpret_cast<const EGLAttrib *>(attrib_list));
596 // std::cout<<" ! createPlatformPixmapSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"native_pixmap="<<native_pixmap<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
597 return ret;
598 }
599
OH_createPlatformPixmapSurfaceEXT(void * dpy,void * config,void * native_pixmap,const int32_t * attrib_list)600 void* RosenContextImpl::OH_createPlatformPixmapSurfaceEXT(void* dpy, void* config, void *native_pixmap, const int32_t *attrib_list)
601 {
602 printf("eglCreatePlatformPixmapSurfaceEXT is not declared\n");
603 return 0;
604 }
605
OH_createPlatformWindowSurface(void * dpy,void * config,void * native_window,const int * attrib_list)606 void* RosenContextImpl::OH_createPlatformWindowSurface(void* dpy, void* config, void *native_window, const int *attrib_list)
607 {
608 auto ret = eglCreatePlatformWindowSurface(dpy, config, native_window, reinterpret_cast<const EGLAttrib *>(attrib_list));
609 // std::cout<<" ! createPlatformWindowSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"native_window="<<native_window<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
610 return ret;
611 }
612
OH_createPlatformWindowSurfaceEXT(void * dpy,void * config,void * native_window,const int32_t * attrib_list)613 void* RosenContextImpl::OH_createPlatformWindowSurfaceEXT(void* dpy, void* config, void *native_window, const int32_t *attrib_list)
614 {
615 printf("eglCreatePlatformWindowSurfaceEXT is not declared\n");
616 return 0;
617 }
618
OH_createSync(void * dpy,uint32_t type,const int * attrib_list)619 void* RosenContextImpl::OH_createSync(void* dpy, uint32_t type, const int *attrib_list)
620 {
621 auto ret = eglCreateSync(dpy, type, reinterpret_cast<const EGLAttrib *>(attrib_list));
622 // std::cout<<" ! createSync("<<"dpy="<<dpy<<", "<<"type="<<type<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
623 return ret;
624 }
625
OH_createSyncKHR(void * dpy,uint32_t type,const int32_t * attrib_list)626 void* RosenContextImpl::OH_createSyncKHR(void* dpy, uint32_t type, const int32_t *attrib_list)
627 {
628 printf("eglCreateSyncKHR is not declared\n");
629 return 0;
630 }
631
OH_createWindowSurface(void * dpy,void * config,void * win,const int32_t * attrib_list)632 void* RosenContextImpl::OH_createWindowSurface(void* dpy, void* config, void* win, const int32_t *attrib_list)
633 {
634 EGLint red, green, blue, alpha, stencil;
635 eglGetConfigAttrib(dpy, config, EGL_RED_SIZE, &red);
636 eglGetConfigAttrib(dpy, config, EGL_GREEN_SIZE, &green);
637 eglGetConfigAttrib(dpy, config, EGL_BLUE_SIZE, &blue);
638 eglGetConfigAttrib(dpy, config, EGL_ALPHA_SIZE, &alpha);
639 eglGetConfigAttrib(dpy, config, EGL_STENCIL_SIZE, &stencil);
640
641 NativeWindowHandleOpt(nativeWindow_, SET_STRIDE, stencil);
642 if (red == 8 && green == 8 && blue == 8 && alpha == 8)
643 {
644 NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGBA_8888);
645 }
646 else if (red == 8 && green == 8 && blue == 8 && alpha == 0)
647 {
648 NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGB_888);
649 }
650 else if (red == 5 && green == 6 && blue == 5 && alpha == 8)
651 {
652 NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGBA_5658);
653 }
654 else if (red == 5 && green == 6 && blue == 5 && alpha == 0)
655 {
656 NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGB_565);
657 }
658 else if (red == 4 && green == 4 && blue == 4 && alpha == 4)
659 {
660 NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGBA_4444);
661 }
662 else if (red == 4 && green == 4 && blue == 4 && alpha == 0)
663 {
664 NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGB_444);
665 }
666 else
667 {
668 printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
669 }
670 auto ret = eglCreateWindowSurface(dpy, config, (NativeWindow *)win, attrib_list);
671 // std::cout<<" ! createWindowSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"win="<<win<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
672 return ret;
673 }
674
OH_destroyContext(void * dpy,void * ctx)675 uint32_t RosenContextImpl::OH_destroyContext(void* dpy, void* ctx)
676 {
677 auto ret = eglDestroyContext(dpy, ctx);
678 // std::cout<<" ! destroyContext("<<"dpy="<<dpy<<", "<<"ctx="<<ctx<<")" << "=" << ret << std::endl;
679 return ret;
680 }
681
OH_destroyImage(void * dpy,void * image)682 uint32_t RosenContextImpl::OH_destroyImage(void* dpy, void* image)
683 {
684 auto ret = eglDestroyImage(dpy, image);
685 // std::cout<<" ! destroyImage("<<"dpy="<<dpy<<", "<<"image="<<image<<")" << "=" << ret << std::endl;
686 return ret;
687 }
688
OH_destroyImageKHR(void * dpy,void * image)689 uint32_t RosenContextImpl::OH_destroyImageKHR(void* dpy, void* image)
690 {
691 printf("eglDestroyImageKHR is not declared\n");
692 return 0;
693 }
694
OH_destroySurface(void * dpy,void * surface)695 uint32_t RosenContextImpl::OH_destroySurface(void* dpy, void* surface)
696 {
697 auto ret = eglDestroySurface(dpy, surface);
698 // std::cout<<" ! destroySurface("<<"dpy="<<dpy<<", "<<"surface="<<surface<<")" << "=" << ret << std::endl;
699 return ret;
700 }
701
OH_destroySync(void * dpy,void * sync)702 uint32_t RosenContextImpl::OH_destroySync(void* dpy, void* sync)
703 {
704 auto ret = eglDestroySync(dpy, sync);
705 // std::cout<<" ! destroySync("<<"dpy="<<dpy<<", "<<"sync="<<sync<<")" << "=" << ret << std::endl;
706 return ret;
707 }
708
OH_destroySyncKHR(void * dpy,void * sync)709 uint32_t RosenContextImpl::OH_destroySyncKHR(void* dpy, void* sync)
710 {
711 printf("eglDestroySyncKHR is not declared\n");
712 return 0;
713 }
714
OH_getConfigAttrib(void * dpy,void * config,int32_t attribute,int32_t * value)715 uint32_t RosenContextImpl::OH_getConfigAttrib(void* dpy, void* config, int32_t attribute, int32_t *value)
716 {
717 auto ret = eglGetConfigAttrib(dpy, config, attribute, value);
718 // std::cout<<" ! getConfigAttrib("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
719 return ret;
720 }
721
OH_getConfigs(void * dpy,void ** configs,int32_t config_size,int32_t * num_config)722 uint32_t RosenContextImpl::OH_getConfigs(void* dpy, void* *configs, int32_t config_size, int32_t *num_config)
723 {
724 auto ret = eglGetConfigs(dpy, configs, config_size, num_config);
725 // std::cout<<" ! getConfigs("<<"dpy="<<dpy<<", "<<"configs="<<configs<<", "<<"config_size="<<config_size<<", "<<"num_config="<<num_config<<")" << "=" << ret << std::endl;
726 return ret;
727 }
728
OH_getCurrentContext()729 void* RosenContextImpl::OH_getCurrentContext()
730 {
731 auto ret = eglGetCurrentContext();
732 // std::cout<<" ! getCurrentContext("<<")" << "=" << ret << std::endl;
733 return ret;
734 }
735
OH_getCurrentDisplay()736 void* RosenContextImpl::OH_getCurrentDisplay()
737 {
738 auto ret = eglGetCurrentDisplay();
739 // std::cout<<" ! getCurrentDisplay("<<")" << "=" << ret << std::endl;
740 return ret;
741 }
742
OH_getCurrentSurface(int32_t readdraw)743 void* RosenContextImpl::OH_getCurrentSurface(int32_t readdraw)
744 {
745 auto ret = eglGetCurrentSurface(readdraw);
746 // std::cout<<" ! getCurrentSurface("<<"readdraw="<<readdraw<<")" << "=" << ret << std::endl;
747 return ret;
748 }
749
OH_getDisplay(void * display_id)750 void* RosenContextImpl::OH_getDisplay(void* display_id)
751 {
752 auto ret = eglGetDisplay(display_id);
753 // std::cout<<" ! getDisplay("<<"display_id="<<display_id<<")" << "=" << ret << std::endl;
754 return ret;
755 }
756
OH_getError()757 int32_t RosenContextImpl::OH_getError()
758 {
759 auto ret = eglGetError();
760 // std::cout<<" ! getError("<<")" << "=" << ret << std::endl;
761 return ret;
762 }
763
OH_getPlatformDisplay(uint32_t platform,void * native_display,const int * attrib_list)764 void* RosenContextImpl::OH_getPlatformDisplay(uint32_t platform, void *native_display, const int *attrib_list)
765 {
766 auto ret = eglGetPlatformDisplay(platform, native_display, reinterpret_cast<const EGLAttrib *>(attrib_list));
767 // std::cout<<" ! getPlatformDisplay("<<"platform="<<platform<<", "<<"native_display="<<native_display<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
768 return ret;
769 }
770
OH_getPlatformDisplayEXT(uint32_t platform,void * native_display,const int32_t * attrib_list)771 void* RosenContextImpl::OH_getPlatformDisplayEXT(uint32_t platform, void *native_display, const int32_t *attrib_list)
772 {
773 printf("eglGetPlatformDisplayEXT is not declared\n");
774 return 0;
775 }
776
OH_getProcAddress(const char * procname)777 FunctionPointer RosenContextImpl::OH_getProcAddress(const char *procname)
778 {
779 auto ret = eglGetProcAddress(procname);
780 // std::cout<<" ! getProcAddress("<<"procname="<<procname<<")" << "=" << ret << std::endl;
781 return ret;
782 }
783
OH_getSyncAttrib(void * dpy,void * sync,int32_t attribute,int * value)784 uint32_t RosenContextImpl::OH_getSyncAttrib(void* dpy, void* sync, int32_t attribute, int *value)
785 {
786 auto ret = eglGetSyncAttrib(dpy, sync, attribute, reinterpret_cast<EGLAttrib *>(value));
787 // std::cout<<" ! getSyncAttrib("<<"dpy="<<dpy<<", "<<"sync="<<sync<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
788 return ret;
789 }
790
OH_getSyncAttribKHR(void * dpy,void * sync,int32_t attribute,int32_t * value)791 uint32_t RosenContextImpl::OH_getSyncAttribKHR(void* dpy, void* sync, int32_t attribute, int32_t *value)
792 {
793 printf("eglGetSyncAttribKHR is not declared\n");
794 return 0;
795 }
796
OH_initialize(void * dpy,int32_t * major,int32_t * minor)797 uint32_t RosenContextImpl::OH_initialize(void* dpy, int32_t *major, int32_t *minor)
798 {
799 auto ret = eglInitialize(dpy, major, minor);
800 // std::cout<<" ! initialize("<<"dpy="<<dpy<<", "<<"major="<<major<<", "<<"minor="<<minor<<")" << "=" << ret << std::endl;
801 return ret;
802 }
803
OH_lockSurfaceKHR(void * dpy,void * surface,const int32_t * attrib_list)804 uint32_t RosenContextImpl::OH_lockSurfaceKHR(void* dpy, void* surface, const int32_t *attrib_list)
805 {
806 printf("eglLockSurfaceKHR is not declared\n");
807 return 0;
808 }
809
OH_makeCurrent(void * dpy,void * draw,void * read,void * ctx)810 uint32_t RosenContextImpl::OH_makeCurrent(void* dpy, void* draw, void* read, void* ctx)
811 {
812 auto ret = eglMakeCurrent(dpy, draw, read, ctx);
813 // std::cout<<" ! makeCurrent("<<"dpy="<<dpy<<", "<<"draw="<<draw<<", "<<"read="<<read<<", "<<"ctx="<<ctx<<")" << "=" << ret << std::endl;
814 return ret;
815 }
816
OH_queryAPI()817 uint32_t RosenContextImpl::OH_queryAPI()
818 {
819 auto ret = eglQueryAPI();
820 // std::cout<<" ! queryAPI("<<")" << "=" << ret << std::endl;
821 return ret;
822 }
823
OH_queryContext(void * dpy,void * ctx,int32_t attribute,int32_t * value)824 uint32_t RosenContextImpl::OH_queryContext(void* dpy, void* ctx, int32_t attribute, int32_t *value)
825 {
826 auto ret = eglQueryContext(dpy, ctx, attribute, value);
827 // std::cout<<" ! queryContext("<<"dpy="<<dpy<<", "<<"ctx="<<ctx<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
828 return ret;
829 }
830
OH_queryString(void * dpy,int32_t name)831 const char* RosenContextImpl::OH_queryString(void* dpy, int32_t name)
832 {
833 auto ret = eglQueryString(dpy, name);
834 // std::cout<<" ! queryString("<<"dpy="<<dpy<<", "<<"name="<<name<<")" << "=" << ret << std::endl;
835 return ret;
836 }
837
OH_querySurface(void * dpy,void * surface,int32_t attribute,int32_t * value)838 uint32_t RosenContextImpl::OH_querySurface(void* dpy, void* surface, int32_t attribute, int32_t *value)
839 {
840 auto ret = eglQuerySurface(dpy, surface, attribute, value);
841 // std::cout<<" ! querySurface("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
842 return ret;
843 }
844
OH_releaseTexImage(void * dpy,void * surface,int32_t buffer)845 uint32_t RosenContextImpl::OH_releaseTexImage(void* dpy, void* surface, int32_t buffer)
846 {
847 auto ret = eglReleaseTexImage(dpy, surface, buffer);
848 // std::cout<<" ! releaseTexImage("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"buffer="<<buffer<<")" << "=" << ret << std::endl;
849 return ret;
850 }
851
OH_releaseThread()852 uint32_t RosenContextImpl::OH_releaseThread()
853 {
854 auto ret = eglReleaseThread();
855 // std::cout<<" ! releaseThread("<<")" << "=" << ret << std::endl;
856 return ret;
857 }
858
OH_setDamageRegionKHR(void * dpy,void * surface,int32_t * rects,int32_t n_rects)859 uint32_t RosenContextImpl::OH_setDamageRegionKHR(void* dpy, void* surface, int32_t *rects, int32_t n_rects)
860 {
861 printf("eglSetDamageRegionKHR is not declared\n");
862 return 0;
863 }
864
OH_signalSyncKHR(void * dpy,void * sync,uint32_t mode)865 uint32_t RosenContextImpl::OH_signalSyncKHR(void* dpy, void* sync, uint32_t mode)
866 {
867 printf("eglSignalSyncKHR is not declared\n");
868 return 0;
869 }
870
OH_surfaceAttrib(void * dpy,void * surface,int32_t attribute,int32_t value)871 uint32_t RosenContextImpl::OH_surfaceAttrib(void* dpy, void* surface, int32_t attribute, int32_t value)
872 {
873 auto ret = eglSurfaceAttrib(dpy, surface, attribute, value);
874 // std::cout<<" ! surfaceAttrib("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
875 return ret;
876 }
877
OH_swapBuffers(void * dpy,void * surface)878 uint32_t RosenContextImpl::OH_swapBuffers(void* dpy, void* surface)
879 {
880 auto ret = eglSwapBuffers(dpy, surface);
881 // std::cout<<" ! swapBuffers("<<"dpy="<<dpy<<", "<<"surface="<<surface<<")" << "=" << ret << std::endl;
882 return ret;
883 }
884
OH_swapBuffersWithDamageKHR(void * dpy,void * surface,int32_t * rects,int32_t n_rects)885 uint32_t RosenContextImpl::OH_swapBuffersWithDamageKHR(void* dpy, void* surface, int32_t *rects, int32_t n_rects)
886 {
887 printf("eglSwapBuffersWithDamageKHR is not declared\n");
888 return 0;
889 }
890
OH_swapInterval(void * dpy,int32_t interval)891 uint32_t RosenContextImpl::OH_swapInterval(void* dpy, int32_t interval)
892 {
893 auto ret = eglSwapInterval(dpy, interval);
894 // std::cout<<" ! swapInterval("<<"dpy="<<dpy<<", "<<"interval="<<interval<<")" << "=" << ret << std::endl;
895 return ret;
896 }
897
OH_terminate(void * dpy)898 uint32_t RosenContextImpl::OH_terminate(void* dpy)
899 {
900 auto ret = eglTerminate(dpy);
901 // std::cout<<" ! terminate("<<"dpy="<<dpy<<")" << "=" << ret << std::endl;
902 return ret;
903 }
904
OH_unlockSurfaceKHR(void * dpy,void * surface)905 uint32_t RosenContextImpl::OH_unlockSurfaceKHR(void* dpy, void* surface)
906 {
907 printf("eglUnlockSurfaceKHR is not declared\n");
908 return 0;
909 }
910
OH_waitClient()911 uint32_t RosenContextImpl::OH_waitClient()
912 {
913 auto ret = eglWaitClient();
914 // std::cout<<" ! waitClient("<<")" << "=" << ret << std::endl;
915 return ret;
916 }
917
OH_waitGL()918 uint32_t RosenContextImpl::OH_waitGL()
919 {
920 auto ret = eglWaitGL();
921 // std::cout<<" ! waitGL("<<")" << "=" << ret << std::endl;
922 return ret;
923 }
924
OH_waitNative(int32_t engine)925 uint32_t RosenContextImpl::OH_waitNative(int32_t engine)
926 {
927 auto ret = eglWaitNative(engine);
928 // std::cout<<" ! waitNative("<<"engine="<<engine<<")" << "=" << ret << std::endl;
929 return ret;
930 }
931
OH_waitSync(void * dpy,void * sync,int32_t flags)932 uint32_t RosenContextImpl::OH_waitSync(void* dpy, void* sync, int32_t flags)
933 {
934 auto ret = eglWaitSync(dpy, sync, flags);
935 // std::cout<<" ! waitSync("<<"dpy="<<dpy<<", "<<"sync="<<sync<<", "<<"flags="<<flags<<")" << "=" << ret << std::endl;
936 return ret;
937 }
938
OH_waitSyncKHR(void * dpy,void * sync,int32_t flags)939 int32_t RosenContextImpl::OH_waitSyncKHR(void* dpy, void* sync, int32_t flags)
940 {
941 printf("eglWaitSyncKHR is not declared\n");
942 return 0;
943 }
944
945 // implemented2_END