X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Fpublic-api%2Frender-tasks%2Frender-task.h;h=5d6be1ae82a5847ce5e42846e70a69a825f055b4;hb=HEAD;hp=87d5e35852aee6fcb372c21491b51f8db59eff37;hpb=f73f51a79fd0dc0e15d4c5d1f8258e7e03c1df74;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/public-api/render-tasks/render-task.h b/dali/public-api/render-tasks/render-task.h index 87d5e35..e00eea8 100644 --- a/dali/public-api/render-tasks/render-task.h +++ b/dali/public-api/render-tasks/render-task.h @@ -1,8 +1,8 @@ -#ifndef __DALI_RENDER_TASK_H__ -#define __DALI_RENDER_TASK_H__ +#ifndef DALI_RENDER_TASK_H +#define DALI_RENDER_TASK_H /* - * Copyright (c) 2015 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. @@ -18,6 +18,9 @@ * */ +// EXTERNAL INCLUDES +#include // uint32_t + // INTERNAL INCLUDES #include #include @@ -45,7 +48,7 @@ class RenderTask; /** * @brief RenderTasks describe how the Dali scene should be rendered. * - * The Stage::GetRenderTaskList() method provides access to an ordered list of render-tasks. + * The Scene provides access to an ordered list of render-tasks. * * Each RenderTask must specify the source actors to be rendered, and a camera actor from * which the scene is viewed. @@ -53,7 +56,7 @@ class RenderTask; * RenderTasks may optionally target a frame-buffer, otherwise the default GL surface is used; * typically this is a window provided by the native system. * - * By default Dali provides a single RenderTask, which renders the entire actor hierachy using + * By default Dali provides a single RenderTask, which renders the entire actor hierarchy using * a default camera actor and GL surface. If stereoscopic rendering is enabled, Dali will create * two additional render tasks, on for each eye. Each render task will have its own camera parented * to the default camera actor. @@ -81,10 +84,9 @@ class RenderTask; * | finished | @ref FinishedSignal() | * @SINCE_1_0.0 */ -class DALI_IMPORT_API RenderTask : public Handle +class DALI_CORE_API RenderTask : public Handle { public: - /** * @brief Enumeration for instances of properties belonging to the RenderTask class. * @SINCE_1_0.0 @@ -128,7 +130,7 @@ public: * @brief Typedef for signals sent by this class. * @SINCE_1_0.0 */ - typedef Signal< void (RenderTask& source) > RenderTaskSignalType; + using RenderTaskSignalType = Signal; /** * @brief A pointer to a function for converting screen to frame-buffer coordinates. @@ -136,7 +138,7 @@ public: * @param[in,out] coordinates The screen coordinates to convert where (0,0) is the top-left of the screen * @return True if the conversion was successful, otherwise coordinates should be unmodified */ - typedef bool (* ScreenToFrameBufferFunction)( Vector2& coordinates ); + using ScreenToFrameBufferFunction = bool (*)(Vector2&); /** * @brief A pointer to a function for converting screen to frame-buffer coordinates. @@ -144,7 +146,7 @@ public: * @param[in,out] coordinates The screen coordinates to convert where (0,0) is the top-left of the screen * @return True if the conversion was successful, otherwise coordinates should be unmodified */ - typedef bool (* const ConstScreenToFrameBufferFunction)( Vector2& coordinates ); + using ConstScreenToFrameBufferFunction = bool (*const)(Vector2&); /** * @brief The default conversion function returns false for any screen coordinates. @@ -171,12 +173,12 @@ public: REFRESH_ALWAYS = 1 ///< Process every frame. @SINCE_1_0.0 }; - static const bool DEFAULT_EXCLUSIVE; ///< false - static const bool DEFAULT_INPUT_ENABLED; ///< true - static const Vector4 DEFAULT_CLEAR_COLOR; ///< Color::BLACK - static const bool DEFAULT_CLEAR_ENABLED; ///< false - static const bool DEFAULT_CULL_MODE; ///< true - static const unsigned int DEFAULT_REFRESH_RATE; ///< REFRESH_ALWAYS + static const bool DEFAULT_EXCLUSIVE; ///< false + static const bool DEFAULT_INPUT_ENABLED; ///< true + static const Vector4 DEFAULT_CLEAR_COLOR; ///< Color::BLACK + static const bool DEFAULT_CLEAR_ENABLED; ///< false + static const bool DEFAULT_CULL_MODE; ///< true + static const uint32_t DEFAULT_REFRESH_RATE; ///< REFRESH_ALWAYS /** * @brief Creates an empty RenderTask handle. @@ -195,7 +197,7 @@ public: * @param[in] handle A handle to an object * @return A handle to a RenderTask or an uninitialized handle */ - static RenderTask DownCast( BaseHandle handle ); + static RenderTask DownCast(BaseHandle handle); /** * @brief Destructor. @@ -223,12 +225,29 @@ public: RenderTask& operator=(const RenderTask& rhs); /** + * @brief Move constructor. + * + * @SINCE_1_9.22 + * @param[in] rhs A reference to the moved handle + */ + RenderTask(RenderTask&& rhs) noexcept; + + /** + * @brief Move assignment operator. + * + * @SINCE_1_9.22 + * @param[in] rhs A reference to the moved handle + * @return A reference to this + */ + RenderTask& operator=(RenderTask&& rhs) noexcept; + + /** * @brief Sets the actors to be rendered. * @SINCE_1_0.0 * @param[in] actor This actor and its children will be rendered. * If actor is an empty handle, then nothing will be rendered */ - void SetSourceActor( Actor actor ); + void SetSourceActor(Actor actor); /** * @brief Retrieves the actors to be rendered. @@ -238,11 +257,18 @@ public: Actor GetSourceActor() const; /** + * @brief Retrives stopper actor. + * @SINCE_2_3.23 + * @return The actor that marks where to stop rendering. + */ + Actor GetStopperActor() const; + + /** * @brief Sets whether the RenderTask has exclusive access to the source actors; the default is false. * @SINCE_1_0.0 * @param[in] exclusive True if the source actors will only be rendered by this render-task */ - void SetExclusive( bool exclusive ); + void SetExclusive(bool exclusive); /** * @brief Queries whether the RenderTask has exclusive access to the source actors. @@ -261,7 +287,7 @@ public: * @SINCE_1_0.0 * @param[in] enabled True if the render-task should be considered for input handling */ - void SetInputEnabled( bool enabled ); + void SetInputEnabled(bool enabled); /** * @brief Queries whether the render-task should be considered for input handling. @@ -275,7 +301,7 @@ public: * @SINCE_1_0.0 * @param[in] cameraActor The scene is viewed from the perspective of this actor */ - void SetCameraActor( CameraActor cameraActor ); + void SetCameraActor(CameraActor cameraActor); /** * @brief Retrieves the actor from which the scene is viewed. @@ -286,24 +312,10 @@ public: /** * @brief Sets the frame-buffer used as a render target. - * @SINCE_1_0.0 - * @param[in] frameBuffer A valid frame-buffer handle to enable off-screen rendering, or an uninitialized handle to disable - */ - void SetTargetFrameBuffer( FrameBufferImage frameBuffer ); - - /** - * @brief Retrieves the frame-buffer used as a render target. - * @SINCE_1_0.0 - * @return A valid frame-buffer handle, or an uninitialised handle if off-screen rendering is disabled - */ - FrameBufferImage GetTargetFrameBuffer() const; - - /** - * @brief Sets the frame-buffer used as a render target. * @SINCE_1_1.38 - * @param[in] frameBuffer er A valid FrameBuffer handle to enable off-screen rendering, or an uninitialized handle to disable it + * @param[in] frameBuffer A valid FrameBuffer handle to enable off-screen rendering, or an uninitialized handle to disable it */ - void SetFrameBuffer( FrameBuffer frameBuffer ); + void SetFrameBuffer(FrameBuffer frameBuffer); /** * @brief Retrieves the frame-buffer used as a render target. @@ -319,7 +331,7 @@ public: * @SINCE_1_0.0 * @param[in] conversionFunction The conversion function */ - void SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction ); + void SetScreenToFrameBufferFunction(ScreenToFrameBufferFunction conversionFunction); /** * @brief Retrieves the function used to convert screen coordinates to frame-buffer coordinates. @@ -337,7 +349,7 @@ public: * @param[in] mappingActor The actor used for conversion * @note The mapping actor needs to be rendered by the default render task to make the mapping work properly. */ - void SetScreenToFrameBufferMappingActor( Actor mappingActor ); + void SetScreenToFrameBufferMappingActor(Actor mappingActor); /** * @brief Retrieves the actor used to convert screen coordinates to frame-buffer coordinates. @@ -347,6 +359,30 @@ public: Actor GetScreenToFrameBufferMappingActor() const; /** + * @brief Sets the actor to compute viewport of this render task. + * Actor should be added on Scene. + * @SINCE_2_1.36 + * @param[in] actor This actor is used to compute viewport of the render task. + * @note If window default camera is rotated and the actor is no longer a rectangle on the screen, Viewport may be computed incorrectly. + * The Viewport properties VIEWPORT_POSITION and VIEWPORT_SIZE is kept during using ViewportGuideActor, but only current value is changed. + */ + void SetViewportGuideActor(Actor actor); + + /** + * @brief Retrieves the actor to compute viewport of this render task. + * @SINCE_2_1.36 + * @return This actor is used to compute viewport of the render task. + */ + Actor GetViewportGuideActor() const; + + /** + * @brief Resets the actor to compute viewport of this render task. + * @SINCE_2_1.36 + * @note The Viewport properties VIEWPORT_POSITION and VIEWPORT_SIZE is still kept. + */ + void ResetViewportGuideActor(); + + /** * @brief Sets the GL viewport position used when rendering. * * This specifies the transformation between normalized device coordinates and target window (or frame-buffer) coordinates. @@ -355,7 +391,7 @@ public: * @param[in] position The viewports position (x,y) * @note Unlike the glViewport method, the x & y coordinates refer to the top-left of the viewport rectangle. */ - void SetViewportPosition( Vector2 position ); + void SetViewportPosition(Vector2 position); /** * @brief Retrieves the GL viewport position used when rendering. @@ -372,7 +408,7 @@ public: * @SINCE_1_0.0 * @param[in] size The viewports size (width,height) */ - void SetViewportSize( Vector2 size ); + void SetViewportSize(Vector2 size); /** * @brief Retrieves the GL viewport size used when rendering. @@ -390,7 +426,7 @@ public: * @param[in] viewport The new viewport * @note Unlike the glViewport method, the x & y coordinates refer to the top-left of the viewport rectangle. */ - void SetViewport( Viewport viewport ); + void SetViewport(Viewport viewport); /** * @brief Retrieves the GL viewport used when rendering. @@ -404,7 +440,7 @@ public: * @SINCE_1_0.0 * @param[in] color The new clear color */ - void SetClearColor( const Vector4& color ); + void SetClearColor(const Vector4& color); /** * @brief Retrieves the clear color used when SetClearEnabled(true) is used. @@ -427,7 +463,7 @@ public: * be (partially) cleared before rendering the second. * */ - void SetClearEnabled( bool enabled ); + void SetClearEnabled(bool enabled); /** * @brief Queries whether the render-task will clear the results of previous render-tasks. @@ -445,7 +481,7 @@ public: * @note If the shader uses @ref Shader::Hint::MODIFIES_GEOMETRY then culling optimizations are disabled. * @see Shader::Hint */ - void SetCullMode( bool cullMode ); + void SetCullMode(bool cullMode); /** * @brief Gets the cull mode. @@ -473,14 +509,14 @@ public: * @SINCE_1_0.0 * @param[in] refreshRate The new refresh rate */ - void SetRefreshRate( unsigned int refreshRate ); + void SetRefreshRate(uint32_t refreshRate); /** * @brief Queries the refresh-rate of the RenderTask. * @SINCE_1_0.0 * @return The refresh-rate */ - unsigned int GetRefreshRate() const; + uint32_t GetRefreshRate() const; /** * @brief Gets viewport coordinates for given world position. @@ -491,7 +527,7 @@ public: * @param[out] viewportY The viewport y position * @return true if the position has a screen coordinate */ - bool WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const; + bool WorldToViewport(const Vector3& position, float& viewportX, float& viewportY) const; /** * @brief Gets actor local coordinates for given viewport coordinates. @@ -504,11 +540,61 @@ public: * @param[out] localY The local y position * @return true if the screen position has a local coordinate */ - bool ViewportToLocal(Actor actor, float viewportX, float viewportY, float &localX, float &localY) const; + bool ViewportToLocal(Actor actor, float viewportX, float viewportY, float& localX, float& localY) const; -public: // Signals + /** + * Sets Render Pass key for this RenderTask. + * Shader code that matches this render pass is used for rendering. + * If no matching shader is found, the code with a render pass of 0 is used. + * In other cases, operation is not guaranteed. + * @param[in] renderPassTag RenderPassTag value for this render task. + * @note RenderPassTag of default RenderTask is 0u. + */ + void SetRenderPassTag(uint32_t renderPassTag); /** + * Gets Render Pass key for this RenderTask. + * @return RenderPassTag value for this render task. + */ + uint32_t GetRenderPassTag() const; + + /** + * Sets Order Index to define rendering order for this RenderTask. + * In the DALi, offscreen renderTasks are rendered earlier than onscreen renderTask. + * In each category of OffScreen RenderTask and OnScreen RenderTask, + * a RenderTask with a smaller orderIndex is rendered first. + * The RenderTasks in RenderTaskList is always sorted as acending order of the OrderIndex. + * The OrderIndex value is needed to be set between [-1000, 1000]. + * Default orderIndex is 0. + * @param[in] orderIndex the order index for this render task. + * @note The order among RenderTasks whose OrderIndex has not changed follows the order in which they were created. + * @note Rendering order among RenderTasks those have same OrderIndex cannot be guaranteed after the OrderIndex is changed + */ + void SetOrderIndex(int32_t orderIndex); + + /** + * Gets Order Index for this RenderTask. + * @return OrderIndex value for this render task. + */ + int32_t GetOrderIndex() const; + + /** + * @brief Get the unique id of RenderTask. It could be 0 given render task is invalid. + * + * @SINCE_2_3.10 + * @return The unique id of RenderTask, or 0 if invalid. + */ + uint32_t GetRenderTaskId() const; + + /** + * @brief Stop rendering from given actor. The actor is not included. + * @SINCE_2_3.23 + * @param[in] stopperActor A marker to stop rendering. + */ + void RenderUntil(Actor stopperActor); + +public: // Signals + /** * @brief If the refresh rate is REFRESH_ONCE, connect to this signal to be notified when a RenderTask has finished. * @SINCE_1_0.0 * @return The signal to connect to @@ -516,14 +602,13 @@ public: // Signals RenderTaskSignalType& FinishedSignal(); public: // Not intended for application developers - /// @cond internal /** * @brief This constructor is used by Dali New() methods. * @SINCE_1_0.0 * @param[in] renderTask A pointer to a newly allocated render-task */ - explicit DALI_INTERNAL RenderTask( Internal::RenderTask* renderTask ); + explicit DALI_INTERNAL RenderTask(Internal::RenderTask* renderTask); /// @endcond }; @@ -532,4 +617,4 @@ public: // Not intended for application developers */ } // namespace Dali -#endif //__DALI_RENDER_TASK_H__ +#endif //DALI_RENDER_TASK_H