License conversion from Flora to Apache 2.0
[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
25 namespace Dali
26 {
27
28 namespace Internal
29 {
30 class ImageTicket;
31 class  ResourceManager;
32
33 typedef IntrusivePtr<ImageTicket>    ImageTicketPtr;
34
35 /**
36  * ImageTicket is essentially the same as a ResourceTicket,
37  * except that it contains additional information about the loaded image resource.
38  * The data is the result of the resource loading request.
39  *
40  * Multi-threading note: this class should be used in the main thread only
41  * i.e. not from within Dali::Integration::Core::Render().
42  */
43 class ImageTicket : public ResourceTicket
44 {
45 public:
46
47   /**
48    * Create an image resource request.
49    * This should only be done by the ResourceTicketRegistry.
50    * @param [in] observer A resource ticket lifetime observer.
51    * @param [in] id A unique ID for this ticket (loading request).
52    * @param [in] typePath The resource Type & Path pair.
53    */
54   ImageTicket( ResourceTicketLifetimeObserver& observer, unsigned int id, ResourceTypePath& typePath );
55
56   /**
57    * Get the attributes of an image.
58    * Only to be used after the image has finished loading.
59    * (Ticket's LoadingSucceeded callback was called)
60    * Reflects the last cached values after a LoadComplete.
61    * If requested width or height was 0, they are replaced by concrete dimensions.
62    * @return a copy of the image attributes
63    */
64   const Dali::ImageAttributes& GetAttributes() const { return mAttributes;}
65
66   /**
67    * Get the width of an image.
68    * Only to be used after the image has finished loading.
69    * (Ticket's LoadingSucceeded callback was called)
70    * Reflects the last cached values after a LoadComplete.
71    * If requested width or height was 0, they are replaced by concrete dimensions.
72    * @return the width
73    */
74   int GetWidth() const;
75
76   /**
77    * Get the height of an image.
78    * Only to be used after the image has finished loading.
79    * (Ticket's LoadingSucceeded callback was called)
80    * Reflects the last cached values after a LoadComplete.
81    * If requested width or height was 0, they are replaced by concrete dimensions.
82    * @return the height
83    */
84   int GetHeight() const;
85
86 protected:
87
88   /**
89    * A reference counted object may only be deleted by calling Unreference()
90    */
91   virtual ~ImageTicket()
92   {
93   }
94
95 private:
96
97   // Undefined copy constructor.
98   ImageTicket(const ImageTicket& typePath);
99
100   // Undefined copy constructor.
101   ImageTicket& operator=(const ImageTicket& rhs);
102
103 private:
104
105   /**
106    * Loaded Image attributes (width, height, pixelformat etc.).
107    * Contains actual values only after the image has finished loading.
108    * If requested width or height was 0, the natural size is used.
109    */
110   Dali::ImageAttributes mAttributes;
111
112   /*
113    * ResourceClient needs to set dimensions and pixelformat.
114    * Image needs to know about them.
115    */
116   friend class ResourceClient;
117 };
118
119 } // namespace Internal
120
121 } // namespace Dali
122
123 #endif // __DALI_INTERNAL_IMAGE_TICKET_H__