Merge changes I8783ad29,I2c860a84 into devel/master
[platform/core/uifw/dali-core.git] / dali / internal / update / render-tasks / scene-graph-render-task-messages.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_H
3
4 /*
5  * Copyright (c) 2023 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/internal/common/buffer-index.h>
23 #include <dali/internal/common/message.h>
24 #include <dali/internal/event/common/event-thread-services.h>
25 #include <dali/internal/render/common/render-instruction.h>
26 #include <dali/internal/render/renderers/render-frame-buffer.h>
27 #include <dali/internal/update/common/animatable-property.h>
28 #include <dali/internal/update/common/property-owner.h>
29 #include <dali/internal/update/manager/update-manager.h>
30 #include <dali/public-api/math/viewport.h>
31 #include <dali/public-api/render-tasks/render-task.h>
32
33 namespace Dali::Internal::SceneGraph
34 {
35 // Messages for RenderTask
36 inline void SetFrameBufferMessage(EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer)
37 {
38   using LocalType = MessageValue1<RenderTask, Render::FrameBuffer*>;
39
40   // Reserve some memory inside the message queue
41   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
42
43   // Construct message in the message queue memory; note that delete should not be called on the return value
44   new(slot) LocalType(&task, &RenderTask::SetFrameBuffer, frameBuffer);
45 }
46
47 inline void SetClearEnabledMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled)
48 {
49   using LocalType = MessageValue1<RenderTask, bool>;
50
51   // Reserve some memory inside the message queue
52   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
53
54   // Construct message in the message queue memory; note that delete should not be called on the return value
55   new(slot) LocalType(&task, &RenderTask::SetClearEnabled, enabled);
56 }
57
58 inline void SetCullModeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool mode)
59 {
60   using LocalType = MessageValue1<RenderTask, bool>;
61
62   // Reserve some memory inside the message queue
63   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
64
65   // Construct message in the message queue memory; note that delete should not be called on the return value
66   new(slot) LocalType(&task, &RenderTask::SetCullMode, mode);
67 }
68
69 inline void SetRefreshRateMessage(EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate)
70 {
71   using LocalType = MessageValue1<RenderTask, uint32_t>;
72
73   // Reserve some memory inside the message queue
74   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
75
76   // Construct message in the message queue memory; note that delete should not be called on the return value
77   new(slot) LocalType(&task, &RenderTask::SetRefreshRate, refreshRate);
78 }
79
80 inline void SetSourceNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode)
81 {
82   // Scene graph thread can destroy this object.
83   Node* node = const_cast<Node*>(constNode);
84
85   using LocalType = MessageValue1<RenderTask, Node*>;
86
87   // Reserve some memory inside the message queue
88   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
89
90   // Construct message in the message queue memory; note that delete should not be called on the return value
91   new(slot) LocalType(&task, &RenderTask::SetSourceNode, node);
92 }
93
94 inline void SetCameraMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera)
95 {
96   using LocalType = MessageValue2<RenderTask, Node*, Camera*>;
97
98   Node*   node   = const_cast<Node*>(constNode);
99   Camera* camera = const_cast<Camera*>(constCamera);
100   // Reserve memory inside the message queue
101   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
102
103   // Construct message in the message queue memory; note that delete should not be called on the return value
104   new(slot) LocalType(&task, &RenderTask::SetCamera, node, camera);
105 }
106
107 inline void SetViewportGuideNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode)
108 {
109   // Scene graph thread can destroy this object.
110   Node* node = const_cast<Node*>(constNode);
111
112   using LocalType = MessageValue1<RenderTask, Node*>;
113
114   // Reserve some memory inside the message queue
115   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
116
117   // Construct message in the message queue memory; note that delete should not be called on the return value
118   new(slot) LocalType(&task, &RenderTask::SetViewportGuideNode, node);
119 }
120
121 inline void SetExclusiveMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive)
122 {
123   using LocalType = MessageValue1<RenderTask, bool>;
124
125   // Reserve some memory inside the message queue
126   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
127
128   // Construct message in the message queue memory; note that delete should not be called on the return value
129   new(slot) LocalType(&task, &RenderTask::SetExclusive, exclusive);
130 }
131
132 inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync)
133 {
134   using LocalType = MessageValue1<RenderTask, bool>;
135
136   // Reserve some memory inside the message queue
137   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
138
139   // Construct message in the message queue memory; note that delete should not be called on the return value
140   new(slot) LocalType(&task, &RenderTask::SetSyncRequired, requiresSync);
141 }
142
143 } // namespace Dali::Internal::SceneGraph
144
145 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_H