#include <stdlib.h>
#include <dali-toolkit-test-suite-utils.h>
#include <dali/devel-api/rendering/renderer.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/texture-set.h>
#include <dali/devel-api/rendering/shader.h>
#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
#include <dali-toolkit-test-suite-utils.h>
#include <toolkit-event-thread-callback.h>
#include <dali/devel-api/rendering/renderer.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/texture-set.h>
#include <dali/devel-api/rendering/shader.h>
#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
controlRenderer.SetOnStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfTextures() == expectedSamplers );
application.SendNotification();
application.Render();
application.Render();
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- // texture is not added until the rasterization completed.
- DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfTextures() == 0 );
EventThreadCallback* eventTrigger = EventThreadCallback::Get();
CallbackBase* callback = eventTrigger->GetCallback();
CallbackBase::Execute( *callback );
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfTextures() == 1 );
-
// waiting for the resource uploading
application.SendNotification();
application.Render();
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfTextures() == 1 );
// reset the renderer to renderer a svg image
factory.ResetRenderer( controlRenderer, actor, TEST_SVG_FILE_NAME, ImageDimensions( 100, 100 ) );
application.Render();
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- // texture is not added until the rasterization completed.
- DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfTextures() == 0 );
EventThreadCallback* eventTrigger = EventThreadCallback::Get();
CallbackBase* callback = eventTrigger->GetCallback();
eventTrigger->WaitingForTrigger( 1 );// waiting until the svg image is rasterized.
CallbackBase::Execute( *callback );
- DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfTextures() == 1 );
-
END_TEST;
}
/**
* @brief ControlRenderer provides renderer for rendering the controls. A control may have multiple ControlRenders.
*
- * ControlRenderers reuses geometry, shader etc. across controls and manages the renderer and material to exist only when control is on-stage.
+ * ControlRenderers reuses geometry, shader etc. across controls and manages the renderer and texture sets to exist only when control is on-stage.
* It also responds to actor size and color change, and provides the clipping at the renderer level.
* Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
*/
const char* const IMAGE_INTENSITY_PROPERTY_NAME = "uImageIntensity";
const char* const IMAGE_SATURATION_PROPERTY_NAME = "uImageSaturation";
-const char* const EFFECT_IMAGE_NAME( "sEffect" );
-
///////////////////////////////////////////////////////
//
// Bloom shaders
// use the completed blur in the first buffer and composite with the original child actors render
mCompositeImageActor.SetImage( mRenderTargetForRenderingChildren );
- Material material = mCompositeImageActor.GetRendererAt(0).GetMaterial();
- int textureIndex = material.GetTextureIndex( EFFECT_IMAGE_NAME );
- if( textureIndex == -1 )
- {
- material.AddTexture( mBlurExtractTarget, EFFECT_IMAGE_NAME );
- }
- else
- {
- material.SetTextureImage( textureIndex, mBlurExtractTarget );
- }
+ TextureSet textureSet = mCompositeImageActor.GetRendererAt(0).GetTextures();
+ textureSet.SetImage( 1u, mBlurExtractTarget );
// set up target actor for rendering result, i.e. the blurred image
mTargetImageActor.SetImage(mOutputRenderTarget);
mActor = Actor::New();
}
-void BubbleActor::MakeRenderable( Geometry geometry, Material material )
+void BubbleActor::MakeRenderable( Geometry geometry, TextureSet textureSet, Shader shader )
{
if( mRenderer )
{
return;
}
- mRenderer = Renderer::New( geometry, material );
+ mRenderer = Renderer::New( geometry, shader );
+ mRenderer.SetTextures( textureSet );
mActor.AddRenderer( mRenderer );
mActor.SetSize( mMovementArea );
/**
* Prepare for the rendering: create and add renderer, and register properties
* @param[in] geometry The geometry to be used by the renderer
- * @param[in] material The material to be used by the renderer
+ * @param[in] textureSet The texture set to be used by the renderer
+ * @param[in] textureSet The shader set to be used by the renderer
*/
- void MakeRenderable( Geometry geometry, Material material );
+ void MakeRenderable( Geometry geometry, TextureSet textureSet, Shader shader );
/**
* Return the mesh actor which is used to display the bubbles
{
/**
- * Create the shader to be used by the material
+ * Create the shader to be used by the renderer
* @param[in] numberOfBubble How many groups of uniforms are used to control the bubble movement.
* @return A handle to the newly created shader.
*/
{\n
// Get the emit pisition color, and Mix with the actor color
mediump vec4 fragColor = texture2D(sBackground, vEffectTexCoord)*uColor;\n
- // Apply the shape defined by the texture contained in the material
+ // Apply the shape defined by the texture contained sBubbleShape
// And make the opacity being 0.7, and animate from 0.7 to 0 during the last 1/3 of movement
fragColor.a *= texture2D(sBubbleShape, vTexCoord).a * ( 2.1 - max( vPercentage*2.1, 1.4 ) );\n
gl_FragColor = fragColor;\n
Shader bubbleShader = CreateBubbleShader (mNumBubblePerActor );
- mMaterial = Material::New( bubbleShader );
- mMaterial.AddTexture( mEffectImage, "sBackground" );
- mMaterial.AddTexture( mShapeImage, "sBubbleShape" );
+ mTextureSet = TextureSet::New();
+ mTextureSet.SetImage( 0u, mEffectImage );
+ mTextureSet.SetImage( 1u, mShapeImage );
mBubbleActors.resize( mNumActor );
for(unsigned int i=0; i < mNumActor; i++ )
{
mBubbleActors[i] = new BubbleActor( mNumBubblePerActor, mMovementArea );
- (mBubbleActors[i])->MakeRenderable( mMeshGeometry, mMaterial );
+ (mBubbleActors[i])->MakeRenderable( mMeshGeometry, mTextureSet, bubbleShader );
mBubbleRoot.Add( (mBubbleActors[i])->GetMeshActor() );
}
void BubbleEmitter::SetShapeImage( Image shapeImage )
{
- mMaterial.SetTextureImage( 1, shapeImage );
+ mTextureSet.SetImage( 1, shapeImage );
}
void BubbleEmitter::SetBubbleScale( float scale )
CameraActor mCameraActor; ///< The render task views the scene from the perspective of this actor.
Geometry mMeshGeometry; ///< The mesh geometry which contains the vertices and indices data
- Material mMaterial; ///< The material which controls the bubble display
+ TextureSet mTextureSet; ///< The texture set which controls the bubble display
std::vector<BubbleActorPtr> mBubbleActors; ///< The meshActor vector, its size is mNumShader.
Vector2 mMovementArea; ///< The size of the bubble moving area, usually the same size as the background image actor.
}
case Toolkit::Model3dView::Property::MATERIAL_URL:
{
- if( value.Get(impl.mMaterialUrl) )
+ if( value.Get(impl.mTextureSetUrl) )
{
impl.LoadMaterial();
impl.CreateMaterial();
}
case Toolkit::Model3dView::Property::MATERIAL_URL:
{
- value = impl.mMaterialUrl;
+ value = impl.mTextureSetUrl;
break;
}
case Toolkit::Model3dView::Property::IMAGES_URL:
//Create empty versions of the geometry and material so we always have a Renderer
Geometry mesh = Geometry::New();
Shader shader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER, (Shader::ShaderHints)(Shader::HINT_REQUIRES_SELF_DEPTH_TEST | Shader::HINT_MODIFIES_GEOMETRY) );
- Material material = Material::New( shader );
- mRenderer = Renderer::New( mesh, material );
+ mRenderer = Renderer::New( mesh, shader );
+
}
void Model3dView::LoadGeometry()
std::streampos fileSize;
Dali::Vector<char> fileContent;
- if( FileLoader::ReadFile(mMaterialUrl, fileSize, fileContent, FileLoader::TEXT) )
+ if( FileLoader::ReadFile(mTextureSetUrl, fileSize, fileContent, FileLoader::TEXT) )
{
mObjLoader.LoadMaterial(fileContent.Begin(), fileSize, mTexture0Url, mTexture1Url, mTexture2Url);
}
mShader = Shader::New( SIMPLE_VERTEX_SHADER, SIMPLE_FRAGMENT_SHADER, (Shader::ShaderHints)(Shader::HINT_REQUIRES_SELF_DEPTH_TEST | Shader::HINT_MODIFIES_GEOMETRY) );
}
- mMaterial = Material::New( mShader );
+ mTextureSet = TextureSet::New();
if( mRenderer )
{
- mRenderer.SetMaterial( mMaterial );
+ mRenderer.SetTextures( mTextureSet );
+ mRenderer.SetShader( mShader );
mRenderer.SetProperty( Renderer::Property::FACE_CULLING_MODE, Renderer::NONE);
}
void Model3dView::LoadTextures()
{
- if( !mMaterial )
+ if( !mTextureSet )
return ;
if( mTexture0Url != "" )
Image tex0 = ResourceImage::New( imgUrl );
if( tex0 )
{
- mMaterial.AddTexture( tex0, "sDiffuse" );
+ mTextureSet.SetImage( 0u, tex0 );
}
}
Image tex1 = ResourceImage::New( imgUrl );
if (tex1)
{
- mMaterial.AddTexture( tex1, "sNormal" );
+ mTextureSet.SetImage( 1u, tex1 );
}
}
Image tex2 = ResourceImage::New( imgUrl );
if( tex2 )
{
- mMaterial.AddTexture( tex2, "sGloss" );
+ mTextureSet.SetImage( 2u, tex2 );
}
}
}
//Properties
std::string mObjUrl;
- std::string mMaterialUrl;
+ std::string mTextureSetUrl;
std::string mImagesUrl;
std::string mTexture0Url;
std::string mTexture1Url;
//Render members
Shader mShader;
- Material mMaterial;
+ TextureSet mTextureSet;
Geometry mMesh;
Renderer mRenderer;
};
const char * const CUSTOM_VERTEX_SHADER( "vertexShader" );
const char * const CUSTOM_FRAGMENT_SHADER( "fragmentShader" );
-// name of the texture in material
-const char * const TEXTURE_NAME( "sTexture" );
-
// properties set on shader, these properties have the constant value in regardless of the page status
const char * const PROPERTY_SPINE_SHADOW ( "uSpineShadowParameter" ); // uniform for both spine and turn effect
void PageTurnView::Page::SetImage( Image image )
{
- if( material.GetNumberOfTextures() > 0 )
- {
- material.SetTextureImage( 0u, image );
- }
- else
+ if( !textureSet )
{
- material.AddTexture(image, TEXTURE_NAME);
+ textureSet = TextureSet::New();
}
+
+ textureSet.SetImage( 0u, image );
}
-void PageTurnView::Page::UseEffect(Shader shader)
+void PageTurnView::Page::UseEffect(Shader newShader)
{
- if( material )
- {
- material.SetShader( shader );
- }
- else
+ shader = newShader;
+ if( renderer )
{
- material = Material::New( shader );
+ renderer.SetShader( shader );
}
}
-void PageTurnView::Page::UseEffect(Shader shader, Geometry geometry)
+void PageTurnView::Page::UseEffect(Shader newShader, Geometry geometry)
{
- UseEffect( shader );
+ UseEffect( newShader );
if( !renderer )
{
- renderer = Renderer::New( geometry, material );
+ renderer = Renderer::New( geometry, shader );
+
+ if( !textureSet )
+ {
+ textureSet = TextureSet::New();
+ }
+
+ renderer.SetTextures( textureSet );
actor.AddRenderer( renderer );
}
}
/**
* Apply an effect onto the page actor.
- * @param[in] shader The shader for rendering effect.
+ * @param[in] newShader The shader for rendering effect.
*/
- void UseEffect(Shader shader);
+ void UseEffect(Shader newShader);
/**
* Apply an effect onto the page actor.
- * @param[in] shader The shader for rendering effect.
+ * @param[in] newShader The shader for rendering effect.
* @param[in] geometry The geometry for rendering effect.
*/
- void UseEffect(Shader shader, Geometry geometry);
+ void UseEffect(Shader newShader, Geometry geometry);
/**
* Change the page turning direction.
void SetCurrentCenter( const Vector2& value );
Actor actor; ///< The page actor
- Material material; ///< The material of the actor
+ Shader shader; ///< The shader used by the actor
+ TextureSet textureSet; ///< The set of textures used by the actor
Renderer renderer; ///< The renderer of the actor
bool isTurnBack; ///< The turning direction
Property::Index propertyPanDisplacement; ///< The horizontal displacement of the pan
mFactoryCache.SaveGeometry( RendererFactoryCache::BORDER_GEOMETRY, geometry );
}
- Material material = Material::New( GetBorderShader() );
- mImpl->mRenderer = Renderer::New( geometry, material );
+
+ Shader shader = GetBorderShader();
+ mImpl->mRenderer = Renderer::New( geometry, shader );
+
}
void BorderRenderer::SetBorderColor(const Vector4& color)
mAntiAliasing = antiAliasing;
if( mImpl->mRenderer )
{
- Material material = mImpl->mRenderer.GetMaterial();
- Shader shader = GetBorderShader();
- material.SetShader( shader );
+ Shader borderShader( GetBorderShader() );
+ mImpl->mRenderer.SetShader( borderShader );
if( mAntiAliasing )
{
mImpl->mRenderer.SetProperty( Renderer::Property::BLENDING_MODE, BlendingMode::ON );
mFactoryCache.SaveShader( RendererFactoryCache::COLOR_SHADER, shader );
}
- Material material = Material::New( shader );
- mImpl->mRenderer = Renderer::New( geometry, material );
+ mImpl->mRenderer = Renderer::New( geometry, shader );
mBlendColorIndex = mImpl->mRenderer.RegisterProperty( COLOR_NAME, mBlendColor );
if( mBlendColor.a < 1.f )
{
Geometry geometry = CreateQuadWireframeGeometry();
Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- Material material = Material::New( shader );
- mImpl->mRenderer = Renderer::New( geometry,
- material );
+
+ mImpl->mRenderer = Renderer::New( geometry, shader);
mFactoryCache.CacheDebugRenderer( mImpl->mRenderer );
}
}
// uniform names
const char * const UNIFORM_ALIGNMENT_MATRIX_NAME( "uAlignmentMatrix" );
-const char * const UNIFORM_TEXTULRE_NAME("sTexture");
// default offset value
const unsigned int DEFAULT_OFFSET_MINIMUM = 0.0f;
mFactoryCache.SaveShader( shaderType, shader );
}
- Material material;
- material = Material::New( shader );
- mImpl->mRenderer = Renderer::New( geometry, material );
-
+ //Set up the texture set
+ TextureSet textureSet = TextureSet::New();
Dali::BufferImage lookupTexture = mGradient->GenerateLookupTexture();
- Sampler sampler = Sampler::New();
+ textureSet.SetImage( 0u, lookupTexture );
Dali::WrapMode::Type wrap = GetWrapMode( mGradient->GetSpreadMethod() );
+ Sampler sampler = Sampler::New();
sampler.SetWrapMode( wrap, wrap );
+ textureSet.SetSampler( 0u, sampler );
- material.AddTexture( lookupTexture, UNIFORM_TEXTULRE_NAME, sampler );
+ mImpl->mRenderer = Renderer::New( geometry, shader );
+ mImpl->mRenderer.SetTextures( textureSet );
mImpl->mRenderer.RegisterProperty( UNIFORM_ALIGNMENT_MATRIX_NAME, mGradientTransform );
}
const uint32_t MAX_ITEM_AREA( MAX_ITEM_SIZE*MAX_ITEM_SIZE );
}
-ImageAtlasManager::ImageAtlasManager( Shader shader, const std::string& textureUniformName )
-: mShader( shader ),
- mTextureUniformName( textureUniformName ),
- mBrokenImageUrl( "" )
+ImageAtlasManager::ImageAtlasManager()
+: mBrokenImageUrl( "" )
{
}
{
}
-Material ImageAtlasManager::Add( Vector4& textureRect,
+TextureSet ImageAtlasManager::Add( Vector4& textureRect,
const std::string& url,
ImageDimensions size,
FittingMode::Type fittingMode,
|| dimensions.GetWidth()>DEFAULT_ATLAS_SIZE
|| dimensions.GetHeight()>DEFAULT_ATLAS_SIZE)
{
- return Material();
+ return TextureSet();
}
unsigned int i = 0;
{
if( (*iter).Upload( textureRect, url, size, fittingMode, orientationCorrection ) )
{
- return mMaterialList[i];
+ return mTextureSetList[i];
}
i++;
}
CreateNewAtlas();
mAtlasList.back().Upload( textureRect, url, size, fittingMode, orientationCorrection );
- return mMaterialList.back();
+ return mTextureSetList.back();
}
-Material ImageAtlasManager::Add( Vector4& textureRect,
+TextureSet ImageAtlasManager::Add( Vector4& textureRect,
PixelDataPtr pixelData )
{
|| pixelData->GetWidth()>DEFAULT_ATLAS_SIZE
|| pixelData->GetHeight()>DEFAULT_ATLAS_SIZE )
{
- return Material();
+ return TextureSet();
}
unsigned int i = 0;
{
if( (*iter).Upload( textureRect, pixelData ) )
{
- return mMaterialList[i];
+ return mTextureSetList[i];
}
i++;
}
CreateNewAtlas();
mAtlasList.back().Upload( textureRect, pixelData );
- return mMaterialList.back();
+ return mTextureSetList.back();
}
-void ImageAtlasManager::Remove( Material material, const Vector4& textureRect )
+void ImageAtlasManager::Remove( TextureSet textureSet, const Vector4& textureRect )
{
unsigned int i = 0;
- for( MaterialContainer::iterator iter = mMaterialList.begin(); iter != mMaterialList.end(); ++iter)
+ for( TextureSetContainer::iterator iter = mTextureSetList.begin(); iter != mTextureSetList.end(); ++iter)
{
- if( (*iter) == material )
+ if( (*iter) == textureSet )
{
mAtlasList[i].Remove(textureRect);
return;
newAtlas.SetBrokenImage( mBrokenImageUrl );
}
mAtlasList.push_back( newAtlas );
- Material newMaterial = Material::New( mShader );
- newMaterial.AddTexture( newAtlas.GetAtlas(), mTextureUniformName );
- mMaterialList.push_back( newMaterial );
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetImage( 0u, newAtlas.GetAtlas() );
+ mTextureSetList.push_back( textureSet );
}
} // namespace Internal
#include <string>
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/object/ref-object.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/texture-set.h>
// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/image-atlas/image-atlas.h>
{
public:
typedef std::vector< Toolkit::ImageAtlas > AtlasContainer;
- typedef std::vector< Material > MaterialContainer;
+ typedef std::vector< TextureSet > TextureSetContainer;
public:
/**
* Construtor
*
- * @param[in] shader The shader for material.
- * @param[in] textureUniformName The texture uniform name for the atlas image.
*/
- ImageAtlasManager( Shader shader, const std::string& textureUniformName );
+ ImageAtlasManager();
/**
* @brief Add an image to the atlas.
* @param [in] size The width and height to fit the loaded image to.
* @param [in] fittingMode The method used to fit the shape of the image before loading to the shape defined by the size parameter.
* @param [in] orientationCorrection Reorient the image to respect any orientation metadata in its header.
- * @return The material containing the image.
+ * @return The texture set containing the image.
*/
- Material Add( Vector4& textureRect,
+ TextureSet Add( Vector4& textureRect,
const std::string& url,
ImageDimensions size = ImageDimensions(),
FittingMode::Type fittingMode = FittingMode::DEFAULT,
*
* @param [out] textureRect The texture area of the resource image in the atlas.
* @param [in] pixelData The pixel data.
- * @return The material containing the image.
+ * @return The texture set containing the image.
*/
- Material Add( Vector4& textureRect,
+ TextureSet Add( Vector4& textureRect,
PixelDataPtr pixelData );
/**
- * Remove the image at the given rectangle from the material.
+ * Remove the image at the given rectangle from the texture set.
*
- * @param [in] material The material containing the atlas image.
+ * @param [in] textureSet The texture set containing the atlas image.
* @param [in] textureRect The texture area to be removed.
*/
- void Remove( Material material, const Vector4& textureRect );
+ void Remove( TextureSet textureSet, const Vector4& textureRect );
/**
* @brief Set the broken image which is used to replace the image if loading fails.
*/
void SetBrokenImage( const std::string& brokenImageUrl );
+ /**
+ * @brief Get shader
+ */
+ Shader GetShader() const;
+
private:
/**
private:
AtlasContainer mAtlasList;
- MaterialContainer mMaterialList;
- Shader mShader;
- std::string mTextureUniformName;
+ TextureSetContainer mTextureSetList;
std::string mBrokenImageUrl;
};
const char * const NO_FILTER("noFilter");
const char * const DONT_CARE("dontCare");
-const std::string TEXTURE_UNIFORM_NAME = "sTexture";
const std::string ATLAS_RECT_UNIFORM_NAME = "uAtlasRect";
const std::string PIXEL_AREA_UNIFORM_NAME = "pixelArea";
}
}
- Material material = Material::New( shader );
- return Renderer::New( geometry, material );
+ TextureSet textureSet = TextureSet::New();
+
+ Renderer renderer = Renderer::New( geometry, shader );
+ renderer.SetTextures( textureSet );
+
+ return renderer;
}
Renderer ImageRenderer::CreateNativeImageRenderer() const
}
}
- Material material = Material::New( shader );
- return Renderer::New( geometry, material );
+ TextureSet textureSet = TextureSet::New();
+ Renderer renderer = Renderer::New( geometry, shader );
+ renderer.SetTextures( textureSet );
+
+ return renderer;
}
void ImageRenderer::InitializeRenderer( const std::string& imageUrl )
if( !mImpl->mRenderer )
{
Vector4 atlasRect;
- Material material = mAtlasManager.Add(atlasRect, imageUrl, mDesiredSize, mFittingMode, mSamplingMode );
- if( material )
+ TextureSet textureSet = mAtlasManager.Add(atlasRect, imageUrl, mDesiredSize, mFittingMode, mSamplingMode );
+ if( textureSet )
{
Geometry geometry = CreateGeometry( mFactoryCache, ImageDimensions( 1, 1 ) );
- mImpl->mRenderer = Renderer::New( geometry, material );
+ Shader shader( GetImageShader(mFactoryCache) );
+ mImpl->mRenderer = Renderer::New( geometry, shader );
+ mImpl->mRenderer.SetTextures( textureSet );
mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, atlasRect );
}
else // big image, atlasing is not applied
ResourceImage image = Dali::ResourceImage::New( imageUrl, mDesiredSize, mFittingMode, mSamplingMode );
image.LoadingFinishedSignal().Connect( this, &ImageRenderer::OnImageLoaded );
- Material material = mImpl->mRenderer.GetMaterial();
- material.AddTexture( image, TEXTURE_UNIFORM_NAME );
+ TextureSet textureSet = mImpl->mRenderer.GetTextures();
+ textureSet.SetImage( 0u, image );
}
mFactoryCache.SaveRenderer( imageUrl, mImpl->mRenderer );
{
if( image )
{
- Material material = mImpl->mRenderer.GetMaterial();
- if( material )
+ TextureSet textureSet = mImpl->mRenderer.GetTextures();
+ if( textureSet )
{
- int index = material.GetTextureIndex( TEXTURE_UNIFORM_NAME );
- if( index != -1 )
- {
- material.SetTextureImage( index, image );
- return;
- }
-
- material.AddTexture( image, TEXTURE_UNIFORM_NAME );
+ textureSet.SetImage( 0u, image );
}
}
}
void ImageRenderer::CleanCache(const std::string& url)
{
- Material material = mImpl->mRenderer.GetMaterial();
+ TextureSet textureSet = mImpl->mRenderer.GetTextures();
Vector4 atlasRect( 0.f, 0.f, 1.f, 1.f );
Property::Index index = mImpl->mRenderer.GetPropertyIndex( ATLAS_RECT_UNIFORM_NAME );
mImpl->mRenderer.Reset();
if( mFactoryCache.CleanRendererCache( url ) && index != Property::INVALID_INDEX )
{
- mAtlasManager.Remove( material, atlasRect );
+ mAtlasManager.Remove( textureSet, atlasRect );
}
}
private:
/**
- * @brief Applies the image to the material used for this renderer
+ * @brief Applies the image to the texture set used for this renderer
*
- * @param[in] image The Image to apply to the material used for this renderer
+ * @param[in] image The Image to apply to the texture set used for this renderer
*/
void ApplyImageToSampler( const Image& image );
const char * const IMAGE_URL_NAME("imageUrl");
const char * const BORDER_ONLY("borderOnly");
-std::string TEXTURE_UNIFORM_NAME = "sTexture";
-
const char* VERTEX_SHADER = DALI_COMPOSE_SHADER(
attribute mediump vec2 aPosition;\n
varying mediump vec2 vTexCoord;\n
vertices.PushBack( Vector2( x, y ) );
}
-void RegisterStretchProperties( Material& material, const char * uniformName, const NinePatchImage::StretchRanges& stretchPixels, uint16_t imageExtent)
+void RegisterStretchProperties( TextureSet& textureSet, const char * uniformName, const NinePatchImage::StretchRanges& stretchPixels, uint16_t imageExtent)
{
uint16_t prevEnd = 0;
uint16_t prevFix = 0;
std::stringstream uniform;
uniform << uniformName << "[" << i << "]";
- material.RegisterProperty( uniform.str(), Vector2( fix, stretch ) );
+ textureSet.RegisterProperty( uniform.str(), Vector2( fix, stretch ) );
prevEnd = end;
prevFix = fix;
prevFix += imageExtent - prevEnd;
std::stringstream uniform;
uniform << uniformName << "[" << i << "]";
- material.RegisterProperty( uniform.str(), Vector2( prevFix, prevStretch ) );
+ textureSet.RegisterProperty( uniform.str(), Vector2( prevFix, prevStretch ) );
}
}
InitializeFromBrokenImage();
}
- Material material = Material::New( shader );
- mImpl->mRenderer = Renderer::New( geometry, material );
+ TextureSet textureSet = TextureSet::New();
+ mImpl->mRenderer = Renderer::New( geometry, shader );
+ mImpl->mRenderer.SetTextures( textureSet );
}
if( gridChanged )
{
Shader shader = CreateShader();
- Material material;
+ TextureSet textureSet;
if( shader )
{
- material = mImpl->mRenderer.GetMaterial();
- if( material )
+ textureSet = mImpl->mRenderer.GetTextures();
+ if( !textureSet )
{
- material.SetShader( shader );
+ InitializeFromBrokenImage();
}
- }
-
- if( !material )
- {
- InitializeFromBrokenImage();
+ mImpl->mRenderer.SetShader( shader );
}
}
}
void NPatchRenderer::ApplyImageToSampler()
{
- Material material = mImpl->mRenderer.GetMaterial();
- if( material )
+ TextureSet textureSet = mImpl->mRenderer.GetTextures();
+ if( textureSet )
{
- int index = material.GetTextureIndex( TEXTURE_UNIFORM_NAME );
- if( index > -1 )
- {
- material.SetTextureImage( index, mCroppedImage );
- }
- else
- {
- material.AddTexture( mCroppedImage, TEXTURE_UNIFORM_NAME );
- }
+ textureSet.SetImage( 0u, mCroppedImage );
if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
{
uint16_t stretchWidth = stretchX.GetY() - stretchX.GetX();
uint16_t stretchHeight = stretchY.GetY() - stretchY.GetX();
- material.RegisterProperty( "uFixed[0]", Vector2::ZERO );
- material.RegisterProperty( "uFixed[1]", Vector2( stretchX.GetX(), stretchY.GetX()) );
- material.RegisterProperty( "uFixed[2]", Vector2( mImageSize.GetWidth() - stretchWidth, mImageSize.GetHeight() - stretchHeight ) );
- material.RegisterProperty( "uStretchTotal", Vector2( stretchWidth, stretchHeight ) );
+ textureSet.RegisterProperty( "uFixed[0]", Vector2::ZERO );
+ textureSet.RegisterProperty( "uFixed[1]", Vector2( stretchX.GetX(), stretchY.GetX()) );
+ textureSet.RegisterProperty( "uFixed[2]", Vector2( mImageSize.GetWidth() - stretchWidth, mImageSize.GetHeight() - stretchHeight ) );
+ textureSet.RegisterProperty( "uStretchTotal", Vector2( stretchWidth, stretchHeight ) );
}
else
{
- material.RegisterProperty( "uNinePatchFactorsX[0]", Vector2::ZERO );
- material.RegisterProperty( "uNinePatchFactorsY[0]", Vector2::ZERO );
+ textureSet.RegisterProperty( "uNinePatchFactorsX[0]", Vector2::ZERO );
+ textureSet.RegisterProperty( "uNinePatchFactorsY[0]", Vector2::ZERO );
- RegisterStretchProperties( material, "uNinePatchFactorsX", mStretchPixelsX, mImageSize.GetWidth() );
- RegisterStretchProperties( material, "uNinePatchFactorsY", mStretchPixelsY, mImageSize.GetHeight() );
+ RegisterStretchProperties( textureSet, "uNinePatchFactorsX", mStretchPixelsX, mImageSize.GetWidth() );
+ RegisterStretchProperties( textureSet, "uNinePatchFactorsY", mStretchPixelsY, mImageSize.GetHeight() );
}
}
}
void InitializeFromBrokenImage();
/**
- * @brief Applies this renderer's image to the sampler to the material used for this renderer
+ * @brief Applies this renderer's image to the sampler to the texture set used for this renderer
*/
void ApplyImageToSampler();
const char * const N_PATCH_RENDERER("nPatch");
const char * const SVG_RENDERER("svg");
-const std::string TEXTURE_UNIFORM_NAME = "sTexture";
-
const char * const BROKEN_RENDERER_IMAGE_URL( DALI_IMAGE_DIR "broken.png");
}
if( !mAtlasManager )
{
Shader shader = ImageRenderer::GetImageShader( *( mFactoryCache.Get() ) );
- mAtlasManager = new ImageAtlasManager(shader, TEXTURE_UNIFORM_NAME);
+ mAtlasManager = new ImageAtlasManager();
mAtlasManager->SetBrokenImage( BROKEN_RENDERER_IMAGE_URL );
}
}
#include "nanosvg/nanosvgrast.h"
#include "svg-renderer.h"
-namespace
-{
-const std::string TEXTURE_UNIFORM_NAME = "sTexture";
-}
-
namespace Dali
{
wasEmpty = mRasterizeTasks.empty();
if( !wasEmpty && task != NULL)
{
- // Remove the tasks with the same material.
- // Older task which waiting to rasterize and apply the svg to the same material is expired.
+ // Remove the tasks with the same renderer.
+ // Older task which waiting to rasterize and apply the svg to the same renderer is expired.
for( std::vector< RasterizingTaskPtr >::iterator it = mRasterizeTasks.begin(), endIt = mRasterizeTasks.end(); it != endIt; ++it )
{
if( (*it) && (*it)->GetSvgRenderer() == task->GetSvgRenderer() )
#include <dali/devel-api/threading/conditional-wait.h>
#include <dali/devel-api/threading/mutex.h>
#include <dali/devel-api/threading/thread.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/texture-set.h>
#include <dali/devel-api/images/pixel-data.h>
#include <dali/public-api/images/buffer-image.h>
#include <dali/public-api/common/intrusive-ptr.h>
RasterizingTaskPtr NextCompletedTask();
/**
- * Remove the task with the given material from the waiting queue, called by main thread.
+ * Remove the task with the given renderer from the waiting queue, called by main thread.
*
- * Typically called when the actor is put off stage, so the material is not needed anymore.
+ * Typically called when the actor is put off stage, so the renderer is not needed anymore.
*
* @param[in] renderer The renderer pointer.
*/
/**
* The entry function of the worker thread.
- * It fetches task from the Queue, rasterizes the image and apply to the material.
+ * It fetches task from the Queue, rasterizes the image and apply to the renderer.
*/
virtual void Run();
geometry = mFactoryCache.CreateQuadGeometry();
mFactoryCache.SaveGeometry( RendererFactoryCache::QUAD_GEOMETRY, geometry );
}
- Material material = Material::New( shader );
- mImpl->mRenderer = Renderer::New( geometry, material );
+ TextureSet textureSet = TextureSet::New();
+ mImpl->mRenderer = Renderer::New( geometry, shader );
+ mImpl->mRenderer.SetTextures( textureSet );
if( mImpl->mSize != Vector2::ZERO && mParsedImage )
{
{
if( GetIsOnStage() )
{
- Material currentMaterial = mImpl->mRenderer.GetMaterial();
+ TextureSet currentTextureSet = mImpl->mRenderer.GetTextures();
if( mAtlasRect != FULL_TEXTURE_RECT )
{
- mAtlasManager.Remove( currentMaterial, mAtlasRect );
+ mAtlasManager.Remove( currentTextureSet, mAtlasRect );
}
Vector4 atlasRect;
- Material material = mAtlasManager.Add(atlasRect, rasterizedPixelData );
- if( material ) // atlasing
+ TextureSet textureSet = mAtlasManager.Add(atlasRect, rasterizedPixelData );
+ if( textureSet ) // atlasing
{
- if( material != currentMaterial )
+ if( textureSet != currentTextureSet )
{
- mImpl->mRenderer.SetMaterial( material );
+ mImpl->mRenderer.SetTextures( textureSet );
}
mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, atlasRect );
mAtlasRect = atlasRect;
if( mAtlasRect == FULL_TEXTURE_RECT )
{
- material = currentMaterial;
+ textureSet = currentTextureSet;
}
else
{
- material = Material::New( ImageRenderer::GetImageShader( mFactoryCache ) );
- mImpl->mRenderer.SetMaterial( material );
+ textureSet = TextureSet::New();
+ mImpl->mRenderer.SetTextures( textureSet );
mImpl->mRenderer.RegisterProperty( ATLAS_RECT_UNIFORM_NAME, FULL_TEXTURE_RECT );
mAtlasRect = FULL_TEXTURE_RECT;
}
- if( material )
+ if( textureSet )
{
- int index = material.GetTextureIndex( TEXTURE_UNIFORM_NAME );
- if( index != -1 )
- {
- material.SetTextureImage( index, texture );
- return;
- }
-
- material.AddTexture( texture, TEXTURE_UNIFORM_NAME );
+ textureSet.SetImage( 0u, texture );
}
}
}
private:
/**
- * @bried Rasterize the svg with the given size, and add it to the material.
+ * @bried Rasterize the svg with the given size, and add it to the renderer.
*
* @param[in] size The target size of the SVG rasterization.
*/
#include <dali/public-api/object/property-map.h>
#include <dali/devel-api/object/property-buffer.h>
#include <dali/devel-api/rendering/geometry.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/texture-set.h>
#include <dali/devel-api/rendering/renderer.h>
#include <dali/devel-api/rendering/shader.h>
meshGeometry.AddVertexBuffer( vertices );
meshGeometry.SetIndexBuffer( indices );
- // Create material
+ // Create the shader
Shader shader = Shader::New( MESH_VERTEX_SHADER, MESH_FRAGMENT_SHADER );
- Material material = Material::New( shader );
// Create renderer
- Renderer renderer = Renderer::New( meshGeometry, material );
+ Renderer renderer = Renderer::New( meshGeometry, shader );
// Create actor
Actor meshActor= Actor::New();
mRootActor.Add( mActorForBlending );
// Add effect texture to blend-two-image custom shader
- Material material = mActorForBlending.GetRendererAt(0).GetMaterial();
- int textureIndex = material.GetTextureIndex( EFFECT_IMAGE_NAME );
- if( textureIndex == -1 )
- {
- material.AddTexture( mInputImage, EFFECT_IMAGE_NAME );
- }
- else
- {
- material.SetTextureImage( textureIndex, mInputImage );
- }
+ TextureSet textureSet = mActorForBlending.GetRendererAt(0).GetTextures();
+ textureSet.SetImage( 1u, mInputImage );
SetupCamera();
CreateRenderTasks();
{
mQuadVertexFormat[ "aPosition" ] = Property::VECTOR2;
mQuadIndexFormat[ "indices" ] = Property::INTEGER;
- mHighlightMaterial = Material::New( Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ) );
-
+ mHighlightShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
SetupTouchEvents();
}
if( !mHighlightRenderer )
{
- mHighlightRenderer = Dali::Renderer::New( mQuadGeometry, mHighlightMaterial );
+ mHighlightRenderer = Dali::Renderer::New( mQuadGeometry, mHighlightShader );
mHighlightActor.AddRenderer( mHighlightRenderer );
}
}
Actor mHighlightActor; ///< Actor to display highlight
Renderer mHighlightRenderer;
- Material mHighlightMaterial; ///< Material used for highlight
+ Shader mHighlightShader; ///< Shader used for highlight
Property::Map mQuadVertexFormat;
Property::Map mQuadIndexFormat;
PopupImpl mCopyPastePopup;
if ( mAtlasManager.Add( bitmap, slot ) )
{
- // A new atlas was created so set the material details for the atlas
+ // A new atlas was created so set the texture set details for the atlas
Dali::Atlas atlas = mAtlasManager.GetAtlasContainer( slot.mAtlasId );
- Pixel::Format pixelFormat = mAtlasManager.GetPixelFormat( slot.mAtlasId );
- Material material = Material::New( pixelFormat == Pixel::L8 ? mShaderL8 : mShaderRgba );
- material.AddTexture( atlas, "sTexture" );
- mAtlasManager.SetMaterial( slot.mAtlasId, material );
+ TextureSet textureSet = TextureSet::New();
+ textureSet.SetImage( 0u, atlas );
+ mAtlasManager.SetTextures( slot.mAtlasId, textureSet );
}
GlyphRecordEntry record;
}
}
-Material AtlasGlyphManager::GetMaterial( uint32_t atlasId ) const
+TextureSet AtlasGlyphManager::GetTextures( uint32_t atlasId ) const
{
- return mAtlasManager.GetMaterial( atlasId );
+ return mAtlasManager.GetTextures( atlasId );
+}
+
+Shader AtlasGlyphManager::GetShader( uint32_t atlasId ) const
+{
+ Pixel::Format pixelFormat = mAtlasManager.GetPixelFormat( atlasId );
+ return pixelFormat == Pixel::L8 ? mShaderL8 : mShaderRgba;
}
AtlasGlyphManager::~AtlasGlyphManager()
void AdjustReferenceCount( Text::FontId fontId, Text::GlyphIndex index, int32_t delta );
/**
- * @copydoc Toolkit::AtlasGlyphManager::GetMaterial
+ * @copydoc Toolkit::AtlasGlyphManager::GetTextures
*/
- Material GetMaterial( uint32_t atlasId ) const;
+ TextureSet GetTextures( uint32_t atlasId ) const;
+
+ /**
+ * @copydoc Toolkit::AtlasGlyphManager::GetShader
+ */
+ Shader GetShader( uint32_t atlasId ) const;
/**
* @copydoc Toolkit::AtlasGlyphManager::GetMetrics
return GetImplementation(*this).GetPixelFormat( atlasId );
}
-Material AtlasGlyphManager::GetMaterial( uint32_t atlasId ) const
+TextureSet AtlasGlyphManager::GetTextures( uint32_t atlasId ) const
{
- return GetImplementation(*this).GetMaterial( atlasId );
+ return GetImplementation(*this).GetTextures( atlasId );
+}
+
+Shader AtlasGlyphManager::GetShader( uint32_t atlasId ) const
+{
+ return GetImplementation(*this).GetShader( atlasId );
}
const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
Pixel::Format GetPixelFormat( uint32_t atlasId );
/**
- * @brief Get the material used by an atlas
+ * @brief Get the texture set used by an atlas
*
* @param[in] atlasId Id of an atlas
*
- * @return The material used by the atlas
+ * @return The texture set used by the atlas
*/
- Material GetMaterial( uint32_t atlasId ) const;
+ TextureSet GetTextures( uint32_t atlasId ) const;
+
+ /**
+ * @brief Get the shader used by an atlas
+ *
+ * @param[in] atlasId Id of an atlas
+ *
+ * @return The shader used by the atlas
+ */
+ Shader GetShader( uint32_t atlasId ) const;
/**
* @brief Get Glyph Manager metrics
return mAtlasList.size();
}
-Pixel::Format AtlasManager::GetPixelFormat( AtlasId atlas )
+Pixel::Format AtlasManager::GetPixelFormat( AtlasId atlas ) const
{
DALI_ASSERT_DEBUG( atlas && atlas <= mAtlasList.size() );
Pixel::Format pixelFormat = Pixel::RGBA8888;
metrics.mTextureMemoryUsed = textureMemoryUsed;
}
-Material AtlasManager::GetMaterial( AtlasId atlas ) const
+TextureSet AtlasManager::GetTextures( AtlasId atlas ) const
{
DALI_ASSERT_DEBUG( atlas && atlas <= mAtlasList.size() );
- Material material;
+ TextureSet textureSet;
if ( atlas && atlas-- <= mAtlasList.size() )
{
- material = mAtlasList[ atlas ].mMaterial;
+ textureSet = mAtlasList[ atlas ].mTextureSet;
}
- return material;
+ return textureSet;
}
-void AtlasManager::SetMaterial( AtlasId atlas, Material& material )
+void AtlasManager::SetTextures( AtlasId atlas, TextureSet& textureSet )
{
DALI_ASSERT_DEBUG( atlas && atlas <= mAtlasList.size() );
if ( atlas && atlas-- <= mAtlasList.size() )
{
- mAtlasList[ atlas ].mMaterial = material;
+ mAtlasList[ atlas ].mTextureSet = textureSet;
}
}
Pixel::Format mPixelFormat; // pixel format used by atlas
BufferImage mHorizontalStrip; // Image used to pad upload
BufferImage mVerticalStrip; // Image used to pad upload
- Material mMaterial; // material used for atlas texture
+ TextureSet mTextureSet; // Texture set used for atlas texture
SizeType mTotalBlocks; // total number of blocks in atlas
SizeType mAvailableBlocks; // number of blocks available in atlas
Dali::Vector< SizeType > mFreeBlocksList; // unless there are any previously freed blocks
/**
* @copydoc Toolkit::AtlasManager::GetPixelFormat
*/
- Pixel::Format GetPixelFormat( AtlasId atlas );
+ Pixel::Format GetPixelFormat( AtlasId atlas ) const;
/**
* @copydoc Toolkit::AtlasManager::GetMetrics
void GetMetrics( Toolkit::AtlasManager::Metrics& metrics );
/**
- * @copydoc Toolkit::AtlasManager::GetMaterial
+ * @copydoc Toolkit::AtlasManager::GetTextures
*/
- Material GetMaterial( AtlasId atlas ) const;
+ TextureSet GetTextures( AtlasId atlas ) const;
/**
- * @copydoc Toolkit::AtlasManager::SetMaterial
+ * @copydoc Toolkit::AtlasManager::SetTextures
*/
- void SetMaterial( AtlasId atlas, Material& material );
+ void SetTextures( AtlasId atlas, TextureSet& textureSet );
private:
return GetImplementation(*this).GetAtlasCount();
}
-Pixel::Format AtlasManager::GetPixelFormat( AtlasId atlas )
+Pixel::Format AtlasManager::GetPixelFormat( AtlasId atlas ) const
{
return GetImplementation(*this).GetPixelFormat( atlas );
}
GetImplementation(*this).GetMetrics( metrics );
}
-Material AtlasManager::GetMaterial( AtlasId atlas ) const
+TextureSet AtlasManager::GetTextures( AtlasId atlas ) const
{
- return GetImplementation(*this).GetMaterial( atlas );
+ return GetImplementation(*this).GetTextures( atlas );
}
-void AtlasManager::SetMaterial( AtlasId atlas, Material& material )
+void AtlasManager::SetTextures( AtlasId atlas, TextureSet& textureSet )
{
- GetImplementation(*this).SetMaterial( atlas, material );
+ GetImplementation(*this).SetTextures( atlas, textureSet );
}
} // namespace Toolkit
#include <dali/public-api/common/dali-vector.h>
#include <dali/public-api/images/buffer-image.h>
#include <dali/devel-api/images/atlas.h>
-#include <dali/devel-api/rendering/material.h>
+#include <dali/devel-api/rendering/texture-set.h>
namespace Dali
{
*
* @return Pixel format used by this atlas
*/
- Pixel::Format GetPixelFormat( AtlasId atlas );
+ Pixel::Format GetPixelFormat( AtlasId atlas ) const;
/**
* @brief Fill in a metrics structure showing current status of this Atlas Manager
void GetMetrics( Metrics& metrics );
/**
- * @brief Get Material used by atlas
+ * @brief Get TextureSet used by atlas
*
* @param[in] atlas AtlasId
*
- * @return Material used by atlas
+ * @return TextureSet used by atlas
*/
- Material GetMaterial( AtlasId atlas ) const;
+ TextureSet GetTextures( AtlasId atlas ) const;
/**
- * @brief Set the material used by an atlas
+ * @brief Set the texture set used by an atlas
*
* @param[in] atlas AtlasId
- * @param[in] material The Material to assign
+ * @param[in] textureSet The texture set to assign
*/
- void SetMaterial( AtlasId atlas, Material& material );
+ void SetTextures( AtlasId atlas, TextureSet& textureSet );
private:
quadGeometry.AddVertexBuffer( quadVertices );
quadGeometry.SetIndexBuffer( quadIndices );
- Material material = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
- Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
+ TextureSet textureSet( mGlyphManager.GetTextures( meshRecord.mAtlasId ) );
+ Shader shader( mGlyphManager.GetShader( meshRecord.mAtlasId ) );
+ Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, shader );
+ renderer.SetTextures( textureSet );
renderer.SetProperty( Dali::Renderer::Property::BLENDING_MODE, BlendingMode::ON );
renderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, DepthIndex::CONTENT + mDepth );
Actor actor = Actor::New();
Geometry geometry = CreateQuadGeometry();
Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER );
- Material material = Material::New( shader );
+ TextureSet textureSet = TextureSet::New();
if( mCurrentImage )
{
- material.AddTexture( mCurrentImage, "sTexture" );
+ textureSet.SetImage( 0u, mCurrentImage );
}
- mCurrentRenderer = Renderer::New( geometry, material );
+ mCurrentRenderer = Renderer::New( geometry, shader );
+ mCurrentRenderer.SetTextures( textureSet );
mCurrentRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, depth );
Self().AddRenderer( mCurrentRenderer );
void CubeTransitionEffect::SetCurrentImage( Image image )
{
mCurrentImage = image;
-
if( mCurrentRenderer )
{
- Material material = mCurrentRenderer.GetMaterial();
-
- int index = material.GetTextureIndex("sTexture" );
- if( index != -1 )
- {
- material.SetTextureImage( index, mCurrentImage );
- }
- else
- {
- material.AddTexture( mCurrentImage, "sTexture" );
- }
+ TextureSet textureSet = mCurrentRenderer.GetTextures();
+ textureSet.SetImage( 0u, mCurrentImage );
}
}
if( mTargetRenderer )
{
- Material material = mTargetRenderer.GetMaterial();
- material.AddTexture( mTargetImage, "sTexture" );
+ TextureSet textureSet = mTargetRenderer.GetTextures();
+ textureSet.SetImage( 0u, mTargetImage );
}
}
}
//create the target renderer
- Material material = Material::New( mCurrentRenderer.GetMaterial().GetShader() );
+ TextureSet textureSet = TextureSet::New();
if( mTargetImage )
{
- material.AddTexture( mTargetImage, "sTexture" );
+ textureSet.SetImage( 0u, mTargetImage );
}
Geometry geometry = mCurrentRenderer.GetGeometry();
- mTargetRenderer = Renderer::New( geometry, material );
+ Shader shader( mCurrentRenderer.GetShader() );
+ mTargetRenderer = Renderer::New( geometry, shader );
+ mTargetRenderer.SetTextures( textureSet );
int depthIndex = mCurrentRenderer.GetProperty<int>(Renderer::Property::DEPTH_INDEX);
mTargetRenderer.SetProperty( Dali::Renderer::Property::DEPTH_INDEX, depthIndex );
${PLUGING_SRC_DIR}/render-tasks/render-task-wrapper.cpp
${PLUGING_SRC_DIR}/rendering/geometry-api.cpp
${PLUGING_SRC_DIR}/rendering/geometry-wrapper.cpp
- ${PLUGING_SRC_DIR}/rendering/material-api.cpp
- ${PLUGING_SRC_DIR}/rendering/material-wrapper.cpp
+ ${PLUGING_SRC_DIR}/rendering/texture-set-api.cpp
+ ${PLUGING_SRC_DIR}/rendering/texture-set-wrapper.cpp
${PLUGING_SRC_DIR}/rendering/renderer-api.cpp
${PLUGING_SRC_DIR}/rendering/renderer-wrapper.cpp
${PLUGING_SRC_DIR}/rendering/sampler-api.cpp
$(v8_plugin_dir)/render-tasks/render-task-wrapper.cpp \
$(v8_plugin_dir)/rendering/geometry-api.cpp \
$(v8_plugin_dir)/rendering/geometry-wrapper.cpp \
- $(v8_plugin_dir)/rendering/material-api.cpp \
- $(v8_plugin_dir)/rendering/material-wrapper.cpp \
+ $(v8_plugin_dir)/rendering/texture-set-api.cpp \
+ $(v8_plugin_dir)/rendering/texture-set-wrapper.cpp \
$(v8_plugin_dir)/rendering/renderer-api.cpp \
$(v8_plugin_dir)/rendering/renderer-wrapper.cpp \
$(v8_plugin_dir)/rendering/sampler-api.cpp \
* Add a renderer to this actor.
* @example
*
- * var renderer = new dali.Renderer( geometry, material );
+ * var renderer = new dali.Renderer( geometry, shader );
* actor.addRenderer( renderer );
*
* @for Actor
#include <events/pan-gesture-detector-wrapper.h>
#include <object/property-buffer-wrapper.h>
#include <rendering/geometry-wrapper.h>
-#include <rendering/material-wrapper.h>
+#include <rendering/texture-set-wrapper.h>
#include <rendering/renderer-wrapper.h>
#include <rendering/shader-wrapper.h>
#include <rendering/sampler-wrapper.h>
{ "ItemFactory", ItemFactoryWrapper::NewItemFactory},
{ "Shader", ShaderWrapper::NewShader},
{ "Sampler", SamplerWrapper::NewSampler},
- { "Material", MaterialWrapper::NewMaterial},
+ { "TextureSet", TextureSetWrapper::NewTextureSet},
{ "Geometry", GeometryWrapper::NewGeometry},
{ "Renderer", RendererWrapper::NewRenderer},
{ "PropertyBuffer", PropertyBufferWrapper::NewPropertyBuffer},
+++ /dev/null
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-
-// CLASS HEADER
-#include "material-api.h"
-
-// EXTERNAL INCLUDES
-#include <dali/public-api/object/type-registry.h>
-
-// INTERNAL INCLUDES
-#include <v8-utils.h>
-#include <rendering/material-wrapper.h>
-#include <rendering/shader-wrapper.h>
-#include <rendering/shader-api.h>
-#include <rendering/sampler-wrapper.h>
-#include <rendering/sampler-api.h>
-#include <image/image-wrapper.h>
-
-namespace Dali
-{
-
-namespace V8Plugin
-{
-
-/**
- * ## Material API
- *
- * Material is a handle to an object that specifies the visual properties of the renderer.
- *
- * @class Material
- * @extends Handle
- */
-
-Material MaterialApi::GetMaterial( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::HandleScope handleScope( isolate );
-
- v8::Local<v8::Object> object = args.This();
- v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
- void* ptr = field->Value();
-
- MaterialWrapper* wrapper = static_cast< MaterialWrapper *>(ptr);
- return wrapper->GetMaterial();
-}
-
-Material MaterialApi::GetMaterialFromParams( int paramIndex,
- bool& found,
- v8::Isolate* isolate,
- const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- found = false;
-
- v8::HandleScope handleScope( isolate );
- BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::MATERIAL, isolate, args );
- if( wrappedObject )
- {
- found = true;
- MaterialWrapper* wrapper = static_cast< MaterialWrapper *>(wrappedObject);
- return wrapper->GetMaterial();
- }
- else
- {
- return Material();
- }
-}
-
-/**
- * Create a new material object.
- *
- * @constructor
- * @method Material
- * @for Material
- * @param {Object} shader The shader used by the material
- * @return {Object} Material
- */
-Material MaterialApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- bool found( false );
- Shader shader = ShaderApi::GetShaderFromParams( 0, found, isolate, args );
- if( found )
- {
- return Material::New( shader );
- }
- else
- {
- DALI_SCRIPT_EXCEPTION( isolate, "missing shader from param 0" );
- return Material();
- }
-}
-
-/**
- * Set the Shader used by this material
- *
- * @method setShader
- * @for Material
- * @param {Object} shader Handle to the shader
- */
-void MaterialApi::SetShader( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- Shader shader = ShaderApi::GetShaderFromParams( 0, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid shader parameter" );
- }
- else
- {
- return material.SetShader( shader );
- }
-}
-
-/**
- * Get the Shader used by this material
- *
- * @method getShader
- * @for Material
- * @return {Object} Shader
- */
-void MaterialApi::GetShader( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
- Shader shader = material.GetShader();
-
- // Wrap the shader
- v8::Local<v8::Object> localObject = ShaderWrapper::WrapShader( isolate, shader );
- args.GetReturnValue().Set( localObject );
-}
-
-/**
- * Add a new texture to be used by the material
- *
- * @method addTexture
- * @for Material
- * @param {Object} image The image used by this sampler
- * @param {String} uniformName The string with the name of the uniform
- * @param {Object} sampler The sampler to add to this material
- * @return {integer} The index of the texture in the array of textures or -1 if texture can not be added
- */
-void MaterialApi::AddTexture( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- Image image = V8Utils::GetImageParameter( PARAMETER_0, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "missing image from param 0" );
- return;
- }
-
- found = false;
- std::string uniformName = V8Utils::GetStringParameter( PARAMETER_1, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "missing uniform name from param 1" );
- return;
- }
-
- found = false;
- Sampler sampler = SamplerApi::GetSamplerFromParams( PARAMETER_2, found, isolate, args );
- if( !found )
- {
- args.GetReturnValue().Set( v8::Integer::New( isolate, material.AddTexture( image, uniformName ) ) );
- }
- else
- {
- args.GetReturnValue().Set( v8::Integer::New( isolate, material.AddTexture( image, uniformName, sampler ) ) );
- }
-}
-
-/**
- * Removes a texture from the material
- *
- * @method removeTexture
- * @for Material
- * @param {integer} index The index of the texture in the array of textures
- */
-void MaterialApi::RemoveTexture( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
- }
- else
- {
- material.RemoveTexture( index );
- }
-}
-
-/**
- * Sets the image to be used by a given texture
- * @method setTextureImage
- * @for Material
- * @param {integer} index The index of the texture in the array of textures
- * @param {Object} image The image used by this sampler
- */
-void MaterialApi::SetTextureImage( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
- return;
- }
-
- found = false;
- Image image = V8Utils::GetImageParameter( PARAMETER_1, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "missing image from param 1" );
- }
- else
- {
- material.SetTextureImage(index, image);
- }
-}
-
-/**
- * Set the sampler used by a given texture
- * @method setTextureSampler
- * @for Material
- * @param {integer} index The index of the texture in the array of textures
- * @param {Object} sampler The new sampler
- */
-void MaterialApi::SetTextureSampler( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
- return;
- }
-
- found = false;
- Sampler sampler = SamplerApi::GetSamplerFromParams( PARAMETER_1, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "missing sampler from param 1" );
- }
- else
- {
- material.SetTextureSampler(index, sampler);
- }
-}
-
-/**
- * Set the uniform name of a given texture
- * @method setTextureUniformName
- * @for Material
- * @param {integer} index The index of the texture in the array of textures
- * @param {string} uniformName The new uniform name
- */
-void MaterialApi::SetTextureUniformName( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
- return;
- }
-
- found = false;
- std::string uniformName = V8Utils::GetStringParameter( PARAMETER_1, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid uniform name parameter" );
- }
- else
- {
- material.SetTextureUniformName(index, uniformName);
- }
-}
-
-/**
- * Retrive the index of a texture given its uniform name
- * @method getTextureIndex
- * @for Material
- * @param {string} uniformName The uniform name
- * @return {integer} The index in the array of textures or -1 if the texture is not found
- */
-void MaterialApi::GetTextureIndex( const v8::FunctionCallbackInfo< v8::Value >& args )
-{
- v8::Isolate* isolate = args.GetIsolate();
- v8::HandleScope handleScope( isolate );
-
- Material material = GetMaterial( isolate, args );
-
- bool found( false );
- std::string uniformName = V8Utils::GetStringParameter( PARAMETER_0, found, isolate, args );
- if( !found )
- {
- DALI_SCRIPT_EXCEPTION( isolate, "invalid uniform name parameter" );
- }
- else
- {
- args.GetReturnValue().Set( v8::Integer::New( isolate, material.GetTextureIndex(uniformName) ) );
- }
-}
-
-/**
- * Retrieve the number of textures used by the material
- *
- * @method getNumberOfTextures
- * @for Material
- * @return {integer} The number of textures
- */
-void MaterialApi::GetNumberOfTextures( 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.GetNumberOfTextures() ) );
-}
-
-} // namespace V8Plugin
-
-} // namespace Dali
+++ /dev/null
-#ifndef __DALI_V8PLUGIN_MATERIAL_API_H__
-#define __DALI_V8PLUGIN_MATERIAL_API_H__
-
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <v8.h>
-#include <dali/devel-api/rendering/material.h>
-
-
-namespace Dali
-{
-
-namespace V8Plugin
-{
-
-namespace MaterialApi
-{
-
- /**
- * Helper to get material from args.This()
- */
- Material GetMaterial( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
-
- /**
- * @brief Helper to get material from the JavaScript object held in the given function argument
- * @param[in] paramIndex Argument index the object is held in
- * @param[in] found Whether material is found in the given function parameter
- * @param[in] isolate v8 isolated instance
- * @param[in] args v8 function call arguments interpreted
- */
- Material GetMaterialFromParams( int paramIndex,
- bool& found,
- v8::Isolate* isolate,
- const v8::FunctionCallbackInfo< v8::Value >& args );
-
- /**
- * Constructor
- */
- Material New( const v8::FunctionCallbackInfo< v8::Value >& args );
-
- /**
- * Material API see material.h for a description
- */
- void SetShader( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetShader( const v8::FunctionCallbackInfo< v8::Value >& args );
- void AddTexture( const v8::FunctionCallbackInfo< v8::Value >& args );
- void RemoveTexture( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetTextureImage( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetTextureSampler( const v8::FunctionCallbackInfo< v8::Value >& args );
- void SetTextureUniformName( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetTextureIndex( const v8::FunctionCallbackInfo< v8::Value >& args );
- void GetNumberOfTextures( const v8::FunctionCallbackInfo< v8::Value >& args );
-
-}; // namespace MaterialApi
-
-} // namespace V8Plugin
-
-} // namespace Dali
-
-#endif // header __DALI_V8PLUGIN_MATERIAL_API_H__
+++ /dev/null
-#ifndef __DALI_V8PLUGIN_MATERIAL_WRAPPER_H__
-#define __DALI_V8PLUGIN_MATERIAL_WRAPPER_H__
-
-/*
- * Copyright (c) 2015 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-// EXTERNAL INCLUDES
-#include <v8.h>
-#include <dali/devel-api/rendering/material.h>
-
-// INTERNAL INCLUDES
-#include <object/handle-wrapper.h>
-
-namespace Dali
-{
-
-namespace V8Plugin
-{
-
-
-/**
- * A Material wrapper.
- * Provides access to Material specific functionality and V8 memory handling.
- */
-class MaterialWrapper : public HandleWrapper
-{
-
-public:
-
- /**
- * @brief Constructor
- * @param[in] material DALi material
- * @param[in] gc garbage collection interface
- */
- MaterialWrapper( const Material& material,
- GarbageCollectorInterface& gc );
-
- /**
- * @brief Destructor
- */
- virtual ~MaterialWrapper()
- {
- };
-
- /**
- * @brief Creates a new Material wrapped inside a Javascript Object.
- * @param[in] args v8 function call arguments interpreted
- */
- static void NewMaterial( const v8::FunctionCallbackInfo< v8::Value >& args);
-
- /**
- * Wraps a sampler
- */
- static v8::Handle<v8::Object> WrapMaterial(v8::Isolate* isolate, const Dali::Material& );
-
-
- // The MaterialAttribute ObjectTemplate, we cache templates so we don't have
- // keep generating them everytime we want to create a Material
- static v8::Persistent<v8::ObjectTemplate> mMaterialTemplate;
-
- /**
- * @brief Gets the handle of material
- * @return the handle of material
- */
- Material GetMaterial();
-
-
-private:
-
- // Material
- Material mMaterial;
-
- /**
- * @brief Creates the object template that used to create material at runtime
- * @param[in] isolate v8 isolated instance
- * @return the object template
- */
- static v8::Handle<v8::ObjectTemplate> MakeMaterialTemplate( v8::Isolate* isolate );
-
- /**
- * @brief Gets the object template that used to create material at runtime
- * @param[in] isolate v8 isolated instance
- * @return the object template
- */
- static v8::Local<v8::ObjectTemplate> GetMaterialTemplate( v8::Isolate* isolate );
-
-};
-
-} // namespace V8Plugin
-
-} // namespace Dali
-
-#endif // __DALI_V8PLUGIN_MATERIAL_WRAPPER_H__
#include <rendering/renderer-wrapper.h>
#include <rendering/geometry-api.h>
#include <rendering/geometry-wrapper.h>
-#include <rendering/material-api.h>
-#include <rendering/material-wrapper.h>
+#include <rendering/texture-set-api.h>
+#include <rendering/texture-set-wrapper.h>
+#include <rendering/shader-api.h>
namespace Dali
{
* @method Renderer
* @for Renderer
* @param {Object} geometry The geometry to be used by this renderer
- * @param {Object} material The material to be used by this renderer
+ * @param {Object} shader The shader to be used by this renderer
* @return {Object} Renderer
*/
Renderer RendererApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
}
found = false;
- Material material = MaterialApi::GetMaterialFromParams( 1, found, isolate, args );
+ Shader shader = ShaderApi::GetShaderFromParams( 1, found, isolate, args );
if( !found )
{
- DALI_SCRIPT_EXCEPTION( isolate, "missing material from param 0" );
+ DALI_SCRIPT_EXCEPTION( isolate, "missing shader from param 0" );
return Renderer();
}
- return Renderer::New(geometry, material);
+ return Renderer::New(geometry, shader);
}
/**
}
/**
- * Sets the material to be used by this renderer
+ * Sets the texture set to be used by this renderer
*
- * @method setMaterial
+ * @method setTextures
* @for Renderer
- * @param {Object} material The material to be used by this renderer
+ * @param {Object} textureSet The TextureSet to be used by this renderer
*/
-void RendererApi::SetMaterial( const v8::FunctionCallbackInfo< v8::Value >& args )
+void RendererApi::SetTextures( const v8::FunctionCallbackInfo< v8::Value >& args )
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
Renderer renderer = GetRenderer( isolate, args );
bool found( false );
- Material material = MaterialApi::GetMaterialFromParams( 0, found, isolate, args );
+ TextureSet textureSet = TextureSetApi::GetTextureSetFromParams( 0, found, isolate, args );
if( !found )
{
- DALI_SCRIPT_EXCEPTION( isolate, "missing material from param 0" );
+ DALI_SCRIPT_EXCEPTION( isolate, "missing texture set from param 0" );
}
else
{
- renderer.SetMaterial(material);
+ renderer.SetTextures(textureSet);
}
}
/**
- * Gets the material used by this renderer
+ * Gets the texture set used by this renderer
*
- * @method getMaterial
+ * @method getTextures
* @for Renderer
- * @return {Object} The material used by this renderer
+ * @return {Object} The texture set used by this renderer
*/
-void RendererApi::GetMaterial( const v8::FunctionCallbackInfo<v8::Value>& args )
+void RendererApi::GetTextures( const v8::FunctionCallbackInfo<v8::Value>& args )
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate );
Renderer renderer = GetRenderer( isolate, args );
- Material material = renderer.GetMaterial();
+ TextureSet textureSet = renderer.GetTextures();
- // Wrap the material
- v8::Local<v8::Object> localObject = MaterialWrapper::WrapMaterial( isolate, material );
+ // Wrap the textureset
+ v8::Local<v8::Object> localObject = TextureSetWrapper::WrapTextureSet( isolate, textureSet );
args.GetReturnValue().Set( localObject );
}
*/
void SetGeometry( const v8::FunctionCallbackInfo< v8::Value >& args );
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 SetTextures( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void GetTextures( 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 );
{ "SetGeometry" , RendererApi::SetGeometry },
{ "GetGeometry" , RendererApi::GetGeometry },
- { "SetMaterial" , RendererApi::SetMaterial },
- { "GetMaterial" , RendererApi::GetMaterial },
+ { "SetTextures" , RendererApi::SetTextures },
+ { "GetTextures" , RendererApi::GetTextures },
{ "SetBlendFunc" , RendererApi::SetBlendFunc },
{ "GetBlendFunc" , RendererApi::GetBlendFunc },
{ "SetBlendEquation" , RendererApi::SetBlendEquation },
--- /dev/null
+/*
+ * Copyright (c) 2015 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+// CLASS HEADER
+#include "texture-set-api.h"
+
+// EXTERNAL INCLUDES
+#include <dali/public-api/object/type-registry.h>
+
+// INTERNAL INCLUDES
+#include <v8-utils.h>
+#include <rendering/texture-set-wrapper.h>
+#include <rendering/shader-wrapper.h>
+#include <rendering/shader-api.h>
+#include <rendering/sampler-wrapper.h>
+#include <rendering/sampler-api.h>
+#include <image/image-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+/**
+ * ## TextureSet API
+ *
+ * TextureSet is a handle to an object that contains the textures used by a renderer
+ *
+ * @class TextureSet
+ * @extends Handle
+ */
+
+TextureSet TextureSetApi::GetTextureSet( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::HandleScope handleScope( isolate );
+
+ v8::Local<v8::Object> object = args.This();
+ v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
+ void* ptr = field->Value();
+
+ TextureSetWrapper* wrapper = static_cast< TextureSetWrapper *>(ptr);
+ return wrapper->GetTextureSet();
+}
+
+TextureSet TextureSetApi::GetTextureSetFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ found = false;
+
+ v8::HandleScope handleScope( isolate );
+ BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::TEXTURE_SET, isolate, args );
+ if( wrappedObject )
+ {
+ found = true;
+ TextureSetWrapper* wrapper = static_cast< TextureSetWrapper *>(wrappedObject);
+ return wrapper->GetTextureSet();
+ }
+ else
+ {
+ return TextureSet();
+ }
+}
+
+/**
+ * Create a new texture set object.
+ *
+ * @constructor
+ * @method TextureSet
+ * @for TextureSet
+ * @return {Object} TextureSet
+ */
+TextureSet TextureSetApi::New( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+ return TextureSet();
+}
+
+
+/**
+ * Sets the image to be used by a given texture
+ * @method setImage
+ * @for TextureSet
+ * @param {integer} index The index of the texture in the array of textures
+ * @param {Object} image The image used by this sampler
+ */
+void TextureSetApi::SetImage( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ TextureSet textureSet = GetTextureSet( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ return;
+ }
+
+ found = false;
+ Image image = V8Utils::GetImageParameter( PARAMETER_1, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing image from param 1" );
+ }
+ else
+ {
+ textureSet.SetImage(index, image);
+ }
+}
+
+/**
+ * Set the sampler used by a given texture
+ * @method setSampler
+ * @for TextureSet
+ * @param {integer} index The index of the texture in the array of textures
+ * @param {Object} sampler The new sampler
+ */
+void TextureSetApi::SetSampler( const v8::FunctionCallbackInfo< v8::Value >& args )
+{
+ v8::Isolate* isolate = args.GetIsolate();
+ v8::HandleScope handleScope( isolate );
+
+ TextureSet textureSet = GetTextureSet( isolate, args );
+
+ bool found( false );
+ int index = V8Utils::GetIntegerParameter( PARAMETER_0, found, isolate, args, 0 /* default */);
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "invalid index parameter" );
+ return;
+ }
+
+ found = false;
+ Sampler sampler = SamplerApi::GetSamplerFromParams( PARAMETER_1, found, isolate, args );
+ if( !found )
+ {
+ DALI_SCRIPT_EXCEPTION( isolate, "missing sampler from param 1" );
+ }
+ else
+ {
+ textureSet.SetSampler(index, sampler);
+ }
+}
+
+} // namespace V8Plugin
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_V8PLUGIN_TEXURE_SET_API_H__
+#define __DALI_V8PLUGIN_TEXURE_SET_API_H__
+
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/texture-set.h>
+
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+namespace TextureSetApi
+{
+
+ /**
+ * Helper to get TextureSet from args.This()
+ */
+ TextureSet GetTextureSet( v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * @brief Helper to get texture set from the JavaScript object held in the given function argument
+ * @param[in] paramIndex Argument index the object is held in
+ * @param[in] found Whether texture set is found in the given function parameter
+ * @param[in] isolate v8 isolated instance
+ * @param[in] args v8 function call arguments interpreted
+ */
+ TextureSet GetTextureSetFromParams( int paramIndex,
+ bool& found,
+ v8::Isolate* isolate,
+ const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * Constructor
+ */
+ TextureSet New( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+ /**
+ * TextureSet API see texture-set.h for a description
+ */
+ void SetImage( const v8::FunctionCallbackInfo< v8::Value >& args );
+ void SetSampler( const v8::FunctionCallbackInfo< v8::Value >& args );
+
+}; // namespace TextureSetApi
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // header __DALI_V8PLUGIN_TEXURE_SET_API_H__
*/
// CLASS HEADER
-#include "material-wrapper.h"
+#include "texture-set-wrapper.h"
// INTERNAL INCLUDES
#include <v8-utils.h>
-#include <rendering/material-api.h>
+#include <rendering/texture-set-api.h>
#include <shared/api-function.h>
#include <shared/object-template-helper.h>
#include <dali-wrapper.h>
namespace V8Plugin
{
-v8::Persistent<v8::ObjectTemplate> MaterialWrapper::mMaterialTemplate;
+v8::Persistent<v8::ObjectTemplate> TextureSetWrapper::mTextureSetTemplate;
namespace // un-named name space
{
/**
* Contains a list of all functions that can be called
*/
-const ApiFunction MaterialFunctionTable[]=
+const ApiFunction TextureSetFunctionTable[]=
{
/**************************************
- * Material API (in order of Material.h)
+ * TextureSet API (in order of texture-set.h)
**************************************/
- { "SetShader" , MaterialApi::SetShader },
- { "GetShader" , MaterialApi::GetShader },
- { "AddTexture" , MaterialApi::AddTexture },
- { "RemoveTexture" , MaterialApi::RemoveTexture },
- { "SetTextureImage" , MaterialApi::SetTextureImage },
- { "SetTextureSampler" , MaterialApi::SetTextureSampler },
- { "SetTextureUniformName" , MaterialApi::SetTextureUniformName },
- { "GetTextureIndex" , MaterialApi::GetTextureIndex },
- { "GetNumberOfTextures" , MaterialApi::GetNumberOfTextures },
+ { "SetImage" , TextureSetApi::SetImage },
+ { "SetSampler" , TextureSetApi::SetSampler },
};
-const unsigned int MaterialFunctionTableCount = sizeof(MaterialFunctionTable)/sizeof(MaterialFunctionTable[0]);
+const unsigned int TextureSetFunctionTableCount = sizeof(TextureSetFunctionTable)/sizeof(TextureSetFunctionTable[0]);
} //un-named space
-MaterialWrapper::MaterialWrapper( const Dali::Material& material, GarbageCollectorInterface& gc )
-: HandleWrapper( BaseWrappedObject::MATERIAL , material, gc )
+TextureSetWrapper::TextureSetWrapper( const Dali::TextureSet& textureSet, GarbageCollectorInterface& gc )
+: HandleWrapper( BaseWrappedObject::TEXTURE_SET , textureSet, gc )
{
- mMaterial = material;
+ mTextureSet = textureSet;
}
-v8::Handle<v8::Object> MaterialWrapper::WrapMaterial(v8::Isolate* isolate, const Dali::Material& material )
+v8::Handle<v8::Object> TextureSetWrapper::WrapTextureSet(v8::Isolate* isolate, const Dali::TextureSet& textureSet )
{
v8::EscapableHandleScope handleScope( isolate );
v8::Local<v8::ObjectTemplate> objectTemplate;
- objectTemplate = GetMaterialTemplate( isolate);
+ objectTemplate = GetTextureSetTemplate( isolate);
// create an instance of the template
v8::Local<v8::Object> localObject = objectTemplate->NewInstance();
- // create the Material wrapper
- MaterialWrapper* pointer = new MaterialWrapper( material, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
+ // create the texture set wrapper
+ TextureSetWrapper* pointer = new TextureSetWrapper( textureSet, Dali::V8Plugin::DaliWrapper::Get().GetDaliGarbageCollector() );
// assign the JavaScript object to the wrapper.
pointer->SetJavascriptObject( isolate, localObject );
return handleScope.Escape( localObject );
}
-v8::Local<v8::ObjectTemplate> MaterialWrapper::GetMaterialTemplate( v8::Isolate* isolate)
+v8::Local<v8::ObjectTemplate> TextureSetWrapper::GetTextureSetTemplate( v8::Isolate* isolate)
{
v8::EscapableHandleScope handleScope( isolate );
v8::Local<v8::ObjectTemplate> objectTemplate;
- if( mMaterialTemplate.IsEmpty() )
+ if( mTextureSetTemplate.IsEmpty() )
{
- objectTemplate = MakeMaterialTemplate( isolate );
- mMaterialTemplate.Reset( isolate, objectTemplate );
+ objectTemplate = MakeTextureSetTemplate( isolate );
+ mTextureSetTemplate.Reset( isolate, objectTemplate );
}
else
{
// get the object template
- objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mMaterialTemplate );
+ objectTemplate = v8::Local<v8::ObjectTemplate>::New( isolate, mTextureSetTemplate );
}
return handleScope.Escape( objectTemplate );
}
-v8::Handle<v8::ObjectTemplate> MaterialWrapper::MakeMaterialTemplate( v8::Isolate* isolate )
+v8::Handle<v8::ObjectTemplate> TextureSetWrapper::MakeTextureSetTemplate( v8::Isolate* isolate )
{
v8::EscapableHandleScope handleScope( isolate );
objTemplate->SetInternalFieldCount( BaseWrappedObject::FIELD_COUNT );
// add our function properties
- ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, MaterialFunctionTable, MaterialFunctionTableCount );
+ ObjectTemplateHelper::InstallFunctions( isolate, objTemplate, TextureSetFunctionTable, TextureSetFunctionTableCount );
return handleScope.Escape( objTemplate );
}
-void MaterialWrapper::NewMaterial( const v8::FunctionCallbackInfo< v8::Value >& args)
+void TextureSetWrapper::NewTextureSet( const v8::FunctionCallbackInfo< v8::Value >& args)
{
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope handleScope( isolate);
if(!args.IsConstructCall())
{
- DALI_SCRIPT_EXCEPTION( isolate, "Material constructor called without 'new'");
+ DALI_SCRIPT_EXCEPTION( isolate, "TextureSet constructor called without 'new'");
return;
}
- Dali::Material material = MaterialApi::New( args );
+ Dali::TextureSet textureSet = TextureSetApi::New( args );
- if(material)
+ if(textureSet)
{
- v8::Local<v8::Object> localObject = WrapMaterial( isolate, material );
+ v8::Local<v8::Object> localObject = WrapTextureSet( isolate, textureSet );
args.GetReturnValue().Set( localObject );
}
}
-Material MaterialWrapper::GetMaterial()
+TextureSet TextureSetWrapper::GetTextureSet()
{
- return mMaterial;
+ return mTextureSet;
}
--- /dev/null
+#ifndef __DALI_V8PLUGIN_TEXTURE_SET_WRAPPER_H__
+#define __DALI_V8PLUGIN_TEXTURE_SET_WRAPPER_H__
+
+/*
+ * Copyright (c) 2016 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// EXTERNAL INCLUDES
+#include <v8.h>
+#include <dali/devel-api/rendering/texture-set.h>
+
+// INTERNAL INCLUDES
+#include <object/handle-wrapper.h>
+
+namespace Dali
+{
+
+namespace V8Plugin
+{
+
+
+/**
+ * A TextureSet wrapper.
+ * Provides access to TextureSet specific functionality and V8 memory handling.
+ */
+class TextureSetWrapper : public HandleWrapper
+{
+
+public:
+
+ /**
+ * @brief Constructor
+ * @param[in] textureSet DALi TextureSet
+ * @param[in] gc garbage collection interface
+ */
+ TextureSetWrapper( const TextureSet& textureSet,
+ GarbageCollectorInterface& gc );
+
+ /**
+ * @brief Destructor
+ */
+ virtual ~TextureSetWrapper()
+ {
+ };
+
+ /**
+ * @brief Creates a new TextureSet wrapped inside a Javascript Object.
+ * @param[in] args v8 function call arguments interpreted
+ */
+ static void NewTextureSet( const v8::FunctionCallbackInfo< v8::Value >& args);
+
+ /**
+ * Wraps a TextureSet
+ */
+ static v8::Handle<v8::Object> WrapTextureSet(v8::Isolate* isolate, const Dali::TextureSet& );
+
+
+ // The TextureSetAttribute ObjectTemplate, we cache templates so we don't have
+ // keep generating them everytime we want to create a TextureSet
+ static v8::Persistent<v8::ObjectTemplate> mTextureSetTemplate;
+
+ /**
+ * @brief Gets the handle of TextureSet
+ * @return the handle of the TextureSet
+ */
+ TextureSet GetTextureSet();
+
+
+private:
+
+ // TextureSet
+ TextureSet mTextureSet;
+
+ /**
+ * @brief Creates the object template that used to create TextureSets at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Handle<v8::ObjectTemplate> MakeTextureSetTemplate( v8::Isolate* isolate );
+
+ /**
+ * @brief Gets the object template that used to create TextureSets at runtime
+ * @param[in] isolate v8 isolated instance
+ * @return the object template
+ */
+ static v8::Local<v8::ObjectTemplate> GetTextureSetTemplate( v8::Isolate* isolate );
+
+};
+
+} // namespace V8Plugin
+
+} // namespace Dali
+
+#endif // __DALI_V8PLUGIN_TEXTURE_SET_WRAPPER_H__
TIMER,
SHADER,
SAMPLER,
- MATERIAL,
+ TEXTURE_SET,
GEOMETRY,
RENDERER,
PROPERTY_BUFFER,