[Tizen]Save textureId directly at RequsetLoad()
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / texture-upload-observer.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXTURE_UPLOAD_OBSERVER_H
2 #define DALI_TOOLKIT_INTERNAL_TEXTURE_UPLOAD_OBSERVER_H
3
4 /*
5  * Copyright (c) 2021 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/devel-api/adaptor-framework/pixel-buffer.h>
23 #include <dali/public-api/signals/dali-signal.h>
24 #include <dali/public-api/rendering/texture-set.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/internal/visuals/visual-url.h>
28 #include <dali-toolkit/public-api/dali-toolkit-common.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35 /**
36  * @brief Base class used to observe the upload status of a texture.
37  *
38  * Derived class must implement the UploadComplete method which is
39  * executed once the texture is ready to draw.
40  */
41 class TextureUploadObserver
42 {
43 public:
44   typedef Signal<void(TextureUploadObserver*)> DestructionSignalType; ///< Signal prototype for the Destruction Signal.
45
46   /**
47    * @brief Constructor.
48    */
49   TextureUploadObserver();
50
51   /**
52    * @brief Virtual destructor.
53    */
54   virtual ~TextureUploadObserver();
55
56   /**
57    * @brief The action to be taken once the async load has finished and the upload to GPU is completed.
58    * This should be overridden by the deriving class.
59    *
60    * @param[in] loadSuccess True if the texture load was successful (i.e. the resource is available). If false, then the resource failed to load. In future, this will automatically upload a "broken" image.
61    * @param[in] textureId   The textureId of the loaded texture in the TextureManager
62    * @param[in] textureSet  The TextureSet containing the Texture
63    * @param[in] useAtlasing True if atlasing was used (note: this may be different to what was requested)
64    * @param[in] atlasRect   If using atlasing, this is the rectangle within the atlas to use.
65    * @param[in] preMultiplied True if the image had pre-multiplied alpha applied
66    */
67   virtual void UploadComplete(bool loadSuccess, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied)
68   {
69   }
70
71   /**
72    * @brief The action to be taken once the async load of animated image has finished and the upload to GPU is completed.
73    * This should be overridden by the deriving class.
74    *
75    * @param[in] loadSuccess   True if the texture load was successful (i.e. the resource is available). If false, then the resource failed to load. In future, this will automatically upload a "broken" image.
76    * @param[in] textureId     The textureId of the loaded texture in the TextureManager
77    * @param[in] frameCount    The frameCount of the animated image
78    * @param[in] interval      Time interval between currently loaded frame and next frame.
79    */
80   virtual void AnimatedImageUploadComplete(bool loadSuccess, int32_t textureId, uint32_t frameCount, uint32_t interval)
81   {
82   }
83
84   /**
85    * @brief The action to be taken once the async load has finished.
86    * This should be overridden by the deriving class.
87    *
88    * @param[in] loadSuccess   True if the image load was successful (i.e. the resource is available). If false, then the resource failed to load.
89    * @param[in] pixelBuffer   The PixelBuffer of the loaded image.
90    * @param[in] url           The url address of the loaded image.
91    * @param[in] preMultiplied True if the image had pre-multiplied alpha applied
92    */
93   virtual void LoadComplete(bool loadSuccess, Devel::PixelBuffer pixelBuffer, const Internal::VisualUrl& url, bool preMultiplied)
94   {
95   }
96
97   /**
98    * @brief Returns the destruction signal.
99    * This is emitted when the observer is destroyed.
100    * This is used by the observer notifier to mark this observer as destroyed (IE. It no longer needs notifying).
101    */
102   DestructionSignalType& DestructionSignal();
103
104 private:
105   DestructionSignalType mDestructionSignal; ///< The destruction signal emitted when the observer is destroyed.
106 };
107
108 } // namespace Toolkit
109
110 } // namespace Dali
111
112 #endif // DALI_TOOLKIT_INTERNAL_TEXTURE_UPLOAD_OBSERVER_H