controlRenderer.SetOnStage( actor );
DALI_TEST_CHECK( actor.GetRendererCount() == 1u );
- DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfSamplers() == expectedSamplers );
+ DALI_TEST_CHECK( actor.GetRendererAt(0u).GetMaterial().GetNumberOfTextures() == expectedSamplers );
application.SendNotification();
application.Render();
controlRenderer.SetOnStage( actor2 );
application.SendNotification();
application.Render(0);
- Image samplerImage = actor2.GetRendererAt(0u).GetMaterial().GetSamplerAt(0u).GetImage();
- DALI_TEST_CHECK( BufferImage::DownCast( samplerImage ) );
END_TEST;
}
application.SendNotification();
application.Render(0);
- Image samplerImage = actor.GetRendererAt(0u).GetMaterial().GetSamplerAt(0u).GetImage();
- DALI_TEST_CHECK( ResourceImage::DownCast( samplerImage ) );
Image bufferImage = CreateBufferImage( 100, 200, Vector4( 1.f, 1.f, 1.f, 1.f ) );
bool isNewRenderer = factory.ResetRenderer( controlRenderer, bufferImage );
DALI_TEST_CHECK( !isNewRenderer );
application.SendNotification();
application.Render(0);
- samplerImage = actor.GetRendererAt(0u).GetMaterial().GetSamplerAt(0u).GetImage();
- DALI_TEST_CHECK( BufferImage::DownCast( samplerImage ) );
isNewRenderer = factory.ResetRenderer( controlRenderer, Color::RED );
DALI_TEST_CHECK( isNewRenderer );
memset( buffer, 0xFF, filledPixelImage.GetBufferSize() );
atlas.Upload( filledPixelImage, 0, 0 );
- Sampler sampler = Sampler::New( atlas, "sTexture" );
- sampler.SetProperty( Sampler::Property::AFFECTS_TRANSPARENCY, true );
atlasDescriptor.mMaterial = Material::New( pixelformat == Pixel::L8 ? mShaderL8 : mShaderRgba );
- atlasDescriptor.mMaterial.AddSampler( sampler );
- atlasDescriptor.mSampler = sampler;
+ atlasDescriptor.mMaterial.AddTexture(atlas, "sTexture" );
+ atlasDescriptor.mImage = atlas;
atlasDescriptor.mMaterial.SetBlendMode( BlendingMode::ON );
mAtlasList.push_back( atlasDescriptor );
return mAtlasList.size();
return null;
}
-Sampler AtlasManager::GetSampler( AtlasId atlas ) const
+Image AtlasManager::GetImage( AtlasId atlas ) const
{
if ( atlas && atlas-- <= mAtlasList.size() )
{
- return mAtlasList[ atlas ].mSampler;
+ return mAtlasList[ atlas ].mImage;
}
- Sampler null;
+ Image null;
return null;
}
BufferImage mHorizontalStrip; // Image used to pad upload
BufferImage mVerticalStrip; // Image used to pad upload
Material mMaterial; // material used for atlas texture
- Sampler mSampler; // sampler used for atlas texture
+ Image mImage;
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
Material GetMaterial( AtlasId atlas ) const;
/**
- * @copydoc Toolkit::AtlasManager::GetSampler
+ * @copydoc Toolkit::AtlasManager::GetImage
*/
- Sampler GetSampler( AtlasId atlas ) const;
+ Image GetImage( AtlasId atlas ) const;
private:
return GetImplementation(*this).GetMaterial( atlas );
}
-Sampler AtlasManager::GetSampler( AtlasId atlas ) const
+Image AtlasManager::GetImage( AtlasId atlas ) const
{
- return GetImplementation(*this).GetSampler( atlas );
+ return GetImplementation(*this).GetImage( atlas );
}
} // namespace Toolkit
Material GetMaterial( AtlasId atlas ) const;
/**
- * @brief Get Sampler used by atlas
+ * @brief Get Image used by atlas
*
* @param atlas[in] atlas AtlasId
*
* @return Sampler used by atlas
*/
- Sampler GetSampler( AtlasId atlas ) const;
+ Image GetImage( AtlasId atlas ) const;
private:
explicit DALI_INTERNAL AtlasManager(Internal::AtlasManager *impl);
// Prepare the frame buffer to store the color adjusted background image
mEffectImage = FrameBufferImage::New( mMovementArea.width/4.f, mMovementArea.height/4.f, Pixel::RGBA8888, Dali::Image::UNUSED );
- // Generate the samplers and geometry, which is used by all bubbleActors
- mSamplerBackground = Sampler::New( mEffectImage, "sBackground" );
- mSamplerBubbleShape = Sampler::New( mShapeImage, "sBubbleShape" );
+ // Generate the geometry, which is used by all bubbleActors
mMeshGeometry = CreateGeometry( mNumBubblePerActor*mDensity );
Shader bubbleShader = CreateBubbleShader (mNumBubblePerActor );
mMaterial = Material::New( bubbleShader );
- mMaterial.AddSampler( mSamplerBackground );
- mMaterial.AddSampler( mSamplerBubbleShape );
+ mMaterial.AddTexture( mEffectImage, "sBackground" );
+ mMaterial.AddTexture( mShapeImage, "sBubbleShape" );
mBubbleActors.resize( mNumActor );
void BubbleEmitter::SetShapeImage( Image shapeImage )
{
- mSamplerBubbleShape.SetImage( shapeImage );
+ mMaterial.SetTextureImage( 1, shapeImage );
}
void BubbleEmitter::SetBubbleScale( float scale )
FrameBufferImage mEffectImage; ///< The image stores the adjusted color of the background image.The bubbles pick color from this image.
CameraActor mCameraActor; ///< The render task views the scene from the perspective of this actor.
- Sampler mSamplerBackground; ///< The sampler which provides the background image to material
- Sampler mSamplerBubbleShape; ///< The sampler which provides the bubble shape image to material
Geometry mMeshGeometry; ///< The mesh geometry which contains the vertices and indices data
Material mMaterial; ///< The material which controls the bubble display
std::vector<BubbleActorPtr> mBubbleActors; ///< The meshActor vector, its size is mNumShader.
Image tex0 = ResourceImage::New( imgUrl );
if( tex0 )
{
- Sampler sampler = Sampler::New( tex0, "sDiffuse" );
- sampler.SetWrapMode(Sampler::REPEAT,Sampler::REPEAT);
- sampler.SetAffectsTransparency(false);
-
- mMaterial.AddSampler( sampler );
+ size_t index = mMaterial.AddTexture( tex0, "sDiffuse" );
+ mMaterial.SetTextureAffectsTransparency(index, false );
}
}
Image tex1 = ResourceImage::New( imgUrl );
if (tex1)
{
- Sampler sampler = Sampler::New( tex1, "sNormal" );
- sampler.SetWrapMode(Sampler::REPEAT,Sampler::REPEAT);
- sampler.SetAffectsTransparency(false);
- sampler.SetFilterMode(Sampler::LINEAR,Sampler::LINEAR);
-
- mMaterial.AddSampler( sampler );
+ size_t index = mMaterial.AddTexture( tex1, "sNormal" );
+ mMaterial.SetTextureAffectsTransparency(index, false );
}
}
Image tex2 = ResourceImage::New( imgUrl );
if( tex2 )
{
- Sampler sampler = Sampler::New( tex2, "sGloss" );
- sampler.SetWrapMode(Sampler::REPEAT,Sampler::REPEAT);
- sampler.SetAffectsTransparency(false);
- sampler.SetFilterMode(Sampler::LINEAR,Sampler::LINEAR);
-
- mMaterial.AddSampler( sampler );
+ size_t index = mMaterial.AddTexture( tex2, "sGloss" );
+ mMaterial.SetTextureAffectsTransparency(index, false );
}
}
}
)
};
-Sampler::WrapMode GetWrapMode( Gradient::SpreadMethod spread )
+Dali::WrapMode::Type GetWrapMode( Gradient::SpreadMethod spread )
{
switch(spread)
{
case Gradient::REPEAT:
{
- return Sampler::REPEAT;
+ return Dali::WrapMode::REPEAT;
}
case Gradient::REFLECT:
{
- return Sampler::MIRRORED_REPEAT;
+ return Dali::WrapMode::MIRRORED_REPEAT;
}
case Gradient::PAD:
default:
{
- return Sampler::CLAMP_TO_EDGE;
+ return Dali::WrapMode::CLAMP_TO_EDGE;
}
}
}
}
Dali::BufferImage lookupTexture = mGradient->GenerateLookupTexture();
- Sampler sampler = Sampler::New( lookupTexture, UNIFORM_TEXTULRE_NAME );
- Sampler::WrapMode wrap = GetWrapMode( mGradient->GetSpreadMethod() );
+ Sampler sampler = Sampler::New();
+ Dali::WrapMode::Type wrap = GetWrapMode( mGradient->GetSpreadMethod() );
sampler.SetWrapMode( wrap, wrap );
- material.AddSampler( sampler );
+ material.AddTexture( lookupTexture, UNIFORM_TEXTULRE_NAME, sampler );
renderer.RegisterProperty( UNIFORM_ALIGNMENT_MATRIX_NAME, mGradientTransform );
}
Material material = mImpl->mRenderer.GetMaterial();
if( material )
{
- for( std::size_t i = 0; i < material.GetNumberOfSamplers(); ++i )
+ int index = material.GetTextureIndex(TEXTURE_UNIFORM_NAME);
+ if( index != -1 )
{
- Sampler sampler = material.GetSamplerAt( i );
- if( sampler.GetUniformName() == TEXTURE_UNIFORM_NAME )
- {
- sampler.SetImage( mImage );
- return;
- }
+ material.SetTextureImage( index, mImage );
+ return;
}
- Sampler sampler = Sampler::New( mImage, TEXTURE_UNIFORM_NAME );
- material.AddSampler( sampler );
+ material.AddTexture( mImage,TEXTURE_UNIFORM_NAME );
}
}
}
vertices.PushBack( Vector2( x, y ) );
}
-void RegisterStretchProperties( Sampler& sampler, const char * uniformName, const NinePatchImage::StretchRanges& stretchPixels, uint16_t imageExtent)
+void RegisterStretchProperties( Material& material, const char * uniformName, const NinePatchImage::StretchRanges& stretchPixels, uint16_t imageExtent)
{
uint16_t prevEnd = 0;
uint16_t prevFix = 0;
std::stringstream uniform;
uniform << uniformName << "[" << i << "]";
- sampler.RegisterProperty( uniform.str(), Vector2( fix, stretch ) );
+ material.RegisterProperty( uniform.str(), Vector2( fix, stretch ) );
prevEnd = end;
prevFix = fix;
prevFix += imageExtent - prevEnd;
std::stringstream uniform;
uniform << uniformName << "[" << i << "]";
- sampler.RegisterProperty( uniform.str(), Vector2( prevFix, prevStretch ) );
+ material.RegisterProperty( uniform.str(), Vector2( prevFix, prevStretch ) );
}
}
Material material = mImpl->mRenderer.GetMaterial();
if( material )
{
- Sampler sampler;
- for( std::size_t i = 0; i < material.GetNumberOfSamplers(); ++i )
+ int index = material.GetTextureIndex( TEXTURE_UNIFORM_NAME );
+ if( index > -1 )
{
- sampler = material.GetSamplerAt( i );
- if( sampler.GetUniformName() == TEXTURE_UNIFORM_NAME )
- {
- sampler.SetImage( mCroppedImage );
- break;
- }
+ material.SetTextureImage( index, mCroppedImage );
}
- if( !sampler )
+ else
{
- sampler = Sampler::New( mCroppedImage, TEXTURE_UNIFORM_NAME );
- material.AddSampler( sampler );
+ material.AddTexture( mCroppedImage, TEXTURE_UNIFORM_NAME );
}
if( mStretchPixelsX.Size() == 1 && mStretchPixelsY.Size() == 1 )
uint16_t stretchWidth = stretchX.GetY() - stretchX.GetX();
uint16_t stretchHeight = stretchY.GetY() - stretchY.GetX();
- sampler.RegisterProperty( "uFixed[0]", Vector2::ZERO );
- sampler.RegisterProperty( "uFixed[1]", Vector2( stretchX.GetX(), stretchY.GetX()) );
- sampler.RegisterProperty( "uFixed[2]", Vector2( mImageSize.GetWidth() - stretchWidth, mImageSize.GetHeight() - stretchHeight ) );
- sampler.RegisterProperty( "uStretchTotal", Vector2( stretchWidth, stretchHeight ) );
+ 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 ) );
}
else
{
- sampler.RegisterProperty( "uNinePatchFactorsX[0]", Vector2::ZERO );
- sampler.RegisterProperty( "uNinePatchFactorsY[0]", Vector2::ZERO );
+ material.RegisterProperty( "uNinePatchFactorsX[0]", Vector2::ZERO );
+ material.RegisterProperty( "uNinePatchFactorsY[0]", Vector2::ZERO );
- RegisterStretchProperties( sampler, "uNinePatchFactorsX", mStretchPixelsX, mImageSize.GetWidth() );
- RegisterStretchProperties( sampler, "uNinePatchFactorsY", mStretchPixelsY, mImageSize.GetHeight() );
+ RegisterStretchProperties( material, "uNinePatchFactorsX", mStretchPixelsX, mImageSize.GetWidth() );
+ RegisterStretchProperties( material, "uNinePatchFactorsY", mStretchPixelsY, mImageSize.GetHeight() );
}
}
}
return mAtlasManager.GetMaterial( atlasId );
}
-Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
+Image AtlasGlyphManager::GetImage( uint32_t atlasId ) const
{
- return mAtlasManager.GetSampler( atlasId );
+ return mAtlasManager.GetImage( atlasId );
}
AtlasGlyphManager::~AtlasGlyphManager()
/**
* @copydoc Toolkit::AtlasGlyphManager::GetMaterial
*/
- Sampler GetSampler( uint32_t atlasId ) const;
+ Image GetImage( uint32_t atlasId ) const;
/**
* @copydoc Toolkit::AtlasGlyphManager::GetMetrics
return GetImplementation(*this).GetMaterial( atlasId );
}
-Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
+Image AtlasGlyphManager::GetImage( uint32_t atlasId ) const
{
- return GetImplementation(*this).GetSampler( atlasId );
+ return GetImplementation(*this).GetImage( atlasId );
}
const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
*
* @return The sampler used by the atlas
*/
- Sampler GetSampler( uint32_t atlasId ) const;
+ Image GetImage( uint32_t atlasId ) const;
/**
* @brief Get Glyph Manager metrics
quadGeometry.AddVertexBuffer( quadVertices );
quadGeometry.SetIndexBuffer( quadIndices );
- Sampler sampler = Sampler::New( meshRecord.mBuffer, "sTexture" );
Material material = Material::New( mGlyphManager.GetEffectBufferShader() );
- material.AddSampler( sampler );
+ material.AddTexture(meshRecord.mBuffer, "sTexture");
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
normGeometry.SetIndexBuffer( normIndices );
Material normMaterial = Material::New( mGlyphManager.GetGlyphShadowShader() );
- Sampler normSampler = mGlyphManager.GetSampler( meshRecord.mAtlasId );
- normMaterial.AddSampler( normSampler );
+ Image normImage = mGlyphManager.GetImage( meshRecord.mAtlasId );
+ normMaterial.AddTexture( normImage, "sTexture" );
Dali::Renderer normRenderer = Dali::Renderer::New( normGeometry, normMaterial );
Actor subActor = Actor::New();
subActor.AddRenderer( normRenderer );