1 #ifndef DALI_TOOLKIT_CANVAS_VIEW_RASTERIZE_TASK_H
2 #define DALI_TOOLKIT_CANVAS_VIEW_RASTERIZE_TASK_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.
21 #include <dali/devel-api/adaptor-framework/canvas-renderer/canvas-renderer.h>
22 #include <dali/devel-api/adaptor-framework/event-thread-callback.h>
23 #include <dali/devel-api/threading/conditional-wait.h>
24 #include <dali/devel-api/threading/mutex.h>
25 #include <dali/devel-api/threading/thread.h>
26 #include <dali/integration-api/adaptor-framework/log-factory-interface.h>
27 #include <dali/public-api/adaptor-framework/async-task-manager.h>
28 #include <dali/public-api/common/intrusive-ptr.h>
29 #include <dali/public-api/object/ref-object.h>
30 #include <dali/public-api/rendering/texture-set.h>
40 class CanvasRendererRasterizingTask;
41 using CanvasRendererRasterizingTaskPtr = IntrusivePtr<CanvasRendererRasterizingTask>;
44 * The canvasview rasterizing tasks to be processed in the worker thread.
46 * Life cycle of a rasterizing task is as follows:
47 * 1. Created by CanvasView in the main thread
48 * 2. Queued in the worked thread waiting to be processed.
49 * 3. If this task gets its turn to do the rasterization, it triggers main thread to apply the rasterized image to material then been deleted in main thread call back.
50 * Or if this task is been removed before its turn to be processed, it then been deleted in the worker thread.
52 class CanvasRendererRasterizingTask : public AsyncTask
57 * @param[in] canvasRenderer The renderer which the rasterized canvas to be applied.
58 * @param[in] callback The callback that is called when the operation is completed.
60 CanvasRendererRasterizingTask(CanvasRenderer canvasRenderer, CallbackBase* callback);
65 ~CanvasRendererRasterizingTask() = default;
68 * Do the rasterization with the mRasterizer.
69 * @return Returns True when it's successful. False otherwise.
74 * Whether the rasterize is completed
75 * @return Returns True when it's completed
80 * Get the rasterization result.
81 * @return The texture with the rasterized pixels.
83 Texture GetRasterizedTexture();
85 public: // Implementation of AsyncTask
87 * @copydoc Dali::AsyncTask::Process()
89 void Process() override;
92 * @copydoc Dali::AsyncTask::IsReady()
94 bool IsReady() override;
97 * @copydoc Dali::AsyncTask::GetTaskName()
99 std::string_view GetTaskName() const override
101 return "CanvasRendererRasterizingTask";
106 CanvasRendererRasterizingTask(const CanvasRendererRasterizingTask& task);
109 CanvasRendererRasterizingTask& operator=(const CanvasRendererRasterizingTask& task);
112 CanvasRenderer mCanvasRenderer;
113 bool mRasterizedSuccessed;
116 } // namespace Internal
118 } // namespace Toolkit
122 #endif // DALI_TOOLKIT_CANVAS_VIEW_RASTERIZE_TASK_H