1 #ifndef DALI_TOOLKIT_INTERNAL_TEXTURE_UPLOAD_OBSERVER_H
2 #define DALI_TOOLKIT_INTERNAL_TEXTURE_UPLOAD_OBSERVER_H
5 * Copyright (c) 2022 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/pixel-buffer.h>
23 #include <dali/public-api/rendering/texture-set.h>
24 #include <dali/public-api/signals/dali-signal.h>
27 #include <dali-toolkit/internal/visuals/visual-url.h>
28 #include <dali-toolkit/public-api/dali-toolkit-common.h>
35 * @brief Base class used to observe the upload status of a texture.
37 * Derived class must implement the LoadComplete method which is
38 * executed once the texture is ready to draw.
40 class TextureUploadObserver
43 typedef Signal<void(TextureUploadObserver*)> DestructionSignalType; ///< Signal prototype for the Destruction Signal.
49 ANIMATED_IMAGE_TEXTURE
52 struct TextureInformation
54 TextureInformation(ReturnType returnType, int32_t textureId, TextureSet textureSet, bool useAtlasing, const Vector4& atlasRect, bool preMultiplied);
55 TextureInformation(ReturnType returnType, Devel::PixelBuffer pixelBuffer, const std::string& url, bool preMultiplied);
56 TextureInformation(ReturnType returnType, int32_t textureId, uint32_t frameCount, uint32_t interval);
60 ReturnType returnType; ///< Returned Texture type.
61 int32_t textureId; ///< The textureId of the loaded texture in the TextureManager
62 TextureSet textureSet; ///< The TextureSet containing the Texture
63 bool useAtlasing; ///< True if atlasing was used (note: this may be different to what was requested)
64 const Vector4& atlasRect; ///< If using atlasing, this is the rectangle within the atlas to use.
65 bool preMultiplied; ///< True if the image had pre-multiplied alpha applied
66 Devel::PixelBuffer pixelBuffer; ///< The PixelBuffer of the loaded image.
67 std::string_view url; ///< The url address of the loaded image.
68 uint32_t frameCount{0}; ///< The frameCount of the animated image
69 uint32_t interval{0}; ///< Time interval between currently loaded frame and next frame.
76 TextureUploadObserver();
79 * @brief Virtual destructor.
81 virtual ~TextureUploadObserver();
84 * The action to be taken once the async load has finished.
85 * And in case of texture loading, this method is called after uploading.
86 * This should be overridden by the deriving class.
88 * @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.
89 * @param[in] textureInformation Structure that contains loaded texture information.
91 virtual void LoadComplete(bool loadSuccess, TextureInformation textureInformation) = 0;
94 * @brief Returns the destruction signal.
95 * This is emitted when the observer is destroyed.
96 * This is used by the observer notifier to mark this observer as destroyed (IE. It no longer needs notifying).
98 DestructionSignalType& DestructionSignal();
101 DestructionSignalType mDestructionSignal; ///< The destruction signal emitted when the observer is destroyed.
104 } // namespace Toolkit
108 #endif // DALI_TOOLKIT_INTERNAL_TEXTURE_UPLOAD_OBSERVER_H