1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_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.
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>
33 namespace Dali::Internal::SceneGraph
35 // Messages for RenderTask
36 inline void SetFrameBufferMessage(EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer)
38 using LocalType = MessageValue1<RenderTask, Render::FrameBuffer*>;
40 // Reserve some memory inside the message queue
41 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
47 inline void SetClearEnabledMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled)
49 using LocalType = MessageValue1<RenderTask, bool>;
51 // Reserve some memory inside the message queue
52 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
58 inline void SetCullModeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool mode)
60 using LocalType = MessageValue1<RenderTask, bool>;
62 // Reserve some memory inside the message queue
63 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
69 inline void SetRefreshRateMessage(EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate)
71 using LocalType = MessageValue1<RenderTask, uint32_t>;
73 // Reserve some memory inside the message queue
74 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
80 inline void SetSourceNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode)
82 // Scene graph thread can destroy this object.
83 Node* node = const_cast<Node*>(constNode);
85 using LocalType = MessageValue1<RenderTask, Node*>;
87 // Reserve some memory inside the message queue
88 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
94 inline void SetCameraMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera)
96 using LocalType = MessageValue2<RenderTask, Node*, Camera*>;
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));
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);
107 inline void SetViewportGuideNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode)
109 // Scene graph thread can destroy this object.
110 Node* node = const_cast<Node*>(constNode);
112 using LocalType = MessageValue1<RenderTask, Node*>;
114 // Reserve some memory inside the message queue
115 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
121 inline void SetExclusiveMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive)
123 using LocalType = MessageValue1<RenderTask, bool>;
125 // Reserve some memory inside the message queue
126 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
132 inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync)
134 using LocalType = MessageValue1<RenderTask, bool>;
136 // Reserve some memory inside the message queue
137 uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
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);
143 } // namespace Dali::Internal::SceneGraph
145 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_MESSAGES_H