Added object sizes to platform abstraction in profiling section
[platform/core/uifw/dali-core.git] / dali / internal / event / images / image-factory-cache.cpp
1 //
2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18 #include <dali/internal/event/images/image-factory-cache.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/public-api/common/dali-common.h>
22 #include <dali/internal/event/common/thread-local-storage.h>
23 #include <dali/internal/event/common/stage-impl.h>
24 #include <dali/internal/event/images/image-factory.h>
25
26 // EXTERNAL INCLUDES
27
28
29 using namespace Dali::Internal::ImageFactoryCache;
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36
37 namespace ImageFactoryCache
38 {
39   Request::Request( RequestLifetimeObserver& observer,
40                     RequestId reqId,
41                     ResourceId resId,
42                     const std::string& path,
43                     const ImageAttributes* attr )
44   : resourceId( resId ),
45     url( path ),
46     mId( reqId ),
47     mLifetimeObserver( &observer )
48   {
49     if( attr )
50     {
51       attributes = new ImageAttributes( *attr );
52     }
53     else
54     {
55       attributes = NULL;
56     }
57   }
58
59   Request::~Request()
60   {
61     if( Stage::IsInstalled() && mLifetimeObserver )
62     {
63       mLifetimeObserver->RequestDiscarded( *this );
64     }
65     delete attributes;
66   }
67
68   RequestId Request::GetId() const
69   {
70     return mId;
71   }
72
73   void Request::StopLifetimeObservation()
74   {
75     mLifetimeObserver = NULL;
76   }
77
78 } // namespace ImageFactoryCache
79
80 } // namespace Internal
81
82 } // namespace Dali