Revert "[Tizen] Add DALi Autofill implementation"
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / animated-image-loading.cpp
1 /*
2  * Copyright (c) 2020 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
18 // CLASS HEADER
19 #include <dali/devel-api/adaptor-framework/animated-image-loading.h>
20
21 // INTERNAL HEADER
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>
25
26 namespace Dali
27 {
28
29 AnimatedImageLoading::AnimatedImageLoading()
30 {
31 }
32
33 AnimatedImageLoading AnimatedImageLoading::New( const std::string& url, bool isLocalResource )
34 {
35   const std::size_t urlSize = url.length();
36
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" ) )
41     {
42       internal = Internal::Adaptor::GifLoading::New( url, isLocalResource );
43     }
44   }
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" ) )
48     {
49       internal = Internal::Adaptor::WebPLoading::New( url, isLocalResource );
50     }
51   }
52
53   return AnimatedImageLoading( internal.Get() );
54 }
55
56 AnimatedImageLoading AnimatedImageLoading::DownCast( BaseHandle handle )
57 {
58   return AnimatedImageLoading( dynamic_cast< Internal::Adaptor::AnimatedImageLoading* >( handle.GetObjectPtr() ) );
59 }
60
61 AnimatedImageLoading::~AnimatedImageLoading()
62 {
63 }
64
65 bool AnimatedImageLoading::LoadNextNFrames( uint32_t frameStartIndex, int count, std::vector<Dali::PixelData>& pixelData )
66 {
67   return GetImplementation( *this ).LoadNextNFrames( frameStartIndex, count, pixelData );
68 }
69
70 Dali::Devel::PixelBuffer AnimatedImageLoading::LoadFrame( uint32_t frameIndex )
71 {
72   return GetImplementation( *this ).LoadFrame( frameIndex );
73 }
74
75 ImageDimensions AnimatedImageLoading::GetImageSize() const
76 {
77   return GetImplementation( *this ).GetImageSize();
78 }
79
80 uint32_t AnimatedImageLoading::GetImageCount() const
81 {
82   return GetImplementation( *this ).GetImageCount();
83 }
84
85 uint32_t AnimatedImageLoading::GetFrameInterval( uint32_t frameIndex ) const
86 {
87   return GetImplementation( *this ).GetFrameInterval( frameIndex );
88 }
89
90 std::string AnimatedImageLoading::GetUrl() const
91 {
92   return GetImplementation( *this ).GetUrl();
93 }
94
95 AnimatedImageLoading::AnimatedImageLoading( Internal::Adaptor::AnimatedImageLoading* internal )
96 : BaseHandle( internal )
97 {
98 }
99
100 } // namespace Dali