X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fnpatch%2Fnpatch-visual.cpp;h=923554588a0375c7dfaa5d5907d08fa27f8ace8f;hb=d26f555fd84d43b0a3e650c66a0e626e841dd9c6;hp=9b94eb544562a84bf789488a7e22cafc080edb96;hpb=e320e3cd737833c295c98313fdd82f287f557a96;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp old mode 100644 new mode 100755 index 9b94eb5..9235545 --- a/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp +++ b/dali-toolkit/internal/visuals/npatch/npatch-visual.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -19,10 +19,10 @@ #include "npatch-visual.h" // EXTERNAL INCLUDES -#include #include #include #include +#include // INTERNAL INCLUDES #include @@ -111,7 +111,6 @@ const char* VERTEX_SHADER_3X3 = DALI_COMPOSE_SHADER( 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 = visualSize.xy;\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 @@ -234,7 +233,7 @@ void RegisterStretchProperties( Renderer& renderer, const char * uniformName, co /////////////////NPatchVisual//////////////// -NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl, const Property::Map& properties ) +NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl, const Property::Map& properties ) { NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) ); nPatchVisual->mImageUrl = imageUrl; @@ -243,7 +242,7 @@ NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std:: return nPatchVisual; } -NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std::string& imageUrl ) +NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const VisualUrl& imageUrl ) { NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) ); nPatchVisual->mImageUrl = imageUrl; @@ -254,8 +253,8 @@ NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, const std:: NPatchVisualPtr NPatchVisual::New( VisualFactoryCache& factoryCache, NinePatchImage image ) { NPatchVisualPtr nPatchVisual( new NPatchVisual( factoryCache ) ); - nPatchVisual->mImageUrl = image.GetUrl(); - + VisualUrl visualUrl( image.GetUrl() ); + nPatchVisual->mImageUrl = visualUrl; return nPatchVisual; } @@ -263,10 +262,11 @@ void NPatchVisual::GetNaturalSize( Vector2& naturalSize ) { naturalSize.x = 0u; naturalSize.y = 0u; + // load now if not already loaded - if( NPatchLoader::UNINITIALIZED_ID == mId ) + if( NPatchLoader::UNINITIALIZED_ID == mId && mImageUrl.IsLocal() ) { - mId = mLoader.Load( mImageUrl, mBorder ); + mId = mLoader.Load( mImageUrl.GetUrl(), mBorder ); } const NPatchLoader::Data* data; if( mLoader.GetNPatchData( mId, data ) ) @@ -304,9 +304,9 @@ void NPatchVisual::DoSetProperties( const Property::Map& propertyMap ) void NPatchVisual::DoSetOnStage( Actor& actor ) { // load when first go on stage - if( NPatchLoader::UNINITIALIZED_ID == mId ) + if( NPatchLoader::UNINITIALIZED_ID == mId && mImageUrl.IsLocal() ) { - mId = mLoader.Load( mImageUrl, mBorder ); + mId = mLoader.Load( mImageUrl.GetUrl(), mBorder ); } Geometry geometry = CreateGeometry(); @@ -316,6 +316,9 @@ void NPatchVisual::DoSetOnStage( Actor& actor ) ApplyTextureAndUniforms(); actor.AddRenderer( mImpl->mRenderer ); + + // npatch loaded and ready to display + ResourceReady(); } void NPatchVisual::DoSetOffStage( Actor& actor ) @@ -336,7 +339,7 @@ void NPatchVisual::DoCreatePropertyMap( Property::Map& map ) const { map.Clear(); map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::DevelVisual::N_PATCH ); - map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl ); + map.Insert( Toolkit::ImageVisual::Property::URL, mImageUrl.GetUrl() ); map.Insert( Toolkit::ImageVisual::Property::BORDER_ONLY, mBorderOnly ); map.Insert( Toolkit::DevelImageVisual::Property::BORDER, mBorder ); } @@ -440,10 +443,17 @@ Shader NPatchVisual::CreateShader() } hints = mImpl->mCustomShader->mHints; + /* Apply Custom Vertex Shader only if image is 9-patch */ if( ( xStretchCount == 1 && yStretchCount == 1 ) || ( xStretchCount == 0 && yStretchCount == 0 ) ) { - shader = Shader::New( VERTEX_SHADER_3X3, fragmentShader, hints ); + const char* vertexShader = VERTEX_SHADER_3X3; + + if( !mImpl->mCustomShader->mVertexShader.empty() ) + { + vertexShader = mImpl->mCustomShader->mVertexShader.c_str(); + } + shader = Shader::New( vertexShader, fragmentShader, hints ); } else if( xStretchCount > 0 || yStretchCount > 0) { @@ -491,7 +501,7 @@ void NPatchVisual::ApplyTextureAndUniforms() } else { - DALI_LOG_ERROR("The N patch image '%s' is not a valid N patch image\n", mImageUrl.c_str() ); + DALI_LOG_ERROR("The N patch image '%s' is not a valid N patch image\n", mImageUrl.GetUrl().c_str() ); TextureSet textureSet = TextureSet::New(); mImpl->mRenderer.SetTextures( textureSet ); Image croppedImage = VisualFactoryCache::GetBrokenVisualImage();