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),
50 mWindow.mPosition = positionSize;
51 mWindow.mTitle = name;
52 mWaylandManager = new Dali::Internal::Adaptor::WaylandManager;
53 mWaylandManager->Initialise();
56 RenderSurface::~RenderSurface()
58 delete mWaylandManager;
61 void RenderSurface::CreateSurface()
63 mWaylandManager->CreateSurface( mWindow );
66 Window* RenderSurface::GetWindow()
72 void RenderSurface::AssignWindowEventInterface( Dali::Internal::Adaptor::WindowEventInterface* eventInterface)
74 mWaylandManager->AssignWindowEventInterface( eventInterface );
77 PositionSize RenderSurface::GetPositionSize() const
79 return mWindow.mPosition;
82 void RenderSurface::InitializeEgl( EglInterface& egl )
84 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
86 if (!eglImpl.InitializeGles(static_cast<EGLNativeDisplayType>( mWaylandManager->mDisplay )))
88 DALI_LOG_ERROR("Failed to initialize GLES.\n");
91 eglImpl.ChooseConfig( true, mColorDepth );
94 void RenderSurface::CreateEglSurface( EglInterface& egl )
96 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
100 mEglWindow = wl_egl_window_create( mWaylandManager->GetSurface(), mWindow.mPosition.width, mWindow.mPosition.height);
102 eglImpl.CreateSurfaceWindow( (EGLNativeWindowType)mEglWindow, mColorDepth ); // reinterpret_cast does not compile
106 void RenderSurface::DestroyEglSurface( EglInterface& eglIf )
108 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( eglIf );
109 eglImpl.DestroySurface();
110 wl_egl_window_destroy( mEglWindow );
114 bool RenderSurface::ReplaceEGLSurface( EglInterface& egl )
119 void RenderSurface::MoveResize( Dali::PositionSize positionSize )
123 void RenderSurface::SetViewMode( ViewMode viewMode )
127 void RenderSurface::StartRender()
131 bool RenderSurface::PreRender( EglInterface&, Integration::GlAbstraction& )
136 void RenderSurface::PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface )
138 Internal::Adaptor::EglImplementation& eglImpl = static_cast<Internal::Adaptor::EglImplementation&>( egl );
139 eglImpl.SwapBuffers();
142 void RenderSurface::StopRender()
146 void RenderSurface::ReleaseLock()
149 void RenderSurface::SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )
153 RenderSurface::Type RenderSurface::GetSurfaceType()
155 return RenderSurface::WAYLAND_RENDER_SURFACE;
158 } // namespace Wayland