2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/devel-api/adaptor-framework/animated-image-loading.h>
22 #include <dali/internal/imaging/common/animated-image-loading-impl.h>
23 #include <dali/internal/imaging/common/gif-loading.h>
24 #include <dali/internal/imaging/common/webp-loading.h>
28 AnimatedImageLoading::AnimatedImageLoading()
32 AnimatedImageLoading AnimatedImageLoading::New(const std::string& url, bool isLocalResource)
34 const std::size_t urlSize = url.length();
36 Internal::Adaptor::AnimatedImageLoadingPtr internal = NULL;
38 { // Avoid throwing out_of_range or failing silently if exceptions are turned-off on the compare(). (http://www.cplusplus.com/reference/string/string/compare/)
39 if(!url.compare(urlSize - 4, 4, ".gif") || !url.compare(urlSize - 4, 4, ".GIF"))
41 internal = Internal::Adaptor::GifLoading::New(url, isLocalResource);
45 { // Avoid throwing out_of_range or failing silently if exceptions are turned-off on the compare(). (http://www.cplusplus.com/reference/string/string/compare/)
46 if(!url.compare(urlSize - 5, 5, ".webp") || !url.compare(urlSize - 5, 5, ".WEBP"))
48 internal = Internal::Adaptor::WebPLoading::New(url, isLocalResource);
52 return AnimatedImageLoading(internal.Get());
55 AnimatedImageLoading AnimatedImageLoading::DownCast(BaseHandle handle)
57 return AnimatedImageLoading(dynamic_cast<Internal::Adaptor::AnimatedImageLoading*>(handle.GetObjectPtr()));
60 AnimatedImageLoading::~AnimatedImageLoading()
64 bool AnimatedImageLoading::LoadNextNFrames(uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData)
66 return GetImplementation(*this).LoadNextNFrames(frameStartIndex, count, pixelData);
69 Dali::Devel::PixelBuffer AnimatedImageLoading::LoadFrame(uint32_t frameIndex)
71 return GetImplementation(*this).LoadFrame(frameIndex);
74 ImageDimensions AnimatedImageLoading::GetImageSize() const
76 return GetImplementation(*this).GetImageSize();
79 uint32_t AnimatedImageLoading::GetImageCount() const
81 return GetImplementation(*this).GetImageCount();
84 uint32_t AnimatedImageLoading::GetFrameInterval(uint32_t frameIndex) const
86 return GetImplementation(*this).GetFrameInterval(frameIndex);
89 std::string AnimatedImageLoading::GetUrl() const
91 return GetImplementation(*this).GetUrl();
94 AnimatedImageLoading::AnimatedImageLoading(Internal::Adaptor::AnimatedImageLoading* internal)
95 : BaseHandle(internal)