\n
void main()\n
{\n
- mediump vec2 texCoord = mix( uAtlasRect.xy, uAtlasRect.zw, clamp( vTexCoord, 0.0, 1.0 ) );\n
+ mediump vec2 texCoord = clamp( mix( uAtlasRect.xy, uAtlasRect.zw, vTexCoord ), uAtlasRect.xy, uAtlasRect.zw );\n
gl_FragColor = texture2D( sTexture, texCoord ) * uColor;\n
}\n
);
uniform lowp vec2 wrapMode;\n
uniform lowp vec4 uColor;\n
\n
- mediump float wrapCoordinate( mediump float coordinate, lowp float wrap )\n
+ mediump float wrapCoordinate( mediump vec2 range, mediump float coordinate, lowp float wrap )\n
{\n
- if( abs(wrap-2.0) < 0.5 )\n // REFLECT
- return 1.0-abs(fract(coordinate*0.5)*2.0 - 1.0);\n
+ mediump float coord;\n
+ if( wrap > 1.5 )\n // REFLECT
+ coord = 1.0-abs(fract(coordinate*0.5)*2.0 - 1.0);\n
else \n// warp == 0 or 1
- return mix( clamp( coordinate, 0.0, 1.0 ), fract( coordinate ), wrap);\n
+ coord = mix(coordinate, fract( coordinate ), wrap);\n
+ return clamp( mix(range.x, range.y, coord), range.x, range.y );
}\n
+ \n
void main()\n
{\n
- mediump vec2 texCoord = mix( uAtlasRect.xy, uAtlasRect.zw,
- vec2( wrapCoordinate( vTexCoord.x, wrapMode.x ), wrapCoordinate( vTexCoord.y, wrapMode.y ) ) );\n
+ mediump vec2 texCoord = vec2( wrapCoordinate( uAtlasRect.xz, vTexCoord.x, wrapMode.x ),
+ wrapCoordinate( uAtlasRect.yw, vTexCoord.y, wrapMode.y ) );\n
gl_FragColor = texture2D( sTexture, texCoord ) * uColor;\n
}\n
);
}
else
{
- textureSet = mFactoryCache.GetAtlasManager()->Add(textureRect, url, mDesiredSize, mFittingMode, mSamplingMode );
+ textureSet = mFactoryCache.GetAtlasManager()->Add(textureRect, url, mDesiredSize, mFittingMode, true, this );
mImpl->mFlags |= Impl::IS_ATLASING_APPLIED;
if( !textureSet ) // big image, no atlasing
{
mImageUrl = imageUrl;
mImpl->mRenderer.Reset();
+ mImpl->mFlags &= ~Impl::IS_ATLASING_APPLIED;
if( !mImpl->mCustomShader &&
( strncasecmp( imageUrl.c_str(), HTTP_URL, sizeof(HTTP_URL) -1 ) != 0 ) && // ignore remote images
}
}
+void ImageVisual::UploadCompleted()
+{
+ // Resource image is loaded. If weak handle is holding a placement actor, it is the time to add the renderer to actor.
+ Actor actor = mPlacementActor.GetHandle();
+ if( actor )
+ {
+ actor.AddRenderer( mImpl->mRenderer );
+ // reset the weak handle so that the renderer only get added to actor once
+ mPlacementActor.Reset();
+ }
+}
+
void ImageVisual::DoSetOnStage( Actor& actor )
{
+ mPlacementActor = actor;
+
if( !mImageUrl.empty() )
{
InitializeRenderer( mImageUrl );
{
mImpl->mRenderer.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, mPixelArea );
}
+
+ if( IsSynchronousResourceLoading() || !(mImpl->mFlags & Impl::IS_ATLASING_APPLIED) )
+ {
+ actor.AddRenderer( mImpl->mRenderer );
+ mPlacementActor.Reset();
+ }
}
void ImageVisual::DoSetOffStage( Actor& actor )
actor.RemoveRenderer( mImpl->mRenderer );
mImpl->mRenderer.Reset();
}
+ mPlacementActor.Reset();
}
void ImageVisual::DoCreatePropertyMap( Property::Map& map ) const
map.Insert( Toolkit::ImageVisual::Property::WRAP_MODE_V, mWrapModeV );
}
+void ImageVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ // TODO
+}
+
+Dali::Property::Value ImageVisual::DoGetProperty( Dali::Property::Index index )
+{
+ // TODO
+ return Dali::Property::Value();
+}
+
Shader ImageVisual::GetImageShader( VisualFactoryCache& factoryCache, bool atlasing, bool defaultTextureWrapping )
{
Shader shader;