1 #ifndef DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
5 * Copyright (c) 2022 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/public-api/controls/control-impl.h>
31 #include <dali-toolkit/internal/controls/canvas-view/canvas-view-rasterize-task.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 * @bried Rasterize the canvas, and add it to the view.
125 * @param[in] size The target size of the canvas view rasterization.
127 void AddRasterizationTask();
131 * @copydoc Dali::Integration::Processor::Process()
133 void Process(bool postProcessor) override;
137 * @bried Apply the rasterized image to the canvas view
139 * @param[in] task CanvasRendererRasterizingTaskPtr
141 void ApplyRasterizedImage(CanvasRendererRasterizingTaskPtr task);
144 CanvasView(const CanvasView&) = delete;
145 CanvasView& operator=(const CanvasView&) = delete;
148 CanvasRenderer mCanvasRenderer;
149 Dali::Texture mTexture;
150 TextureSet mTextureSet;
152 CanvasRendererRasterizingTaskPtr mRasterizingTask;
155 } // namespace Internal
157 // Helpers for public-api forwarding methods
158 inline Toolkit::Internal::CanvasView& GetImpl(Toolkit::CanvasView& obj)
160 DALI_ASSERT_ALWAYS(obj);
161 Dali::RefObject& handle = obj.GetImplementation();
162 return static_cast<Toolkit::Internal::CanvasView&>(handle);
165 inline const Toolkit::Internal::CanvasView& GetImpl(const Toolkit::CanvasView& obj)
167 DALI_ASSERT_ALWAYS(obj);
168 const Dali::RefObject& handle = obj.GetImplementation();
169 return static_cast<const Toolkit::Internal::CanvasView&>(handle);
172 } // namespace Toolkit
176 #endif // DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H