/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
unsigned int width,
unsigned int height,
Dali::Pixel::Format pixelFormat )
-: mBuffer( buffer ),
+: mMetadata(),
+ mBuffer( buffer ),
mBufferSize( bufferSize ),
mWidth( width ),
mHeight( height ),
}
}
+void PixelBuffer::AllocateFixedSize( uint32_t size )
+{
+ ReleaseBuffer();
+ mBuffer = reinterpret_cast<unsigned char*>(malloc( size ));
+ mBufferSize = size;
+}
+
void PixelBuffer::ScaleAndCrop( float scaleFactor, ImageDimensions cropDimensions )
{
ImageDimensions outDimensions( float(mWidth) * scaleFactor,
}
+void PixelBuffer::SetMetadata( const Property::Map& map )
+{
+ mMetadata.reset(new Property::Map(map));
+}
+
+bool PixelBuffer::GetMetadata(Property::Map& outMetadata) const
+{
+ if( !mMetadata )
+ {
+ return false;
+ }
+ outMetadata = *mMetadata;
+ return true;
+}
+
+void PixelBuffer::SetMetadata(std::unique_ptr<Property::Map> metadata)
+{
+ mMetadata = std::move(metadata);
+}
+
void PixelBuffer::Resize( ImageDimensions outDimensions )
{
if( mWidth != outDimensions.GetWidth() || mHeight != outDimensions.GetHeight() )
{
auto bytesPerPixel = Pixel::GetBytesPerPixel( mPixelFormat );
- if( Pixel::HasAlpha(mPixelFormat) )
+ // Compressed textures have unknown size of the pixel. Alpha premultiplication
+ // must be skipped in such case
+ if( Pixel::GetBytesPerPixel(mPixelFormat) && Pixel::HasAlpha(mPixelFormat) )
{
unsigned char* pixel = mBuffer;
const unsigned int bufferSize = mWidth * mHeight;