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