[3.0] Mark Clipping API as being part of the Tizen 3 version
[platform/core/uifw/dali-core.git] / dali / public-api / images / buffer-image.cpp
1 /*
2  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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
18 // CLASS HEADER
19 #include <dali/public-api/images/buffer-image.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/internal/event/images/buffer-image-impl.h>
25
26 namespace Dali
27 {
28
29 BufferImage::BufferImage()
30 {
31 }
32
33 BufferImage::BufferImage(Internal::BufferImage* internal)
34   : Image(internal)
35 {
36 }
37
38 BufferImage BufferImage::DownCast( BaseHandle handle )
39 {
40   return BufferImage( dynamic_cast<Dali::Internal::BufferImage*>(handle.GetObjectPtr()) );
41 }
42
43 BufferImage::~BufferImage()
44 {
45 }
46
47 BufferImage::BufferImage(const BufferImage& handle)
48 : Image(handle)
49 {
50 }
51
52 BufferImage& BufferImage::operator=(const BufferImage& rhs)
53 {
54   BaseHandle::operator=(rhs);
55   return *this;
56 }
57
58 const BufferImage BufferImage::WHITE()
59 {
60   Internal::BufferImage* internal = new Internal::BufferImage(1,1,Pixel::RGBA8888, Dali::Image::NEVER);
61   PixelBuffer* pBuf = internal->GetBuffer();
62   if ( pBuf )
63   {
64     pBuf[0] = pBuf[1] = pBuf[2] = pBuf[3] = 0xFF;
65   }
66   return BufferImage(internal);
67 }
68
69 BufferImage BufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat)
70 {
71   DALI_ASSERT_ALWAYS( 0u != width  && "Invalid BufferImage width requested" );
72   DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
73
74   Internal::BufferImagePtr internal = Internal::BufferImage::New(width, height, pixelformat);
75   return BufferImage(internal.Get());
76 }
77
78 BufferImage BufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol)
79 {
80   DALI_ASSERT_ALWAYS( 0u != width  && "Invalid BufferImage width requested" );
81   DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
82
83   Internal::BufferImagePtr internal = Internal::BufferImage::New(width, height, pixelformat, releasePol);
84   return BufferImage(internal.Get());
85 }
86
87 BufferImage BufferImage::New(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride)
88 {
89   DALI_ASSERT_ALWAYS( 0u != width  && "Invalid BufferImage width requested" );
90   DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
91
92   Internal::BufferImagePtr internal = Internal::BufferImage::New(pixBuf, width, height, pixelformat, stride);
93   return BufferImage(internal.Get());
94 }
95
96 BufferImage BufferImage::New(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride, ReleasePolicy releasePol)
97 {
98   DALI_ASSERT_ALWAYS( 0u != width  && "Invalid BufferImage width requested" );
99   DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
100   Internal::BufferImagePtr internal = Internal::BufferImage::New(pixBuf, width, height, pixelformat, stride, releasePol);
101   return BufferImage(internal.Get());
102 }
103
104 PixelBuffer* BufferImage::GetBuffer()
105 {
106   return GetImplementation(*this).GetBuffer();
107 }
108
109 unsigned int BufferImage::GetBufferSize() const
110 {
111   return GetImplementation(*this).GetBufferSize();
112 }
113
114 unsigned int BufferImage::GetBufferStride() const
115 {
116   return GetImplementation(*this).GetBufferStride();
117 }
118
119 Pixel::Format BufferImage::GetPixelFormat() const
120 {
121   return GetImplementation(*this).GetPixelFormat();
122 }
123
124 void BufferImage::Update ()
125 {
126   RectArea area;
127   GetImplementation(*this).Update(area);
128 }
129
130 void BufferImage::Update (RectArea updateArea)
131 {
132   GetImplementation(*this).Update(updateArea);
133 }
134
135 bool BufferImage::IsDataExternal() const
136 {
137   return GetImplementation(*this).IsDataExternal();
138 }
139
140 } // namespace Dali