• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     return wid;
471 }
472 
GetNativeWindow(uint64_t windowId)473 void *RosenContextImpl::GetNativeWindow(uint64_t windowId)
474 {
475     // printf("impl get native window %llu\n",windowId);
476     return vulkanWindows_[windowId].nativeWindow_;
477 }
478 
DestoryWindow(uint64_t windowId)479 void RosenContextImpl::DestoryWindow(uint64_t windowId)
480 {
481     // printf("impl destory window %llu\n",windowId);
482     displayNode_->RemoveChild(vulkanWindows_[windowId].surfaceNode_);
483     vulkanWindows_.erase(windowId);
484 }
485 
OhosWindowResize(int32_t w,int32_t h)486 void RosenContextImpl::OhosWindowResize(int32_t w, int32_t h)
487 {
488     printf("RosenContextImpl::OhosWindowResize %d %d\n", w, h);
489     width_ = w;
490     height_ = h;
491 }
492 
GetNativeWindowEx()493 void *RosenContextImpl::GetNativeWindowEx()
494 {
495     printf("RosenContextImpl::GetNativeWindowEx\n");
496     if (nativeWindow_ == nullptr)
497     {
498         nativeWindow_ = CreateNativeWindowFromSurface(&producer_);
499     }
500     if (width_ > 0 && height_ > 0)
501     {
502         NativeWindowHandleOpt(nativeWindow_, SET_BUFFER_GEOMETRY, width_, height_);
503     }
504 
505     return nativeWindow_;
506 }
507 
508 // implemented2_BEGIN
OH_bindAPI(uint32_t api)509 uint32_t RosenContextImpl::OH_bindAPI(uint32_t api)
510 {
511     auto ret = eglBindAPI(api);
512     // std::cout<<" ! bindAPI("<<"api="<<api<<")" << "=" << ret << std::endl;
513     return ret;
514 }
515 
OH_bindTexImage(void * dpy,void * surface,int32_t buffer)516 uint32_t RosenContextImpl::OH_bindTexImage(void* dpy, void* surface, int32_t buffer)
517 {
518     auto ret = eglBindTexImage(dpy, surface, buffer);
519     // std::cout<<" ! bindTexImage("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"buffer="<<buffer<<")" << "=" << ret << std::endl;
520     return ret;
521 }
522 
OH_chooseConfig(void * dpy,const int32_t * attrib_list,void ** configs,int32_t config_size,int32_t * num_config)523 uint32_t RosenContextImpl::OH_chooseConfig(void* dpy, const int32_t *attrib_list, void* *configs, int32_t config_size, int32_t *num_config)
524 {
525     auto ret = eglChooseConfig(dpy, attrib_list, configs, config_size, num_config);
526     // std::cout<<" ! chooseConfig("<<"dpy="<<dpy<<", "<<"attrib_list="<<attrib_list<<", "<<"configs="<<configs<<", "<<"config_size="<<config_size<<", "<<"num_config="<<num_config<<")" << "=" << ret << std::endl;
527     return ret;
528 }
529 
OH_clientWaitSync(void * dpy,void * sync,int32_t flags,uint64_t timeout)530 int32_t RosenContextImpl::OH_clientWaitSync(void* dpy, void* sync, int32_t flags, uint64_t timeout)
531 {
532     auto ret = eglClientWaitSync(dpy, sync, flags, timeout);
533     // std::cout<<" ! clientWaitSync("<<"dpy="<<dpy<<", "<<"sync="<<sync<<", "<<"flags="<<flags<<", "<<"timeout="<<timeout<<")" << "=" << ret << std::endl;
534     return ret;
535 }
536 
OH_clientWaitSyncKHR(void * dpy,void * sync,int32_t flags,uint64_t timeout)537 int32_t RosenContextImpl::OH_clientWaitSyncKHR(void* dpy, void* sync, int32_t flags, uint64_t timeout)
538 {
539     printf("eglClientWaitSyncKHR is not declared\n");
540     return 0;
541 }
542 
OH_copyBuffers(void * dpy,void * surface,void * target)543 uint32_t RosenContextImpl::OH_copyBuffers(void* dpy, void* surface, void* target)
544 {
545     auto ret = eglCopyBuffers(dpy, surface, target);
546     // std::cout<<" ! copyBuffers("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"target="<<target<<")" << "=" << ret << std::endl;
547     return ret;
548 }
549 
OH_createContext(void * dpy,void * config,void * share_context,const int32_t * attrib_list)550 void* RosenContextImpl::OH_createContext(void* dpy, void* config, void* share_context, const int32_t *attrib_list)
551 {
552     auto ret = eglCreateContext(dpy, config, share_context, attrib_list);
553     // std::cout<<" ! createContext("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"share_context="<<share_context<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
554     return ret;
555 }
556 
OH_createImage(void * dpy,void * ctx,uint32_t target,void * buffer,const int * attrib_list)557 void* RosenContextImpl::OH_createImage(void* dpy, void* ctx, uint32_t target, void* buffer, const int *attrib_list)
558 {
559     auto ret = eglCreateImage(dpy, ctx, target, buffer, reinterpret_cast<const EGLAttrib *>(attrib_list));
560     // std::cout<<" ! createImage("<<"dpy="<<dpy<<", "<<"ctx="<<ctx<<", "<<"target="<<target<<", "<<"buffer="<<buffer<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
561     return ret;
562 }
563 
OH_createImageKHR(void * dpy,void * ctx,uint32_t target,void * buffer,const int32_t * attrib_list)564 void* RosenContextImpl::OH_createImageKHR(void* dpy, void* ctx, uint32_t target, void* buffer, const int32_t *attrib_list)
565 {
566     printf("eglCreateImageKHR is not declared\n");
567     return 0;
568 }
569 
OH_createPbufferFromClientBuffer(void * dpy,uint32_t buftype,void * buffer,void * config,const int32_t * attrib_list)570 void* RosenContextImpl::OH_createPbufferFromClientBuffer(void* dpy, uint32_t buftype, void* buffer, void* config, const int32_t *attrib_list)
571 {
572     auto ret = eglCreatePbufferFromClientBuffer(dpy, buftype, buffer, config, attrib_list);
573     // std::cout<<" ! createPbufferFromClientBuffer("<<"dpy="<<dpy<<", "<<"buftype="<<buftype<<", "<<"buffer="<<buffer<<", "<<"config="<<config<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
574     return ret;
575 }
576 
OH_createPbufferSurface(void * dpy,void * config,const int32_t * attrib_list)577 void* RosenContextImpl::OH_createPbufferSurface(void* dpy, void* config, const int32_t *attrib_list)
578 {
579     auto ret = eglCreatePbufferSurface(dpy, config, attrib_list);
580     // std::cout<<" ! createPbufferSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
581     return ret;
582 }
583 
OH_createPixmapSurface(void * dpy,void * config,void * pixmap,const int32_t * attrib_list)584 void* RosenContextImpl::OH_createPixmapSurface(void* dpy, void* config, void* pixmap, const int32_t *attrib_list)
585 {
586     auto ret = eglCreatePixmapSurface(dpy, config, pixmap, attrib_list);
587     // std::cout<<" ! createPixmapSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"pixmap="<<pixmap<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
588     return ret;
589 }
590 
OH_createPlatformPixmapSurface(void * dpy,void * config,void * native_pixmap,const int * attrib_list)591 void* RosenContextImpl::OH_createPlatformPixmapSurface(void* dpy, void* config, void *native_pixmap, const int *attrib_list)
592 {
593     auto ret = eglCreatePlatformPixmapSurface(dpy, config, native_pixmap, reinterpret_cast<const EGLAttrib *>(attrib_list));
594     // std::cout<<" ! createPlatformPixmapSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"native_pixmap="<<native_pixmap<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
595     return ret;
596 }
597 
OH_createPlatformPixmapSurfaceEXT(void * dpy,void * config,void * native_pixmap,const int32_t * attrib_list)598 void* RosenContextImpl::OH_createPlatformPixmapSurfaceEXT(void* dpy, void* config, void *native_pixmap, const int32_t *attrib_list)
599 {
600     printf("eglCreatePlatformPixmapSurfaceEXT is not declared\n");
601     return 0;
602 }
603 
OH_createPlatformWindowSurface(void * dpy,void * config,void * native_window,const int * attrib_list)604 void* RosenContextImpl::OH_createPlatformWindowSurface(void* dpy, void* config, void *native_window, const int *attrib_list)
605 {
606     auto ret = eglCreatePlatformWindowSurface(dpy, config, native_window, reinterpret_cast<const EGLAttrib *>(attrib_list));
607     // std::cout<<" ! createPlatformWindowSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"native_window="<<native_window<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
608     return ret;
609 }
610 
OH_createPlatformWindowSurfaceEXT(void * dpy,void * config,void * native_window,const int32_t * attrib_list)611 void* RosenContextImpl::OH_createPlatformWindowSurfaceEXT(void* dpy, void* config, void *native_window, const int32_t *attrib_list)
612 {
613     printf("eglCreatePlatformWindowSurfaceEXT is not declared\n");
614     return 0;
615 }
616 
OH_createSync(void * dpy,uint32_t type,const int * attrib_list)617 void* RosenContextImpl::OH_createSync(void* dpy, uint32_t type, const int *attrib_list)
618 {
619     auto ret = eglCreateSync(dpy, type, reinterpret_cast<const EGLAttrib *>(attrib_list));
620     // std::cout<<" ! createSync("<<"dpy="<<dpy<<", "<<"type="<<type<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
621     return ret;
622 }
623 
OH_createSyncKHR(void * dpy,uint32_t type,const int32_t * attrib_list)624 void* RosenContextImpl::OH_createSyncKHR(void* dpy, uint32_t type, const int32_t *attrib_list)
625 {
626     printf("eglCreateSyncKHR is not declared\n");
627     return 0;
628 }
629 
OH_createWindowSurface(void * dpy,void * config,void * win,const int32_t * attrib_list)630 void* RosenContextImpl::OH_createWindowSurface(void* dpy, void* config, void* win, const int32_t *attrib_list)
631 {
632     EGLint red, green, blue, alpha, stencil;
633     eglGetConfigAttrib(dpy, config, EGL_RED_SIZE, &red);
634     eglGetConfigAttrib(dpy, config, EGL_GREEN_SIZE, &green);
635     eglGetConfigAttrib(dpy, config, EGL_BLUE_SIZE, &blue);
636     eglGetConfigAttrib(dpy, config, EGL_ALPHA_SIZE, &alpha);
637     eglGetConfigAttrib(dpy, config, EGL_STENCIL_SIZE, &stencil);
638 
639     NativeWindowHandleOpt(nativeWindow_, SET_STRIDE, stencil);
640     if (red == 8 && green == 8 && blue == 8 && alpha == 8)
641     {
642         NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGBA_8888);
643     }
644     else if (red == 8 && green == 8 && blue == 8 && alpha == 0)
645     {
646         NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGB_888);
647     }
648     else if (red == 5 && green == 6 && blue == 5 && alpha == 8)
649     {
650         NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGBA_5658);
651     }
652     else if (red == 5 && green == 6 && blue == 5 && alpha == 0)
653     {
654         NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGB_565);
655     }
656     else if (red == 4 && green == 4 && blue == 4 && alpha == 4)
657     {
658         NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGBA_4444);
659     }
660     else if (red == 4 && green == 4 && blue == 4 && alpha == 0)
661     {
662         NativeWindowHandleOpt((OHNativeWindow *)win, SET_FORMAT, GRAPHIC_PIXEL_FMT_RGB_444);
663     }
664     else
665     {
666         printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
667     }
668     auto ret = eglCreateWindowSurface(dpy, config, (NativeWindow *)win, attrib_list);
669     // std::cout<<" ! createWindowSurface("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"win="<<win<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
670     return ret;
671 }
672 
OH_destroyContext(void * dpy,void * ctx)673 uint32_t RosenContextImpl::OH_destroyContext(void* dpy, void* ctx)
674 {
675     auto ret = eglDestroyContext(dpy, ctx);
676     // std::cout<<" ! destroyContext("<<"dpy="<<dpy<<", "<<"ctx="<<ctx<<")" << "=" << ret << std::endl;
677     return ret;
678 }
679 
OH_destroyImage(void * dpy,void * image)680 uint32_t RosenContextImpl::OH_destroyImage(void* dpy, void* image)
681 {
682     auto ret = eglDestroyImage(dpy, image);
683     // std::cout<<" ! destroyImage("<<"dpy="<<dpy<<", "<<"image="<<image<<")" << "=" << ret << std::endl;
684     return ret;
685 }
686 
OH_destroyImageKHR(void * dpy,void * image)687 uint32_t RosenContextImpl::OH_destroyImageKHR(void* dpy, void* image)
688 {
689     printf("eglDestroyImageKHR is not declared\n");
690     return 0;
691 }
692 
OH_destroySurface(void * dpy,void * surface)693 uint32_t RosenContextImpl::OH_destroySurface(void* dpy, void* surface)
694 {
695     auto ret = eglDestroySurface(dpy, surface);
696     // std::cout<<" ! destroySurface("<<"dpy="<<dpy<<", "<<"surface="<<surface<<")" << "=" << ret << std::endl;
697     return ret;
698 }
699 
OH_destroySync(void * dpy,void * sync)700 uint32_t RosenContextImpl::OH_destroySync(void* dpy, void* sync)
701 {
702     auto ret = eglDestroySync(dpy, sync);
703     // std::cout<<" ! destroySync("<<"dpy="<<dpy<<", "<<"sync="<<sync<<")" << "=" << ret << std::endl;
704     return ret;
705 }
706 
OH_destroySyncKHR(void * dpy,void * sync)707 uint32_t RosenContextImpl::OH_destroySyncKHR(void* dpy, void* sync)
708 {
709     printf("eglDestroySyncKHR is not declared\n");
710     return 0;
711 }
712 
OH_getConfigAttrib(void * dpy,void * config,int32_t attribute,int32_t * value)713 uint32_t RosenContextImpl::OH_getConfigAttrib(void* dpy, void* config, int32_t attribute, int32_t *value)
714 {
715     auto ret = eglGetConfigAttrib(dpy, config, attribute, value);
716     // std::cout<<" ! getConfigAttrib("<<"dpy="<<dpy<<", "<<"config="<<config<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
717     return ret;
718 }
719 
OH_getConfigs(void * dpy,void ** configs,int32_t config_size,int32_t * num_config)720 uint32_t RosenContextImpl::OH_getConfigs(void* dpy, void* *configs, int32_t config_size, int32_t *num_config)
721 {
722     auto ret = eglGetConfigs(dpy, configs, config_size, num_config);
723     // std::cout<<" ! getConfigs("<<"dpy="<<dpy<<", "<<"configs="<<configs<<", "<<"config_size="<<config_size<<", "<<"num_config="<<num_config<<")" << "=" << ret << std::endl;
724     return ret;
725 }
726 
OH_getCurrentContext()727 void* RosenContextImpl::OH_getCurrentContext()
728 {
729     auto ret = eglGetCurrentContext();
730     // std::cout<<" ! getCurrentContext("<<")" << "=" << ret << std::endl;
731     return ret;
732 }
733 
OH_getCurrentDisplay()734 void* RosenContextImpl::OH_getCurrentDisplay()
735 {
736     auto ret = eglGetCurrentDisplay();
737     // std::cout<<" ! getCurrentDisplay("<<")" << "=" << ret << std::endl;
738     return ret;
739 }
740 
OH_getCurrentSurface(int32_t readdraw)741 void* RosenContextImpl::OH_getCurrentSurface(int32_t readdraw)
742 {
743     auto ret = eglGetCurrentSurface(readdraw);
744     // std::cout<<" ! getCurrentSurface("<<"readdraw="<<readdraw<<")" << "=" << ret << std::endl;
745     return ret;
746 }
747 
OH_getDisplay(void * display_id)748 void* RosenContextImpl::OH_getDisplay(void* display_id)
749 {
750     auto ret = eglGetDisplay(display_id);
751     // std::cout<<" ! getDisplay("<<"display_id="<<display_id<<")" << "=" << ret << std::endl;
752     return ret;
753 }
754 
OH_getError()755 int32_t RosenContextImpl::OH_getError()
756 {
757     auto ret = eglGetError();
758     // std::cout<<" ! getError("<<")" << "=" << ret << std::endl;
759     return ret;
760 }
761 
OH_getPlatformDisplay(uint32_t platform,void * native_display,const int * attrib_list)762 void* RosenContextImpl::OH_getPlatformDisplay(uint32_t platform, void *native_display, const int *attrib_list)
763 {
764     auto ret = eglGetPlatformDisplay(platform, native_display, reinterpret_cast<const EGLAttrib *>(attrib_list));
765     // std::cout<<" ! getPlatformDisplay("<<"platform="<<platform<<", "<<"native_display="<<native_display<<", "<<"attrib_list="<<attrib_list<<")" << "=" << ret << std::endl;
766     return ret;
767 }
768 
OH_getPlatformDisplayEXT(uint32_t platform,void * native_display,const int32_t * attrib_list)769 void* RosenContextImpl::OH_getPlatformDisplayEXT(uint32_t platform, void *native_display, const int32_t *attrib_list)
770 {
771     printf("eglGetPlatformDisplayEXT is not declared\n");
772     return 0;
773 }
774 
OH_getProcAddress(const char * procname)775 FunctionPointer RosenContextImpl::OH_getProcAddress(const char *procname)
776 {
777     auto ret = eglGetProcAddress(procname);
778     // std::cout<<" ! getProcAddress("<<"procname="<<procname<<")" << "=" << ret << std::endl;
779     return ret;
780 }
781 
OH_getSyncAttrib(void * dpy,void * sync,int32_t attribute,int * value)782 uint32_t RosenContextImpl::OH_getSyncAttrib(void* dpy, void* sync, int32_t attribute, int *value)
783 {
784     auto ret = eglGetSyncAttrib(dpy, sync, attribute, reinterpret_cast<EGLAttrib *>(value));
785     // std::cout<<" ! getSyncAttrib("<<"dpy="<<dpy<<", "<<"sync="<<sync<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
786     return ret;
787 }
788 
OH_getSyncAttribKHR(void * dpy,void * sync,int32_t attribute,int32_t * value)789 uint32_t RosenContextImpl::OH_getSyncAttribKHR(void* dpy, void* sync, int32_t attribute, int32_t *value)
790 {
791     printf("eglGetSyncAttribKHR is not declared\n");
792     return 0;
793 }
794 
OH_initialize(void * dpy,int32_t * major,int32_t * minor)795 uint32_t RosenContextImpl::OH_initialize(void* dpy, int32_t *major, int32_t *minor)
796 {
797     auto ret = eglInitialize(dpy, major, minor);
798     // std::cout<<" ! initialize("<<"dpy="<<dpy<<", "<<"major="<<major<<", "<<"minor="<<minor<<")" << "=" << ret << std::endl;
799     return ret;
800 }
801 
OH_lockSurfaceKHR(void * dpy,void * surface,const int32_t * attrib_list)802 uint32_t RosenContextImpl::OH_lockSurfaceKHR(void* dpy, void* surface, const int32_t *attrib_list)
803 {
804     printf("eglLockSurfaceKHR is not declared\n");
805     return 0;
806 }
807 
OH_makeCurrent(void * dpy,void * draw,void * read,void * ctx)808 uint32_t RosenContextImpl::OH_makeCurrent(void* dpy, void* draw, void* read, void* ctx)
809 {
810     auto ret = eglMakeCurrent(dpy, draw, read, ctx);
811     // std::cout<<" ! makeCurrent("<<"dpy="<<dpy<<", "<<"draw="<<draw<<", "<<"read="<<read<<", "<<"ctx="<<ctx<<")" << "=" << ret << std::endl;
812     return ret;
813 }
814 
OH_queryAPI()815 uint32_t RosenContextImpl::OH_queryAPI()
816 {
817     auto ret = eglQueryAPI();
818     // std::cout<<" ! queryAPI("<<")" << "=" << ret << std::endl;
819     return ret;
820 }
821 
OH_queryContext(void * dpy,void * ctx,int32_t attribute,int32_t * value)822 uint32_t RosenContextImpl::OH_queryContext(void* dpy, void* ctx, int32_t attribute, int32_t *value)
823 {
824     auto ret = eglQueryContext(dpy, ctx, attribute, value);
825     // std::cout<<" ! queryContext("<<"dpy="<<dpy<<", "<<"ctx="<<ctx<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
826     return ret;
827 }
828 
OH_queryString(void * dpy,int32_t name)829 const char* RosenContextImpl::OH_queryString(void* dpy, int32_t name)
830 {
831     auto ret = eglQueryString(dpy, name);
832     // std::cout<<" ! queryString("<<"dpy="<<dpy<<", "<<"name="<<name<<")" << "=" << ret << std::endl;
833     return ret;
834 }
835 
OH_querySurface(void * dpy,void * surface,int32_t attribute,int32_t * value)836 uint32_t RosenContextImpl::OH_querySurface(void* dpy, void* surface, int32_t attribute, int32_t *value)
837 {
838     auto ret = eglQuerySurface(dpy, surface, attribute, value);
839     // std::cout<<" ! querySurface("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
840     return ret;
841 }
842 
OH_releaseTexImage(void * dpy,void * surface,int32_t buffer)843 uint32_t RosenContextImpl::OH_releaseTexImage(void* dpy, void* surface, int32_t buffer)
844 {
845     auto ret = eglReleaseTexImage(dpy, surface, buffer);
846     // std::cout<<" ! releaseTexImage("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"buffer="<<buffer<<")" << "=" << ret << std::endl;
847     return ret;
848 }
849 
OH_releaseThread()850 uint32_t RosenContextImpl::OH_releaseThread()
851 {
852     auto ret = eglReleaseThread();
853     // std::cout<<" ! releaseThread("<<")" << "=" << ret << std::endl;
854     return ret;
855 }
856 
OH_setDamageRegionKHR(void * dpy,void * surface,int32_t * rects,int32_t n_rects)857 uint32_t RosenContextImpl::OH_setDamageRegionKHR(void* dpy, void* surface, int32_t *rects, int32_t n_rects)
858 {
859     printf("eglSetDamageRegionKHR is not declared\n");
860     return 0;
861 }
862 
OH_signalSyncKHR(void * dpy,void * sync,uint32_t mode)863 uint32_t RosenContextImpl::OH_signalSyncKHR(void* dpy, void* sync, uint32_t mode)
864 {
865     printf("eglSignalSyncKHR is not declared\n");
866     return 0;
867 }
868 
OH_surfaceAttrib(void * dpy,void * surface,int32_t attribute,int32_t value)869 uint32_t RosenContextImpl::OH_surfaceAttrib(void* dpy, void* surface, int32_t attribute, int32_t value)
870 {
871     auto ret = eglSurfaceAttrib(dpy, surface, attribute, value);
872     // std::cout<<" ! surfaceAttrib("<<"dpy="<<dpy<<", "<<"surface="<<surface<<", "<<"attribute="<<attribute<<", "<<"value="<<value<<")" << "=" << ret << std::endl;
873     return ret;
874 }
875 
OH_swapBuffers(void * dpy,void * surface)876 uint32_t RosenContextImpl::OH_swapBuffers(void* dpy, void* surface)
877 {
878     auto ret = eglSwapBuffers(dpy, surface);
879     // std::cout<<" ! swapBuffers("<<"dpy="<<dpy<<", "<<"surface="<<surface<<")" << "=" << ret << std::endl;
880     return ret;
881 }
882 
OH_swapBuffersWithDamageKHR(void * dpy,void * surface,int32_t * rects,int32_t n_rects)883 uint32_t RosenContextImpl::OH_swapBuffersWithDamageKHR(void* dpy, void* surface, int32_t *rects, int32_t n_rects)
884 {
885     printf("eglSwapBuffersWithDamageKHR is not declared\n");
886     return 0;
887 }
888 
OH_swapInterval(void * dpy,int32_t interval)889 uint32_t RosenContextImpl::OH_swapInterval(void* dpy, int32_t interval)
890 {
891     auto ret = eglSwapInterval(dpy, interval);
892     // std::cout<<" ! swapInterval("<<"dpy="<<dpy<<", "<<"interval="<<interval<<")" << "=" << ret << std::endl;
893     return ret;
894 }
895 
OH_terminate(void * dpy)896 uint32_t RosenContextImpl::OH_terminate(void* dpy)
897 {
898     auto ret = eglTerminate(dpy);
899     // std::cout<<" ! terminate("<<"dpy="<<dpy<<")" << "=" << ret << std::endl;
900     return ret;
901 }
902 
OH_unlockSurfaceKHR(void * dpy,void * surface)903 uint32_t RosenContextImpl::OH_unlockSurfaceKHR(void* dpy, void* surface)
904 {
905     printf("eglUnlockSurfaceKHR is not declared\n");
906     return 0;
907 }
908 
OH_waitClient()909 uint32_t RosenContextImpl::OH_waitClient()
910 {
911     auto ret = eglWaitClient();
912     // std::cout<<" ! waitClient("<<")" << "=" << ret << std::endl;
913     return ret;
914 }
915 
OH_waitGL()916 uint32_t RosenContextImpl::OH_waitGL()
917 {
918     auto ret = eglWaitGL();
919     // std::cout<<" ! waitGL("<<")" << "=" << ret << std::endl;
920     return ret;
921 }
922 
OH_waitNative(int32_t engine)923 uint32_t RosenContextImpl::OH_waitNative(int32_t engine)
924 {
925     auto ret = eglWaitNative(engine);
926     // std::cout<<" ! waitNative("<<"engine="<<engine<<")" << "=" << ret << std::endl;
927     return ret;
928 }
929 
OH_waitSync(void * dpy,void * sync,int32_t flags)930 uint32_t RosenContextImpl::OH_waitSync(void* dpy, void* sync, int32_t flags)
931 {
932     auto ret = eglWaitSync(dpy, sync, flags);
933     // std::cout<<" ! waitSync("<<"dpy="<<dpy<<", "<<"sync="<<sync<<", "<<"flags="<<flags<<")" << "=" << ret << std::endl;
934     return ret;
935 }
936 
OH_waitSyncKHR(void * dpy,void * sync,int32_t flags)937 int32_t RosenContextImpl::OH_waitSyncKHR(void* dpy, void* sync, int32_t flags)
938 {
939     printf("eglWaitSyncKHR is not declared\n");
940     return 0;
941 }
942 
943 // implemented2_END