// </svg>
DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION );
+ // svg visual with a size
+ Visual::Base svgVisual2 = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions(200, 200) );
+ DALI_TEST_EQUALS( svgVisual2.GetSize(), Vector2( 200.f, 200.f ), TEST_LOCATION );
+ svgVisual2.GetNaturalSize(naturalSize);
+ DALI_TEST_EQUALS( naturalSize, Vector2(100.f, 100.f), TEST_LOCATION ); // Natural size should still be 100, 100
+
// Batch Image visual
propertyMap.Clear();
propertyMap.Insert( Visual::Property::TYPE, Visual::IMAGE );
END_TEST;
}
+int UtcDaliVisualFactoryGetSvgVisualLarge(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline( "UtcDaliVisualFactoryGetSvgVisual: Request svg visual with a svg url" );
+
+ VisualFactory factory = VisualFactory::Get();
+ Visual::Base visual = factory.CreateVisual( TEST_SVG_FILE_NAME, ImageDimensions( 2000, 2000 ) );
+ DALI_TEST_CHECK( visual );
+
+ TestGlAbstraction& gl = application.GetGlAbstraction();
+ TraceCallStack& textureTrace = gl.GetTextureTrace();
+ textureTrace.Enable(true);
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add( actor );
+ visual.SetOnStage( actor );
+ application.SendNotification();
+ application.Render();
+
+ // renderer is not added to actor until the rasterization is completed.
+ DALI_TEST_CHECK( actor.GetRendererCount() == 0u );
+
+ EventThreadCallback* eventTrigger = EventThreadCallback::Get();
+ CallbackBase* callback = eventTrigger->GetCallback();
+
+ eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
+ CallbackBase::Execute( *callback );
+
+ // renderer is added to actor
+ DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
+
+ // waiting for the resource uploading
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_EQUALS( textureTrace.FindMethod("BindTexture"), true, TEST_LOCATION );
+
+ END_TEST;
+}
+
//Creates a mesh visual from the given propertyMap and tries to load it on stage in the given application.
//This is expected to succeed, which will then pass the test.
void MeshVisualLoadsCorrectlyTest( Property::Map& propertyMap, ToolkitTestApplication& application )
ImageVisual::ImageVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
+ mImage(),
+ mPixels(),
mPixelArea( FULL_TEXTURE_RECT ),
+ mPlacementActor(),
+ mImageUrl(),
mDesiredSize(),
mFittingMode( FittingMode::DEFAULT ),
mSamplingMode( SamplingMode::DEFAULT ),
mWrapModeU( WrapMode::DEFAULT ),
mWrapModeV( WrapMode::DEFAULT ),
- mNativeFragmentShaderCode( ),
+ mNativeFragmentShaderCode(),
mNativeImageFlag( false )
{
}
+ImageVisual::ImageVisual( VisualFactoryCache& factoryCache,
+ const std::string& imageUrl,
+ ImageDimensions size,
+ FittingMode::Type fittingMode,
+ Dali::SamplingMode::Type samplingMode )
+: Visual::Base( factoryCache ),
+ mImage(),
+ mPixels(),
+ mPixelArea( FULL_TEXTURE_RECT ),
+ mPlacementActor(),
+ mImageUrl( imageUrl ),
+ mDesiredSize( size ),
+ mFittingMode( fittingMode ),
+ mSamplingMode( samplingMode ),
+ mWrapModeU( WrapMode::DEFAULT ),
+ mWrapModeV( WrapMode::DEFAULT ),
+ mNativeFragmentShaderCode(),
+ mNativeImageFlag( false )
+{
+}
+
+ImageVisual::ImageVisual( VisualFactoryCache& factoryCache, const Image& image )
+: Visual::Base( factoryCache ),
+ mImage( image ),
+ mPixels(),
+ mPixelArea( FULL_TEXTURE_RECT ),
+ mPlacementActor(),
+ mImageUrl(),
+ mDesiredSize(),
+ mFittingMode( FittingMode::DEFAULT ),
+ mSamplingMode( SamplingMode::DEFAULT ),
+ mWrapModeU( WrapMode::DEFAULT ),
+ mWrapModeV( WrapMode::DEFAULT ),
+ mNativeFragmentShaderCode(),
+ mNativeImageFlag( false )
+{
+ NativeImage newNativeImage = NativeImage::DownCast( image );
+ if( newNativeImage )
+ {
+ SetNativeFragmentShaderCode( newNativeImage );
+ mNativeImageFlag = true;
+ }
+ else
+ {
+ mNativeImageFlag = false;
+ }
+}
+
ImageVisual::~ImageVisual()
{
}
// if sync loading is required, the loading should start immediately when new image url is set or the actor is off stage
// ( for on-stage actor with image url unchanged, resource loading is already finished)
- if( ( !mImpl->mRenderer || imageURLValue) && IsSynchronousResourceLoading() )
+ if( imageURLValue && IsSynchronousResourceLoading() )
{
- DoSynchronousResourceLoading();
- }
-
- // remove old renderer if exit
- if( mImpl->mRenderer )
- {
- if( actor ) //remove old renderer from actor
- {
- actor.RemoveRenderer( mImpl->mRenderer );
- }
- if( !oldImageUrl.empty() ) //clean old renderer from cache
- {
- CleanCache( oldImageUrl );
- }
+ LoadResourceSynchronously();
}
NativeImage nativeImage = NativeImage::DownCast( mImage );
return mImpl->mFlags & Impl::IS_SYNCHRONOUS_RESOURCE_LOADING;
}
-void ImageVisual::DoSynchronousResourceLoading()
+void ImageVisual::LoadResourceSynchronously()
{
if( !mImageUrl.empty() )
{
return shader;
}
-void ImageVisual::SetImage( Actor& actor, const std::string& imageUrl, ImageDimensions size, Dali::FittingMode::Type fittingMode, Dali::SamplingMode::Type samplingMode )
-{
- if( mImageUrl != imageUrl )
- {
- std::string oldImageUrl = mImageUrl;
- mImageUrl = imageUrl;
- mDesiredSize = size;
- mFittingMode = fittingMode;
- mSamplingMode = samplingMode;
- mImage.Reset();
-
- if( IsSynchronousResourceLoading() )
- {
- DoSynchronousResourceLoading();
- }
-
- if( mImpl->mRenderer )
- {
- if( GetIsFromCache() ) // if renderer is from cache, remove the old one
- {
- //remove old renderer
- if( actor )
- {
- actor.RemoveRenderer( mImpl->mRenderer );
- }
-
- //clean the cache
- if( !oldImageUrl.empty() )
- {
- CleanCache(oldImageUrl);
- }
-
- if( actor && actor.OnStage() ) // if actor on stage, create a new renderer and apply to actor
- {
- SetOnStage(actor);
- }
- }
- else // if renderer is not from cache, reuse the same renderer and only change the texture
- {
- Image image = LoadImage( imageUrl, IsSynchronousResourceLoading() );
- ApplyImageToSampler( image );
- }
- }
- }
-}
-
-void ImageVisual::SetImage( Actor& actor, const Image& image )
-{
- if( mImage != image )
- {
- NativeImage newNativeImage = NativeImage::DownCast( image );
- bool newRendererFlag = true;
-
- if( newNativeImage && !mNativeImageFlag )
- {
- SetNativeFragmentShaderCode( newNativeImage );
- }
-
- if( ( newNativeImage && mNativeImageFlag ) || ( !newNativeImage && !mNativeImageFlag ) )
- {
- newRendererFlag = false;
- }
-
- if( newNativeImage )
- {
- mNativeImageFlag = true;
- }
- else
- {
- mNativeFragmentShaderCode.clear();
- mNativeImageFlag = false;
- }
-
- mImage = image;
-
- if( mImpl->mRenderer )
- {
- // if renderer is from cache, remove the old one, and create new renderer
- if( GetIsFromCache() )
- {
- //remove old renderer
- if( actor )
- {
- actor.RemoveRenderer( mImpl->mRenderer );
- }
-
- //clean the cache
- if( !mImageUrl.empty() )
- {
- CleanCache(mImageUrl);
- }
- mImageUrl.clear();
-
- if( actor && actor.OnStage() ) // if actor on stage, create a new renderer and apply to actor
- {
- SetOnStage(actor);
- }
- }
- // if input image is nativeImage and mImage is regular image or the reverse, remove the old one, and create new renderer
- else if( newRendererFlag )
- {
- //remove old renderer
- if( actor )
- {
- actor.RemoveRenderer( mImpl->mRenderer );
- }
-
- if( actor && actor.OnStage() ) // if actor on stage, create a new renderer and apply to actor
- {
- SetOnStage(actor);
- }
- }
- else // if renderer is not from cache, reuse the same renderer and only change the texture
- {
- ApplyImageToSampler( image );
- }
- }
-
- mImageUrl.clear();
- mDesiredSize = ImageDimensions();
- mFittingMode = FittingMode::DEFAULT;
- mSamplingMode = SamplingMode::DEFAULT;
- }
-}
-
void ImageVisual::ApplyImageToSampler( const Image& image )
{
if( image )
void ImageVisual::CleanCache(const std::string& url)
{
- TextureSet textureSet = mImpl->mRenderer.GetTextures();
-
- Vector4 atlasRect( 0.f, 0.f, 1.f, 1.f );
- Property::Index index = mImpl->mRenderer.GetPropertyIndex( ATLAS_RECT_UNIFORM_NAME );
- if( index != Property::INVALID_INDEX )
+ if( IsFromCache() )
{
- Property::Value atlasRectValue = mImpl->mRenderer.GetProperty( index );
- atlasRectValue.Get( atlasRect );
- }
+ TextureSet textureSet = mImpl->mRenderer.GetTextures();
- mImpl->mRenderer.Reset();
- if( mFactoryCache.CleanRendererCache( url ) && index != Property::INVALID_INDEX )
- {
- mFactoryCache.GetAtlasManager()->Remove( textureSet, atlasRect );
+ Vector4 atlasRect( 0.f, 0.f, 1.f, 1.f );
+ Property::Index index = mImpl->mRenderer.GetPropertyIndex( ATLAS_RECT_UNIFORM_NAME );
+ if( index != Property::INVALID_INDEX )
+ {
+ Property::Value atlasRectValue = mImpl->mRenderer.GetProperty( index );
+ atlasRectValue.Get( atlasRect );
+ }
+
+ mImpl->mRenderer.Reset();
+ if( mFactoryCache.CleanRendererCache( url ) && index != Property::INVALID_INDEX )
+ {
+ mFactoryCache.GetAtlasManager()->Remove( textureSet, atlasRect );
+ }
}
}
#define DALI_TOOLKIT_INTERNAL_IMAGE_VISUAL_H
/*
- * 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.
ImageVisual( VisualFactoryCache& factoryCache );
/**
+ * @brief Constructor with a URL.
+ *
+ * The visual will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
+ *
+ * @param[in] factoryCache The VisualFactoryCache object
+ * @param[in] imageUrl The URL of the image resource to use
+ * @param[in] size The width and height to fit the loaded image to.
+ * @param[in] fittingMode The FittingMode of the resource to load
+ * @param[in] samplingMode The SamplingMode of the resource to load
+ */
+ ImageVisual( VisualFactoryCache& factoryCache,
+ const std::string& imageUrl,
+ ImageDimensions size=ImageDimensions(),
+ FittingMode::Type fittingMode = FittingMode::DEFAULT,
+ Dali::SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR );
+
+ /**
+ * @brief Constructor with an Image type.
+ *
+ * @param[in] factoryCache The VisualFactoryCache object
+ * @param[in] image The image to use
+ */
+ ImageVisual( VisualFactoryCache& factoryCache, const Image& image );
+
+ /**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
~ImageVisual();
static Shader GetImageShader( VisualFactoryCache& factoryCache, bool atlasing, bool defaultTextureWrapping );
/**
- * @brief Sets the image of this visual to the resource at imageUrl
- * The visual will load the Image asynchronously when the associated actor is put on stage, and destroy the image when it is off stage
- *
- * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
- * @param[in] imageUrl The URL of the image resource to use
- * @param[in] size The width and height to fit the loaded image to.
- * @param[in] fittingMode The FittingMode of the resource to load
- * @param[in] samplingMode The SamplingMode of the resource to load
- */
- void SetImage( Actor& actor,
- const std::string& imageUrl,
- ImageDimensions size=ImageDimensions(),
- FittingMode::Type fittingMode = FittingMode::DEFAULT,
- Dali::SamplingMode::Type samplingMode = SamplingMode::BOX_THEN_LINEAR );
-
- /**
- * @brief Sets the image to be rendered by this visual
- *
- * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
- * @param[in] image The image to use
- */
- void SetImage( Actor& actor, const Image& image );
-
- /**
* @copydoc AtlasUploadObserver::UploadCompleted
*
* To avoid rendering garbage pixels, renderer should be added to actor after the resources are ready.
/**
* @brief Query whether resources requires to be loaded synchronously.
- * @return Returns true if synchronoud resource loading is required, false otherwise.
+ * @return Returns true if synchronous resource loading is required, false otherwise.
*/
bool IsSynchronousResourceLoading() const;
/**
- * @brief Do the synchronous resource loading
+ * @brief Load the resource synchronously
*/
- void DoSynchronousResourceLoading();
+ void LoadResourceSynchronously();
/**
* Load the image.
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()
{
}
}
}
-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();
NPatchVisual( VisualFactoryCache& factoryCache );
/**
+ * @brief Constructor which creates an N-patch visual using an image URL.
+ *
+ * The visual will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] imageUrl The URL to 9 patch image resource to use
+ * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
+ */
+ NPatchVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, bool borderOnly = false );
+
+ /**
+ * @brief Constructor which creates an N-patch viusal with a NinePatchImage resource.
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] image The NinePatchImage to use
+ * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
+ */
+ NPatchVisual( VisualFactoryCache& factoryCache, NinePatchImage image, bool borderOnly = false );
+
+ /**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
~NPatchVisual();
*/
virtual void DoSetOffStage( Actor& actor );
-public:
-
- /**
- * @brief Sets the 9 patch image of this visual to the resource at imageUrl
- * The visual will load the image synchronously when the associated actor is put on stage, and destroy the image when it is off stage
- *
- * @param[in] imageUrl The URL to 9 patch image resource to use
- * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
- */
- void SetImage( const std::string& imageUrl, bool borderOnly = false );
-
- /**
- * @brief Sets the 9 patch image of this viusal to the 9 patch image
- *
- * @param[in] image The NinePatchImage to use
- * @param[in] borderOnly A Flag to indicate if the image should omit the centre of the n-patch and only render the border
- */
- void SetImage( NinePatchImage image, bool borderOnly = false );
-
private:
/**
SvgVisual::SvgVisual( VisualFactoryCache& factoryCache )
: Visual::Base( factoryCache ),
mAtlasRect( FULL_TEXTURE_RECT ),
- mParsedImage( NULL )
+ mImageUrl(),
+ mParsedImage( NULL ),
+ mPlacementActor()
{
// the rasterized image is with pre-multiplied alpha format
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
}
+SvgVisual::SvgVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size )
+: Visual::Base( factoryCache ),
+ mAtlasRect( FULL_TEXTURE_RECT ),
+ mImageUrl(),
+ mParsedImage( NULL ),
+ mPlacementActor()
+{
+ // the rasterized image is with pre-multiplied alpha format
+ mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
+
+ ParseFromUrl( imageUrl, size );
+}
+
SvgVisual::~SvgVisual()
{
if( mParsedImage )
std::string imageUrl;
if( imageURLValue->Get( imageUrl ) )
{
- SetImage( imageUrl );
+ ParseFromUrl( imageUrl );
}
else
{
void SvgVisual::SetSize( const Vector2& size )
{
- if(mImpl->mSize != size && mParsedImage && GetIsOnStage() )
+ if(mImpl->mSize != size && mParsedImage && IsOnStage() )
{
AddRasterizationTask( size );
}
return Dali::Property::Value();
}
-void SvgVisual::SetImage( const std::string& imageUrl, ImageDimensions size )
+void SvgVisual::ParseFromUrl( const std::string& imageUrl, ImageDimensions size )
{
- if( mImageUrl != imageUrl )
- {
- mImageUrl = imageUrl;
+ mImageUrl = imageUrl;
- NSVGimage* parsedImageOld = mParsedImage;
+ Vector2 dpi = Stage::GetCurrent().GetDpi();
+ float meanDpi = (dpi.height + dpi.width) * 0.5f;
+ mParsedImage = nsvgParseFromFile( imageUrl.c_str(), UNITS, meanDpi );
- Vector2 dpi = Stage::GetCurrent().GetDpi();
- float meanDpi = (dpi.height + dpi.width) * 0.5f;
- mParsedImage = nsvgParseFromFile(mImageUrl.c_str(), UNITS, meanDpi);
-
- if( size.GetWidth() != 0u && size.GetHeight() != 0u)
- {
- mImpl->mSize.x = size.GetWidth();
- mImpl->mSize.y = size.GetHeight();
- }
-
- if( mImpl->mSize != Vector2::ZERO && GetIsOnStage() )
- {
- AddRasterizationTask( mImpl->mSize );
- }
-
- mFactoryCache.GetSVGRasterizationThread()->DeleteImage( parsedImageOld );
+ if( size.GetWidth() != 0u && size.GetHeight() != 0u)
+ {
+ mImpl->mSize.x = size.GetWidth();
+ mImpl->mSize.y = size.GetHeight();
}
}
void SvgVisual::ApplyRasterizedImage( PixelData rasterizedPixelData )
{
- if( GetIsOnStage() )
+ if( IsOnStage() )
{
TextureSet currentTextureSet = mImpl->mRenderer.GetTextures();
if( mAtlasRect != FULL_TEXTURE_RECT )
}
else // no atlasing
{
- Atlas texture = Atlas::New( rasterizedPixelData.GetWidth(), rasterizedPixelData.GetHeight() );
- texture.Upload( rasterizedPixelData, 0, 0 );
+ Texture texture = Texture::New( Dali::TextureType::TEXTURE_2D, Pixel::RGBA8888,
+ rasterizedPixelData.GetWidth(), rasterizedPixelData.GetHeight() );
+ texture.Upload( rasterizedPixelData );
mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
if( mAtlasRect == FULL_TEXTURE_RECT )
if( textureSet )
{
- TextureSetImage( textureSet, 0u, texture );
+ textureSet.SetTexture( 0, texture );
}
}
SvgVisual( VisualFactoryCache& factoryCache );
/**
+ * @brief Constructor which creates the SVG Visual using the image URL.
+ *
+ * The visual will parse the SVG image once it is set.
+ * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
+ *
+ * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
+ * @param[in] imageUrl The URL to svg resource to use
+ */
+ SvgVisual( VisualFactoryCache& factoryCache, const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
+
+ /**
* @brief A reference counted object may only be deleted by calling Unreference().
*/
~SvgVisual();
public:
/**
- * @brief Sets the svg image of this visual to the resource at imageUrl
- * The visual will parse the svg image once it is set.
- * And rasterize it into BufferImage synchronously when the associated actor is put on stage, and destroy the BufferImage when it is off stage
- *
- * @param[in] imageUrl The URL to svg resource to use
- */
- void SetImage( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
-
- /**
* @bried Apply the rasterized image to the visual.
*
* @param[in] rasterizedPixelData The pixel buffer with the rasterized pixels
void ApplyRasterizedImage( PixelData rasterizedPixelData );
private:
+
+ /**
+ * @brief Parses the SVG Image from the set URL.
+ *
+ * @param[in] imageUrl The URL of the image to parse the SVG from.
+ * @param[in] size The required size of the SVG
+ */
+ void ParseFromUrl( const std::string& imageUrl, ImageDimensions size = ImageDimensions() );
+
/**
* @bried Rasterize the svg with the given size, and add it to the visual.
*
void Visual::Base::SetOffStage( Actor& actor )
{
- if( GetIsOnStage() )
+ if( IsOnStage() )
{
DoSetOffStage( actor );
}
}
-bool Visual::Base::GetIsOnStage() const
+bool Visual::Base::IsOnStage() const
{
return mImpl->mFlags & Impl::IS_ON_STAGE;
}
-bool Visual::Base::GetIsFromCache() const
+bool Visual::Base::IsFromCache() const
{
return mImpl->mFlags & Impl::IS_FROM_CACHE;
}
virtual void DoSetOffStage( Actor& actor );
protected:
+
/**
* @brief Gets the on stage state for this Visual
*
* @return Returns true if this Visual is on stage, false if it is off the stage
*/
- bool GetIsOnStage() const;
+ bool IsOnStage() const;
/**
* @brief Gets whether the Dali::Renderer is from a shared cache (and therefore any modifications will affect other users of that renderer)
*
* @return Returns true if the renderer is from shared cache, false otherwise
*/
- bool GetIsFromCache() const;
+ bool IsFromCache() const;
protected:
/**
NinePatchImage npatchImage = NinePatchImage::DownCast( image );
if( npatchImage )
{
- NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
- visualPtr->SetImage( npatchImage );
-
+ NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ), npatchImage );
return Toolkit::Visual::Base( visualPtr );
}
else
{
- ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ) );
- Actor actor;
- visualPtr->SetImage( actor, image );
-
+ ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ), image );
return Toolkit::Visual::Base( visualPtr );
}
}
UrlType::Type type = ResolveUrlType( url );
if( UrlType::N_PATCH == type )
{
- NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ) );
- visualPtr->SetImage( url );
-
+ NPatchVisual* visualPtr = new NPatchVisual( *( mFactoryCache.Get() ), url );
return Toolkit::Visual::Base( visualPtr );
}
else if( UrlType::SVG == type )
{
- SvgVisual* visualPtr = new SvgVisual( *( mFactoryCache.Get() ) );
- visualPtr->SetImage( url, size );
+ SvgVisual* visualPtr = new SvgVisual( *( mFactoryCache.Get() ), url, size );
return Toolkit::Visual::Base( visualPtr );
}
else // Regular image
{
- ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ));
- Actor actor;
- visualPtr->SetImage( actor, url, size );
-
+ ImageVisual* visualPtr = new ImageVisual( *( mFactoryCache.Get() ), url, size );
return Toolkit::Visual::Base( visualPtr );
}
}