1 #ifndef DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H
5 * Copyright (c) 2021 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-drawable.h>
23 #include <dali/devel-api/adaptor-framework/canvas-renderer-shape.h>
24 #include <dali/devel-api/adaptor-framework/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);
87 private: // From Control
89 * @copydoc Control::OnRelayout
91 void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
94 * @copydoc Toolkit::Control::OnSizeSet()
96 void OnSizeSet(const Vector3& targetSize) override;
99 * @copydoc Toolkit::Control::OnInitialize
101 void OnInitialize() override;
104 * @brief This is the viewbox of the Canvas.
105 * @param[in] viewBox The size of viewbox.
106 * @return Returns True when it's successful. False otherwise.
108 bool SetViewBox(const Vector2& viewBox);
111 * @brief This is the viewbox of the Canvas.
112 * @return Returns The size of viewbox.
114 const Vector2& GetViewBox();
117 * @bried Rasterize the canvas, and add it to the view.
119 * @param[in] size The target size of the canvas view rasterization.
121 void AddRasterizationTask();
125 * @copydoc Dali::Integration::Processor::Process()
127 void Process(bool postProcessor) override;
131 * @bried Apply the rasterized image to the canvas view
133 * @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
135 void ApplyRasterizedImage(PixelData rasterizedPixelData);
138 CanvasView(const CanvasView&) = delete;
139 CanvasView& operator=(const CanvasView&) = delete;
142 CanvasRenderer mCanvasRenderer;
143 Dali::Texture mTexture;
144 TextureSet mTextureSet;
146 CanvasViewRasterizeThread* mCanvasViewRasterizeThread;
149 } // namespace Internal
151 // Helpers for public-api forwarding methods
152 inline Toolkit::Internal::CanvasView& GetImpl(Toolkit::CanvasView& obj)
154 DALI_ASSERT_ALWAYS(obj);
155 Dali::RefObject& handle = obj.GetImplementation();
156 return static_cast<Toolkit::Internal::CanvasView&>(handle);
159 inline const Toolkit::Internal::CanvasView& GetImpl(const Toolkit::CanvasView& obj)
161 DALI_ASSERT_ALWAYS(obj);
162 const Dali::RefObject& handle = obj.GetImplementation();
163 return static_cast<const Toolkit::Internal::CanvasView&>(handle);
166 } // namespace Toolkit
170 #endif // DALI_TOOLKIT_INTERNAL_CANVAS_VIEW_H