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>
29 AnimatedImageLoading::AnimatedImageLoading()
33 AnimatedImageLoading AnimatedImageLoading::New( const std::string& url, bool isLocalResource )
35 const std::size_t urlSize = url.length();
37 Internal::Adaptor::AnimatedImageLoadingPtr internal = NULL;
38 if(urlSize >= 4){ // 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" )
40 || !url.compare( urlSize - 4, 4, ".GIF" ) )
42 internal = Internal::Adaptor::GifLoading::New( url, isLocalResource );
45 if(urlSize >= 5){ // 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" )
47 || !url.compare( urlSize - 5, 5, ".WEBP" ) )
49 internal = Internal::Adaptor::WebPLoading::New( url, isLocalResource );
53 return AnimatedImageLoading( internal.Get() );
56 AnimatedImageLoading AnimatedImageLoading::DownCast( BaseHandle handle )
58 return AnimatedImageLoading( dynamic_cast< Internal::Adaptor::AnimatedImageLoading* >( handle.GetObjectPtr() ) );
61 AnimatedImageLoading::~AnimatedImageLoading()
65 bool AnimatedImageLoading::LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData )
67 return GetImplementation( *this ).LoadNextNFrames( frameStartIndex, count, pixelData );
70 Dali::Devel::PixelBuffer AnimatedImageLoading::LoadFrame( uint32_t frameIndex )
72 return GetImplementation( *this ).LoadFrame( frameIndex );
75 ImageDimensions AnimatedImageLoading::GetImageSize() const
77 return GetImplementation( *this ).GetImageSize();
80 uint32_t AnimatedImageLoading::GetImageCount() const
82 return GetImplementation( *this ).GetImageCount();
85 uint32_t AnimatedImageLoading::GetFrameInterval( uint32_t frameIndex ) const
87 return GetImplementation( *this ).GetFrameInterval( frameIndex );
90 std::string AnimatedImageLoading::GetUrl() const
92 return GetImplementation( *this ).GetUrl();
95 AnimatedImageLoading::AnimatedImageLoading( Internal::Adaptor::AnimatedImageLoading* internal )
96 : BaseHandle( internal )