1 #ifndef __DALI_INTERNAL_RENDER_THREAD_H__
2 #define __DALI_INTERNAL_RENDER_THREAD_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <egl-interface.h>
26 #include <render-surface.h> // needed for Dali::RenderSurface
32 class DisplayConnection;
45 class AdaptorInternalServices;
46 class ThreadSynchronization;
47 class EglFactoryInterface;
48 class EnvironmentOptions;
55 REPLACE_SURFACE, // Request to replace surface
60 * @param[in] type The type of the request
62 RenderRequest( Request type );
65 * @return the type of the request
73 class ReplaceSurfaceRequest : public RenderRequest
80 ReplaceSurfaceRequest();
84 * @param[in] newSurface The new surface to use
86 void SetSurface(RenderSurface* newSurface);
89 * @return the new surface
91 RenderSurface* GetSurface();
94 * Called when the request has been completed to set the result.
96 void ReplaceCompleted();
99 * @return true if the replace has completed.
101 bool GetReplaceCompleted();
104 RenderSurface* mNewSurface; ///< The new surface to use.
105 unsigned int mReplaceCompleted; ///< Set to true when the replace has completed.
110 * The render-thread is responsible for calling Core::Render() after each update.
117 * Create the render-thread; this will not do anything until Start() is called.
118 * @param[in] sync thread synchronization object
119 * @param[in] adaptorInterfaces base adaptor interface
120 * @param[in] environmentOptions environment options
122 RenderThread( ThreadSynchronization& sync,
123 AdaptorInternalServices& adaptorInterfaces,
124 const EnvironmentOptions& environmentOptions );
134 * Starts the render-thread
139 * Stops the render-thread
143 private: // Render thread side helpers
146 * This method is used by the Render thread for rendering the Core to the screen.
147 * Called from render thread
148 * @return true, if the thread finishes properly.
154 * Called from render thread
156 void InitializeEgl();
159 * Check if main thread made any requests, e.g. ReplaceSurface
160 * Called from render thread
162 void ProcessRequest( RenderRequest* request );
165 * Replaces the rendering surface
166 * Used for replacing pixmaps due to resizing
167 * Called from render thread
168 * @param newSurface to use
170 void ReplaceSurface( RenderSurface* newSurface );
174 * Called from render thread
179 * Called before core renders the scene
180 * Called from render thread
181 * @return true if successful and Core::Render should be called.
186 * Called after core has rendered the scene
187 * Called from render thread
192 * Helper for the thread calling the entry function.
193 * @param[in] This A pointer to the current RenderThread object
195 static inline void* InternalThreadEntryFunc( void* This )
197 ( static_cast<RenderThread*>( This ) )->Run();
204 RenderThread( const RenderThread& renderThread );
207 RenderThread& operator=( const RenderThread& renderThread );
211 ThreadSynchronization& mThreadSynchronization; ///< Used to synchronize the all threads
212 Dali::Integration::Core& mCore; ///< Dali core reference
213 Integration::GlAbstraction& mGLES; ///< GL abstraction reference
214 EglFactoryInterface* mEglFactory; ///< Factory class to create EGL implementation
215 EglInterface* mEGL; ///< Interface to EGL implementation
216 pthread_t* mThread; ///< render thread
217 RenderSurface* mSurface; ///< Current surface
218 Dali::DisplayConnection* mDisplayConnection; ///< Display connection
219 const EnvironmentOptions& mEnvironmentOptions; ///< Environment options
220 bool mSurfaceReplaced; ///< True when new surface has been initialzed.
223 } // namespace Adaptor
225 } // namespace Internal
229 #endif // __DALI_INTERNAL_RENDER_THREAD_H__