[3.0] Remove/move experimental features
[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/internal/common/image-attributes.h>
23 #include <dali/internal/event/images/resource-image-impl.h>
24 #include <dali/internal/event/common/thread-local-storage.h>
25 #include <dali/integration-api/platform-abstraction.h>
26
27 namespace Dali
28 {
29
30 ImageDimensions ResourceImage::GetImageSize( const std::string& url )
31 {
32   const Internal::ImageAttributes& attribs = Internal::ImageAttributes::DEFAULT_ATTRIBUTES;
33   const ImageDimensions desiredSize = ImageDimensions( attribs.GetWidth(), attribs.GetHeight() );
34   const ImageDimensions size = Internal::ThreadLocalStorage::Get().GetPlatformAbstraction().GetClosestImageSize( url, desiredSize, attribs.GetScalingMode(), attribs.GetFilterMode(), attribs.GetOrientationCorrection() );
35   return size;
36 }
37
38 ResourceImage::ResourceImage()
39 {
40 }
41
42 ResourceImage::ResourceImage(Internal::ResourceImage* internal) : Image(internal)
43 {
44 }
45
46 ResourceImage::~ResourceImage()
47 {
48 }
49
50 ResourceImage::ResourceImage( const ResourceImage& handle )
51 : Image(handle)
52 {
53 }
54
55 ResourceImage& ResourceImage::operator=( const ResourceImage& rhs )
56 {
57   BaseHandle::operator=(rhs);
58   return *this;
59 }
60
61 ResourceImage ResourceImage::New( const std::string& url, bool orientationCorrection )
62 {
63   Internal::ImageAttributes attributes = Internal::ImageAttributes::DEFAULT_ATTRIBUTES;
64   attributes.SetOrientationCorrection( orientationCorrection );
65   return ResourceImage( Internal::ResourceImage::New( url, attributes ).Get() );
66 }
67
68 ResourceImage ResourceImage::New( const std::string& url, ImageDimensions size, FittingMode::Type scalingMode, SamplingMode::Type samplingMode, bool orientationCorrection )
69 {
70   Internal::ImageAttributes attributes = Internal::ImageAttributes::DEFAULT_ATTRIBUTES;
71   attributes.SetSize( Size( size.GetWidth(), size.GetHeight() ) );
72   attributes.SetScalingMode( scalingMode );
73   attributes.SetFilterMode( samplingMode );
74   attributes.SetOrientationCorrection( orientationCorrection );
75   return ResourceImage( Internal::ResourceImage::New( url, attributes ).Get() );
76 }
77
78 ResourceImage ResourceImage::DownCast( BaseHandle handle )
79 {
80   return ResourceImage( dynamic_cast<Dali::Internal::ResourceImage*>(handle.GetObjectPtr()) );
81 }
82
83 LoadingState ResourceImage::GetLoadingState() const
84 {
85   return GetImplementation(*this).GetLoadingState();
86 }
87
88 std::string ResourceImage::GetUrl() const
89 {
90   return GetImplementation(*this).GetUrl();
91 }
92
93 void ResourceImage::Reload()
94 {
95   GetImplementation(*this).Reload();
96 }
97
98 ResourceImage::ResourceImageSignal& ResourceImage::LoadingFinishedSignal()
99 {
100   return GetImplementation(*this).LoadingFinishedSignal();
101 }
102
103 } // namespace Dali