2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/images/buffer-image.h>
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>
29 BufferImage::BufferImage()
33 BufferImage::BufferImage(Internal::BufferImage* internal)
38 BufferImage BufferImage::DownCast( BaseHandle handle )
40 return BufferImage( dynamic_cast<Dali::Internal::BufferImage*>(handle.GetObjectPtr()) );
43 BufferImage::~BufferImage()
47 BufferImage::BufferImage(const BufferImage& handle)
52 BufferImage& BufferImage::operator=(const BufferImage& rhs)
54 BaseHandle::operator=(rhs);
58 const BufferImage BufferImage::WHITE()
60 Internal::BufferImage* internal = new Internal::BufferImage(1,1,Pixel::RGBA8888);
61 PixelBuffer* pBuf = internal->GetBuffer();
64 pBuf[0] = pBuf[1] = pBuf[2] = pBuf[3] = 0xFF;
66 return BufferImage(internal);
69 BufferImage BufferImage::New(unsigned int width, unsigned int height, Pixel::Format pixelformat)
71 DALI_ASSERT_ALWAYS( 0u != width && "Invalid BufferImage width requested" );
72 DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
74 Internal::BufferImagePtr internal = Internal::BufferImage::New(width, height, pixelformat);
75 return BufferImage(internal.Get());
78 BufferImage BufferImage::New(PixelBuffer* pixBuf, unsigned int width, unsigned int height, Pixel::Format pixelformat, unsigned int stride)
80 DALI_ASSERT_ALWAYS( 0u != width && "Invalid BufferImage width requested" );
81 DALI_ASSERT_ALWAYS( 0u != height && "Invalid BufferImage height requested" );
83 Internal::BufferImagePtr internal = Internal::BufferImage::New(pixBuf, width, height, pixelformat, stride);
84 return BufferImage(internal.Get());
87 PixelBuffer* BufferImage::GetBuffer()
89 return GetImplementation(*this).GetBuffer();
92 unsigned int BufferImage::GetBufferSize() const
94 return GetImplementation(*this).GetBufferSize();
97 unsigned int BufferImage::GetBufferStride() const
99 return GetImplementation(*this).GetBufferStride();
102 Pixel::Format BufferImage::GetPixelFormat() const
104 return GetImplementation(*this).GetPixelFormat();
107 void BufferImage::Update ()
110 GetImplementation(*this).Update(area);
113 void BufferImage::Update (RectArea updateArea)
115 GetImplementation(*this).Update(updateArea);
118 bool BufferImage::IsDataExternal() const
120 return GetImplementation(*this).IsDataExternal();