END_TEST;
}
-int UtcDaliBubbleEmitterSetBlendMode(void)
-{
- ToolkitTestApplication application;
- tet_infoline( " UtcDaliBubbleEmitterSetBlendMode " );
-
- Image shapeImage = CreateSolidColorImage( application, Color::GREEN, 5, 5 );
- BubbleEmitter emitter = BubbleEmitter::New( Vector2(50.f,50.f),shapeImage, 150, Vector2( 5.f, 10.f ));
- DALI_TEST_CHECK(emitter);
- Actor root = emitter.GetRootActor();
- Stage::GetCurrent().Add( root );
- root.SetPosition( Vector3::ZERO );
- root.SetParentOrigin( ParentOrigin::CENTER );
- root.SetAnchorPoint( AnchorPoint::CENTER );
-
- TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- Wait(application);
- DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
-
- emitter.SetBlendMode( true );
- Wait(application);
- DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ZERO, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
-
- emitter.SetBlendMode( false );
- Wait(application);
- DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
- DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
-
- END_TEST;
-}
-
int UtcDaliBubbleEmitterEmitBubble(void)
{
ToolkitTestApplication application;
Stage::GetCurrent().Add( actor );
controlRenderer.SetOnStage( actor );
- DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), 1, TEST_LOCATION );
+ int depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
+ DALI_TEST_EQUALS( depthIndex, 1, TEST_LOCATION );
DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), 1.f, TEST_LOCATION );
controlRenderer.SetDepthIndex( -1.f );
- DALI_TEST_EQUALS( actor.GetRendererAt(0u).GetDepthIndex(), -1, TEST_LOCATION );
+ depthIndex = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::DEPTH_INDEX );
+ DALI_TEST_EQUALS( depthIndex, -1, TEST_LOCATION );
DALI_TEST_EQUALS( controlRenderer.GetDepthIndex(), -1.f, TEST_LOCATION );
END_TEST;
#include <dali-toolkit/dali-toolkit.h>
#include <dali/devel-api/scripting/scripting.h>
-#include <dali/devel-api/rendering/material.h>
#include <dali/devel-api/rendering/renderer.h>
#include <test-native-image.h>
application.Render();
// conventional alpha blending
- Material material = imageView.GetRendererAt( 0 ).GetMaterial();
+ Renderer renderer = imageView.GetRendererAt( 0 );
BlendingFactor::Type srcFactorRgb;
BlendingFactor::Type destFactorRgb;
BlendingFactor::Type srcFactorAlpha;
BlendingFactor::Type destFactorAlpha;
- material.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ renderer.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::SRC_ALPHA );
DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE_MINUS_SRC_ALPHA );
- TestGlAbstraction& gl = application.GetGlAbstraction();
-
- float alphaBlendingUniform;
- DALI_TEST_CHECK( gl.GetUniformValue<float>( "uAlphaBlending", alphaBlendingUniform ) );
- DALI_TEST_EQUALS( alphaBlendingUniform, 1.f, TEST_LOCATION );
+ Property::Value value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+ bool enable;
+ DALI_TEST_CHECK( value.Get( enable ) );
+ DALI_TEST_CHECK( !enable );
// pre-multiplied alpha blending
imageView.SetProperty( Toolkit::ImageView::Property::PRE_MULTIPLIED_ALPHA, true );
application.SendNotification();
application.Render();
- material.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
+ renderer.GetBlendFunc(srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha);
DALI_TEST_CHECK( srcFactorRgb == BlendingFactor::ONE );
DALI_TEST_CHECK( destFactorRgb == BlendingFactor::ONE_MINUS_SRC_ALPHA );
DALI_TEST_CHECK( srcFactorAlpha == BlendingFactor::ONE );
DALI_TEST_CHECK( destFactorAlpha == BlendingFactor::ONE );
- DALI_TEST_CHECK( gl.GetUniformValue<float>( "uAlphaBlending", alphaBlendingUniform ) );
- DALI_TEST_EQUALS( alphaBlendingUniform, 0.f, TEST_LOCATION );
+ value = renderer.GetProperty( Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA );
+ DALI_TEST_CHECK( value.Get( enable ) );
+ DALI_TEST_CHECK( enable );
END_TEST;
}
controlRenderer.SetOnStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- DALI_TEST_EQUALS( actor.GetRendererAt(0).GetMaterial().GetBlendMode(), BlendingMode::ON, TEST_LOCATION );
+ int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLENDING_MODE );
+ DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::ON, TEST_LOCATION );
TestGlAbstraction& gl = application.GetGlAbstraction();
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( actor.GetRendererAt(0).GetMaterial().GetBlendMode(), BlendingMode::AUTO, TEST_LOCATION );
+ int blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLENDING_MODE );
+ DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::AUTO, TEST_LOCATION );
Vector4 actualColor(Vector4::ZERO);
DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "borderColor", actualColor ) );
application.SendNotification();
application.Render(0);
- DALI_TEST_EQUALS( actor.GetRendererAt(0).GetMaterial().GetBlendMode(), BlendingMode::ON, TEST_LOCATION );
-
+ blendMode = actor.GetRendererAt(0u).GetProperty<int>( Renderer::Property::BLENDING_MODE );
+ DALI_TEST_EQUALS( static_cast<BlendingMode::Type>(blendMode), BlendingMode::ON, TEST_LOCATION );
END_TEST;
}
GetImpl(*this).SetBubbleDensity( density );
}
-void BubbleEmitter::SetBlendMode( bool enable )
-{
- GetImpl(*this).SetBlendMode( enable );
-}
-
void BubbleEmitter::EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement )
{
GetImpl(*this).EmitBubble( animation, emitPosition, direction, displacement );
void SetBubbleDensity( unsigned int density );
/**
- * @brief Enable different blending mode for rendering.
- *
- * @param[in] enable If false, the default blending function if ImageActor is used.
- */
- void SetBlendMode( bool enable );
-
- /**
* @brief Add a bubble movement to the animation.
*
* @param[in] animation The animation reference.
}
}
-void BubbleEmitter::SetBlendMode( bool enable )
-{
- if(enable)
- {
- // linear overlay
- mMaterial.SetBlendFunc(BlendingFactor::SRC_ALPHA, BlendingFactor::ONE,
- BlendingFactor::ZERO, BlendingFactor::ONE);
- }
- else
- {
- // using default blend func
- mMaterial.SetBlendFunc( BlendingFactor::SRC_ALPHA, BlendingFactor::ONE_MINUS_SRC_ALPHA,
- BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA );
- }
-}
-
// clear the resources created for the off screen rendering
void BubbleEmitter::OnRenderFinished(RenderTask& source)
{
void SetBubbleDensity( unsigned int density );
/**
- * @copydoc Toolkit::BubbleEmitter::SetBlendMode
- */
- void SetBlendMode( bool enable );
-
- /**
* @copydoc Toolkit::BubbleEmitter::EmitBubble
*/
void EmitBubble( Animation& animation, const Vector2& emitPosition, const Vector2& direction, const Vector2& displacement );
mMaterial = Material::New( mShader );
- mMaterial.SetFaceCullingMode(Material::NONE);
-
if( mRenderer )
{
mRenderer.SetMaterial( mMaterial );
+ mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, Renderer::NONE);
}
UpdateShaderUniforms();
mBorderColorIndex = (mImpl->mRenderer).RegisterProperty( COLOR_NAME, mBorderColor );
if( mBorderColor.a < 1.f || mAntiAliasing)
{
- (mImpl->mRenderer).GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
mBorderSizeIndex = (mImpl->mRenderer).RegisterProperty( SIZE_NAME, mBorderSize );
}
(mImpl->mRenderer).SetProperty( mBorderColorIndex, color );
if( color.a < 1.f )
{
- (mImpl->mRenderer).GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
}
}
material.SetShader( shader );
if( mAntiAliasing )
{
- material.SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
}
}
mBlendColorIndex = mImpl->mRenderer.RegisterProperty( COLOR_NAME, mBlendColor );
if( mBlendColor.a < 1.f )
{
- mImpl->mRenderer.GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
}
if( mImpl->mRenderer )
{
(mImpl->mRenderer).SetProperty( mBlendColorIndex, color );
- if( color.a < 1.f && (mImpl->mRenderer).GetMaterial().GetBlendMode() != BlendingMode::ON)
+ if( color.a < 1.f )
{
- (mImpl->mRenderer).GetMaterial().SetBlendMode( BlendingMode::ON );
+ mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
}
}
}
mImpl->mDepthIndex = index;
if( mImpl->mRenderer )
{
- mImpl->mRenderer.SetDepthIndex( mImpl->mDepthIndex );
+ mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
}
}
{
DoSetOnStage( actor );
- mImpl->mRenderer.SetDepthIndex( mImpl->mDepthIndex );
+ mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex );
actor.AddRenderer( mImpl->mRenderer );
mImpl->mFlags |= Impl::IS_ON_STAGE;
}
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
);
{
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 );
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, mIsAlphaPreMultiplied);
}
void ImageRenderer::DoSetOffStage( Actor& actor )
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;
}
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 );
- }
- }
+ mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, mIsAlphaPreMultiplied);
}
}
if( mHighlightRenderer )
{
- mHighlightRenderer.SetDepthIndex( mTextDepth - 2u ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
+ mHighlightRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mTextDepth - 2 ); // text is rendered at mTextDepth and text's shadow at mTextDepth -1u.
}
}
}
Pixel::Format pixelFormat = mAtlasManager.GetPixelFormat( slot.mAtlasId );
Material material = Material::New( pixelFormat == Pixel::L8 ? mShaderL8 : mShaderRgba );
material.AddTexture( atlas, "sTexture" );
- material.SetBlendMode( BlendingMode::ON );
mAtlasManager.SetMaterial( slot.mAtlasId, material );
}
if( actor.GetRendererCount() )
{
Dali::Renderer renderer( shadowActor.GetRendererAt( 0 ) );
- renderer.SetDepthIndex( renderer.GetDepthIndex() - 1 );
+ int depthIndex = renderer.GetProperty<int>(Dali::Renderer::Property::DEPTH_INDEX);
+ renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex - 1 );
shadowActor.SetParentOrigin( ParentOrigin::CENTER );
shadowActor.SetSize( actorSize );
containerActor.Add( shadowActor );
Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
- renderer.SetDepthIndex( DepthIndex::CONTENT + mDepth );
+ renderer.SetProperty( Dali::Renderer::Property::BLENDING_MODE, BlendingMode::ON );
+ renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, DepthIndex::CONTENT + mDepth );
Actor actor = Actor::New();
#if defined(DEBUG_ENABLED)
actor.SetName( "Text renderable actor" );
}
mCurrentRenderer = Renderer::New( geometry, material );
- mCurrentRenderer.SetDepthIndex( depth );
+ mCurrentRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, depth );
Self().AddRenderer( mCurrentRenderer );
}
Geometry geometry = mCurrentRenderer.GetGeometry();
mTargetRenderer = Renderer::New( geometry, material );
- mTargetRenderer.SetDepthIndex( mCurrentRenderer.GetDepthIndex() );
+ int depthIndex = mCurrentRenderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX);
+ mTargetRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex );
for( size_t i = 0; i < mBoxes.size(); ++i )
{
#include <dali/public-api/actors/sampling.h>
#include <dali/public-api/render-tasks/render-task.h>
#include <dali/public-api/common/loading-state.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/renderer.h>
#include <dali/devel-api/rendering/geometry.h>
#include <dali-toolkit/public-api/controls/scrollable/item-view/default-item-layout.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
{ "WRAP_MODE_REPEAT", WrapMode::REPEAT },
{ "WRAP_MODE_MIRRORED_REPEAT", WrapMode::MIRRORED_REPEAT },
- { "MATERIAL_NONE", Material::NONE },
- { "MATERIAL_CULL_BACK", Material::CULL_BACK },
- { "MATERIAL_CULL_FRONT", Material::CULL_FRONT },
- { "MATERIAL_CULL_BACK_AND_FRONT", Material::CULL_BACK_AND_FRONT },
+ { "MATERIAL_NONE", Renderer::NONE },
+ { "MATERIAL_CULL_BACK", Renderer::CULL_BACK },
+ { "MATERIAL_CULL_FRONT", Renderer::CULL_FRONT },
+ { "MATERIAL_CULL_BACK_AND_FRONT", Renderer::CULL_BACK_AND_FRONT },
{ "GEOMETRY_POINTS", Geometry::POINTS },
{ "GEOMETRY_LINES", Geometry::LINES },
args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetNumberOfTextures() ) );
}
-/**
- * Set the culling mode for this material
- *
- * @method setFaceCullingMode
- * @for Material
- * @param {integer} cullingMode The culling mode for this material
- * @example
- * // face culling mode is one of the following
- * dali.MATERIAL_NONE // None of the faces should be culled
- * dali.MATERIAL_CULL_BACK // Cull back face, back face should never be shown
- * dali.MATERIAL_CULL_FRONT // Cull front face, back face should never be shown
- * dali.MATERIAL_CULL_BACK_AND_FRONT // Cull back and front faces, if the geometry is composed of triangles none of the faces will be shown
- *
- * material.setFaceCullingMode( dali.MATERIAL_NONE );
- */
-void MaterialApi::SetFaceCullingMode( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0);
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid cullingMode parameter" );
- }
- else
- {
- material.SetFaceCullingMode( static_cast<Material::FaceCullingMode>(mode) );
- }
-}
-
-/**
- * Set the blending mode.
- *
- * If blending is disabled (BLENDING_OFF) fade in and fade out animations do not work.
- *
- * @for Material
- * @method setBlendMode
- * @param { integer } mode The blending mode.
- * @example
- * // blend mode is one of the following
- * dali.BLENDING_OFF // Blending is disabled.
- * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel.
- * dali.BLENDING_ON // Blending is enabled.
- *
- * material.setBlendMode( dali.BLENDING_AUTO );
- */
-void MaterialApi::SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int mode = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid blendMode parameter" );
- }
- else
- {
- material.SetBlendMode( static_cast<Dali::BlendingMode::Type>( mode ) );
- }
-}
-
-/**
- * Retrieves the blending mode.
- *
- * @for Material
- * @method getBlendMode
- * @return { integer } blendMode
- * @example returns one of the following:
- *
- * dali.BLENDING_OFF // Blending is disabled.
- * dali.BLENDING_AUTO // Blending is enabled if there is alpha channel.
- * dali.BLENDING_ON // Blending is enabled.
- */
-void MaterialApi::GetBlendMode( const v8::FunctionCallbackInfo<v8::Value>& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetBlendMode() ) );
-}
-
-/**
- * Specify the pixel arithmetic used when the actor is blended.
- *
- * @for Material
- * @method setBlendFunc
- * @param {integer} srcFactorRgb Source Blending RGB
- * @param {integer} destFactorRgb Destination Blending RGB
- * @param {integer} srcFactorAlpha Source Blending Alpha
- * @param {integer} destFactorAlpha Destinatino Blending Alpha
- * @example
- * //blending constants
- * dali.BLEND_FACTOR_ZERO
- * dali.BLEND_FACTOR_ONE
- * dali.BLEND_FACTOR_SRC_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_SRC_COLOR
- * dali.BLEND_FACTOR_SRC_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
- * dali.BLEND_FACTOR_DST_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_DST_ALPHA
- * dali.BLEND_FACTOR_DST_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_DST_COLOR
- * dali.BLEND_FACTOR_SRC_ALPHA_SATURATE
- * dali.BLEND_FACTOR_CONSTANT_COLOR
- * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
- * dali.BLEND_FACTOR_CONSTANT_ALPHA
- * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA
- *
- * material.setBlendFunc( dali.BLEND_FACTOR_CONSTANT_COLOR, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
- * dali.BLEND_FACTOR_CONSTANT_ALPHA, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA );
- */
-void MaterialApi::SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- int params[4];
- bool foundAllParams(false);
- V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 4, args, 0 );
- if( foundAllParams )
- {
- material.SetBlendFunc( static_cast< Dali::BlendingFactor::Type>(params[0]),
- static_cast< Dali::BlendingFactor::Type>(params[1]),
- static_cast< Dali::BlendingFactor::Type>(params[2]),
- static_cast< Dali::BlendingFactor::Type>(params[3]) );
- }
- else
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid blendFunc parameter");
- }
-}
-
-/**
- * Query the pixel arithmetic used when the actor is blended.
- *
- * @for Material
- * @method getBlendFunc
- * @return {Object} Blend properties
- * @example Blend properties object has 4 fields
- *
- * blendProperties.sourceRgb // source rgb enum
- * blendProperties.destinationRgb // destination rgb enum
- * blendProperties.sourceAlpha source // alpha enum
- * blendProperties.destinationAlpha // destination alpha enum
- */
-void MaterialApi::GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- // Pass by reference doesn't work in Javascript
- // For now just return a vector 4...
-
- BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha;
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
-
- v8::Local<v8::Object> blendProperties = v8::Object::New( isolate );
-
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceRgb" ), v8::Integer::New( isolate, srcFactorRgb) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationRgb" ), v8::Integer::New( isolate, destFactorRgb ) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceAlpha" ), v8::Integer::New( isolate, srcFactorAlpha ) );
- blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationAlpha" ), v8::Integer::New( isolate, destFactorAlpha ) );
-
- args.GetReturnValue().Set( blendProperties );
-}
-
-/**
- * Specify the equation used when the actor is blended.
- *
- * @for Material
- * @method setBlendEquation
- * @param { integer } equationRgb The equation used for combining red, green, and blue components.
- * @param { integer } equationAlpha The equation used for combining the alpha component.
- * @example
- * // blend equation is one of the following
- * dali.BLEND_EQUATION_ADD
- * dali.BLEND_EQUATION_SUBTRACT
- * dali.BLEND_EQUATION_REVERSE_SUBTRACT
- *
- * material.setBlendEquation( dali.BLEND_EQUATION_ADD, dali.BLEND_EQUATION_REVERSE_SUBTRACT );
- */
-void MaterialApi::SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- int params[2];
- bool foundAllParams(false);
- V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 2, args, 0 );
- if( foundAllParams )
- {
- material.SetBlendEquation( static_cast< BlendingEquation::Type>(params[0]), static_cast< BlendingEquation::Type>(params[1]) );
- }
- else
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendEquation parameter");
- }
-}
-
-/**
- * Query the equation used when the actor is blended.
- *
- * @for Material
- * @method getBlendEquation
- * @return {Object} Blend equations
- * @example Blend equations object has 2 fields
- *
- * blendEquations.equationRgb // equation used for combining rgb components
- * blendEquations.equationAlpha // equation used for combining alpha components
- */
-void MaterialApi::GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- // Pass by reference doesn't work in Javascript
- // For now just return a vector 2...
-
- BlendingEquation::Type equationRgb, equationAlpha;
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- material.GetBlendEquation( equationRgb, equationAlpha );
-
- v8::Local<v8::Object> blendEquations = v8::Object::New( isolate );
-
- blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationRgb" ), v8::Integer::New( isolate, equationRgb) );
- blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationAlpha" ), v8::Integer::New( isolate, equationAlpha ) );
-
- args.GetReturnValue().Set( blendEquations );
-}
-
} // namespace V8Plugin
} // namespace Dali
void SetTextureUniformName( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetTextureIndex( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetNumberOfTextures( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetFaceCullingMode( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetBlendMode( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
}; // namespace MaterialApi
{ "SetTextureUniformName" , MaterialApi::SetTextureUniformName },
{ "GetTextureIndex" , MaterialApi::GetTextureIndex },
{ "GetNumberOfTextures" , MaterialApi::GetNumberOfTextures },
- { "SetFaceCullingMode" , MaterialApi::SetFaceCullingMode },
- { "SetBlendMode" , MaterialApi::SetBlendMode },
- { "GetBlendMode" , MaterialApi::GetBlendMode },
- { "SetBlendFunc" , MaterialApi::SetBlendFunc },
- { "GetBlendFunc" , MaterialApi::GetBlendFunc },
- { "SetBlendEquation" , MaterialApi::SetBlendEquation },
- { "GetBlendEquation" , MaterialApi::GetBlendEquation },
};
const unsigned int MaterialFunctionTableCount = sizeof(MaterialFunctionTable)/sizeof(MaterialFunctionTable[0]);
args.GetReturnValue().Set( localObject );
}
+/**
+ * Specify the pixel arithmetic used when the actor is blended.
+ *
+ * @for Renderer
+ * @method setBlendFunc
+ * @param {integer} srcFactorRgb Source Blending RGB
+ * @param {integer} destFactorRgb Destination Blending RGB
+ * @param {integer} srcFactorAlpha Source Blending Alpha
+ * @param {integer} destFactorAlpha Destination Blending Alpha
+ * @example
+ * //blending constants
+ * dali.BLEND_FACTOR_ZERO
+ * dali.BLEND_FACTOR_ONE
+ * dali.BLEND_FACTOR_SRC_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_SRC_COLOR
+ * dali.BLEND_FACTOR_SRC_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
+ * dali.BLEND_FACTOR_DST_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_DST_ALPHA
+ * dali.BLEND_FACTOR_DST_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_DST_COLOR
+ * dali.BLEND_FACTOR_SRC_ALPHA_SATURATE
+ * dali.BLEND_FACTOR_CONSTANT_COLOR
+ * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
+ * dali.BLEND_FACTOR_CONSTANT_ALPHA
+ * dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA
+ *
+ * renderer.setBlendFunc( dali.BLEND_FACTOR_CONSTANT_COLOR, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
+ * dali.BLEND_FACTOR_CONSTANT_ALPHA, dali.BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA );
+ */
+void RendererApi::SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ int params[4];
+ bool foundAllParams(false);
+ V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 4, args, 0 );
+ if( foundAllParams )
+ {
+ renderer.SetBlendFunc( static_cast< Dali::BlendingFactor::Type>(params[0]),
+ static_cast< Dali::BlendingFactor::Type>(params[1]),
+ static_cast< Dali::BlendingFactor::Type>(params[2]),
+ static_cast< Dali::BlendingFactor::Type>(params[3]) );
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid blendFunc parameter");
+ }
+}
+
+/**
+ * Query the pixel arithmetic used when the actor is blended.
+ *
+ * @for Renderer
+ * @method getBlendFunc
+ * @return {Object} Blend properties
+ * @example Blend properties object has 4 fields
+ *
+ * blendProperties.sourceRgb // source rgb enum
+ * blendProperties.destinationRgb // destination rgb enum
+ * blendProperties.sourceAlpha source // alpha enum
+ * blendProperties.destinationAlpha // destination alpha enum
+ */
+void RendererApi::GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ // Pass by reference doesn't work in Javascript
+ // For now just return a vector 4...
+
+ BlendingFactor::Type srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha;
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ renderer.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+
+ v8::Local<v8::Object> blendProperties = v8::Object::New( isolate );
+
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceRgb" ), v8::Integer::New( isolate, srcFactorRgb) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationRgb" ), v8::Integer::New( isolate, destFactorRgb ) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "sourceAlpha" ), v8::Integer::New( isolate, srcFactorAlpha ) );
+ blendProperties->Set( v8::String::NewFromUtf8( isolate, "destinationAlpha" ), v8::Integer::New( isolate, destFactorAlpha ) );
+
+ args.GetReturnValue().Set( blendProperties );
+}
+
+/**
+ * Specify the equation used when the actor is blended.
+ *
+ * @for Renderer
+ * @method setBlendEquation
+ * @param { integer } equationRgb The equation used for combining red, green, and blue components.
+ * @param { integer } equationAlpha The equation used for combining the alpha component.
+ * @example
+ * // blend equation is one of the following
+ * dali.BLEND_EQUATION_ADD
+ * dali.BLEND_EQUATION_SUBTRACT
+ * dali.BLEND_EQUATION_REVERSE_SUBTRACT
+ *
+ * renderer.setBlendEquation( dali.BLEND_EQUATION_ADD, dali.BLEND_EQUATION_REVERSE_SUBTRACT );
+ */
+void RendererApi::SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ int params[2];
+ bool foundAllParams(false);
+ V8Utils::ReadIntegerArguments( foundAllParams, ¶ms[0], 2, args, 0 );
+ if( foundAllParams )
+ {
+ renderer.SetBlendEquation( static_cast< BlendingEquation::Type>(params[0]), static_cast< BlendingEquation::Type>(params[1]) );
+ }
+ else
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid BlendEquation parameter");
+ }
+}
+
+/**
+ * Query the equation used when the actor is blended.
+ *
+ * @for Renderer
+ * @method getBlendEquation
+ * @return {Object} Blend equations
+ * @example Blend equations object has 2 fields
+ *
+ * blendEquations.equationRgb // equation used for combining rgb components
+ * blendEquations.equationAlpha // equation used for combining alpha components
+ */
+void RendererApi::GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ // Pass by reference doesn't work in Javascript
+ // For now just return a vector 2...
+
+ BlendingEquation::Type equationRgb, equationAlpha;
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ Renderer renderer = GetRenderer( isolate, args );
+
+ renderer.GetBlendEquation( equationRgb, equationAlpha );
+
+ v8::Local<v8::Object> blendEquations = v8::Object::New( isolate );
+
+ blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationRgb" ), v8::Integer::New( isolate, equationRgb) );
+ blendEquations->Set( v8::String::NewFromUtf8( isolate, "equationAlpha" ), v8::Integer::New( isolate, equationAlpha ) );
+
+ args.GetReturnValue().Set( blendEquations );
+}
+
} // namespace V8Plugin
} // namespace Dali
void GetGeometry( const v8::FunctionCallbackInfo< v8::Value >& args );
void SetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args );
void GetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetBlendFunc( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetBlendEquation( const v8::FunctionCallbackInfo< v8::Value >& args );
}; // namespace RendererApi
{ "GetGeometry" , RendererApi::GetGeometry },
{ "SetMaterial" , RendererApi::SetMaterial },
{ "GetMaterial" , RendererApi::GetMaterial },
+ { "SetBlendFunc" , RendererApi::SetBlendFunc },
+ { "GetBlendFunc" , RendererApi::GetBlendFunc },
+ { "SetBlendEquation" , RendererApi::SetBlendEquation },
+ { "GetBlendEquation" , RendererApi::GetBlendEquation },
};
const unsigned int RendererFunctionTableCount = sizeof(RendererFunctionTable)/sizeof(RendererFunctionTable[0]);