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>
39 class CanvasViewRasterizeThread;
41 class CanvasView : public Control, public Integration::Processor
45 * Construct a new CanvasView.
47 CanvasView(const Vector2& viewBox);
50 * A reference counted object may only be deleted by calling Unreference()
52 virtual ~CanvasView();
56 * Create a new CanvasView.
57 * @return A smart-pointer to the newly allocated CanvasView.
59 static Toolkit::CanvasView New(const Vector2& viewBox);
62 * @copydoc Toolkit::Control::CanvasView::AddDrawable
64 bool AddDrawable(Dali::CanvasRenderer::Drawable& drawable);
67 * Called when a property of an object of this type is set.
68 * @param[in] object The object whose property is set.
69 * @param[in] propertyIndex The property index.
70 * @param[in] value The new property value.
72 static void SetProperty(BaseObject* object, Property::Index propertyIndex, const Property::Value& value);
75 * Called to retrieve a property of an object of this type.
76 * @param[in] object The object whose property is to be retrieved.
77 * @param[in] propertyIndex The property index.
78 * @return The current value of the property.
80 static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
83 * @copydoc Toolkit::Control::CanvasView::RemoveDrawable
85 bool RemoveDrawable(Dali::CanvasRenderer::Drawable& drawable);
88 * @copydoc Toolkit::Control::CanvasView::RemoveAllDrawables
90 bool RemoveAllDrawables();
92 private: // From Control
94 * @copydoc Control::OnRelayout
96 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
99 * @copydoc Toolkit::Control::OnSizeSet()
101 void OnSizeSet(const Vector3& targetSize) override;
104 * @copydoc Toolkit::Control::OnInitialize
106 void OnInitialize() override;
109 * @brief This is the viewbox of the Canvas.
110 * @param[in] viewBox The size of viewbox.
111 * @return Returns True when it's successful. False otherwise.
113 bool SetViewBox(const Vector2& viewBox);
116 * @brief This is the viewbox of the Canvas.
117 * @return Returns The size of viewbox.
119 const Vector2& GetViewBox();
122 * @bried Rasterize the canvas, and add it to the view.
124 * @param[in] size The target size of the canvas view rasterization.
126 void AddRasterizationTask();
130 * @copydoc Dali::Integration::Processor::Process()
132 void Process(bool postProcessor) override;
136 * @bried Apply the rasterized image to the canvas view
138 * @param[in] rasterizedTexture The texture with the rasterized pixels
140 void ApplyRasterizedImage(Texture rasterizedTexture);
143 CanvasView(const CanvasView&) = delete;
144 CanvasView& operator=(const CanvasView&) = delete;
147 CanvasRenderer mCanvasRenderer;
148 Dali::Texture mTexture;
149 TextureSet mTextureSet;
151 CanvasViewRasterizeThread* mCanvasViewRasterizeThread;
154 } // namespace Internal
156 // Helpers for public-api forwarding methods
157 inline Toolkit::Internal::CanvasView& GetImpl(Toolkit::CanvasView& obj)
159 DALI_ASSERT_ALWAYS(obj);
160 Dali::RefObject& handle = obj.GetImplementation();
161 return static_cast<Toolkit::Internal::CanvasView&>(handle);
164 inline const Toolkit::Internal::CanvasView& GetImpl(const Toolkit::CanvasView& obj)
166 DALI_ASSERT_ALWAYS(obj);
167 const Dali::RefObject& handle = obj.GetImplementation();
168 return static_cast<const Toolkit::Internal::CanvasView&>(handle);
171 } // namespace Toolkit
175 #endif // DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H