[3.0] Mark Clipping API as being part of the Tizen 3 version
[platform/core/uifw/dali-core.git] / dali / internal / event / images / encoded-buffer-image-impl.h
1 #ifndef __DALI_INTERNAL_ENCODED_BUFFER_IMAGE_H__
2 #define __DALI_INTERNAL_ENCODED_BUFFER_IMAGE_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/public-api/object/ref-object.h>
23 #include <dali/internal/event/images/image-impl.h>
24 #include <dali/public-api/images/encoded-buffer-image.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 class EncodedBufferImage;
33 typedef IntrusivePtr<EncodedBufferImage> EncodedBufferImagePtr;
34
35 class ResourceClient;
36 class ResourceManager;
37
38 namespace SceneGraph
39 {
40 class UpdateManager;
41 }
42 /**
43  * EncodedBufferImage represents an image resource that can be added to actors etc.
44  *
45  * A memory buffer of encoded image data is provided by the application and
46  * decoded asynchronously on a background thread to fill the image's
47  * pixel data.
48  */
49 class EncodedBufferImage : public Image
50 {
51 private:
52   /**
53    * Construct using the supplied load policy.
54    */
55   EncodedBufferImage( ReleasePolicy releasePol = IMAGE_RELEASE_POLICY_DEFAULT ) : Image( releasePol ) {}
56
57 public:
58   /**
59    * Create an initialised image object from an encoded image buffer in memory.
60    * @param [in] encodedImage The encoded bytes of an image, in a supported
61    * image format such as PNG, JPEG, GIF, BMP, KTX, ICO, and WBMP, organised
62    * exactly as it would be as a file in the filesystem.
63    * The caller retains ownership of this buffer and is free to modify or
64    * discard it as soon as the function returns.
65    * @param [in] encodedImageByteCount The size in bytes of the buffer pointed to
66    * by encodedImage.
67    * @param [in] attributes Requested parameters for loading (size, scaling etc.).
68    * @param [in] releasePol The ReleasePolicy to apply to image. Since it cannot
69    * be recreated by dali, the default of Never will usually make sense.
70    * @return A pointer to a newly allocated object, or null on error.
71    */
72   static EncodedBufferImagePtr New(const uint8_t * const encodedImage,
73                                    const std::size_t encodedImageByteCount,
74                                    ImageDimensions size = ImageDimensions(0, 0),
75                                    FittingMode::Type scalingMode = FittingMode::SHRINK_TO_FIT,
76                                    SamplingMode::Type samplingMode = SamplingMode::BOX,
77                                    bool orientationCorrection = true,
78                                    const ReleasePolicy releasePol=Dali::Image::NEVER);
79 };
80
81 } // namespace Internal
82
83 /**
84  * Helper methods for public API.
85  */
86 inline Internal::EncodedBufferImage& GetImplementation(Dali::EncodedBufferImage& image)
87 {
88   DALI_ASSERT_ALWAYS( image && "EncodedBufferImage handle is empty" );
89
90   BaseObject& handle = image.GetBaseObject();
91
92   return static_cast<Internal::EncodedBufferImage&>(handle);
93 }
94
95 inline const Internal::EncodedBufferImage& GetImplementation(const Dali::EncodedBufferImage& image)
96 {
97   DALI_ASSERT_ALWAYS( image && "EncodedBufferImage handle is empty" );
98
99   const BaseObject& handle = image.GetBaseObject();
100
101   return static_cast<const Internal::EncodedBufferImage&>(handle);
102 }
103
104 } // namespace Dali
105
106 #endif // __DALI_INTERNAL_ENCODED_BUFFER_IMAGE_H__