Support YUV decoding for JPEG
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / public-api / image-loader / async-image-loader.cpp
1 /*
2  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 // CLASS HEADER
18 #include "async-image-loader.h"
19
20 // INTERNAL INCLUDES
21 #include <dali-toolkit/internal/image-loader/async-image-loader-impl.h>
22 #include <dali-toolkit/internal/visuals/visual-url.h>
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28 AsyncImageLoader::AsyncImageLoader()
29 {
30 }
31
32 AsyncImageLoader::~AsyncImageLoader()
33 {
34 }
35
36 AsyncImageLoader::AsyncImageLoader(Internal::AsyncImageLoader* impl)
37 : BaseHandle(impl)
38 {
39 }
40
41 AsyncImageLoader::AsyncImageLoader(const AsyncImageLoader& handle) = default;
42
43 AsyncImageLoader::AsyncImageLoader(AsyncImageLoader&& rhs) = default;
44
45 AsyncImageLoader& AsyncImageLoader::operator=(const AsyncImageLoader& handle) = default;
46
47 AsyncImageLoader& AsyncImageLoader::operator=(AsyncImageLoader&& rhs) = default;
48
49 AsyncImageLoader AsyncImageLoader::DownCast(BaseHandle handle)
50 {
51   return AsyncImageLoader(dynamic_cast<Dali::Toolkit::Internal::AsyncImageLoader*>(handle.GetObjectPtr()));
52 }
53
54 AsyncImageLoader AsyncImageLoader::New()
55 {
56   IntrusivePtr<Internal::AsyncImageLoader> internal = Internal::AsyncImageLoader::New();
57   return AsyncImageLoader(internal.Get());
58 }
59
60 uint32_t AsyncImageLoader::Load(const std::string& url)
61 {
62   return GetImplementation(*this).Load(Toolkit::Internal::VisualUrl(url), ImageDimensions(), FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF, false);
63 }
64
65 uint32_t AsyncImageLoader::Load(const std::string& url, ImageDimensions dimensions)
66 {
67   return GetImplementation(*this).Load(Toolkit::Internal::VisualUrl(url), dimensions, FittingMode::DEFAULT, SamplingMode::BOX_THEN_LINEAR, true, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF, false);
68 }
69
70 uint32_t AsyncImageLoader::Load(const std::string& url,
71                                 ImageDimensions    dimensions,
72                                 FittingMode::Type  fittingMode,
73                                 SamplingMode::Type samplingMode,
74                                 bool               orientationCorrection)
75 {
76   return GetImplementation(*this).Load(Toolkit::Internal::VisualUrl(url), dimensions, fittingMode, samplingMode, orientationCorrection, DevelAsyncImageLoader::PreMultiplyOnLoad::OFF, false);
77 }
78
79 bool AsyncImageLoader::Cancel(uint32_t loadingTaskId)
80 {
81   return GetImplementation(*this).Cancel(loadingTaskId);
82 }
83
84 void AsyncImageLoader::CancelAll()
85 {
86   GetImplementation(*this).CancelAll();
87 }
88
89 AsyncImageLoader::ImageLoadedSignalType& AsyncImageLoader::ImageLoadedSignal()
90 {
91   return GetImplementation(*this).ImageLoadedSignal();
92 }
93 } // namespace Toolkit
94
95 } // namespace Dali