Merge branch 'devel/master (1.2.0)' into tizen
[platform/core/uifw/dali-core.git] / dali / internal / event / resources / image-ticket.h
1 #ifndef __DALI_INTERNAL_IMAGE_TICKET_H__
2 #define __DALI_INTERNAL_IMAGE_TICKET_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/resources/resource-ticket.h>
23 #include <dali/public-api/images/image.h>
24 #include <dali/internal/common/image-attributes.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31 class ImageTicket;
32 class  ResourceManager;
33
34 typedef IntrusivePtr<ImageTicket>    ImageTicketPtr;
35
36 /**
37  * ImageTicket is essentially the same as a ResourceTicket,
38  * except that it contains additional information about the loaded image resource.
39  * The data is the result of the resource loading request.
40  *
41  * Multi-threading note: this class should be used in the main thread only
42  * i.e. not from within Dali::Integration::Core::Render().
43  */
44 class ImageTicket : public ResourceTicket
45 {
46 public:
47
48   /**
49    * Create an image resource request.
50    * This should only be done by the ResourceTicketRegistry.
51    * @param [in] observer A resource ticket lifetime observer.
52    * @param [in] id A unique ID for this ticket (loading request).
53    * @param [in] typePath The resource Type & Path pair.
54    */
55   ImageTicket( ResourceTicketLifetimeObserver& observer, unsigned int id, ResourceTypePath& typePath );
56
57   /**
58    * Get the attributes of an image.
59    * Only to be used after the image has finished loading.
60    * (Ticket's LoadingSucceeded callback was called)
61    * Reflects the last cached values after a LoadComplete.
62    * If requested width or height was 0, they are replaced by concrete dimensions.
63    * @return a copy of the image attributes
64    */
65   const ImageAttributes& GetAttributes() const { return mAttributes;}
66
67   /**
68    * Get the width of an image.
69    * Only to be used after the image has finished loading.
70    * (Ticket's LoadingSucceeded callback was called)
71    * Reflects the last cached values after a LoadComplete.
72    * If requested width or height was 0, they are replaced by concrete dimensions.
73    * @return the width
74    */
75   int GetWidth() const;
76
77   /**
78    * Get the height of an image.
79    * Only to be used after the image has finished loading.
80    * (Ticket's LoadingSucceeded callback was called)
81    * Reflects the last cached values after a LoadComplete.
82    * If requested width or height was 0, they are replaced by concrete dimensions.
83    * @return the height
84    */
85   int GetHeight() const;
86
87 protected:
88
89   /**
90    * A reference counted object may only be deleted by calling Unreference()
91    */
92   virtual ~ImageTicket()
93   {
94   }
95
96 private:
97
98   // Undefined copy constructor.
99   ImageTicket(const ImageTicket& typePath);
100
101   // Undefined copy constructor.
102   ImageTicket& operator=(const ImageTicket& rhs);
103
104 private:
105
106   /**
107    * Loaded Image attributes (width, height, pixelformat etc.).
108    * Contains actual values only after the image has finished loading.
109    * If requested width or height was 0, the natural size is used.
110    */
111   ImageAttributes mAttributes;
112
113   /*
114    * ResourceClient needs to set dimensions and pixelformat.
115    * Image needs to know about them.
116    */
117   friend class ResourceClient;
118 };
119
120 } // namespace Internal
121
122 } // namespace Dali
123
124 #endif // __DALI_INTERNAL_IMAGE_TICKET_H__