X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali%2Finternal%2Fevent%2Fimages%2Fnine-patch-image-impl.cpp;h=ca962369d628aa9bcc31ffbb3f9830e2982119d7;hb=65bb67c665fe465e388e8510eeb5fadda45cf202;hp=14c33f40ef5ac5c5a2c51c3914513e11b79507bf;hpb=5fab3d3bc329a7a19ec9cf1cac82031ca97af72d;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/images/nine-patch-image-impl.cpp b/dali/internal/event/images/nine-patch-image-impl.cpp index 14c33f4..ca96236 100644 --- a/dali/internal/event/images/nine-patch-image-impl.cpp +++ b/dali/internal/event/images/nine-patch-image-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -25,12 +25,9 @@ #include #include #include -#include #include -#include #include #include -#include namespace @@ -150,6 +147,15 @@ void GetRedOffsetAndMask(Dali::Pixel::Format pixelFormat, int& byteOffset, int& bitMask=0; break; } + + case Dali::Pixel::RGB16F: + case Dali::Pixel::RGB32F: + { + DALI_LOG_ERROR("Pixel format not compatible.\n"); + byteOffset=0; + bitMask=0; + break; + } } } @@ -161,11 +167,6 @@ namespace Dali namespace Internal { -namespace -{ -TypeRegistration mType( typeid( Dali::NinePatchImage ), typeid( Dali::Image ), NULL ); -} // unnamed namespace - NinePatchImagePtr NinePatchImage::New( const std::string& filename ) { Internal::NinePatchImagePtr internal( new NinePatchImage( filename ) ); @@ -179,23 +180,22 @@ NinePatchImage::NinePatchImage( const std::string& filename ) { mUrl = filename; ThreadLocalStorage& tls = ThreadLocalStorage::Get(); - mResourceClient = &tls.GetResourceClient(); Integration::PlatformAbstraction& platformAbstraction = tls.GetPlatformAbstraction(); Integration::BitmapResourceType resourceType; // Note, bitmap is only destroyed when the image is destroyed. - Integration::ResourcePointer resource = platformAbstraction.LoadResourceSynchronously( resourceType, filename ); + Integration::ResourcePointer resource = platformAbstraction.LoadImageSynchronously( resourceType, filename ); if( resource ) { mBitmap = static_cast( resource.Get()); mWidth = mBitmap->GetImageWidth(); mHeight = mBitmap->GetImageHeight(); - mTexture = NewTexture::New( Dali::TextureType::TEXTURE_2D, mBitmap->GetPixelFormat(), mWidth, mHeight ); + mTexture = Texture::New( Dali::TextureType::TEXTURE_2D, mBitmap->GetPixelFormat(), mWidth, mHeight ); - size_t bufferSize = mBitmap->GetBufferSize(); - unsigned char* buffer = new unsigned char[bufferSize]; + uint32_t bufferSize = mBitmap->GetBufferSize(); + uint8_t* buffer = new uint8_t[bufferSize]; memcpy( buffer, mBitmap->GetBuffer(), bufferSize ); PixelDataPtr pixelData = PixelData::New( buffer, bufferSize, mWidth, mHeight, mBitmap->GetPixelFormat(), Dali::PixelData::DELETE_ARRAY ); mTexture->Upload( pixelData ); @@ -264,13 +264,13 @@ Internal::BufferImagePtr NinePatchImage::CreateCroppedBufferImage() if( srcProfile ) { PixelBuffer* destPixels = cropped->GetBuffer(); - unsigned int destStride = cropped->GetBufferStride(); - unsigned int pixelWidth = GetBytesPerPixel(pixelFormat); + uint32_t destStride = cropped->GetBufferStride(); + uint32_t pixelWidth = GetBytesPerPixel(pixelFormat); PixelBuffer* srcPixels = mBitmap->GetBuffer(); - unsigned int srcStride = srcProfile->GetBufferStride(); + uint32_t srcStride = srcProfile->GetBufferStride(); - for( unsigned int row=1; row < mHeight-1; ++row ) + for( uint32_t row=1; row < mHeight-1; ++row ) { PixelBuffer* src = srcPixels + row*srcStride + pixelWidth; PixelBuffer* dest = destPixels + (row-1)*destStride; @@ -320,15 +320,15 @@ void NinePatchImage::ParseBorders() testValue = 0; // Black == stretch } - unsigned int pixelWidth = GetBytesPerPixel( pixelFormat ); + uint32_t pixelWidth = GetBytesPerPixel( pixelFormat ); const PixelBuffer* srcPixels = mBitmap->GetBuffer(); - unsigned int srcStride = srcProfile->GetBufferStride(); + uint32_t srcStride = srcProfile->GetBufferStride(); //TOP const PixelBuffer* top = srcPixels + pixelWidth; - unsigned int index = 0; - unsigned int width = mBitmap->GetImageWidth(); - unsigned int height = mBitmap->GetImageHeight(); + uint32_t index = 0; + uint32_t width = mBitmap->GetImageWidth(); + uint32_t height = mBitmap->GetImageHeight(); for(; index < width - 2; ) { @@ -389,9 +389,9 @@ void NinePatchImage::ParseBorders() } } -Uint16Pair NinePatchImage::ParseRange( unsigned int& index, unsigned int width, const PixelBuffer* & pixel, unsigned int pixelStride, int testByte, int testBits, int testValue ) +Uint16Pair NinePatchImage::ParseRange( uint32_t& index, uint32_t width, const PixelBuffer* & pixel, uint32_t pixelStride, int testByte, int testBits, int testValue ) { - unsigned int start = 0xFFFF; + uint32_t start = 0xFFFF; for( ; index < width; ++index, pixel += pixelStride ) { if( ( pixel[ testByte ] & testBits ) == testValue ) @@ -403,7 +403,7 @@ Uint16Pair NinePatchImage::ParseRange( unsigned int& index, unsigned int width, } } - unsigned int end = width; + uint32_t end = width; for( ; index < width; ++index, pixel += pixelStride ) { if( ( pixel[ testByte ] & testBits ) != testValue )