Initial Version of LayerManagementService added.
[profile/ivi/layer-management.git] / LayerManagerPlugins / Renderers / Platform / X11GLESRenderer / src / X11GLESRenderer.cpp
1 /***************************************************************************
2 *
3 * Copyright 2010 BMW Car IT GmbH
4 *
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *               http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 ****************************************************************************/
19
20 #include "X11GLESRenderer.h"
21 #include "ShaderProgramGLES.h"
22 #include "GraphicSystems/GLESGraphicSystem.h"
23 #include "WindowSystems/X11WindowSystem.h"
24 #include "X11/Xlib.h"
25 #include "TextureBinders/X11CopyGLES.h"
26 #include "TextureBinders/X11EglImage.h"
27
28 X11GLESRenderer::X11GLESRenderer(LayerList* layerlist) : BaseRenderer(layerlist)
29 {
30         LOG_DEBUG("X11GLESRenderer", "Creating Renderer");
31
32         // if no binder has been set yet
33         Display* display = XOpenDisplay(0);
34         EGLDisplay m_eglDisplay = eglGetDisplay(display);
35         ITextureBinder* binder=NULL;
36         const char* query = eglQueryString(m_eglDisplay, EGL_EXTENSIONS);
37         LOG_DEBUG("X11GLESRenderer", "EGL_EXTENSIONS: " << query);
38         #ifdef EGL_NATIVE_PIXMAP_KHR
39                         binder = new X11EglImage((Display*)display);
40         #else
41                         binder = new X11CopyGLES((Display*)display);
42         #endif
43
44         BaseGraphicSystem* graphicSystem = new GLESGraphicsystem( ShaderProgramGLES::createProgram, binder);
45         m_windowSystem = new X11WindowSystem(layerlist, graphicSystem);
46 };
47
48 extern "C" BaseRenderer* createX11GLESRenderer(LayerList* layerlist){
49     return new X11GLESRenderer(layerlist);
50 }
51
52 extern "C" void destroyX11GLESRenderer(X11GLESRenderer* p){
53     delete p;
54 }