[Tizen] Fix to do not update state of render task in case of uploadOnly
[platform/core/uifw/dali-core.git] / dali / internal / common / core-impl.h
1 #ifndef DALI_INTERNAL_CORE_H
2 #define DALI_INTERNAL_CORE_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/devel-api/common/owner-container.h>
23 #include <dali/integration-api/context-notifier.h>
24 #include <dali/integration-api/core-enumerations.h>
25 #include <dali/integration-api/resource-policies.h>
26 #include <dali/internal/common/owner-pointer.h>
27 #include <dali/internal/event/animation/animation-playlist-declarations.h>
28 #include <dali/internal/event/common/object-registry-impl.h>
29 #include <dali/internal/event/common/scene-impl.h>
30 #include <dali/internal/event/common/stage-def.h>
31 #include <dali/public-api/common/dali-vector.h>
32 #include <dali/public-api/object/ref-object.h>
33
34 namespace Dali
35 {
36 namespace Graphics
37 {
38 class Controller;
39 }
40
41 namespace Integration
42 {
43 class Processor;
44 class RenderController;
45 class GlAbstraction;
46 class PlatformAbstraction;
47 class UpdateStatus;
48 class RenderStatus;
49 struct Event;
50 struct TouchEvent;
51 } // namespace Integration
52
53 namespace Internal
54 {
55 class NotificationManager;
56 class AnimationPlaylist;
57 class PropertyNotificationManager;
58 class EventProcessor;
59 class GestureEventProcessor;
60 class ShaderFactory;
61 class TouchResampler;
62 class RelayoutController;
63 class EventThreadServices;
64
65 namespace SceneGraph
66 {
67 class UpdateManager;
68 class RenderManager;
69 class DiscardQueue;
70 class RenderTaskProcessor;
71 } // namespace SceneGraph
72
73 /**
74  * Internal class for Dali::Integration::Core
75  */
76 class Core : public EventThreadServices
77 {
78 public:
79   /**
80    * Create and initialise a new Core instance
81    */
82   Core(Integration::RenderController&      renderController,
83        Integration::PlatformAbstraction&   platform,
84        Graphics::Controller&               graphicsController,
85        Integration::RenderToFrameBuffer    renderToFboEnabled,
86        Integration::DepthBufferAvailable   depthBufferAvailable,
87        Integration::StencilBufferAvailable stencilBufferAvailable,
88        Integration::PartialUpdateAvailable partialUpdateAvailable);
89
90   /**
91    * Destructor
92    */
93   ~Core() override;
94
95   /**
96    * @copydoc Dali::Integration::Core::Initialize()
97    */
98   void Initialize();
99
100   /**
101    * @copydoc Dali::Integration::Core::GetContextNotifier()
102    */
103   Integration::ContextNotifierInterface* GetContextNotifier();
104
105   /**
106    * @copydoc Dali::Integration::Core::ContextCreated()
107    */
108   void ContextCreated();
109
110   /**
111    * @copydoc Dali::Integration::Core::ContextDestroyed()
112    */
113   void ContextDestroyed();
114
115   /**
116    * @copydoc Dali::Integration::Core::RecoverFromContextLoss()
117    */
118   void RecoverFromContextLoss();
119
120   /**
121    * @copydoc Dali::Integration::Core::SetMinimumFrameTimeInterval(uint32_t)
122    */
123   void SetMinimumFrameTimeInterval(uint32_t interval);
124
125   /**
126    * @copydoc Dali::Integration::Core::Update()
127    */
128   void Update(float elapsedSeconds, uint32_t lastVSyncTimeMilliseconds, uint32_t nextVSyncTimeMilliseconds, Integration::UpdateStatus& status, bool renderToFboEnabled, bool isRenderingToFbo, bool uploadOnly);
129
130   /**
131    * @copydoc Dali::Integration::Core::PreRender()
132    */
133   void PreRender(Integration::RenderStatus& status, bool forceClear);
134
135   /**
136    * @copydoc Dali::Integration::Core::PreRender()
137    */
138   void PreRender(Integration::RenderStatus& status, Integration::Scene& scene, std::vector<Rect<int>>& damagedRects);
139
140   /**
141    * @copydoc Dali::Integration::Core::RenderScene()
142    */
143   void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo);
144
145   /**
146    * @copydoc Dali::Integration::Core::RenderScene()
147    */
148   void RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect<int>& clippingRect);
149
150   /**
151    * @copydoc Dali::Integration::Core::Render()
152    */
153   void PostRender();
154
155   /**
156    * @copydoc Dali::Integration::Core::SceneCreated()
157    */
158   void SceneCreated();
159
160   /**
161    * @copydoc Dali::Integration::Core::QueueEvent(const Integration::Event&)
162    */
163   void QueueEvent(const Integration::Event& event);
164
165   /**
166    * @copydoc Dali::Integration::Core::ProcessEvents()
167    */
168   void ProcessEvents();
169
170   /**
171    * @copydoc Dali::Integration::Core::GetMaximumUpdateCount()
172    */
173   uint32_t GetMaximumUpdateCount() const;
174
175   /**
176    * @copydoc Dali::Integration::Core::RegisterProcessor
177    */
178   void RegisterProcessor(Integration::Processor& processor, bool postProcessor = false);
179
180   /**
181    * @copydoc Dali::Integration::Core::UnregisterProcessor
182    */
183   void UnregisterProcessor(Dali::Integration::Processor& processor, bool postProcessor = false);
184
185   /**
186    * @copydoc Dali::Internal::ThreadLocalStorage::AddScene()
187    */
188   void AddScene(Scene* scene);
189
190   /**
191    * @copydoc Dali::Internal::ThreadLocalStorage::RemoveScene()
192    */
193   void RemoveScene(Scene* scene);
194
195   /**
196    * @brief Gets the Object registry.
197    * @return A reference to the object registry
198    */
199   ObjectRegistry& GetObjectRegistry() const;
200
201 public: // Implementation of EventThreadServices
202   /**
203    * @copydoc EventThreadServices::RegisterObject
204    */
205   void RegisterObject(BaseObject* object) override;
206
207   /**
208    * @copydoc EventThreadServices::UnregisterObject
209    */
210   void UnregisterObject(BaseObject* object) override;
211
212   /**
213    * @copydoc EventThreadServices::GetUpdateManager
214    */
215   SceneGraph::UpdateManager& GetUpdateManager() override;
216
217   /**
218    * @copydoc EventThreadServices::GetRenderController
219    */
220   Integration::RenderController& GetRenderController() override;
221
222   /**
223    * @copydoc EventThreadServices::ReserveMessageSlot
224    */
225   uint32_t* ReserveMessageSlot(uint32_t size, bool updateScene) override;
226
227   /**
228    * @copydoc EventThreadServices::GetEventBufferIndex
229    */
230   BufferIndex GetEventBufferIndex() const override;
231
232   /**
233    * @copydoc EventThreadServices::ForceNextUpdate
234    */
235   void ForceNextUpdate() override;
236
237   /**
238    * @copydoc EventThreadServices::IsNextUpdateForced
239    */
240   bool IsNextUpdateForced() override;
241
242 private:
243   /**
244    * Run each registered processor
245    */
246   void RunProcessors();
247
248   /**
249    * Run each registered postprocessor
250    */
251   void RunPostProcessors();
252
253   // for use by ThreadLocalStorage
254
255   /**
256    * Returns the current stage.
257    * @return A smart-pointer to the current stage.
258    */
259   StagePtr GetCurrentStage();
260
261   /**
262    * Returns the platform abstraction.
263    * @return A reference to the platform abstraction.
264    */
265   Integration::PlatformAbstraction& GetPlatform();
266
267   /**
268    * Returns the render manager.
269    * @return A reference to the render manager.
270    */
271   SceneGraph::RenderManager& GetRenderManager();
272
273   /**
274    * Returns the notification manager.
275    * @return A reference to the Notification Manager.
276    */
277   NotificationManager& GetNotificationManager();
278
279   /**
280    * Returns the Shader factory
281    * @return A reference to the Shader binary factory.
282    */
283   ShaderFactory& GetShaderFactory();
284
285   /**
286    * Returns the gesture event processor.
287    * @return A reference to the gesture event processor.
288    */
289   GestureEventProcessor& GetGestureEventProcessor();
290
291   /**
292    * Return the relayout controller
293    * @Return Return a reference to the relayout controller
294    */
295   RelayoutController& GetRelayoutController();
296
297   /**
298    * @brief Gets the event thread services.
299    * @return A reference to the event thread services
300    */
301   EventThreadServices& GetEventThreadServices();
302
303   /**
304    * @brief Gets the property notification manager.
305    * @return A reference to the property notification manager
306    */
307   PropertyNotificationManager& GetPropertyNotificationManager() const;
308
309   /**
310    * @brief Gets the animation play list.
311    * @return A reference to the animation play list
312    */
313   AnimationPlaylist& GetAnimationPlaylist() const;
314
315   /**
316    * @brief Returns GlAbstraction.
317    * @note Use only for the capability. Do not use this for bypass context
318    * @return GlAbstraction
319    */
320   Integration::GlAbstraction& GetGlAbstraction() const;
321
322 private:
323   /**
324    * Undefined copy and assignment operators
325    */
326   Core(const Core& core) = delete;            // No definition
327   Core& operator=(const Core& core) = delete; // No definition
328
329   /**
330    * Create Thread local storage
331    */
332   void CreateThreadLocalStorage();
333
334 private:
335   Integration::RenderController&    mRenderController; ///< Reference to Render controller to tell it to keep rendering
336   Integration::PlatformAbstraction& mPlatform;         ///< The interface providing platform specific services.
337
338   IntrusivePtr<Stage>                       mStage;                       ///< The current stage
339   AnimationPlaylistOwner                    mAnimationPlaylist;           ///< For 'Fire and forget' animation support
340   OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
341   IntrusivePtr<RelayoutController>          mRelayoutController;          ///< Size negotiation relayout controller
342
343   OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor;   ///< Handles the processing of render tasks
344   OwnerPointer<SceneGraph::RenderManager>       mRenderManager;         ///< Render manager
345   OwnerPointer<SceneGraph::UpdateManager>       mUpdateManager;         ///< Update manager
346   OwnerPointer<SceneGraph::DiscardQueue>        mDiscardQueue;          ///< Used to cleanup nodes & resources when no longer in use.
347   OwnerPointer<ShaderFactory>                   mShaderFactory;         ///< Shader resource factory
348   OwnerPointer<NotificationManager>             mNotificationManager;   ///< Notification manager
349   OwnerPointer<GestureEventProcessor>           mGestureEventProcessor; ///< The gesture event processor
350   Dali::Vector<Integration::Processor*>         mProcessors;            ///< Registered processors (not owned)
351   Dali::Vector<Integration::Processor*>         mPostProcessors;        ///< Registered post processors those will called after relayout(not owned)
352
353   using SceneContainer = std::vector<ScenePtr>;
354   SceneContainer mScenes; ///< A container of scenes that bound to a surface for rendering, owned by Core
355
356   // The object registry
357   ObjectRegistryPtr mObjectRegistry;
358
359   Graphics::Controller& mGraphicsController;
360
361   bool mProcessingEvent : 1; ///< True during ProcessEvents()
362   bool mForceNextUpdate : 1; ///< True if the next rendering is really required.
363
364   friend class ThreadLocalStorage;
365 };
366
367 } // namespace Internal
368
369 } // namespace Dali
370
371 #endif // DALI_INTERNAL_CORE_H