const char HTTPS_URL[] = "https://";
const char * const RENDERER_TYPE("rendererType");
-const char * const RENDERER_TYPE_VALUE("imageRenderer");
+const char * const RENDERER_TYPE_VALUE("image");
// property names
const char * const IMAGE_URL_NAME( "imageUrl" );
const std::string ATLAS_RECT_UNIFORM_NAME = "uAtlasRect";
const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
-// Set this uniform to 1.0 for conventional alpha blending; if pre-multiplied alpha blending, set this uniform to 0.0
-const std::string ALPHA_BLENDING_UNIFORM_NAME = "uAlphaBlending";
-
const Vector4 FULL_TEXTURE_RECT(0.f, 0.f, 1.f, 1.f);
const char* DEFAULT_SAMPLER_TYPENAME = "sampler2D";
varying mediump vec2 vTexCoord;\n
uniform sampler2D sTexture;\n
uniform lowp vec4 uColor;\n
- uniform lowp float uAlphaBlending; // Set to 1.0 for conventional alpha blending; if pre-multiplied alpha blending, set to 0.0
\n
void main()\n
{\n
- gl_FragColor = texture2D( sTexture, vTexCoord ) * vec4( uColor.rgb*max( uAlphaBlending, uColor.a ), uColor.a );\n
+ gl_FragColor = texture2D( sTexture, vTexCoord ) * uColor;\n
}\n
);
{
Property::Map vertexFormat;
vertexFormat[ "aPosition" ] = Property::VECTOR2;
- PropertyBuffer vertexPropertyBuffer = PropertyBuffer::New( vertexFormat, vertices.Size() );
+ PropertyBuffer vertexPropertyBuffer = PropertyBuffer::New( vertexFormat );
if( vertices.Size() > 0 )
{
- vertexPropertyBuffer.SetData( &vertices[ 0 ] );
+ vertexPropertyBuffer.SetData( &vertices[ 0 ], vertices.Size() );
}
Property::Map indexFormat;
indexFormat[ "indices" ] = Property::INTEGER;
- PropertyBuffer indexPropertyBuffer = PropertyBuffer::New( indexFormat, indices.Size() );
+ PropertyBuffer indexPropertyBuffer = PropertyBuffer::New( indexFormat );
if( indices.Size() > 0 )
{
- indexPropertyBuffer.SetData( &indices[ 0 ] );
+ indexPropertyBuffer.SetData( &indices[ 0 ], indices.Size() );
}
// Create the geometry object
mDesiredSize(),
mFittingMode( FittingMode::DEFAULT ),
mSamplingMode( SamplingMode::DEFAULT ),
- mIsAlphaPreMultiplied( false ),
mNativeFragmentShaderCode( ),
mNativeImageFlag( false )
{
{
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- shader.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 1.f );
}
}
}
shader = Shader::New( VERTEX_SHADER, mNativeFragmentShaderCode );
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- shader.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 1.f );
}
else
{
{
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- shader.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 1.f );
}
}
}
InitializeRenderer( mImage );
}
- EnablePreMultipliedAlpha( mIsAlphaPreMultiplied );
}
void ImageRenderer::DoSetOffStage( Actor& actor )
{
actor.RemoveRenderer( mImpl->mRenderer );
CleanCache(mImageUrl);
-
mImage.Reset();
}
else
factoryCache.SaveShader( RendererFactoryCache::IMAGE_SHADER, shader );
shader.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
shader.RegisterProperty( PIXEL_AREA_UNIFORM_NAME, FULL_TEXTURE_RECT );
- shader.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 1.f );
}
return shader;
}
}
}
-void ImageRenderer::EnablePreMultipliedAlpha( bool preMultipled )
-{
- mIsAlphaPreMultiplied = preMultipled;
- if( mImpl->mRenderer )
- {
- Material material = mImpl->mRenderer.GetMaterial();
-
- if( preMultipled )
- {
- material.SetBlendFunc( BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA,
- BlendingFactor::ONE, BlendingFactor::ONE );
- if( !mImpl->mCustomShader || mImpl->mCustomShader->mVertexShader.empty())
- {
- material.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 0.f );
- }
- }
- else
- {
- // using default blend func
- material.SetBlendFunc( BlendingFactor::SRC_ALPHA, BlendingFactor::ONE_MINUS_SRC_ALPHA,
- BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA );
-
- Property::Index index = material.GetPropertyIndex( ALPHA_BLENDING_UNIFORM_NAME );
- if( index != Property::INVALID_INDEX ) // only set value when the property already exist on the Material
- {
- material.SetProperty( index, 1.f );
- }
- }
- }
-}
-
void ImageRenderer::ApplyImageToSampler( const Image& image )
{
if( image )