1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_ITEM_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_ITEM_H
5 * Copyright (c) 2023 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.
23 #include <dali/internal/render/common/render-item-key.h>
24 #include <dali/internal/update/nodes/node.h>
25 #include <dali/public-api/actors/layer.h>
26 #include <dali/public-api/common/vector-wrapper.h>
27 #include <dali/public-api/math/matrix.h>
41 * A RenderItem contains all the data needed for rendering
46 * Construct a new RenderItem
47 * @return A pointer to a new RenderItem.
49 static RenderItem* New();
52 * Construct a new RenderItem
53 * @return A key to a new RenderItem
55 static RenderItemKey NewKey();
58 * Non-virtual destructor; RenderItem is not suitable as a base class.
63 * Get a pointer to the given object in the associated memory pool.
64 * @param[in] key A key to the memory pool object
65 * @return a ptr to the given object, or nullptr if not found/invalid
67 static RenderItem* Get(RenderItemKey::KeyType key);
70 * Get the key of the given renderer in the associated memory pool.
71 * @param[in] renderer the given renderer
72 * @return The key in the associated memory pool.
74 static RenderItemKey GetKey(const RenderItem& renderer);
77 * Get the key of the given renderer in the associated memory pool.
78 * @param[in] renderer the given renderer
79 * @return The key in the associated memory pool, or -1 if not
82 static RenderItemKey GetKey(RenderItem* renderer);
85 * Produce a 2D AABB in transformed space
86 * See below for caveats.
88 * @param[in] transformMatrix The matrix for converting to a different space
89 * @param[in] position The center position of the render item
90 * @param[in] size The size of the render item
92 static ClippingBox CalculateTransformSpaceAABB(const Matrix& transformMatrix, const Vector3& position, const Vector3& size);
95 * @brief This method is an optimized calculation of a viewport-space AABB (Axis-Aligned-Bounding-Box).
97 * We use the model-view-matrix, but we do not use projection. Therefore we assume Z = 0.
98 * As the box is Axis-Aligned (in viewport space) rotations on Z axis are correctly delt with by expanding the box as necessary.
99 * Rotations on X & Y axis will resize the AABB, but it will not handle the projection error due to the new coordinates having non-zero Z values.
101 * Note: We pass in the viewport dimensions rather than allow the caller to modify the raw AABB in order to optimally generate the final result.
103 * Note: ASSUMES THAT THE VIEWPORT COVERS THE SCREEN AND THAT THE CANVAS SIZE AND VIEWPORT SIZE ARE THE SAME!!!!! (Not the case for magnifier)
105 * @param[in] modelViewMatrix The model view matrix
106 * @param[in] position The center position of the render item
107 * @param[in] size The size of the render item
108 * @param[in] viewportWidth The width of the viewport to calculate for
109 * @param[in] viewportHeight The height of the viewport to calculate for
110 * @return The AABB coordinates in viewport-space (x, y, width, height)
112 static ClippingBox CalculateViewportSpaceAABB(const Matrix& modelViewMatrix, const Vector3& position, const Vector3& size, const int viewportWidth, const int viewportHeight);
115 * Overriden delete operator.
116 * Deletes the RenderItem from its global memory pool
117 * @param[in] A pointer to the RenderItem to delete.
119 void operator delete(void* ptr);
122 Matrix mModelViewMatrix;
124 Vector4 mUpdateArea; ///< Update area hint is provided for damaged area calculation. (x, y, width, height)
125 Render::RendererKey mRenderer;
127 const void* mTextureSet; ///< Used for sorting only
133 * Get the capacity of the global pool.
135 static uint32_t GetMemoryPoolCapacity();
139 * Private constructor. See RenderItem::New
143 // RenderItems should not be copied as they are heavy
144 RenderItem(const RenderItem& item) = delete;
145 RenderItem& operator=(const RenderItem& item) = delete;
148 } // namespace SceneGraph
150 } // namespace Internal
154 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_ITEM_H