#include <dali/public-api/images/resource-image.h>
#include <dali/devel-api/images/texture-set-image.h>
-// INTERNAL IINCLUDES
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
+#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/internal/visuals/npatch-loader.h>
#include <dali-toolkit/internal/visuals/visual-factory-impl.h>
#include <dali-toolkit/internal/visuals/visual-factory-cache.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
uniform mediump vec2 uNinePatchFactorsX[ FACTOR_SIZE_X ];\n
uniform mediump vec2 uNinePatchFactorsY[ FACTOR_SIZE_Y ];\n
\n
+
+ //Visual size and offset
+ uniform mediump vec2 offset;\n
+ uniform mediump vec2 size;\n
+ uniform mediump vec4 offsetSizeMode;\n
+ uniform mediump vec2 origin;\n
+ uniform mediump vec2 anchorPoint;\n
+
void main()\n
{\n
mediump vec2 fixedFactor = vec2( uNinePatchFactorsX[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uNinePatchFactorsY[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].x );\n
mediump vec2 fixedTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].x, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].x );\n
mediump vec2 stretchTotal = vec2( uNinePatchFactorsX[ FACTOR_SIZE_X - 1 ].y, uNinePatchFactorsY[ FACTOR_SIZE_Y - 1 ].y );\n
\n
- mediump vec4 vertexPosition = vec4( ( fixedFactor + ( uSize.xy - fixedTotal ) * stretch / stretchTotal ), 0.0, 1.0 );\n
- vertexPosition.xy -= uSize.xy * vec2( 0.5, 0.5 );\n
+
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
+
+ mediump vec4 vertexPosition = vec4( ( fixedFactor + ( visualSize.xy - fixedTotal ) * stretch / stretchTotal ) + anchorPoint*visualSize + (visualOffset + origin)*uSize.xy, 0.0, 1.0 );\n
+ vertexPosition.xy -= visualSize.xy * vec2( 0.5, 0.5 );\n
+
vertexPosition = uMvpMatrix * vertexPosition;\n
\n
vTexCoord = ( fixedFactor + stretch ) / ( fixedTotal + stretchTotal );\n
uniform mediump vec2 uFixed[ 3 ];\n
uniform mediump vec2 uStretchTotal;\n
\n
+
+ //Visual size and offset
+ uniform mediump vec2 offset;\n
+ uniform mediump vec2 size;\n
+ uniform mediump vec4 offsetSizeMode;\n
+ uniform mediump vec2 origin;\n
+ uniform mediump vec2 anchorPoint;\n
+
void main()\n
{\n
+ vec2 visualSize = mix(uSize.xy*size, size, offsetSizeMode.zw );\n
+ vec2 visualOffset = mix( offset, offset/uSize.xy, offsetSizeMode.xy);\n
+
mediump vec2 scale = vec2( length( uModelMatrix[ 0 ].xyz ), length( uModelMatrix[ 1 ].xyz ) );\n
- mediump vec2 size = uSize.xy * scale;\n
+ mediump vec2 size = visualSize.xy * scale;\n
\n
mediump vec2 fixedFactor = vec2( uFixed[ int( ( aPosition.x + 1.0 ) * 0.5 ) ].x, uFixed[ int( ( aPosition.y + 1.0 ) * 0.5 ) ].y );\n
mediump vec2 stretch = floor( aPosition * 0.5 );\n
mediump vec2 fixedTotal = uFixed[ 2 ];\n
\n
- mediump vec4 vertexPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );\n
+ mediump vec4 vertexPosition = vec4( fixedFactor + ( size - fixedTotal ) * stretch, 0.0, 1.0 );
vertexPosition.xy -= size * vec2( 0.5, 0.5 );\n
- vertexPosition.xy = vertexPosition.xy / scale;\n
+ vertexPosition.xy = vertexPosition.xy / scale + anchorPoint*size + (visualOffset + origin)*uSize.xy;\
\n
vertexPosition = uMvpMatrix * vertexPosition;\n
\n
/////////////////NPatchVisual////////////////
-NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache ),
- mBorderOnly( false )
+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl )
{
+ NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache );
+ nPatchVisual->mImageUrl = imageUrl;
+
+ return nPatchVisual;
}
-NPatchVisual::~NPatchVisual()
+NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, NinePatchImage image )
{
+ NPatchVisual* nPatchVisual = new NPatchVisual( factoryCache );
+ nPatchVisual->mImageUrl = image.GetUrl();
+
+ return nPatchVisual;
}
-void NPatchVisual::DoInitialize( Actor& actor, const Property::Map& propertyMap )
+void NPatchVisual::GetNaturalSize( Vector2& naturalSize )
{
- Property::Value* imageURLValue = propertyMap.Find( IMAGE_URL_NAME );
- if( imageURLValue )
+ naturalSize.x = 0u;
+ naturalSize.y = 0u;
+ // load now if not already loaded
+ if( NPatchLoader::UNINITIALIZED_ID == mId )
{
- //Read the borderOnly property first since InitialiseFromImage relies on mBorderOnly to be properly set
- Property::Value* borderOnlyValue = propertyMap.Find( BORDER_ONLY );
- if( borderOnlyValue )
- {
- borderOnlyValue->Get( mBorderOnly );
- }
-
- if( imageURLValue->Get( mImageUrl ) )
- {
- NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
- InitializeFromImage( nPatch );
- }
- else
- {
- InitializeFromBrokenImage();
- DALI_LOG_ERROR( "The property '%s' is not a string\n", IMAGE_URL_NAME );
- }
+ mId = mLoader.Load( mImageUrl );
+ }
+ const NPatchLoader::Data* data;
+ if( mLoader.GetNPatchData( mId, data ) )
+ {
+ naturalSize.x = data->croppedWidth;
+ naturalSize.y = data->croppedHeight;
}
}
-void NPatchVisual::GetNaturalSize( Vector2& naturalSize ) const
+void NPatchVisual::DoSetProperties( const Property::Map& propertyMap )
{
- if( mImage )
+ // URL is already passed in via constructor
+
+ Property::Value* borderOnlyValue = propertyMap.Find( Toolkit::ImageVisual::Property::BORDER_ONLY, BORDER_ONLY );
+ if( borderOnlyValue )
{
- naturalSize.x = mImage.GetWidth();
- naturalSize.y = mImage.GetHeight();
+ borderOnlyValue->Get( mBorderOnly );
}
- else if( !mImageUrl.empty() )
+}
+
+void NPatchVisual::DoSetOnStage( Actor& actor )
+{
+ // load when first go on stage
+ if( NPatchLoader::UNINITIALIZED_ID == mId )
{
- ImageDimensions dimentions = ResourceImage::GetImageSize( mImageUrl );
- naturalSize.x = dimentions.GetWidth();
- naturalSize.y = dimentions.GetHeight();
+ mId = mLoader.Load( mImageUrl );
}
- else
+
+ Geometry geometry = CreateGeometry();
+ Shader shader = CreateShader();
+ mImpl->mRenderer = Renderer::New( geometry, shader );
+
+ ApplyTextureAndUniforms();
+
+ actor.AddRenderer( mImpl->mRenderer );
+}
+
+void NPatchVisual::DoSetOffStage( Actor& actor )
+{
+ actor.RemoveRenderer( mImpl->mRenderer );
+ mImpl->mRenderer.Reset();
+}
+
+void NPatchVisual::OnSetTransform()
+{
+ if( mImpl->mRenderer )
{
- naturalSize = Vector2::ZERO;
+ mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
}
}
-void NPatchVisual::SetClipRect( const Rect<int>& clipRect )
+void NPatchVisual::DoCreatePropertyMap( Property::Map& map ) const
{
- Visual::Base::SetClipRect( clipRect );
- //ToDo: renderer responds to the clipRect change
+ map.Clear();
+ map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::IMAGE );
+ map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl );
+ map.Insert( Toolkit::ImageVisual::Property::BORDER_ONLY, mBorderOnly );
}
-void NPatchVisual::SetOffset( const Vector2& offset )
+NPatchVisual::NPatchVisual( VisualFactoryCache& factoryCache )
+: Visual::Base( factoryCache ),
+ mLoader( factoryCache.GetNPatchLoader() ),
+ mImageUrl(),
+ mId( NPatchLoader::UNINITIALIZED_ID ),
+ mBorderOnly( false )
+{
+}
+
+NPatchVisual::~NPatchVisual()
{
- //ToDo: renderer applies the offset
}
Geometry NPatchVisual::CreateGeometry()
{
Geometry geometry;
- if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
+ const NPatchLoader::Data* data;
+ if( mLoader.GetNPatchData( mId, data ) )
{
- if( !mBorderOnly )
+ if( data->stretchPixelsX.Size() == 1 && data->stretchPixelsY.Size() == 1 )
{
- geometry = mFactoryCache.GetGeometry( VisualFactoryCache::NINE_PATCH_GEOMETRY );
- if( !geometry )
+ if( DALI_UNLIKELY( mBorderOnly ) )
{
- geometry = CreateGeometry( Uint16Pair( 3, 3 ) );
- mFactoryCache.SaveGeometry( VisualFactoryCache::NINE_PATCH_GEOMETRY, geometry );
+ geometry = GetNinePatchGeometry( VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY );
}
- }
- else
- {
- geometry = mFactoryCache.GetGeometry( VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY );
- if( !geometry )
+ else
{
- geometry = CreateGeometryBorder( Uint16Pair( 3, 3 ) );
- mFactoryCache.SaveGeometry( VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY, geometry );
+ geometry = GetNinePatchGeometry( VisualFactoryCache::NINE_PATCH_GEOMETRY );
}
}
+ else if( data->stretchPixelsX.Size() > 0 || data->stretchPixelsY.Size() > 0)
+ {
+ Uint16Pair gridSize( 2 * data->stretchPixelsX.Size() + 1, 2 * data->stretchPixelsY.Size() + 1 );
+ geometry = !mBorderOnly ? CreateGridGeometry( gridSize ) : CreateBorderGeometry( gridSize );
+ }
}
- else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
+ else
{
- Uint16Pair gridSize( 2 * mStretchPixelsX.Size() + 1, 2 * mStretchPixelsY.Size() + 1 );
- geometry = !mBorderOnly ? CreateGeometry( gridSize ) : CreateGeometryBorder( gridSize );
+ // no N patch data so use default geometry
+ geometry = GetNinePatchGeometry( VisualFactoryCache::NINE_PATCH_GEOMETRY );
}
-
return geometry;
}
Shader NPatchVisual::CreateShader()
{
Shader shader;
- if( !mImpl->mCustomShader )
+ const NPatchLoader::Data* data;
+ // 0 is either no data (load failed?) or no stretch regions on image
+ // for both cases we use the default shader
+ NinePatchImage::StretchRanges::SizeType xStretchCount = 0;
+ NinePatchImage::StretchRanges::SizeType yStretchCount = 0;
+
+ // ask loader for the regions
+ if( mLoader.GetNPatchData( mId, data ) )
+ {
+ xStretchCount = data->stretchPixelsX.Count();
+ yStretchCount = data->stretchPixelsY.Count();
+ }
+
+ if( DALI_LIKELY( !mImpl->mCustomShader ) )
{
- if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
+ if( DALI_LIKELY( ( xStretchCount == 1 && yStretchCount == 1 ) ||
+ ( xStretchCount == 0 && yStretchCount == 0 ) ) )
{
shader = mFactoryCache.GetShader( VisualFactoryCache::NINE_PATCH_SHADER );
- if( !shader )
+ if( DALI_UNLIKELY( !shader ) )
{
shader = Shader::New( VERTEX_SHADER_3X3, FRAGMENT_SHADER );
mFactoryCache.SaveShader( VisualFactoryCache::NINE_PATCH_SHADER, shader );
}
}
- else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
+ else if( xStretchCount > 0 || yStretchCount > 0)
{
std::stringstream vertexShader;
- vertexShader << "#define FACTOR_SIZE_X " << mStretchPixelsX.Size() + 2 << "\n"
- << "#define FACTOR_SIZE_Y " << mStretchPixelsY.Size() + 2 << "\n"
+ vertexShader << "#define FACTOR_SIZE_X " << xStretchCount + 2 << "\n"
+ << "#define FACTOR_SIZE_Y " << yStretchCount + 2 << "\n"
<< VERTEX_SHADER;
shader = Shader::New( vertexShader.str(), FRAGMENT_SHADER );
}
hints = mImpl->mCustomShader->mHints;
- if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
+ if( ( xStretchCount == 1 && yStretchCount == 1 ) ||
+ ( xStretchCount == 0 && yStretchCount == 0 ) )
{
shader = Shader::New( VERTEX_SHADER_3X3, fragmentShader, hints );
}
- else if( mStretchPixelsX.Size() > 0 || mStretchPixelsY.Size() > 0)
+ else if( xStretchCount > 0 || yStretchCount > 0)
{
std::stringstream vertexShader;
- vertexShader << "#define FACTOR_SIZE_X " << mStretchPixelsX.Size() + 2 << "\n"
- << "#define FACTOR_SIZE_Y " << mStretchPixelsY.Size() + 2 << "\n"
+ vertexShader << "#define FACTOR_SIZE_X " << xStretchCount + 2 << "\n"
+ << "#define FACTOR_SIZE_Y " << yStretchCount + 2 << "\n"
<< VERTEX_SHADER;
shader = Shader::New( vertexShader.str(), fragmentShader, hints );
return shader;
}
-void NPatchVisual::InitializeRenderer()
+void NPatchVisual::ApplyTextureAndUniforms()
{
- Geometry geometry = CreateGeometry();
- Shader shader = CreateShader();
-
- if( !geometry || !shader )
+ const NPatchLoader::Data* data;
+ if( mLoader.GetNPatchData( mId, data ) )
{
- DALI_LOG_ERROR("The 9 patch image '%s' doesn't have any valid stretch borders and so is not a valid 9 patch image\n", mImageUrl.c_str() );
- InitializeFromBrokenImage();
- }
-
- TextureSet textureSet = TextureSet::New();
- mImpl->mRenderer = Renderer::New( geometry, shader );
- mImpl->mRenderer.SetTextures( textureSet );
-}
-
-
-void NPatchVisual::DoSetOnStage( Actor& actor )
-{
- if( !mCroppedImage )
- {
- if( !mImageUrl.empty() )
- {
- NinePatchImage nPatch = NinePatchImage::New( mImageUrl );
- InitializeFromImage( nPatch );
- }
- else if( mImage )
+ TextureSet textures( data->textureSet );
+ mImpl->mRenderer.SetTextures( textures );
+ if( data->stretchPixelsX.Size() == 1 && data->stretchPixelsY.Size() == 1 )
{
- InitializeFromImage( mImage );
- }
- }
-
- //initialize the renderer after initializing from the image since we need to know the grid size from the image before creating the geometry
- InitializeRenderer();
-
- if( mCroppedImage )
- {
- ApplyImageToSampler();
- }
-}
-
-void NPatchVisual::DoSetOffStage( Actor& actor )
-{
- mCroppedImage.Reset();
- actor.RemoveRenderer( mImpl->mRenderer );
- mImpl->mRenderer.Reset();
-}
-
-void NPatchVisual::DoCreatePropertyMap( Property::Map& map ) const
-{
- map.Clear();
- map.Insert( RENDERER_TYPE, IMAGE_RENDERER );
- if( !mImageUrl.empty() )
- {
- map.Insert( IMAGE_URL_NAME, mImageUrl );
- }
- else if( mImage )
- {
- map.Insert( IMAGE_URL_NAME, mImage.GetUrl() );
- }
- map.Insert( BORDER_ONLY, mBorderOnly );
-}
-
-void NPatchVisual::ChangeRenderer( bool oldBorderOnly, size_t oldGridX, size_t oldGridY )
-{
- //check to see if the border style has changed
+ //special case for 9 patch
+ Uint16Pair stretchX = data->stretchPixelsX[ 0 ];
+ Uint16Pair stretchY = data->stretchPixelsY[ 0 ];
- bool borderOnlyChanged = oldBorderOnly != mBorderOnly;
- bool gridChanged = oldGridX != mStretchPixelsX.Size() || oldGridY != mStretchPixelsY.Size();
+ uint16_t stretchWidth = stretchX.GetY() - stretchX.GetX();
+ uint16_t stretchHeight = stretchY.GetY() - stretchY.GetX();
- if( borderOnlyChanged || gridChanged )
- {
- Geometry geometry = CreateGeometry();
- if( geometry )
- {
- mImpl->mRenderer.SetGeometry( geometry );
+ mImpl->mRenderer.RegisterProperty( "uFixed[0]", Vector2::ZERO );
+ mImpl->mRenderer.RegisterProperty( "uFixed[1]", Vector2( stretchX.GetX(), stretchY.GetX()) );
+ mImpl->mRenderer.RegisterProperty( "uFixed[2]", Vector2( data->croppedWidth - stretchWidth, data->croppedHeight - stretchHeight ) );
+ mImpl->mRenderer.RegisterProperty( "uStretchTotal", Vector2( stretchWidth, stretchHeight ) );
}
else
{
- InitializeFromBrokenImage();
- }
- }
-
- if( gridChanged )
- {
- Shader shader = CreateShader();
- TextureSet textureSet;
- if( shader )
- {
- textureSet = mImpl->mRenderer.GetTextures();
- if( !textureSet )
- {
- InitializeFromBrokenImage();
- }
- mImpl->mRenderer.SetShader( shader );
- }
- }
-}
-
-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 );
+ mImpl->mRenderer.RegisterProperty( "uNinePatchFactorsX[0]", Vector2::ZERO );
+ mImpl->mRenderer.RegisterProperty( "uNinePatchFactorsY[0]", Vector2::ZERO );
- if( mCroppedImage )
- {
- ApplyImageToSampler();
+ RegisterStretchProperties( mImpl->mRenderer, "uNinePatchFactorsX", data->stretchPixelsX, data->croppedWidth );
+ RegisterStretchProperties( mImpl->mRenderer, "uNinePatchFactorsY", data->stretchPixelsY, data->croppedHeight );
}
}
-}
-
-void NPatchVisual::InitializeFromImage( NinePatchImage nPatch )
-{
- mCroppedImage = nPatch.CreateCroppedBufferImage();
- if( !mCroppedImage )
+ else
{
- DALI_LOG_ERROR("'%s' specify a valid 9 patch image\n", mImageUrl.c_str() );
- InitializeFromBrokenImage();
- return;
+ DALI_LOG_ERROR("The N patch image '%s' is not a valid N patch image\n", mImageUrl.c_str() );
+ TextureSet textureSet = TextureSet::New();
+ mImpl->mRenderer.SetTextures( textureSet );
+ Image croppedImage = VisualFactoryCache::GetBrokenVisualImage();
+ TextureSetImage( textureSet, 0u, croppedImage );
+ mImpl->mRenderer.RegisterProperty( "uFixed[0]", Vector2::ZERO );
+ mImpl->mRenderer.RegisterProperty( "uFixed[1]", Vector2::ZERO );
+ mImpl->mRenderer.RegisterProperty( "uFixed[2]", Vector2::ZERO );
+ mImpl->mRenderer.RegisterProperty( "uStretchTotal", Vector2( croppedImage.GetWidth(), croppedImage.GetHeight() ) );
}
- mImageSize = ImageDimensions( mCroppedImage.GetWidth(), mCroppedImage.GetHeight() );
-
- mStretchPixelsX = nPatch.GetStretchPixelsX();
- mStretchPixelsY = nPatch.GetStretchPixelsY();
+ //Register transform properties
+ mImpl->mTransform.RegisterUniforms( mImpl->mRenderer, Direction::LEFT_TO_RIGHT );
}
-void NPatchVisual::InitializeFromBrokenImage()
+Geometry NPatchVisual::GetNinePatchGeometry( VisualFactoryCache::GeometryType subType )
{
- mCroppedImage = VisualFactory::GetBrokenRendererImage();
- mImageSize = ImageDimensions( mCroppedImage.GetWidth(), mCroppedImage.GetHeight() );
-
- mStretchPixelsX.Clear();
- mStretchPixelsX.PushBack( Uint16Pair( 0, mImageSize.GetWidth() ) );
- mStretchPixelsY.Clear();
- mStretchPixelsY.PushBack( Uint16Pair( 0, mImageSize.GetHeight() ) );
-}
-
-void NPatchVisual::ApplyImageToSampler()
-{
- TextureSet textureSet = mImpl->mRenderer.GetTextures();
- if( textureSet )
+ Geometry geometry = mFactoryCache.GetGeometry( subType );
+ if( !geometry )
{
- TextureSetImage( textureSet, 0u, mCroppedImage );
-
- if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
+ if( DALI_LIKELY( VisualFactoryCache::NINE_PATCH_GEOMETRY == subType ) )
{
- //special case for 9 patch
- Uint16Pair stretchX = mStretchPixelsX[ 0 ];
- Uint16Pair stretchY = mStretchPixelsY[ 0 ];
-
- uint16_t stretchWidth = stretchX.GetY() - stretchX.GetX();
- uint16_t stretchHeight = stretchY.GetY() - stretchY.GetX();
-
- mImpl->mRenderer.RegisterProperty( "uFixed[0]", Vector2::ZERO );
- mImpl->mRenderer.RegisterProperty( "uFixed[1]", Vector2( stretchX.GetX(), stretchY.GetX()) );
- mImpl->mRenderer.RegisterProperty( "uFixed[2]", Vector2( mImageSize.GetWidth() - stretchWidth, mImageSize.GetHeight() - stretchHeight ) );
- mImpl->mRenderer.RegisterProperty( "uStretchTotal", Vector2( stretchWidth, stretchHeight ) );
+ geometry = CreateGridGeometry( Uint16Pair( 3, 3 ) );
}
- else
+ else if( VisualFactoryCache::NINE_PATCH_BORDER_GEOMETRY == subType )
{
- mImpl->mRenderer.RegisterProperty( "uNinePatchFactorsX[0]", Vector2::ZERO );
- mImpl->mRenderer.RegisterProperty( "uNinePatchFactorsY[0]", Vector2::ZERO );
-
- RegisterStretchProperties( mImpl->mRenderer, "uNinePatchFactorsX", mStretchPixelsX, mImageSize.GetWidth() );
- RegisterStretchProperties( mImpl->mRenderer, "uNinePatchFactorsY", mStretchPixelsY, mImageSize.GetHeight() );
+ geometry = CreateBorderGeometry( Uint16Pair( 3, 3 ) );
}
+ mFactoryCache.SaveGeometry( subType, geometry );
}
+ return geometry;
}
-Geometry NPatchVisual::CreateGeometry( Uint16Pair gridSize )
+Geometry NPatchVisual::CreateGridGeometry( Uint16Pair gridSize )
{
uint16_t gridWidth = gridSize.GetWidth();
uint16_t gridHeight = gridSize.GetHeight();
}
// Create indices
- //TODO: compare performance with triangle strip when Geometry supports it
Vector< unsigned short > indices;
indices.Reserve( gridWidth * gridHeight * 6 );
return GenerateGeometry( vertices, indices );
}
-Geometry NPatchVisual::CreateGeometryBorder( Uint16Pair gridSize )
+Geometry NPatchVisual::CreateBorderGeometry( Uint16Pair gridSize )
{
uint16_t gridWidth = gridSize.GetWidth();
uint16_t gridHeight = gridSize.GetHeight();
}
// Create indices
- //TODO: compare performance with triangle strip when Geometry supports it
Vector< unsigned short > indices;
indices.Reserve( gridWidth * gridHeight * 6 );