ResourceImage/Image split
[platform/core/uifw/dali-core.git] / dali / public-api / images / resource-image.cpp
1 /*
2  * Copyright (c) 2015 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/public-api/images/resource-image.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/images/image-attributes.h>
23 #include <dali/public-api/math/vector2.h>
24 #include <dali/internal/event/images/resource-image-impl.h>
25 #include <dali/internal/event/common/thread-local-storage.h>
26 #include <dali/integration-api/platform-abstraction.h>
27
28 namespace Dali
29 {
30
31 const char* const ResourceImage::SIGNAL_IMAGE_LOADING_FINISHED = "image-loading-finished";
32
33 Vector2 ResourceImage::GetImageSize( const std::string& url )
34 {
35   Vector2 size;
36   Internal::ThreadLocalStorage::Get().GetPlatformAbstraction().GetClosestImageSize( url, ImageAttributes::DEFAULT_ATTRIBUTES, size );
37   return size;
38 }
39
40 ResourceImage::ResourceImage()
41 {
42 }
43
44 ResourceImage::ResourceImage(Internal::ResourceImage* internal) : Image(internal)
45 {
46 }
47
48 ResourceImage::~ResourceImage()
49 {
50 }
51
52 ResourceImage::ResourceImage( const ResourceImage& handle )
53 : Image(handle)
54 {
55 }
56
57 ResourceImage& ResourceImage::operator=( const ResourceImage& rhs )
58 {
59   BaseHandle::operator=(rhs);
60   return *this;
61 }
62
63 ResourceImage ResourceImage::New( const std::string& url )
64 {
65   Internal::ResourceImagePtr internal = Internal::ResourceImage::New( url,
66                                                          Dali::ImageAttributes::DEFAULT_ATTRIBUTES );
67   return ResourceImage(internal.Get());
68 }
69
70 ResourceImage ResourceImage::New( const std::string& url, LoadPolicy loadPol, ReleasePolicy releasePol )
71 {
72   Internal::ResourceImagePtr internal = Internal::ResourceImage::New( url,
73                                                          Dali::ImageAttributes::DEFAULT_ATTRIBUTES,
74                                                          loadPol, releasePol );
75   return ResourceImage(internal.Get());
76 }
77
78 ResourceImage ResourceImage::New( const std::string& url, const ImageAttributes& attributes )
79 {
80   Internal::ResourceImagePtr internal = Internal::ResourceImage::New( url, attributes );
81   return ResourceImage(internal.Get());
82 }
83
84 ResourceImage ResourceImage::New( const std::string& url, const ImageAttributes& attributes, LoadPolicy loadPol, ReleasePolicy releasePol )
85 {
86   Internal::ResourceImagePtr internal = Internal::ResourceImage::New( url, attributes, loadPol, releasePol );
87   return ResourceImage(internal.Get());
88 }
89
90 ResourceImage ResourceImage::DownCast( BaseHandle handle )
91 {
92   return ResourceImage( dynamic_cast<Dali::Internal::ResourceImage*>(handle.GetObjectPtr()) );
93 }
94
95 ResourceImage::LoadPolicy ResourceImage::GetLoadPolicy() const
96 {
97   return GetImplementation(*this).GetLoadPolicy();
98 }
99
100 LoadingState ResourceImage::GetLoadingState() const
101 {
102   return GetImplementation(*this).GetLoadingState();
103 }
104
105 std::string ResourceImage::GetUrl() const
106 {
107   return GetImplementation(*this).GetUrl();
108 }
109
110 void ResourceImage::Reload()
111 {
112   GetImplementation(*this).Reload();
113 }
114
115 ImageAttributes ResourceImage::GetAttributes() const
116 {
117   return GetImplementation(*this).GetAttributes();
118 }
119
120 ResourceImage::ResourceImageSignal& ResourceImage::LoadingFinishedSignal()
121 {
122   return GetImplementation(*this).LoadingFinishedSignal();
123 }
124
125 } // namespace Dali