/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
VisualFactoryCache* factoryCache = new VisualFactoryCache(false);
DummyVisualPtr dummyVisualPtr( new DummyVisual( *factoryCache ) );
-
+ dummyVisualPtr->Initialize();
return dummyVisualPtr;
}
{
}
+void DummyVisual::OnInitialize()
+{
+ // Implement if required
+}
+
void DummyVisual::DoCreatePropertyMap( Property::Map& map ) const
{
// Implement if required
#define DALI_TOOLKIT_TEST_DUMMY_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
DummyVisual( VisualFactoryCache& factoryCache );
+ void OnInitialize() override;
void DoCreatePropertyMap( Property::Map& map ) const override;
void DoCreateInstancePropertyMap( Property::Map& map ) const override;
void DoSetProperties( const Property::Map& propertyMap ) override;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
END_TEST;
}
-
-int UtcDaliTransitionDataMapN3(void)
-{
- ToolkitTestApplication application;
-
- tet_printf("Testing visual lookup with no renderers\n");
-
- Property::Map map;
- map["target"] = "visual1";
- map["property"] = "mixColor";
- map["initialValue"] = Vector3(Color::MAGENTA);
- map["targetValue"] = Vector3(Color::RED);
- map["animator"] = Property::Map()
- .Add("alphaFunction", "EASE_OUT_BACK")
- .Add("timePeriod", Property::Map()
- .Add("delay", 0.5f)
- .Add("duration", 1.0f));
-
- Dali::Toolkit::TransitionData transition = TransitionData::New( map );
- CHECK_MAP_EQUALS( map, transition.GetAnimatorAt(0) );
-
- DummyControl actor = DummyControl::New();
- actor.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS);
- actor.SetProperty( Dali::Actor::Property::NAME,"Actor1");
- actor.SetProperty( Actor::Property::COLOR,Color::CYAN);
- // Don't stage actor
-
- DummyControlImpl& dummyImpl = static_cast<DummyControlImpl&>(actor.GetImplementation());
- Property::Map visualMap;
- visualMap[Visual::Property::TYPE] = Visual::COLOR;
- visualMap[ColorVisual::Property::MIX_COLOR] = Vector3(Color::MAGENTA);
- Visual::Base visual = VisualFactory::Get().CreateVisual( visualMap );
- visual.SetName( "visual1" );
-
- Property::Index visualIndex = Control::CONTROL_PROPERTY_END_INDEX + 1;
- dummyImpl.RegisterVisual( visualIndex, visual );
-
- Animation anim = dummyImpl.CreateTransition( transition );
- DALI_TEST_CHECK( !anim );
- END_TEST;
-}
-
-
int UtcDaliTransitionDataMapN4(void)
{
ToolkitTestApplication application;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
DALI_TEST_CHECK(!property3.object);
DALI_TEST_CHECK(property3.propertyIndex == Property::INVALID_INDEX);
- // Test after the control is unparented
- dummyControl.Unparent();
-
- Property property4 = DevelControl::GetVisualProperty(dummyControl, DummyControl::Property::TEST_VISUAL, Visual::Property::MIX_COLOR);
- DALI_TEST_CHECK(!property4.object);
- DALI_TEST_CHECK(property4.propertyIndex == Property::INVALID_INDEX);
-
END_TEST;
}
* @param[in] index The Property index of the visual.
* @param[in] visualPropertyKey The key of the visual's property.
* @return The Property object
- * @pre The control should be added to the Scene.
- * @pre The returned object is valid for as long as the control is on the Scene.
*/
DALI_TOOLKIT_API Dali::Property GetVisualProperty(Control control, Dali::Property::Index index, Dali::Property::Key visualPropertyKey);
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
AnimatedGradientVisualPtr animatedGradientVisualPtr( new AnimatedGradientVisual( factoryCache ) );
animatedGradientVisualPtr->SetProperties( properties );
+ animatedGradientVisualPtr->Initialize();
return animatedGradientVisualPtr;
}
void AnimatedGradientVisual::DoSetOnScene( Actor& actor )
{
- InitializeRenderer();
actor.AddRenderer( mImpl->mRenderer );
SetupAnimation();
PlayAnimation();
StopAnimation();
actor.RemoveRenderer( mImpl->mRenderer );
- mImpl->mRenderer.Reset();
}
void AnimatedGradientVisual::DoCreatePropertyMap( Property::Map& map ) const
return shader;
}
-void AnimatedGradientVisual::InitializeRenderer()
+void AnimatedGradientVisual::OnInitialize()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
VisualFactoryCache::ShaderType shaderType = GetShaderType( mGradientType, mUnitType, mSpreadType );
#define DALI_TOOLKIT_INTERNAL_ANIMATED_GRADIENT_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~AnimatedGradientVisual();
protected: //from Visual
+ /**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
/**
* @copydoc Visual::Base::DoSetProperties
void SetupDefaultValue();
/**
- * @brief Initialize the rendere with the geometry from the cache, and shader which made by CreateShader()
- */
- void InitializeRenderer();
-
- /**
* @brief Make animations with GradientAnimationData
*/
void SetupAnimation();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
visual->LoadFirstBatch();
}
+ visual->Initialize();
+
return visual;
}
visual->LoadFirstBatch();
}
+ visual->Initialize();
+
return visual;
}
visual->LoadFirstBatch();
}
+ visual->Initialize();
+
return visual;
}
{
mPlacementActor = actor;
TextureSet textureSet = PrepareTextureSet();
- CreateRenderer(); // Always create a renderer when on stage
if( textureSet ) // if the image loading is successful
{
}
actor.RemoveRenderer( mImpl->mRenderer );
- mImpl->mRenderer.Reset();
mPlacementActor.Reset();
mStartFirstFrame = false;
}
}
}
-void AnimatedImageVisual::CreateRenderer()
+void AnimatedImageVisual::OnInitialize()
{
bool defaultWrapMode = mWrapModeU <= WrapMode::CLAMP_TO_EDGE && mWrapModeV <= WrapMode::CLAMP_TO_EDGE;
bool atlasing = false;
#define DALI_TOOLKIT_INTERNAL_ANIMATED_IMAGE_VISUAL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
~AnimatedImageVisual() override;
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
AnimatedVectorImageVisualPtr visual( new AnimatedVectorImageVisual( factoryCache, shaderFactory, imageUrl ) );
visual->SetProperties( properties );
-
+ visual->Initialize();
return visual;
}
AnimatedVectorImageVisualPtr AnimatedVectorImageVisual::New( VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl )
{
AnimatedVectorImageVisualPtr visual( new AnimatedVectorImageVisual( factoryCache, shaderFactory, imageUrl ) );
-
+ visual->Initialize();
return visual;
}
}
}
-void AnimatedVectorImageVisual::DoSetOnScene( Actor& actor )
+void AnimatedVectorImageVisual::OnInitialize(void)
{
Shader shader;
// Register transform properties
mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
+}
+void AnimatedVectorImageVisual::DoSetOnScene(Actor& actor)
+{
// Defer the rasterisation task until we get given a size (by Size Negotiation algorithm)
// Hold the weak handle of the placement actor and delay the adding of renderer until the rasterization is finished.
if( mImpl->mRenderer )
{
actor.RemoveRenderer( mImpl->mRenderer );
- mImpl->mRenderer.Reset();
-
mRendererAdded = false;
}
#define DALI_TOOLKIT_INTERNAL_ANIMATED_VECTOR_IMAGE_VISUAL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
~AnimatedVectorImageVisual() override;
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
ArcVisualPtr arcVisualPtr( new ArcVisual( factoryCache ) );
arcVisualPtr->SetProperties( properties );
+ arcVisualPtr->Initialize();
return arcVisualPtr;
}
void ArcVisual::DoSetOnScene( Actor& actor )
{
- InitializeRenderer();
-
actor.AddRenderer( mImpl->mRenderer );
// Arc Visual generated and ready to display
void ArcVisual::DoSetOffScene(Actor& actor)
{
- if(mImpl->mRenderer)
- {
- // Update values from Renderer
- mThickness = mImpl->mRenderer.GetProperty<float>(mThicknessIndex);
- mStartAngle = mImpl->mRenderer.GetProperty<float>(mStartAngleIndex);
- mSweepAngle = mImpl->mRenderer.GetProperty<float>(mSweepAngleIndex);
- }
-
actor.RemoveRenderer(mImpl->mRenderer);
- mImpl->mRenderer.Reset();
-
- mThicknessIndex = Property::INVALID_INDEX;
- mStartAngleIndex = Property::INVALID_INDEX;
- mSweepAngleIndex = Property::INVALID_INDEX;
}
void ArcVisual::DoCreatePropertyMap( Property::Map& map ) const
}
}
-void ArcVisual::InitializeRenderer()
+void ArcVisual::OnInitialize()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
#define DALI_TOOLKIT_INTERNAL_ARC_VISUAL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~ArcVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
private:
- /**
- * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
- */
- void InitializeRenderer();
-
-private:
-
// Undefined
ArcVisual( const ArcVisual& arcVisual ) = delete;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
BorderVisualPtr borderVisualPtr( new BorderVisual( factoryCache ) );
borderVisualPtr->SetProperties( properties );
+ borderVisualPtr->Initialize();
return borderVisualPtr;
}
void BorderVisual::DoSetOnScene( Actor& actor )
{
- InitializeRenderer();
-
mBorderColorIndex = mImpl->mRenderer.RegisterProperty( Toolkit::BorderVisual::Property::COLOR, COLOR_NAME, mBorderColor );
if( mBorderColor.a < 1.f || mAntiAliasing )
{
}
}
-void BorderVisual::InitializeRenderer()
+void BorderVisual::OnInitialize()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::BORDER_GEOMETRY );
if( !geometry )
#define DALI_TOOLKIT_INTERNAL_BORDER_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~BorderVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
private:
/**
- * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
- */
- void InitializeRenderer();
-
- /**
* Request the border shader from the factory cache. If fail, create tha shader and add it to cache.
* @return The border shader.
*/
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
ColorVisualPtr colorVisualPtr( new ColorVisual( factoryCache ) );
colorVisualPtr->SetProperties( properties );
+ colorVisualPtr->Initialize();
return colorVisualPtr;
}
void ColorVisual::DoSetOnScene( Actor& actor )
{
- InitializeRenderer();
-
// Only add the renderer if it's not fully transparent
// We cannot avoid creating a renderer as it's used in the base class
if( mRenderIfTransparent || mImpl->mMixColor.a > 0.0f )
void ColorVisual::DoSetOffScene(Actor& actor)
{
- if(mImpl->mRenderer && mBlurRadiusIndex != Property::INVALID_INDEX)
- {
- // Update values from Renderer
- mBlurRadius = mImpl->mRenderer.GetProperty<float>(mBlurRadiusIndex);
- }
-
actor.RemoveRenderer(mImpl->mRenderer);
- mImpl->mRenderer.Reset();
- mBlurRadiusIndex = Property::INVALID_INDEX;
}
void ColorVisual::DoCreatePropertyMap( Property::Map& map ) const
}
}
-void ColorVisual::InitializeRenderer()
+void ColorVisual::OnInitialize()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
#define DALI_TOOLKIT_INTERNAL_COLOR_VISUAL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~ColorVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
Dali::Property OnGetPropertyObject(Dali::Property::Key key) override;
private:
- /**
- * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
- */
- void InitializeRenderer();
/**
* @brief Get a shader for the current properties.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
GradientVisualPtr gradientVisualPtr( new GradientVisual( factoryCache ) );
gradientVisualPtr->SetProperties( properties );
+ gradientVisualPtr->Initialize();
return gradientVisualPtr;
}
void GradientVisual::DoSetOnScene( Actor& actor )
{
- InitializeRenderer();
-
actor.AddRenderer( mImpl->mRenderer );
// Gradient Visual generated and ready to display
// Do nothing
}
-void GradientVisual::InitializeRenderer()
+void GradientVisual::OnInitialize()
{
Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
Shader shader = GetShader();
#define DALI_TOOLKIT_INTERNAL_GRADIENT_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~GradientVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
private:
/**
- * @brief Initialize the renderer with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
- */
- void InitializeRenderer();
-
- /**
* New a gradient object with the given property map.
*
* @return True if the property map provides valid properties to create a gradient. Otherwise, returns false.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
ImageVisualPtr imageVisualPtr( new ImageVisual( factoryCache, shaderFactory, imageUrl, size, fittingMode, samplingMode ) );
imageVisualPtr->SetProperties( properties );
+ imageVisualPtr->Initialize();
return imageVisualPtr;
}
FittingMode::Type fittingMode,
Dali::SamplingMode::Type samplingMode )
{
- return new ImageVisual( factoryCache, shaderFactory, imageUrl, size, fittingMode, samplingMode );
+ ImageVisualPtr imageVisualPtr(new ImageVisual(factoryCache, shaderFactory, imageUrl, size, fittingMode, samplingMode));
+ imageVisualPtr->Initialize();
+ return imageVisualPtr;
}
ImageVisual::ImageVisual(VisualFactoryCache& factoryCache,
naturalSize = Vector2::ZERO;
}
-void ImageVisual::CreateRenderer( TextureSet& textureSet )
+void ImageVisual::OnInitialize()
{
Geometry geometry;
// Create the renderer
mImpl->mRenderer = Renderer::New( geometry, shader );
- if( textureSet )
- {
- mImpl->mRenderer.SetTextures( textureSet );
- }
- // else still waiting for texture load to finish.
-
//Register transform properties
mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
EnablePreMultipliedAlpha( IsPreMultipliedAlphaEnabled() );
}
-
void ImageVisual::LoadTexture( bool& atlasing, Vector4& atlasRect, TextureSet& textures, bool orientationCorrection,
TextureManager::ReloadPolicy forceReload )
{
}
}
- CreateRenderer( mTextures );
- mTextures.Reset(); // Visual should not keep a handle to the texture after this point.
+ if(mTextures)
+ {
+ mImpl->mRenderer.SetTextures(mTextures);
+ mTextures.Reset(); // Visual should not keep a handle to the texture after this point.
+ }
if( attemptAtlasing ) // the texture is packed inside atlas
{
{
// Visual::Base::SetOffScene only calls DoSetOffScene if mRenderer exists (is on onstage)
- // Image release is dependent on the ReleasePolicy, renderer is destroyed.
+ // Image release is dependent on the ReleasePolicy, renderer is removed.
actor.RemoveRenderer( mImpl->mRenderer);
if( mReleasePolicy == Toolkit::ImageVisual::ReleasePolicy::DETACHED )
{
RemoveTexture(); // If INVALID_TEXTURE_ID then removal will be attempted on atlas
mImpl->mResourceStatus = Toolkit::Visual::ResourceStatus::PREPARING;
+ TextureSet textureSet = TextureSet::New();
+ mImpl->mRenderer.SetTextures(textureSet);
+
mLoadState = TextureManager::LoadState::NOT_STARTED;
}
- mImpl->mRenderer.Reset();
mPlacementActor.Reset();
}
}
TextureSet textureSet = mImpl->mRenderer.GetTextures();
- mImpl->mRenderer.Reset();
if( index != Property::INVALID_INDEX )
{
#define DALI_TOOLKIT_INTERNAL_IMAGE_VISUAL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~ImageVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
void InitializeRenderer();
/**
- * @brief Creates the Dali::Renderer (potentially from the renderer cache), initializing it
- * @param[in] textures to use
- */
- void CreateRenderer( TextureSet& textures );
-
- /**
* Creates the texture set and adds the texture to it
* @param[out] textureRect The texture area of the texture in the atlas.
* @param[in] url The URL of the image resource to use.
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
MeshVisualPtr meshVisualPtr( new MeshVisual( factoryCache ) );
meshVisualPtr->SetProperties( properties );
+ meshVisualPtr->Initialize();
return meshVisualPtr;
}
void MeshVisual::DoSetOnScene( Actor& actor )
{
- InitializeRenderer();
-
actor.AddRenderer( mImpl->mRenderer );
// Mesh loaded and ready to display
// Do nothing
}
-void MeshVisual::InitializeRenderer()
+void MeshVisual::OnInitialize()
{
//Try to load the geometry from the file.
if( !LoadGeometry() )
#define DALI_TOOLKIT_INTERNAL_MESH_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~MeshVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
void SupplyEmptyGeometry();
/**
- * @brief Initialize the visual with the geometry and shader from the cache, if not available, create and save to the cache for sharing.
- */
- void InitializeRenderer();
-
- /**
* @brief Create a shader for the object to use.
*/
void CreateShader();
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/visuals/image-visual-properties-devel.h>
-#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+#include <dali-toolkit/internal/visuals/image-visual-shader-factory.h>
#include <dali-toolkit/internal/visuals/npatch-loader.h>
-#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
+#include <dali-toolkit/internal/visuals/rendering-addon.h>
+#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
+#include <dali-toolkit/internal/visuals/visual-base-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
+#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
-#include <dali-toolkit/internal/visuals/visual-base-impl.h>
-#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
-#include <dali-toolkit/internal/visuals/rendering-addon.h>
-#include <dali-toolkit/internal/graphics/builtin-shader-extern-gen.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
namespace Dali
{
/////////////////NPatchVisual////////////////
-NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl, const Property::Map& properties )
+NPatchVisualPtr NPatchVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties)
{
- NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) );
+ NPatchVisualPtr nPatchVisual(new NPatchVisual(factoryCache, shaderFactory));
nPatchVisual->mImageUrl = imageUrl;
nPatchVisual->SetProperties( properties );
-
+ nPatchVisual->Initialize();
return nPatchVisual;
}
-NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl )
+NPatchVisualPtr NPatchVisual::New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl)
{
- NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) );
+ NPatchVisualPtr nPatchVisual(new NPatchVisual(factoryCache, shaderFactory));
nPatchVisual->mImageUrl = imageUrl;
-
+ nPatchVisual->Initialize();
return nPatchVisual;
}
Geometry geometry = CreateGeometry();
Shader shader = CreateShader();
- mImpl->mRenderer = Renderer::New( geometry, shader );
+ mImpl->mRenderer.SetGeometry(geometry);
+ mImpl->mRenderer.SetShader(shader);
mPlacementActor = actor;
if( data->GetLoadingState() != NPatchData::LoadingState::LOADING )
}
actor.RemoveRenderer( mImpl->mRenderer );
- mImpl->mRenderer.Reset();
mPlacementActor.Reset();
}
}
}
-NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::N_PATCH ),
+NPatchVisual::NPatchVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory)
+: Visual::Base(factoryCache, Visual::FittingMode::FILL, Toolkit::Visual::N_PATCH),
mPlacementActor(),
- mLoader( factoryCache.GetNPatchLoader() ),
+ mLoader(factoryCache.GetNPatchLoader()),
+ mImageVisualShaderFactory(shaderFactory),
mImageUrl(),
mAuxiliaryUrl(),
mId(NPatchData::INVALID_NPATCH_DATA_ID),
- mBorderOnly( false ),
+ mBorderOnly(false),
mBorder(),
- mAuxiliaryImageAlpha( 0.0f ),
- mReleasePolicy( Toolkit::ImageVisual::ReleasePolicy::DETACHED )
+ mAuxiliaryImageAlpha(0.0f),
+ mReleasePolicy(Toolkit::ImageVisual::ReleasePolicy::DETACHED)
{
EnablePreMultipliedAlpha( mFactoryCache.GetPreMultiplyOnLoad() );
}
}
}
+void NPatchVisual::OnInitialize()
+{
+ // Get basic geometry and shader
+ Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
+ Shader shader = mImageVisualShaderFactory.GetShader(mFactoryCache, false, true, false);
+
+ mImpl->mRenderer = Renderer::New(geometry, shader);
+
+ //Register transform properties
+ mImpl->mTransform.RegisterUniforms(mImpl->mRenderer, Direction::LEFT_TO_RIGHT);
+}
+
Geometry NPatchVisual::CreateGeometry()
{
Geometry geometry;
#define DALI_TOOLKIT_INTERNAL_N_PATCH_VISUAL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
namespace Internal
{
-
+class ImageVisualShaderFactory;
class NPatchVisual;
typedef IntrusivePtr< NPatchVisual > NPatchVisualPtr;
class NPatchVisual: public Visual::Base, public TextureUploadObserver
{
public:
-
/**
* @brief Create 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] shaderFactory The ImageVisualShaderFactory object
* @param[in] imageUrl The URL to 9 patch image resource to use
* @param[in] properties A Property::Map containing settings for this visual
* @return A smart-pointer to the newly allocated visual.
*/
- static NPatchVisualPtr New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl, const Property::Map& properties );
+ static NPatchVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl, const Property::Map& properties);
/**
* @brief Create 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] shaderFactory The ImageVisualShaderFactory object
* @param[in] imageUrl The URL to 9 patch image resource to use
* @return A smart-pointer to the newly allocated visual.
*/
- static NPatchVisualPtr New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl );
+ static NPatchVisualPtr New(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory, const VisualUrl& imageUrl);
public: // from Visual
*
* @param[in] factoryCache Reference to the VisualFactoryCache object
*/
- NPatchVisual( VisualFactoryCache& factoryCache );
+ NPatchVisual(VisualFactoryCache& factoryCache, ImageVisualShaderFactory& shaderFactory);
/**
* @brief A reference counted object may only be deleted by calling Unreference().
virtual ~NPatchVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
void LoadComplete( bool loadSuccess, Devel::PixelBuffer pixelBuffer, const VisualUrl& url, bool preMultiplied ) override;
private:
- WeakHandle<Actor> mPlacementActor; ///< Weakhandle to contain Actor during texture loading
- NPatchLoader& mLoader; ///< reference to N patch loader for fast access
- VisualUrl mImageUrl; ///< The url to the N patch to load
- VisualUrl mAuxiliaryUrl; ///< An auxiliary image that can be displayed on top of the N-Patch
- NPatchData::NPatchDataId mId; ///< id of the N patch (from loader/cache)
- Devel::PixelBuffer mAuxiliaryPixelBuffer; ///< pixel buffer of the auxiliary mask image
- bool mBorderOnly; ///< if only border is desired
- Rect<int> mBorder; ///< The size of the border
- float mAuxiliaryImageAlpha; ///< The alpha value for the auxiliary image only
+ WeakHandle<Actor> mPlacementActor; ///< Weakhandle to contain Actor during texture loading
+ NPatchLoader& mLoader; ///< reference to N patch loader for fast access
+ ImageVisualShaderFactory& mImageVisualShaderFactory;
+ VisualUrl mImageUrl; ///< The url to the N patch to load
+ VisualUrl mAuxiliaryUrl; ///< An auxiliary image that can be displayed on top of the N-Patch
+ NPatchData::NPatchDataId mId; ///< id of the N patch (from loader/cache)
+ Devel::PixelBuffer mAuxiliaryPixelBuffer; ///< pixel buffer of the auxiliary mask image
+ bool mBorderOnly; ///< if only border is desired
+ Rect<int> mBorder; ///< The size of the border
+ float mAuxiliaryImageAlpha; ///< The alpha value for the auxiliary image only
Toolkit::ImageVisual::ReleasePolicy::Type mReleasePolicy; ///< The release policy to determine when an image should no longer be cached.
};
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
{
PrimitiveVisualPtr primitiveVisualPtr( new PrimitiveVisual( factoryCache ) );
primitiveVisualPtr->SetProperties( properties );
+ primitiveVisualPtr->Initialize();
return primitiveVisualPtr;
}
void PrimitiveVisual::DoSetOnScene( Actor& actor )
{
- InitializeRenderer();
-
actor.AddRenderer( mImpl->mRenderer );
// Primitive generated and ready to display
}
}
-void PrimitiveVisual::InitializeRenderer()
+void PrimitiveVisual::OnInitialize()
{
if( !mGeometry )
{
#define DALI_TOOLKIT_INTERNAL_PRIMITIVE_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~PrimitiveVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
SvgVisualPtr svgVisual( new SvgVisual( factoryCache, shaderFactory, imageUrl ) );
svgVisual->Load();
svgVisual->SetProperties(properties);
+ svgVisual->Initialize();
return svgVisual;
}
{
SvgVisualPtr svgVisual( new SvgVisual( factoryCache, shaderFactory, imageUrl ) );
svgVisual->Load();
+ svgVisual->Initialize();
return svgVisual;
}
{
}
+void SvgVisual::OnInitialize()
+{
+ Shader shader;
+ if(!mImpl->mCustomShader)
+ {
+ shader = mImageVisualShaderFactory.GetShader(mFactoryCache, mAttemptAtlasing, true, IsRoundedCornerRequired());
+ }
+ else
+ {
+ shader = Shader::New(mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader,
+ mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader,
+ mImpl->mCustomShader->mHints);
+
+ shader.RegisterProperty(PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT);
+ }
+
+ Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
+ mImpl->mRenderer = Renderer::New(geometry, shader);
+}
+
void SvgVisual::DoSetProperties( const Property::Map& propertyMap )
{
// url already passed in from constructor
void SvgVisual::DoSetOnScene( Actor& actor )
{
- Shader shader;
- if( !mImpl->mCustomShader )
- {
- shader = mImageVisualShaderFactory.GetShader( mFactoryCache, mAttemptAtlasing, true, IsRoundedCornerRequired() );
- }
- else
- {
- shader = Shader::New( mImpl->mCustomShader->mVertexShader.empty() ? mImageVisualShaderFactory.GetVertexShaderSource().data() : mImpl->mCustomShader->mVertexShader,
- mImpl->mCustomShader->mFragmentShader.empty() ? mImageVisualShaderFactory.GetFragmentShaderSource().data() : mImpl->mCustomShader->mFragmentShader,
- mImpl->mCustomShader->mHints );
-
- shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- }
-
- Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
TextureSet textureSet = TextureSet::New();
- mImpl->mRenderer = Renderer::New( geometry, shader );
mImpl->mRenderer.SetTextures( textureSet );
// Register transform properties
mFactoryCache.GetSVGRasterizationThread()->RemoveTask( this );
actor.RemoveRenderer( mImpl->mRenderer );
- mImpl->mRenderer.Reset();
mPlacementActor.Reset();
// Reset the visual size to zero so that when adding the actor back to stage the SVG rasterization is forced
#define DALI_TOOLKIT_INTERNAL_SVG_VISUAL_H
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~SvgVisual();
/**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
+ /**
* @copydoc Visual::Base::DoSetProperties
*/
void DoSetProperties( const Property::Map& propertyMap ) override;
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
{
- TextVisualPtr TextVisualPtr( new TextVisual( factoryCache ) );
- TextVisualPtr->SetProperties( properties );
- return TextVisualPtr;
+ TextVisualPtr textVisualPtr(new TextVisual(factoryCache));
+ textVisualPtr->SetProperties(properties);
+ textVisualPtr->Initialize();
+ return textVisualPtr;
}
Property::Map TextVisual::ConvertStringKeysToIndexKeys( const Property::Map& propertyMap )
{
}
+void TextVisual::OnInitialize()
+{
+ Geometry geometry = mFactoryCache.GetGeometry(VisualFactoryCache::QUAD_GEOMETRY);
+ Shader shader = GetTextShader(mFactoryCache, TextType::SINGLE_COLOR_TEXT, TextType::NO_EMOJI, TextType::NO_STYLES);
+
+ mImpl->mRenderer = Renderer::New(geometry, shader);
+}
+
void TextVisual::DoSetProperties( const Property::Map& propertyMap )
{
for( Property::Map::SizeType index = 0u, count = propertyMap.Count(); index < count; ++index )
{
mControl = actor;
- Geometry geometry = mFactoryCache.GetGeometry( VisualFactoryCache::QUAD_GEOMETRY );
- Shader shader = GetTextShader(mFactoryCache, TextType::SINGLE_COLOR_TEXT, TextType::NO_EMOJI, TextType::NO_STYLES);
-
- mImpl->mRenderer = Renderer::New( geometry, shader );
mImpl->mRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, Toolkit::DepthIndex::CONTENT );
// Enable the pre-multiplied alpha to improve the text quality
{
RemoveRenderer( actor );
- // Resets the renderer.
- mImpl->mRenderer.Reset();
-
// Resets the control handle.
mControl.Reset();
}
#define DALI_TOOLKIT_INTERNAL_TEXT_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
virtual ~TextVisual();
+ /**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
+
// from Visual::Base
/**
/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
delete mImpl;
}
+void Visual::Base::Initialize()
+{
+ // The Renderer should be created inside derived class here.
+ OnInitialize();
+
+ if(mImpl->mRenderer)
+ {
+ RegisterMixColor();
+
+ if(IsRoundedCornerRequired())
+ {
+ mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
+ mImpl->mRenderer.RegisterProperty(CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy);
+
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_MODE, BlendMode::ON);
+ }
+ }
+}
+
void Visual::Base::SetCustomShader( const Property::Map& shaderMap )
{
if( mImpl->mCustomShader )
{
mImpl->mCustomShader = new Impl::CustomShader( shaderMap );
}
+
+ // Let derived class know
+ UpdateShader();
}
void Visual::Base::SetProperties( const Property::Map& propertyMap )
// Thus the calling of actor.AddRenderer() should happen inside derived class as base class does not know the exact timing.
DoSetOnScene( actor );
- if( mImpl->mRenderer )
+ if(mImpl->mRenderer)
{
- RegisterMixColor();
-
- if( IsRoundedCornerRequired() )
- {
- mImpl->mCornerRadiusIndex = mImpl->mRenderer.RegisterProperty(DevelVisual::Property::CORNER_RADIUS, CORNER_RADIUS, mImpl->mCornerRadius);
- mImpl->mRenderer.RegisterProperty( CORNER_RADIUS_POLICY, mImpl->mCornerRadiusPolicy );
-
- mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_MODE, BlendMode::ON );
- }
-
- mImpl->mRenderer.SetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
- mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
- mImpl->mFlags |= Impl::IS_ON_SCENE; // Only sets the flag if renderer exists
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled());
+ mImpl->mRenderer.SetProperty(Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex);
}
+
+ mImpl->mFlags |= Impl::IS_ON_SCENE;
}
}
{
if( IsOnScene() )
{
- if(mImpl->mRenderer)
- {
- // Update values from Renderer
- mImpl->mMixColor = mImpl->mRenderer.GetProperty<Vector3>(mImpl->mMixColorIndex);
- mImpl->mMixColor.a = mImpl->mRenderer.GetProperty<float>(DevelRenderer::Property::OPACITY);
- if(mImpl->mTransform.mOffsetIndex != Property::INVALID_INDEX)
- {
- mImpl->mTransform.mOffset = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mOffsetIndex);
- }
- if(mImpl->mTransform.mSizeIndex != Property::INVALID_INDEX)
- {
- mImpl->mTransform.mSize = mImpl->mRenderer.GetProperty<Vector2>(mImpl->mTransform.mSizeIndex);
- }
- if(mImpl->mCornerRadiusIndex != Property::INVALID_INDEX)
- {
- mImpl->mCornerRadius = mImpl->mRenderer.GetProperty<float>(mImpl->mCornerRadiusIndex);
- }
- }
-
DoSetOffScene( actor );
- mImpl->mMixColorIndex = Property::INVALID_INDEX;
- mImpl->mCornerRadiusIndex = Property::INVALID_INDEX;
mImpl->mFlags &= ~Impl::IS_ON_SCENE;
}
}
{
mImpl->mCustomShader->CreatePropertyMap( map );
}
-
- //map.Insert( Toolkit::Visual::Property::DEPTH_INDEX, mImpl->mDepthIndex );
- //map.Insert( Toolkit::Visual::Property::ENABLED, (bool) mImpl->mRenderer );
}
void Visual::Base::DoSetOffScene( Actor& actor )
{
actor.RemoveRenderer( mImpl->mRenderer );
- mImpl->mRenderer.Reset();
}
bool Visual::Base::IsOnScene() const
#define DALI_TOOLKIT_INTERNAL_VISUAL_H
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*/
~Base() override;
+ /**
+ * @brief Second-phase constructor.
+ */
+ void Initialize();
+
protected:
+ /**
+ * @brief Called by Initialize() allowing sub classes to initialize them.
+ */
+ virtual void OnInitialize() = 0;
/**
* @brief Called by CreatePropertyMap() allowing sub classes to respond to the CreatePropertyMap event
- /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+/*
+ * Copyright (c) 2021 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.
{
case VisualUrl::N_PATCH:
{
- visualPtr = NPatchVisual::New( GetFactoryCache(), visualUrl, propertyMap );
+ visualPtr = NPatchVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl, propertyMap);
break;
}
case VisualUrl::SVG:
std::string imageUrl;
if( imageURLValue && imageURLValue->Get( imageUrl ) )
{
- visualPtr = NPatchVisual::New( GetFactoryCache(), imageUrl, propertyMap );
+ visualPtr = NPatchVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), imageUrl, propertyMap);
}
break;
}
{
case VisualUrl::N_PATCH:
{
- visualPtr = NPatchVisual::New( GetFactoryCache(), visualUrl );
+ visualPtr = NPatchVisual::New(GetFactoryCache(), GetImageVisualShaderFactory(), visualUrl);
break;
}
case VisualUrl::SVG:
/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
*
*/
-
// CLASS HEADER
#include "wireframe-visual.h"
WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual )
{
- return new WireframeVisual( factoryCache, actualVisual );
+ WireframeVisualPtr wireframeVisual(new WireframeVisual(factoryCache, actualVisual));
+ wireframeVisual->Initialize();
+ return wireframeVisual;
}
WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual, const Property::Map& properties )
{
wireframeVisual->SetTransformAndSize( transformMap, Vector2::ZERO );
}
-
+ wireframeVisual->Initialize();
return wireframeVisual;
}
void WireframeVisual::DoSetOnScene( Actor& actor )
{
- InitializeRenderer();
-
actor.AddRenderer( mImpl->mRenderer );
// Wireframe generated and ready to display
ResourceReady( Toolkit::Visual::ResourceStatus::READY );
}
-void WireframeVisual::InitializeRenderer()
+void WireframeVisual::OnInitialize()
{
Shader shader = mFactoryCache.GetShader( VisualFactoryCache::WIREFRAME_SHADER );
if( !shader )
#define DALI_TOOLKIT_INTERNAL_WIREFRAME_VISUAL_H
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
virtual ~WireframeVisual();
protected: // from Visual::Base
+ /**
+ * @copydoc Visual::Base::OnInitialize
+ */
+ void OnInitialize() override;
/**
* @copydoc Visual::Base::GetHeightForWidth()
*/
Geometry CreateQuadWireframeGeometry();
- /**
- * @brief Initialise the renderer from the cache, if not available, create and save to the cache for sharing.
- */
- void InitializeRenderer();
-
// Undefined
WireframeVisual( const WireframeVisual& visual);