1 #ifndef DALI_CANVAS_RENDERER_H
2 #define DALI_CANVAS_RENDERER_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/public-api/object/base-handle.h>
25 #include <dali/devel-api/adaptor-framework/pixel-buffer.h>
26 #include <dali/public-api/dali-adaptor-common.h>
31 * @addtogroup dali_adaptor_framework
35 namespace Internal DALI_INTERNAL
41 } // namespace DALI_INTERNAL
44 * @brief Used for rendering a vector primitives
46 class DALI_ADAPTOR_API CanvasRenderer : public BaseHandle
50 * @brief Creates an initialized handle to a new CanvasRenderer.
51 * @param[in] viewBox The viewBox of canvas.
52 * @return A handle to a newly allocated CanvasRenderer
54 static CanvasRenderer New(const Vector2& viewBox);
58 * @brief Creates an empty handle.
59 * Use CanvasRenderer::New() to create an initialized object.
70 * @brief This copy constructor is required for (smart) pointer semantics.
72 * @param[in] handle A reference to the copied handle
74 CanvasRenderer(const CanvasRenderer& handle) = default;
77 * @brief This assignment operator is required for (smart) pointer semantics.
79 * @param[in] rhs A reference to the copied handle
80 * @return A reference to this
82 CanvasRenderer& operator=(const CanvasRenderer& rhs) = default;
96 * @brief Prepare for drawing drawables added to CanvasRenderer on inner canvas.
97 * @return Returns True when it's successful. False otherwise.
102 * @brief Add drawable object to the Canvas. This method is similar to registration.
103 * The added drawable object(shape) is drawn on the inner canvas using @ref Commit().
104 * @param[in] drawable The drawable object.
105 * @return Returns True when it's successful. False otherwise.
107 bool AddDrawable(Drawable& drawable);
110 * @brief Remove drawable object to the CanvasView.
111 * This method is similar to deregistration. Freeing memory is not concerned for drawables being removed.
112 * @param[in] drawable the drawable object.
113 * @return Returns True when it's successful. False otherwise.
115 bool RemoveDrawable(Drawable& drawable);
118 * @brief Remove all drawable objects added to the CanvasRenderer.
119 * @return Returns True when it's successful. False otherwise.
121 bool RemoveAllDrawables();
124 * @brief Returns the PixelBuffer, which is the Render buffer of Canvas.
126 * @return Returns the pixel buffer.
128 Devel::PixelBuffer GetPixelBuffer();
131 * @brief Draw drawables added to CanvasRenderer to inner buffer.
132 * @return Returns True when it's successful. False otherwise.
137 * @brief Returns whether the drawables added to the Canvas are changed.
138 * @return Returns True when drawables added to the Canvas are changed, False otherwise.
140 bool IsCanvasChanged() const;
143 * @brief This is the size of the buffer in the Canvas.
144 * @param[in] size The size of canvas buffer.
145 * @return Returns True when it's successful. False otherwise.
147 bool SetSize(Vector2 size);
150 * @brief This is the size of the Buffer in the Canvas.
151 * @return Returns The size of canvas buffer.
153 Vector2 GetSize() const;
156 * @brief This is the viewbox of the Canvas.
157 * @param[in] viewBox The size of viewbox.
158 * @return Returns True when it's successful. False otherwise.
160 bool SetViewBox(const Vector2& viewBox);
163 * @brief This is the viewbox of the Canvas.
164 * @return Returns The size of viewbox.
166 const Vector2& GetViewBox();
168 public: // Not intended for application developers
171 * @brief The constructor.
172 * @note Not intended for application developers.
174 * @param[in] pointer A pointer to a newly allocated CanvasRenderer
176 explicit DALI_INTERNAL CanvasRenderer(Internal::Adaptor::CanvasRenderer* internal);
185 #endif // DALI_CANVAS_RENDERER_H