• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef CORE_IMAGE_IMAGE_LOADER_MANAGER_H
17 #define CORE_IMAGE_IMAGE_LOADER_MANAGER_H
18 
19 #include <base/containers/vector.h>
20 #include <core/image/intf_image_container.h>
21 #include <core/image/intf_image_loader_manager.h>
22 #include <core/io/intf_file_manager.h>
23 #include <core/namespace.h>
24 
25 CORE_BEGIN_NAMESPACE()
26 class IFileManager;
27 
28 class ImageLoaderManager final : public IImageLoaderManager {
29 public:
ImageLoaderManager(IFileManager & fileManager)30     explicit ImageLoaderManager(IFileManager& fileManager) : fileManager_(fileManager) {};
31     ~ImageLoaderManager() override = default;
32 
33     void RegisterImageLoader(IImageLoader::Ptr imageLoader) override;
34 
35     LoadResult LoadImage(const BASE_NS::string_view uri, uint32_t loadFlags) override;
36     LoadResult LoadImage(IFile& file, uint32_t loadFlags) override;
37     LoadResult LoadImage(BASE_NS::array_view<const uint8_t> imageFileBytes, uint32_t loadFlags) override;
38 
39     LoadAnimatedResult LoadAnimatedImage(const BASE_NS::string_view uri, uint32_t loadFlags) override;
40     LoadAnimatedResult LoadAnimatedImage(IFile& file, uint32_t loadFlags) override;
41     LoadAnimatedResult LoadAnimatedImage(
42         BASE_NS::array_view<const uint8_t> imageFileBytes, uint32_t loadFlags) override;
43 
44     static LoadResult ResultFailure(const BASE_NS::string_view error);
45     static LoadResult ResultSuccess(IImageContainer::Ptr image);
46     static LoadAnimatedResult ResultFailureAnimated(const BASE_NS::string_view error);
47     static LoadAnimatedResult ResultSuccessAnimated(IAnimatedImage::Ptr image);
48 
49 private:
50     IFileManager& fileManager_;
51     BASE_NS::vector<IImageLoader::Ptr> imageLoaders_;
52 };
53 CORE_END_NAMESPACE()
54 
55 #endif // CORE_IMAGE_IMAGE_LOADER_MANAGER_H
56