Formatting API
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / visual-factory / visual-factory.h
1 #ifndef DALI_TOOLKIT_VISUAL_FACTORY_H
2 #define DALI_TOOLKIT_VISUAL_FACTORY_H
3
4 /*
5  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/images/image-operations.h>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/object/property-map.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
28
29 namespace Dali
30 {
31 class Image;
32 struct Vector4;
33
34 namespace Toolkit
35 {
36 namespace Internal DALI_INTERNAL
37 {
38 class VisualFactory;
39 }
40
41 /**
42  * @brief VisualFactory is a singleton object that provides and shares visuals between controls
43  *
44  * By setting environment variable 'DALI_DEBUG_RENDERING', a debug visual is used which renders a quad wireframe.
45  *
46  * The visual type is required in the property map for requesting a visual.
47  *
48  * | %Property Name           | Type              |
49  * |--------------------------|-------------------|
50  * | visualType               | INTEGER or STRING |
51  * | shader                   | MAP               |
52  */
53 class DALI_TOOLKIT_API VisualFactory : public BaseHandle
54 {
55 public:
56   /**
57    * @brief Create or retrieve VisualFactory singleton.
58    *
59    * @return A handle to the VisualFactory control.
60    */
61   static VisualFactory Get();
62
63   /**
64    * @brief Create a VisualFactory handle.
65    *
66    * Calling member functions with an uninitialised handle is not allowed.
67    */
68   VisualFactory();
69
70   /**
71    * @brief Destructor
72    *
73    * This is non-virtual since derived Handle types must not contain data or virtual methods.
74    */
75   ~VisualFactory();
76
77   /**
78    * @brief This copy constructor is required for (smart) pointer semantics.
79    *
80    * @param[in] handle A reference to the copied handle.
81    */
82   VisualFactory(const VisualFactory& handle);
83
84   /**
85    * @brief This assignment operator is required for (smart) pointer semantics.
86    *
87    * @param [in] handle  A reference to the copied handle.
88    * @return A reference to this.
89    */
90   VisualFactory& operator=(const VisualFactory& handle);
91
92   /**
93    * @brief Request the visual
94    *
95    * @param[in] propertyMap The map contains the properties required by the visual.
96    *            The content of the map determines the type of visual that will be returned.
97    * @return The handle to the created visual
98    */
99   Visual::Base CreateVisual(const Property::Map& propertyMap);
100
101   /**
102    * @brief Request the visual to render the given resource at the url.
103    *
104    * @param[in] url The URL to the resource to be rendered.
105    * @param[in] size The width and height to fit the loaded image to.
106    * @return The pointer pointing to the visual
107    */
108   Visual::Base CreateVisual(const std::string& url, ImageDimensions size);
109
110   /**
111    * @brief Enable or disable premultiplying alpha in images and image visuals.
112    *
113    * The default is to enable pre-multiplication on load.
114    *
115    * Applications that have assets with pre-multiplied alpha already applied should turn this option off.
116    *
117    * @param[in] preMultiply True if loaded images for image visuals should have alpha multiplied into the color
118    * channels.
119    */
120   void SetPreMultiplyOnLoad(bool preMultiply);
121
122   /**
123    * @brief Get the setting for automatically pre-multiplying image visual images on load.
124    *
125    * @return True if loaded images have pre-multiplied alpha applied on load, false otherwise.
126    */
127   bool GetPreMultiplyOnLoad() const;
128
129 private:
130   explicit DALI_INTERNAL VisualFactory(Internal::VisualFactory* impl);
131 };
132
133 } // namespace Toolkit
134
135 } // namespace Dali
136
137 #endif // DALI_TOOLKIT_VISUAL_FACTORY_H