/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
BufferImagePtr BufferImage::New( unsigned int width,
unsigned int height,
- Pixel::Format pixelformat,
- ReleasePolicy releasePol )
+ Pixel::Format pixelformat )
{
- BufferImagePtr internal = new BufferImage( width, height, pixelformat, releasePol );
+ BufferImagePtr internal = new BufferImage( width, height, pixelformat );
internal->Initialize();
return internal;
}
unsigned int width,
unsigned int height,
Pixel::Format pixelformat,
- unsigned int stride,
- ReleasePolicy releasePol )
+ unsigned int stride )
{
- BufferImagePtr internal = new BufferImage( pixBuf, width, height, pixelformat, stride, releasePol );
+ BufferImagePtr internal = new BufferImage( pixBuf, width, height, pixelformat, stride );
internal->Initialize();
return internal;
}
-BufferImage::BufferImage(unsigned int width, unsigned int height, Pixel::Format pixelformat, ReleasePolicy releasePol)
-: Image(releasePol),
- mInternalBuffer(NULL),
- mExternalBuffer(NULL)
+BufferImage::BufferImage(unsigned int width, unsigned int height, Pixel::Format pixelformat)
+: Image(),
+ mInternalBuffer( NULL ),
+ mExternalBuffer( NULL ),
+ mResourceClient( NULL ),
+ mBufferSize( 0 ),
+ mByteStride( 0 ),
+ mBytesPerPixel( 0 ),
+ mBufferWidth( 0 ),
+ mPixelFormat( pixelformat ),
+ mResourcePolicy( ResourcePolicy::OWNED_DISCARD )
{
- SetupBuffer( width, height, pixelformat, width, releasePol );
+ SetupBuffer( width, height, pixelformat, width );
// Allocate a persistent internal buffer
mInternalBuffer = new PixelBuffer[ mBufferSize ];
unsigned int width,
unsigned int height,
Pixel::Format pixelformat,
- unsigned int stride,
- ReleasePolicy releasePol )
-: Image(releasePol),
- mInternalBuffer(NULL),
- mExternalBuffer(pixBuf)
-{
- SetupBuffer( width, height, pixelformat, stride ? stride: width, releasePol );
+ unsigned int stride)
+: Image(),
+ mInternalBuffer( NULL ),
+ mExternalBuffer( pixBuf ),
+ mResourceClient( NULL ),
+ mBufferSize( 0 ),
+ mByteStride( 0 ),
+ mBytesPerPixel( 0 ),
+ mBufferWidth( 0 ),
+ mPixelFormat( pixelformat ),
+ mResourcePolicy( ResourcePolicy::OWNED_DISCARD )
+{
+ SetupBuffer( width, height, pixelformat, stride ? stride: width );
}
BufferImage::~BufferImage()
{
+ if( mTicket )
+ {
+ mTicket->RemoveObserver(*this);
+ mTicket.Reset();
+ }
+
delete[] mInternalBuffer;
}
void BufferImage::SetupBuffer( unsigned int width,
unsigned int height,
Pixel::Format pixelformat,
- unsigned int byteStride,
- ReleasePolicy releasePol )
+ unsigned int byteStride )
{
ThreadLocalStorage& tls = ThreadLocalStorage::Get();
mResourceClient = &tls.GetResourceClient();
mBufferSize = height * mByteStride;
// Respect the desired release policy
- mResourcePolicy = releasePol == Dali::Image::UNUSED ? ResourcePolicy::OWNED_DISCARD : ResourcePolicy::OWNED_RETAIN;
+ mResourcePolicy = ResourcePolicy::OWNED_RETAIN;
}
bool BufferImage::IsDataExternal() const
void BufferImage::Connect()
{
- if ( !mConnectionCount++ )
+ if ( !mConnectionCount++ && !mTicket )
{
RectArea area;
Update( area );
void BufferImage::Disconnect()
{
- if ( mTicket )
- {
- if ( !( --mConnectionCount ) && mReleasePolicy == Dali::Image::UNUSED )
- {
- mTicket->RemoveObserver(*this);
- mTicket.Reset();
- }
- }
+ --mConnectionCount;
}
} // namespace Internal