X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fnpatch%2Fnpatch-visual.cpp;h=1a3f640cb9f01366c2ffbdaabd6c6ee930307374;hp=77d522e3d234d44c61ee8790ef52908a1b24624c;hb=e7229b4d17bab7395474229f3b209e42dc3ca9fa;hpb=2985aed6fcace8037f075d1598e8a454c2243ff7 diff --git a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp index 77d522e..1a3f640 100644 --- a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp +++ b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp @@ -202,10 +202,43 @@ void RegisterStretchProperties( Renderer& renderer, const char * uniformName, co NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache ) : Visual::Base( factoryCache ), + mImage(), + mCroppedImage(), + mImageUrl(), + mStretchPixelsX(), + mStretchPixelsY(), + mImageSize(), mBorderOnly( false ) { } +NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly ) +: Visual::Base( factoryCache ), + mImage(), + mCroppedImage(), + mImageUrl( imageUrl ), + mStretchPixelsX(), + mStretchPixelsY(), + mImageSize(), + mBorderOnly( borderOnly ) +{ + NinePatchImage nPatch = NinePatchImage::New( mImageUrl ); + InitializeFromImage( nPatch ); +} + +NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly ) +: Visual::Base( factoryCache ), + mImage( image ), + mCroppedImage(), + mImageUrl(), + mStretchPixelsX(), + mStretchPixelsY(), + mImageSize(), + mBorderOnly( borderOnly ) +{ + InitializeFromImage( image ); +} + NPatchVisual::~NPatchVisual() { } @@ -452,60 +485,6 @@ void NPatchVisual::ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t o } } -void NPatchVisual::SetImage( const std::string& imageUrl, bool borderOnly ) -{ - bool oldBorderOnly = mBorderOnly; - size_t oldGridX = mStretchPixelsX.Size(); - size_t oldGridY = mStretchPixelsY.Size(); - - mBorderOnly = borderOnly; - mImage.Reset(); - if( mImageUrl == imageUrl ) - { - return; - } - - mImageUrl = imageUrl; - if( mImpl->mRenderer ) - { - NinePatchImage nPatch = NinePatchImage::New( mImageUrl ); - InitializeFromImage( nPatch ); - - ChangeRenderer( oldBorderOnly, oldGridX, oldGridY ); - - if( mCroppedImage ) - { - ApplyImageToSampler(); - } - } -} - -void NPatchVisual::SetImage( NinePatchImage image, bool borderOnly ) -{ - bool oldBorderOnly = mBorderOnly; - size_t oldGridX = mStretchPixelsX.Size(); - size_t oldGridY = mStretchPixelsY.Size(); - - mBorderOnly = borderOnly; - mImageUrl.empty(); - if( mImage == image ) - { - return; - } - - mImage = image; - if( mImpl->mRenderer ) - { - InitializeFromImage( mImage ); - ChangeRenderer( oldBorderOnly, oldGridX, oldGridY ); - - if( mCroppedImage ) - { - ApplyImageToSampler(); - } - } -} - void NPatchVisual::InitializeFromImage( NinePatchImage nPatch ) { mCroppedImage = nPatch.CreateCroppedBufferImage();