2 * Copyright (c) 2019 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/window-system/ubuntu-x11/display-connection-impl-x.h>
22 #include <dali/internal/system/linux/dali-ecore-x.h>
23 #include <dali/integration-api/debug.h>
26 #include <dali/internal/window-system/ubuntu-x11/pixmap-render-surface-ecore-x.h>
27 #include <dali/internal/graphics/gles/egl-graphics.h>
38 DisplayConnection* DisplayConnectionX11::New()
40 //DisplayConnection* pDisplayConnection(new DisplayConnection());
42 //return pDisplayConnection;
46 DisplayConnectionX11::DisplayConnectionX11()
47 : mGraphics( nullptr ),
52 DisplayConnectionX11::~DisplayConnectionX11()
56 XCloseDisplay(mDisplay);
60 Any DisplayConnectionX11::GetDisplay()
65 void DisplayConnectionX11::ConsumeEvents()
67 // check events so that we can flush the queue and avoid any potential memory leaks in X
68 // looping if events remain
72 // Check if there are any events in the queue
73 events = XEventsQueued(mDisplay, QueuedAfterFlush);
77 // Just flush event to prevent memory leak from event queue as the events get built up in
78 // memory but are only deleted when we retrieve them
80 XNextEvent(mDisplay, &ev);
86 bool DisplayConnectionX11::InitializeGraphics()
88 auto eglGraphics = static_cast<EglGraphics *>(mGraphics);
89 EglImplementation& eglImpl = eglGraphics->GetEglImplementation();
91 if (!eglImpl.InitializeGles(reinterpret_cast<EGLNativeDisplayType>(mDisplay)))
93 DALI_LOG_ERROR("Failed to initialize GLES.\n");
100 void DisplayConnectionX11::SetSurfaceType( Integration::RenderSurface::Type type )
102 if( type == Integration::RenderSurface::WINDOW_RENDER_SURFACE )
104 // Because of DDK issue, we need to use separated x display instead of ecore default display
105 mDisplay = XOpenDisplay(0);
109 void DisplayConnectionX11::SetGraphicsInterface( GraphicsInterface& graphics )
111 mGraphics = &graphics;
114 } // namespace Adaptor
116 } // namespace Internal