2 * Copyright (c) 2015 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 "render-surface-wl.h"
23 #include <dali/integration-api/gl-abstraction.h>
24 #include <dali/integration-api/debug.h>
29 #include <base/separate-update-render/thread-synchronization.h>
30 #include <gl/egl-implementation.h>
31 #include <trigger-event.h>
32 #include <base/interfaces/window-event-interface.h>
33 #include <wayland-manager.h>
42 RenderSurface::RenderSurface(Dali::PositionSize positionSize,
44 const std::string& name,
46 : mRenderNotification(NULL),
47 mColorDepth(isTransparent ? COLOR_DEPTH_32 : COLOR_DEPTH_24)
49 mWindow.mPosition = positionSize;
50 mWindow.mTitle = name;
51 mWaylandManager = new Dali::Internal::Adaptor::WaylandManager;
52 mWaylandManager->Initialise();
55 RenderSurface::~RenderSurface()
57 delete mWaylandManager;
60 void RenderSurface::CreateSurface()
62 mWaylandManager->CreateSurface( mWindow );
65 Window* RenderSurface::GetWindow()
71 void RenderSurface::AssignWindowEventInterface( Dali::Internal::Adaptor::WindowEventInterface* eventInterface)
73 mWaylandManager->AssignWindowEventInterface( eventInterface );
76 PositionSize RenderSurface::GetPositionSize() const
78 return mWindow.mPosition;
81 void RenderSurface::InitializeEgl( EglInterface& egl )
83 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
85 if (!eglImpl.InitializeGles(static_cast<EGLNativeDisplayType>( mWaylandManager->mDisplay )))
87 DALI_LOG_ERROR("Failed to initialize GLES.");
90 eglImpl.ChooseConfig( true, mColorDepth );
93 void RenderSurface::CreateEglSurface( EglInterface& egl )
95 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
99 mEglWindow = wl_egl_window_create( mWaylandManager->GetSurface(), mWindow.mPosition.width, mWindow.mPosition.height);
101 eglImpl.CreateSurfaceWindow( (EGLNativeWindowType)mEglWindow, mColorDepth ); // reinterpret_cast does not compile
105 void RenderSurface::DestroyEglSurface( EglInterface& eglIf )
107 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
108 eglImpl.DestroySurface();
109 wl_egl_window_destroy( mEglWindow );
113 bool RenderSurface::ReplaceEGLSurface( EglInterface& egl )
118 void RenderSurface::MoveResize( Dali::PositionSize positionSize )
122 void RenderSurface::SetViewMode( ViewMode viewMode )
126 void RenderSurface::StartRender()
130 bool RenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
135 void RenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface )
137 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
138 eglImpl.SwapBuffers();
141 void RenderSurface::StopRender()
145 void RenderSurface::ReleaseLock()
148 void RenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
152 RenderSurface::Type RenderSurface::GetSurfaceType()
154 return RenderSurface::WAYLAND_RENDER_SURFACE;
157 } // namespace Wayland