1 #ifndef DALI_CANVAS_RENDERER_DRAWABLE_H
2 #define DALI_CANVAS_RENDERER_DRAWABLE_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/canvas-renderer.h>
26 #include <dali/public-api/dali-adaptor-common.h>
31 * @addtogroup dali_adaptor_framework
35 namespace Internal DALI_INTERNAL
42 } // namespace Adaptor
43 } // namespace DALI_INTERNAL
46 * @brief Drawable is a object class for drawing a vector primitive.
48 class DALI_ADAPTOR_API CanvasRenderer::Drawable : public BaseHandle
62 * @brief This copy constructor is required for (smart) pointer semantics.
64 * @param[in] handle A reference to the copied handle
66 Drawable(const Drawable& handle) = default;
70 * @brief Enumeration indicating the type used in the masking of two objects - the mask drawable and the own drawable.
74 ALPHA = 0, ///< The pixels of the own drawable and the mask drawable are alpha blended. As a result, only the part of the own drawable, which intersects with the mask drawable is visible.
75 ALPHA_INVERSE ///< The pixels of the own drawable and the complement to the mask drawable's pixels are alpha blended. As a result, only the part of the own which is not covered by the mask is visible.
80 * @brief Set the transparency value
81 * @param[in] opacity The transparency level [0 ~ 1.0], 0 means totally transparent, while 1 means opaque.
82 * @return Returns True when it's successful. False otherwise.
84 bool SetOpacity(float opacity);
87 * @brief Get the transparency value
88 * @return Returns the transparency level
90 float GetOpacity() const;
93 * @brief Set the angle of rotation transformation.
94 * @param[in] degree The degree value of angle.
95 * @return Returns True when it's successful. False otherwise.
97 bool Rotate(Degree degree);
100 * @brief Set the scale value of scale transformation.
101 * @param[in] factor The scale factor value.
102 * @return Returns True when it's successful. False otherwise.
104 bool Scale(float factor);
107 * @brief Set the x, y movement value of translate transformation.
108 * @param[in] translate The x and y-axis movement value.
109 * @return Returns True when it's successful. False otherwise.
111 bool Translate(Vector2 translate);
114 * @brief Set the matrix value for affine transform.
115 * @param[in] matrix The 3x3 matrix value.
116 * @return Returns True when it's successful. False otherwise.
118 bool Transform(const Dali::Matrix3& matrix);
121 * @brief Gets the bounding box of the drawable object before any transformation.
122 * @note The bounding box doesn't indicate the rendering region in the result but primitive region of the object.
123 * @return Returns the bounding box information.
125 Rect<float> GetBoundingBox() const;
128 * @brief The intersection with clip drawable is determined and only the resulting pixels from own drawable are rendered.
129 * @param[in] clip The clip drawable object.
130 * @return Returns True when it's successful. False otherwise.
132 bool SetClipPath(Drawable& clip);
135 * @brief The pixels of mask drawable and own drawable are blended according to MaskType.
136 * @param[in] mask The mask drawable object.
137 * @param[in] type The masking type.
138 * @return Returns True when it's successful. False otherwise.
140 bool SetMask(Drawable& mask, MaskType type);
143 * @brief Downcast a handle to Drawable handle.
145 * If handle points to an InputMethodContext the downcast produces valid
146 * handle. If not the returned handle is left uninitialized.
148 * @param[in] handle Handle to an object.
149 * @return Handle to an Drawable or an uninitialized handle.
151 static Drawable DownCast(BaseHandle handle);
153 public: // Not intended for application developers
156 * @brief The constructor.
157 * @note Not intended for application developers.
159 * @param[in] pointer A pointer to a newly allocated CanvasRenderer::Drawable
161 explicit DALI_INTERNAL Drawable(Internal::Adaptor::Drawable* pImpl);
170 #endif // DALI_CANVAS_RENDERER_DRAWABLE_H