2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FGrpBufferInfo.cpp
20 * @brief This is the implementation file for internal BufferInfo class.
26 #include <FGrpBufferInfo.h>
28 #include <FBaseSysLog.h>
30 #include "FGrp_BufferInfoImpl.h"
33 using namespace Tizen::Base;
36 namespace Tizen { namespace Graphics
39 BufferInfo::BufferInfo(void)
44 , pixelFormat(PIXEL_FORMAT_MIN)
48 __pImpl = new (std::nothrow) _BufferInfoImpl;
50 SysTryReturnVoidResult(NID_GRP, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
53 BufferInfo::BufferInfo(const BufferInfo& rhs)
57 , bitsPerPixel(rhs.bitsPerPixel)
58 , pixelFormat(rhs.pixelFormat)
59 , pPixels(rhs.pPixels)
62 if (_BufferInfoImpl::GetInstance(rhs) != null)
64 __pImpl = new (std::nothrow) _BufferInfoImpl(*_BufferInfoImpl::GetInstance(rhs));
66 SysTryReturnVoidResult(NID_GRP, __pImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient.");
70 BufferInfo::~BufferInfo(void)
80 BufferInfo::operator =(const BufferInfo& rhs)
87 this->width = rhs.width;
88 this->height = rhs.height;
89 this->pitch = rhs.pitch;
90 this->bitsPerPixel = rhs.bitsPerPixel;
91 this->pixelFormat = rhs.pixelFormat;
92 this->pPixels = rhs.pPixels;
94 if (this->__pImpl && _BufferInfoImpl::GetInstance(rhs))
96 *(this->__pImpl) = *_BufferInfoImpl::GetInstance(rhs);
103 BufferInfo::Equals(const Tizen::Base::Object& rhs) const
110 const BufferInfo* pBufferInfo = dynamic_cast <const BufferInfo*>(&rhs);
112 if (pBufferInfo == null)
117 return ((this->width == pBufferInfo->width &&
118 this->height == pBufferInfo->height &&
119 this->pitch == pBufferInfo->pitch &&
120 this->bitsPerPixel == pBufferInfo->bitsPerPixel &&
121 this->pixelFormat == pBufferInfo->pixelFormat &&
122 this->pPixels == pBufferInfo->pPixels) ? true : false);
126 BufferInfo::GetHashCode(void) const
128 return ((((this->width & 0xFF) << 24) |
129 ((this->height & 0xFF) << 16) |
130 ((this->pitch & 0xF) << 12) |
131 ((this->bitsPerPixel & 0xF) << 8) |
132 ((this->pixelFormat & 0xF) << 4)) ^
133 (reinterpret_cast<int>(this->pPixels)));
136 }} // Tizen::Graphics