X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Frender-tasks%2Fscene-graph-render-task.h;h=15c0e4f91ae280ce5181ab49817ad10cb122701c;hb=79881246746f65474b24ea4fe14151ccef8df3f4;hp=0797dd3de108d595b5cb79970b287fe087dcb3b3;hpb=57d182fb519d68bc12b5078bf837f1f425d98721;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/render-tasks/scene-graph-render-task.h b/dali/internal/update/render-tasks/scene-graph-render-task.h index 0797dd3..15c0e4f 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task.h +++ b/dali/internal/update/render-tasks/scene-graph-render-task.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ #include #include #include +#include namespace Dali { @@ -49,11 +50,11 @@ class RenderMessageDispatcher; /** * RenderTasks describe how the Dali scene should be rendered. */ -class RenderTask : public PropertyOwner +class RenderTask : public PropertyOwner, public PropertyOwner::Observer { public: - enum State + enum State : uint8_t { RENDER_CONTINUOUSLY, ///< mRefreshRate > 0 RENDER_ONCE_WAITING_FOR_RESOURCES, ///< mRefreshRate = REFRESH_ONCE @@ -232,13 +233,13 @@ public: * Set the refresh-rate of the RenderTask. * @param[in] refreshRate The new refresh rate. */ - void SetRefreshRate( unsigned int refreshRate ); + void SetRefreshRate( uint32_t refreshRate ); /** * Retrieve the refresh-rate of the RenderTask. * @return The refresh rate. */ - unsigned int GetRefreshRate() const; + uint32_t GetRefreshRate() const; /** * Check if the render task is ready for rendering. @@ -277,7 +278,7 @@ public: /** * @return The number of times we have transited from RENDERED_ONCE to RENDERED_ONCE_AND_NOTIFIED state. */ - unsigned int GetRenderedOnceCounter() const; + uint32_t GetRenderedOnceCounter() const; /** * Retrieve the view-matrix; this is double buffered for input handling. @@ -310,10 +311,10 @@ public: * then this method will ensure that a GL sync object is created to track * when the rendering has finished. * - * @param[out] instruction to prepare * @param[in] updateBufferIndex The current update buffer index. + * @return instruction to prepare */ - void PrepareRenderInstruction( RenderInstruction& instruction, BufferIndex updateBufferIndex ); + RenderInstruction& PrepareRenderInstruction( BufferIndex updateBufferIndex ); /** * @return true if the view matrix has been updated during this or last frame @@ -326,22 +327,45 @@ public: */ void SetSyncRequired( bool requiresSync ); -private: + /** + * Retrieve the render instruction. + * @param[in] updateBufferIndex The current update buffer index. + * @return The render instruction + */ + RenderInstruction& GetRenderInstruction( BufferIndex updateBufferIndex ) + { + return mRenderInstruction[updateBufferIndex]; + } + +private: // from PropertyOwner::Observer /** - * Protected constructor. + * @copydoc PropertyOwner::Observer::PropertyOwnerConnected( PropertyOwner& owner ) */ - RenderTask(); + void PropertyOwnerConnected( PropertyOwner& owner ); - // Undefined - RenderTask(const RenderTask&); + /** + * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ) + */ + void PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner ); - // Undefined - RenderTask& operator=(const RenderTask&); + /** + * @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed( PropertyOwner& owner ) + */ + void PropertyOwnerDestroyed( PropertyOwner& owner ); + +private: + + void SetActiveStatus(); -private: // PropertyOwner + /** + * Constructor. + */ + RenderTask(); - virtual void ResetDefaultProperties( BufferIndex currentBufferIndex ); + // Undefined + RenderTask(const RenderTask&) = delete; + RenderTask& operator=(const RenderTask&) = delete; public: // Animatable Properties AnimatableProperty< Vector2 > mViewportPosition; ///< viewportPosition @@ -356,39 +380,42 @@ private: SceneGraph::Camera* mCamera; Render::FrameBuffer* mFrameBuffer; - bool mWaitingToRender:1; ///< True when an render once to FBO is waiting - bool mNotifyTrigger:1; ///< True if a render once render task has finished renderering - bool mExclusive: 1; ///< Whether the render task has exclusive access to the source actor (node in the scene graph implementation). - bool mClearEnabled: 1; ///< Whether previous results are cleared. - bool mCullMode: 1; ///< Whether renderers should be frustum culled + RenderInstruction mRenderInstruction[2]; ///< Owned double buffered render instruction. (Double buffered because this owns render commands for the currently drawn frame) + + uint32_t mRefreshRate; ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames + uint32_t mFrameCounter; ///< counter for rendering every N frames + uint32_t mRenderedOnceCounter;///< Incremented whenever state changes to RENDERED_ONCE_AND_NOTIFIED - State mState; ///< Render state. - unsigned int mRefreshRate; ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames - unsigned int mFrameCounter; ///< counter for rendering every N frames + State mState; ///< Render state. - unsigned int mRenderedOnceCounter; ///< Incremented whenever state changes to RENDERED_ONCE_AND_NOTIFIED - bool mRequiresSync; ///< Whether sync is needed to track the render + bool mRequiresSync:1; ///< Whether sync is needed to track the render + bool mActive:1; ///< True when the task is active, i.e. has valid source and camera + bool mWaitingToRender:1;///< True when an render once to FBO is waiting + bool mNotifyTrigger:1; ///< True if a render once render task has finished renderering + bool mExclusive:1; ///< Whether the render task has exclusive access to the source actor (node in the scene graph). + bool mClearEnabled:1; ///< Whether previous results are cleared. + bool mCullMode:1; ///< Whether renderers should be frustum culled }; // Messages for RenderTask -inline void SetFrameBufferMessage( EventThreadServices& eventThreadServices, RenderTask& task, Render::FrameBuffer* frameBuffer ) +inline void SetFrameBufferMessage( EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer ) { typedef MessageValue1< RenderTask, Render::FrameBuffer*> LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetFrameBuffer, frameBuffer ); } -inline void SetClearColorMessage( EventThreadServices& eventThreadServices, RenderTask& task, const Vector4& value ) +inline void SetClearColorMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value ) { typedef MessageDoubleBuffered1< RenderTask, Vector4 > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetClearColor, value ); @@ -399,46 +426,46 @@ inline void BakeClearColorMessage( EventThreadServices& eventThreadServices, con typedef MessageDoubleBuffered1< RenderTask, Vector4 > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::BakeClearColor, value ); } -inline void SetClearEnabledMessage( EventThreadServices& eventThreadServices, RenderTask& task, bool enabled ) +inline void SetClearEnabledMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled ) { typedef MessageValue1< RenderTask, bool > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetClearEnabled, enabled ); } -inline void SetCullModeMessage( EventThreadServices& eventThreadServices, RenderTask& task, bool mode ) +inline void SetCullModeMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool mode ) { typedef MessageValue1< RenderTask, bool > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetCullMode, mode ); } -inline void SetRefreshRateMessage( EventThreadServices& eventThreadServices, RenderTask& task, unsigned int refreshRate ) +inline void SetRefreshRateMessage( EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate ) { - typedef MessageValue1< RenderTask, unsigned int > LocalType; + typedef MessageValue1< RenderTask, uint32_t > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetRefreshRate, refreshRate ); } -inline void SetSourceNodeMessage( EventThreadServices& eventThreadServices, RenderTask& task, const Node* constNode ) +inline void SetSourceNodeMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode ) { // Scene graph thread can destroy this object. Node* node = const_cast< Node* >( constNode ); @@ -446,42 +473,42 @@ inline void SetSourceNodeMessage( EventThreadServices& eventThreadServices, Rend typedef MessageValue1< RenderTask, Node* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetSourceNode, node ); } -inline void SetCameraMessage( EventThreadServices& eventThreadServices, RenderTask& task, const Node* constNode, const Camera* constCamera ) +inline void SetCameraMessage( EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera ) { typedef MessageValue2< RenderTask, Node*, Camera* > LocalType; Node* node = const_cast< Node* >( constNode ); Camera* camera = const_cast< Camera* >( constCamera ); // Reserve memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetCamera, node, camera ); } -inline void SetExclusiveMessage( EventThreadServices& eventThreadServices, RenderTask& task, bool exclusive ) +inline void SetExclusiveMessage( EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive ) { typedef MessageValue1< RenderTask, bool > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetExclusive, exclusive ); } -inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, RenderTask& task, bool requiresSync ) +inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync ) { typedef MessageValue1< RenderTask, bool > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::SetSyncRequired, requiresSync ); @@ -492,7 +519,7 @@ inline void BakeViewportPositionMessage( EventThreadServices& eventThreadService typedef MessageDoubleBuffered1< RenderTask, Vector2 > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::BakeViewportPosition, value ); @@ -503,7 +530,7 @@ inline void BakeViewportSizeMessage( EventThreadServices& eventThreadServices, c typedef MessageDoubleBuffered1< RenderTask, Vector2 > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); // Construct message in the message queue memory; note that delete should not be called on the return value new (slot) LocalType( &task, &RenderTask::BakeViewportSize, value );