• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 #include <core/plugin/intf_plugin.h>
17 #include <core/plugin/intf_plugin_decl.h>
18 #include <core/plugin/intf_plugin_register.h>
19 #include <png/implementation_uids.h>
20 
21 #include "png/image_loader_png.h"
22 
23 using namespace CORE_NS;
24 
CORE_BEGIN_NAMESPACE()25 CORE_BEGIN_NAMESPACE()
26 #if defined(CORE_PLUGIN) && (CORE_PLUGIN == 1)
27 IPluginRegister* gPluginRegistry { nullptr };
GetPluginRegister()28 IPluginRegister& GetPluginRegister()
29 {
30     return *gPluginRegistry;
31 }
32 #endif
33 CORE_END_NAMESPACE()
34 
35 namespace PNGPlugin {
36 #ifdef __OHOS_PLATFORM__
GetVersionInfo()37 const char* GetVersionInfo()
38 {
39     return "GIT_TAG: GIT_REVISION: cd1bd88 GIT_BRANCH: dev";
40 }
41 #else
42 const char* GetVersionInfo();
43 #endif
44 
45 static constexpr CORE_NS::IImageLoaderManager::ImageLoaderTypeInfo PNG_LOADER {
46     { CORE_NS::IImageLoaderManager::ImageLoaderTypeInfo::UID },
47     nullptr,
48     BASE_NS::Uid { "41c1b7d1-e8a6-4aee-851b-c84de689a984" },
49     CreateImageLoaderPng,
50     IMAGE_TYPES,
51 };
52 
RegisterInterfaces(IPluginRegister & pluginRegistry)53 PluginToken RegisterInterfaces(IPluginRegister& pluginRegistry)
54 {
55 #if defined(CORE_PLUGIN) && (CORE_PLUGIN == 1)
56     gPluginRegistry = &pluginRegistry;
57 #endif
58     pluginRegistry.RegisterTypeInfo(PNG_LOADER);
59     return &pluginRegistry;
60 }
61 
UnregisterInterfaces(PluginToken token)62 void UnregisterInterfaces(PluginToken token)
63 {
64     static_cast<IPluginRegister*>(token)->UnregisterTypeInfo(PNG_LOADER);
65 }
66 } // namespace PNGPlugin
67 
68 extern "C" {
PLUGIN_DATA(PngPlugin)69 PLUGIN_DATA(PngPlugin) {
70     { IPlugin::UID },
71     "PNGPlugin",
72     /** Version information of the plugin. */
73     { PNGPlugin::UID_PNG_PLUGIN, PNGPlugin::GetVersionInfo },
74     PNGPlugin::RegisterInterfaces,
75     PNGPlugin::UnregisterInterfaces,
76     {},
77 };
78 }
79