2 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/graphics/gles/egl-graphics.h>
20 #include <dali/internal/window-system/tizen-wayland/display-connection-impl-ecore-wl.h>
23 #include <dali/integration-api/debug.h>
24 #include <tbm_dummy_display.h>
27 #include <Ecore_Wl2.h>
29 #include <Ecore_Wayland.h>
38 DisplayConnection* DisplayConnectionEcoreWl::New()
40 DisplayConnection* pDisplayConnection(new DisplayConnectionEcoreWl());
42 return pDisplayConnection;
45 DisplayConnectionEcoreWl::DisplayConnectionEcoreWl()
47 mSurfaceType(RenderSurfaceInterface::WINDOW_RENDER_SURFACE),
53 DisplayConnectionEcoreWl::~DisplayConnectionEcoreWl()
55 if(mSurfaceType == RenderSurfaceInterface::NATIVE_RENDER_SURFACE)
57 ReleaseNativeDisplay();
61 Any DisplayConnectionEcoreWl::GetDisplay()
66 void DisplayConnectionEcoreWl::ConsumeEvents()
70 bool DisplayConnectionEcoreWl::InitializeGraphics()
72 auto eglGraphics = static_cast<EglGraphics*>(mGraphics);
73 EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
75 if(!eglImpl.InitializeGles(mDisplay))
77 DALI_LOG_ERROR("Failed to initialize GLES.\n");
84 void DisplayConnectionEcoreWl::SetSurfaceType(Dali::RenderSurfaceInterface::Type type)
88 if(mSurfaceType == Dali::RenderSurfaceInterface::NATIVE_RENDER_SURFACE)
90 mDisplay = GetNativeDisplay();
95 Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
96 mDisplay = reinterpret_cast<EGLNativeDisplayType>(ecore_wl2_display_get(display));
98 mDisplay = reinterpret_cast<EGLNativeDisplayType>(ecore_wl_display_get());
103 void DisplayConnectionEcoreWl::SetGraphicsInterface(GraphicsInterface& graphics)
105 mGraphics = &graphics;
108 EGLNativeDisplayType DisplayConnectionEcoreWl::GetNativeDisplay()
110 mBufMgr = tbm_bufmgr_init(-1); // -1 is meaningless. The parameter in this function is deprecated.
111 if(mBufMgr == nullptr)
113 DALI_LOG_ERROR("Fail to init tbm buf mgr\n");
116 return reinterpret_cast<EGLNativeDisplayType>(tbm_dummy_display_create());
119 void DisplayConnectionEcoreWl::ReleaseNativeDisplay()
123 tbm_dummy_display_destroy(reinterpret_cast<tbm_dummy_display*>(mDisplay));
126 if(mBufMgr != nullptr)
128 tbm_bufmgr_deinit(mBufMgr);
132 } // namespace Adaptor
134 } // namespace Internal