Delay image size checking until someone asks for it
[platform/core/uifw/dali-core.git] / dali / internal / event / images / bitmap-external.h
1 #ifndef __DALI_INTERNAL_BITMAP_EXTERNAL_H__
2 #define __DALI_INTERNAL_BITMAP_EXTERNAL_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 // EXTERNAL INCLUDES
22
23 // INTERNAL INCLUDES
24 #include <dali/internal/event/images/bitmap-packed-pixel.h>
25
26 namespace Dali
27 {
28
29 namespace Internal
30 {
31
32 /**
33  * Bitmap class.
34  * A container for external image data
35  */
36 class BitmapExternal : public BitmapPackedPixel
37 {
38 public:
39   /**
40    * Constructor
41    */
42
43   /**
44    * Creates new BitmapExternal instance with pixel buffer pointer and details.
45    * Application has ownership of the buffer, its contents can be modified.
46    * Bitmap stores given size information about the image.
47    * @pre bufferWidth, bufferHeight have to be power of two
48    * @param[in] pixBuf        pointer to external pixel buffer
49    * @param[in] width         Image width in pixels
50    * @param[in] height        Image height in pixels
51    * @param[in] pixelformat   pixel format
52    * @param[in] bufferWidth   Buffer width in pixels
53    * @param[in] bufferHeight  Buffer height in pixels
54    */
55   BitmapExternal(Dali::Integration::PixelBuffer* pixBuf,
56                  unsigned int width,
57                  unsigned int height,
58                  Pixel::Format pixelformat,
59                  unsigned int bufferWidth  = 0,
60                  unsigned int bufferHeight = 0);
61
62   /**
63    * This does nothing, data is owned by external application.
64    */
65   virtual Dali::Integration::PixelBuffer* ReserveBuffer(Pixel::Format pixelFormat,
66                                      unsigned int width,
67                                      unsigned int height,
68                                      unsigned int bufferWidth = 0,
69                                      unsigned int bufferHeight = 0)
70   {
71     return NULL;
72   }
73
74   /**
75    * Get the pixel buffer
76    * @return The buffer. You can modify its contents.
77    */
78   virtual Dali::Integration::PixelBuffer* GetBuffer()
79   {
80     return mExternalData;
81   }
82
83 protected:
84   /**
85    * A reference counted object may only be deleted by calling Unreference()
86    */
87   virtual ~BitmapExternal();
88
89 private:
90
91   Dali::Integration::PixelBuffer* mExternalData; ///< Externally owned pixel data
92
93 private:
94   BitmapExternal();  ///< defined private to prevent use
95   BitmapExternal(const BitmapExternal& other);  ///< defined private to prevent use
96   BitmapExternal& operator = (const BitmapExternal& other); ///< defined private to prevent use
97
98   // Changes scope, should be at end of class
99   DALI_LOG_OBJECT_STRING_DECLARATION;
100 };
101
102 } // namespace Internal
103
104 } // namespace Dali
105
106 #endif // __DALI_INTERNAL_BITMAP_EXTERNAL_H__