+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, NinePatchImage image )
+{
+ NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) );
+ VisualUrl visualUrl( image.GetUrl() );
+ nPatchVisual->mImageUrl = visualUrl;
+ return nPatchVisual;
+}
+
+void NPatchVisual::LoadImages()
+{
+ TextureManager& textureManager = mFactoryCache.GetTextureManager();
+ bool synchronousLoading = mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
+
+ if( NPatchLoader::UNINITIALIZED_ID == mId && mImageUrl.IsLocalResource() )
+ {
+ bool preMultiplyOnLoad = IsPreMultipliedAlphaEnabled() && !mImpl->mCustomShader ? true : false;
+ mId = mLoader.Load( textureManager, this, mImageUrl.GetUrl(), mBorder, preMultiplyOnLoad, synchronousLoading );
+
+ const NPatchLoader::Data* data;
+ if( mLoader.GetNPatchData( mId, data ) && data->loadCompleted )
+ {
+ EnablePreMultipliedAlpha( preMultiplyOnLoad );
+ }
+ }
+
+ if( !mAuxiliaryPixelBuffer && mAuxiliaryUrl.IsValid() && mAuxiliaryUrl.IsLocalResource() )
+ {
+ // Load the auxiliary image
+ auto preMultiplyOnLoading = TextureManager::MultiplyOnLoad::LOAD_WITHOUT_MULTIPLY;
+ mAuxiliaryPixelBuffer = textureManager.LoadPixelBuffer( mAuxiliaryUrl, Dali::ImageDimensions(), FittingMode::DEFAULT,
+ SamplingMode::BOX_THEN_LINEAR, synchronousLoading,
+ this, true, preMultiplyOnLoading );
+ }
+}
+