1 #ifndef DALI_INTERNAL_RENDER_ALGORITHMS_H
2 #define DALI_INTERNAL_RENDER_ALGORITHMS_H
5 * Copyright (c) 2019 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.
22 #include <dali/integration-api/core-enumerations.h>
23 #include <dali/internal/common/buffer-index.h>
24 #include <dali/internal/render/common/render-list.h>
35 class RenderInstruction;
43 * @brief The responsibility of the RenderAlgorithms object is to action renders required by a RenderInstruction.
45 class RenderAlgorithms
55 * Process a render-instruction.
56 * @param[in] instruction The render-instruction to process.
57 * @param[in] context The GL context.
58 * @param[in] bufferIndex The current render buffer index (previous update buffer)
59 * @param[in] depthBufferAvailable Whether the depth buffer is available
60 * @param[in] stencilBufferAvailable Whether the stencil buffer is available
61 * @param[in] boundTextures The textures bound for rendering
63 void ProcessRenderInstruction( const SceneGraph::RenderInstruction& instruction,
65 BufferIndex bufferIndex,
66 Integration::DepthBufferAvailable depthBufferAvailable,
67 Integration::StencilBufferAvailable stencilBufferAvailable,
68 Vector<GLuint>& boundTextures,
69 const Rect<int>& rootClippingRect );
74 * @brief Calculate a 2D AABB (axis aligned bounding box) in screen space.
75 * The RenderItems dimensions are translated and a Z value of 0 is assumed for this purpose.
76 * No projection is performed, but rotation on Z is supported.
77 * @param[in] item The RenderItem to generate an AABB for
78 * @return The generated AABB in screen space
80 inline Dali::ClippingBox CalculateScreenSpaceAABB( const Dali::Internal::SceneGraph::RenderItem& item );
83 * @brief Perform any scissor clipping related operations based on the current RenderItem.
85 * - Determining if any action is to be taken (so the method can be exited early if not).
86 * - If the node is a clipping node, apply the nodes clip intersected with the current/parent scissor clip.
87 * - If we have gone up the scissor hierarchy, and need to un-apply a scissor clip.
88 * - Disable scissor clipping completely if it is not needed
89 * @param[in] item The current RenderItem (about to be rendered)
90 * @param[in] context The current Context
92 inline void SetupScissorClipping( const Dali::Internal::SceneGraph::RenderItem& item, Context& context );
95 * @brief Set up the clipping based on the specified clipping settings.
96 * @param[in] item The current RenderItem (about to be rendered)
97 * @param[in] context The context
98 * @param[in/out] usedStencilBuffer True if the stencil buffer has been used so far within this RenderList. Used by StencilMode::ON.
99 * @param[in/out] lastClippingDepth The stencil depth of the last renderer drawn. Used by the clipping feature.
100 * @param[in/out] lastClippingId The clipping ID of the last renderer drawn. Used by the clipping feature.
101 * @param[in] stencilBufferAvailable Whether the stencil buffer is available
103 inline void SetupClipping( const Dali::Internal::SceneGraph::RenderItem& item,
105 bool& usedStencilBuffer,
106 uint32_t& lastClippingDepth,
107 uint32_t& lastClippingId,
108 Integration::StencilBufferAvailable stencilBufferAvailable );
111 * @brief Process a render-list.
112 * @param[in] renderList The render-list to process.
113 * @param[in] context The GL context.
114 * @param[in] buffer The current render buffer index (previous update buffer)
115 * @param[in] viewMatrix The view matrix from the appropriate camera.
116 * @param[in] projectionMatrix The projection matrix from the appropriate camera.
117 * @param[in] depthBufferAvailable Whether the depth buffer is available
118 * @param[in] stencilBufferAvailable Whether the stencil buffer is available
119 * @param[in] boundTextures The textures bound for rendering
121 inline void ProcessRenderList( const Dali::Internal::SceneGraph::RenderList& renderList,
123 BufferIndex bufferIndex,
124 const Matrix& viewMatrix,
125 const Matrix& projectionMatrix,
126 Integration::DepthBufferAvailable depthBufferAvailable,
127 Integration::StencilBufferAvailable stencilBufferAvailable,
128 Vector<GLuint>& boundTextures,
129 const Dali::Internal::SceneGraph::RenderInstruction& instruction, // in the case of reflection, things like CullFace need to be adjusted for reflection world
130 const Rect<int>& rootClippingRect );
133 RenderAlgorithms( RenderAlgorithms& rhs );
134 RenderAlgorithms& operator=( const RenderAlgorithms& rhs );
139 using ScissorStackType = std::vector<Dali::ClippingBox>; ///< The container type used to maintain the applied scissor hierarchy
141 ScissorStackType mScissorStack; ///< Contains the currently applied scissor hierarchy (so we can undo clips)
142 Dali::ClippingBox mViewportRectangle; ///< The viewport dimensions, used to translate AABBs to scissor coordinates
143 bool mHasLayerScissor:1; ///< Marks if the currently process render instruction has a layer-based clipping region
146 } // namespace Render
148 } // namespace Internal
152 #endif // DALI_INTERNAL_RENDER_ALGORITHMS_H