1 #ifndef DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_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/devel-api/adaptor-framework/canvas-renderer/canvas-renderer-drawable.h>
23 #include <dali/devel-api/adaptor-framework/canvas-renderer/canvas-renderer-shape.h>
24 #include <dali/devel-api/adaptor-framework/canvas-renderer/canvas-renderer.h>
25 #include <dali/devel-api/rendering/renderer-devel.h>
26 #include <dali/integration-api/processor-interface.h>
29 #include <dali-toolkit/devel-api/controls/canvas-view/canvas-view.h>
30 #include <dali-toolkit/internal/controls/canvas-view/canvas-view-rasterize-task.h>
31 #include <dali-toolkit/public-api/controls/control-impl.h>
40 class CanvasViewRasterizeThread;
42 class CanvasView : public Control, public Integration::Processor
46 * Construct a new CanvasView.
48 CanvasView(const Vector2& viewBox);
51 * A reference counted object may only be deleted by calling Unreference()
53 virtual ~CanvasView();
57 * Create a new CanvasView.
58 * @return A smart-pointer to the newly allocated CanvasView.
60 static Toolkit::CanvasView New(const Vector2& viewBox);
63 * @copydoc Toolkit::Control::CanvasView::AddDrawable
65 bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
68 * Called when a property of an object of this type is set.
69 * @param[in] object The object whose property is set.
70 * @param[in] propertyIndex The property index.
71 * @param[in] value The new property value.
73 static void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value);
76 * Called to retrieve a property of an object of this type.
77 * @param[in] object The object whose property is to be retrieved.
78 * @param[in] propertyIndex The property index.
79 * @return The current value of the property.
81 static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
84 * @copydoc Toolkit::Control::CanvasView::RemoveDrawable
86 bool RemoveDrawable(Dali::CanvasRenderer::Drawable& drawable);
89 * @copydoc Toolkit::Control::CanvasView::RemoveAllDrawables
91 bool RemoveAllDrawables();
93 private: // From Control
95 * @copydoc Control::OnRelayout
97 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
100 * @copydoc Toolkit::Control::OnSizeSet()
102 void OnSizeSet(const Vector3& targetSize) override;
105 * @copydoc Toolkit::Control::OnInitialize
107 void OnInitialize() override;
110 * @brief This is the viewbox of the Canvas.
111 * @param[in] viewBox The size of viewbox.
112 * @return Returns True when it's successful. False otherwise.
114 bool SetViewBox(const Vector2& viewBox);
117 * @brief This is the viewbox of the Canvas.
118 * @return Returns The size of viewbox.
120 const Vector2& GetViewBox();
123 * @brief Set to load the canvas synchronously.
125 * @param isSynchronous The synchronous
127 void SetSynchronous(const bool isSynchronous);
130 * @brief Whether to load the canvas synchronously.
132 * @return Returns true if synchronously.
134 const bool IsSynchronous();
137 * @bried Rasterize the canvas, and add it to the view.
139 * @param[in] size The target size of the canvas view rasterization.
141 void AddRasterizationTask();
145 * @copydoc Dali::Integration::Processor::Process()
147 void Process(bool postProcessor) override;
150 * @copydoc Dali::Integration::Processor::GetProcessorName()
152 std::string_view GetProcessorName() const override
159 * @bried Apply the rasterized image to the canvas view
161 * @param[in] task CanvasRendererRasterizingTaskPtr
163 void ApplyRasterizedImage(CanvasRendererRasterizingTaskPtr task);
166 CanvasView(const CanvasView&) = delete;
167 CanvasView& operator=(const CanvasView&) = delete;
170 CanvasRenderer mCanvasRenderer;
171 Dali::Texture mTexture;
172 TextureSet mTextureSet;
174 CanvasRendererRasterizingTaskPtr mRasterizingTask;
178 } // namespace Internal
180 // Helpers for public-api forwarding methods
181 inline Toolkit::Internal::CanvasView& GetImpl(Toolkit::CanvasView& obj)
183 DALI_ASSERT_ALWAYS(obj);
184 Dali::RefObject& handle = obj.GetImplementation();
185 return static_cast<Toolkit::Internal::CanvasView&>(handle);
188 inline const Toolkit::Internal::CanvasView& GetImpl(const Toolkit::CanvasView& obj)
190 DALI_ASSERT_ALWAYS(obj);
191 const Dali::RefObject& handle = obj.GetImplementation();
192 return static_cast<const Toolkit::Internal::CanvasView&>(handle);
195 } // namespace Toolkit
199 #endif // DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H