Change-Id: Id427d2be2c3cdc110ad4fba2ef3125ced62f7eca
Signed-off-by: Richard Underhill <r.underhill@partner.samsung.com>
atlas.Upload( atlasDescriptor.mFilledPixelImage, 0, 0 );
Sampler sampler = Sampler::New( atlas, "sTexture" );
atlas.Upload( atlasDescriptor.mFilledPixelImage, 0, 0 );
Sampler sampler = Sampler::New( atlas, "sTexture" );
- sampler.SetFilterMode( Sampler::NEAREST, Sampler::NEAREST );
sampler.SetProperty( Sampler::Property::AFFECTS_TRANSPARENCY, true );
Shader shader;
if ( pixelformat == Pixel::BGRA8888 )
sampler.SetProperty( Sampler::Property::AFFECTS_TRANSPARENCY, true );
Shader shader;
if ( pixelformat == Pixel::BGRA8888 )
}
atlasDescriptor.mMaterial = Material::New( shader );
atlasDescriptor.mMaterial.AddSampler( sampler );
}
atlasDescriptor.mMaterial = Material::New( shader );
atlasDescriptor.mMaterial.AddSampler( sampler );
+ atlasDescriptor.mSampler = sampler;
atlasDescriptor.mMaterial.SetBlendMode( BlendingMode::ON );
mAtlasList.push_back( atlasDescriptor );
return mAtlasList.size();
atlasDescriptor.mMaterial.SetBlendMode( BlendingMode::ON );
mAtlasList.push_back( atlasDescriptor );
return mAtlasList.size();
+Sampler AtlasManager::GetSampler( AtlasId atlas ) const
+{
+ if ( atlas && atlas <= mAtlasList.size() )
+ {
+ return mAtlasList[ atlas -1u ].mSampler;
+ }
+ Sampler null;
+ return null;
+}
+
} // namespace Internal
} // namespace Toolkit
} // namespace Internal
} // namespace Toolkit
BufferImage mFilledPixelImage; // Image used by atlas for operations such as underline
PixelBuffer* mStripBuffer; // Blank image buffer used to pad upload
Material mMaterial; // material used for atlas texture
BufferImage mFilledPixelImage; // Image used by atlas for operations such as underline
PixelBuffer* mStripBuffer; // Blank image buffer used to pad upload
Material mMaterial; // material used for atlas texture
+ Sampler mSampler; // sampler used for atlas texture
SizeType mNextFreeBlock; // next free block will be placed here ( actually +1 )
Dali::Vector< SizeType > mFreeBlocksList; // unless there are any previously freed blocks
};
SizeType mNextFreeBlock; // next free block will be placed here ( actually +1 )
Dali::Vector< SizeType > mFreeBlocksList; // unless there are any previously freed blocks
};
*/
Material GetMaterial( AtlasId atlas ) const;
*/
Material GetMaterial( AtlasId atlas ) const;
+/**
+ * @copydoc Toolkit::AtlasManager::GetSampler
+ */
+ Sampler GetSampler( AtlasId atlas ) const;
+
private:
std::vector< AtlasDescriptor > mAtlasList; // List of atlases created
private:
std::vector< AtlasDescriptor > mAtlasList; // List of atlases created
return GetImplementation(*this).GetMaterial( atlas );
}
return GetImplementation(*this).GetMaterial( atlas );
}
+Sampler AtlasManager::GetSampler( AtlasId atlas ) const
+{
+ return GetImplementation(*this).GetSampler( atlas );
+}
+
} // namespace Toolkit
} // namespace Dali
} // namespace Toolkit
} // namespace Dali
struct Mesh2D
{
Vector< Vertex2D > mVertices;
struct Mesh2D
{
Vector< Vertex2D > mVertices;
- Vector< unsigned short> mIndices;
+ Vector< unsigned int> mIndices;
*/
Material GetMaterial( AtlasId atlas ) const;
*/
Material GetMaterial( AtlasId atlas ) const;
+ /**
+ * @brief Get Sampler used by atlas
+ *
+ * @param atlas[in] atlas AtlasId
+ *
+ * @return Sampler used by atlas
+ */
+ Sampler GetSampler( AtlasId atlas ) const;
private:
explicit DALI_INTERNAL AtlasManager(Internal::AtlasManager *impl);
private:
explicit DALI_INTERNAL AtlasManager(Internal::AtlasManager *impl);
return mAtlasManager.GetMaterial( atlasId );
}
return mAtlasManager.GetMaterial( atlasId );
}
+Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
+{
+ return mAtlasManager.GetSampler( atlasId );
+}
+
const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
{
mMetrics.mGlyphCount = mGlyphRecords.Size();
const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
{
mMetrics.mGlyphCount = mGlyphRecords.Size();
Material GetMaterial( uint32_t atlasId ) const;
/**
Material GetMaterial( uint32_t atlasId ) const;
/**
+ * @copydoc Toolkit::AtlasGlyphManager::GetMaterial
+ */
+ Sampler GetSampler( uint32_t atlasId ) const;
+
+ /**
* @copydoc Toolkit::AtlasGlyphManager::GetMetrics
*/
const Toolkit::AtlasGlyphManager::Metrics& GetMetrics();
* @copydoc Toolkit::AtlasGlyphManager::GetMetrics
*/
const Toolkit::AtlasGlyphManager::Metrics& GetMetrics();
return GetImplementation(*this).GetMaterial( atlasId );
}
return GetImplementation(*this).GetMaterial( atlasId );
}
+Sampler AtlasGlyphManager::GetSampler( uint32_t atlasId ) const
+{
+ return GetImplementation(*this).GetSampler( atlasId );
+}
+
const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
{
return GetImplementation(*this).GetMetrics();
}
const Toolkit::AtlasGlyphManager::Metrics& AtlasGlyphManager::GetMetrics()
{
return GetImplementation(*this).GetMetrics();
}
} // namespace Toolkit
} // namespace Dali
} // namespace Toolkit
} // namespace Dali
Material GetMaterial( uint32_t atlasId ) const;
/**
Material GetMaterial( uint32_t atlasId ) const;
/**
+ * @brief Get the sampler used by an atlas
+ *
+ * @param[in] atlasId Id of an atlas
+ *
+ * @return The sampler used by the atlas
+ */
+ Sampler GetSampler( uint32_t atlasId ) const;
+
+ /**
* @brief Get Glyph Manager metrics
*
* @return const reference to glyph manager metrics
* @brief Get Glyph Manager metrics
*
* @return const reference to glyph manager metrics
Actor CreateMeshActor( const MeshRecord& meshRecord )
{
PropertyBuffer quadVertices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadVertexFormat, meshRecord.mMesh.mVertices.Size() );
Actor CreateMeshActor( const MeshRecord& meshRecord )
{
PropertyBuffer quadVertices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadVertexFormat, meshRecord.mMesh.mVertices.Size() );
- PropertyBuffer quadIndices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() >> 1 );
+ PropertyBuffer quadIndices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ) );
quadVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &meshRecord.mMesh.mVertices[ 0 ] ) );
- quadIndices.SetData( const_cast< unsigned short* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
+ quadIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
Geometry quadGeometry = Geometry::New();
quadGeometry.AddVertexBuffer( quadVertices );
Geometry quadGeometry = Geometry::New();
quadGeometry.AddVertexBuffer( quadVertices );
meshRecord.mBuffer = FrameBufferImage::New( width, height );
// We will render a quad into this buffer
meshRecord.mBuffer = FrameBufferImage::New( width, height );
// We will render a quad into this buffer
- unsigned short indices[ 6 ] = { 1, 0, 2, 2, 3, 1 };
+ unsigned int indices[ 6 ] = { 1, 0, 2, 2, 3, 1 };
PropertyBuffer quadVertices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadVertexFormat, 4u );
PropertyBuffer quadVertices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadVertexFormat, 4u );
- PropertyBuffer quadIndices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadIndexFormat, 3u );
+ PropertyBuffer quadIndices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadIndexFormat, sizeof(indices)/sizeof(indices[0]) );
AtlasManager::Vertex2D vertices[ 4 ] = {
{ Vector2( tlx + shadowOffset.x, tly + shadowOffset.y ), Vector2( ZERO, ZERO ) },
AtlasManager::Vertex2D vertices[ 4 ] = {
{ Vector2( tlx + shadowOffset.x, tly + shadowOffset.y ), Vector2( ZERO, ZERO ) },
material.AddSampler( sampler );
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
material.AddSampler( sampler );
Dali::Renderer renderer = Dali::Renderer::New( quadGeometry, material );
- renderer.SetDepthIndex( 0.1f );
+ renderer.SetDepthIndex( 1.0f );
Actor actor = Actor::New();
actor.AddRenderer( renderer );
actor.SetSize( 1.0f, 1.0f );
// Create a sub actor to render the source with normalized vertex positions
Vector< AtlasManager::Vertex2D > normVertexList;
Actor actor = Actor::New();
actor.AddRenderer( renderer );
actor.SetSize( 1.0f, 1.0f );
// Create a sub actor to render the source with normalized vertex positions
Vector< AtlasManager::Vertex2D > normVertexList;
- Vector< unsigned short > normIndexList;
for ( uint32_t i = 0; i < verts.Size(); ++i )
{
AtlasManager::Vertex2D vertex = verts[ i ];
for ( uint32_t i = 0; i < verts.Size(); ++i )
{
AtlasManager::Vertex2D vertex = verts[ i ];
normVertexList.PushBack( vertex );
}
normVertexList.PushBack( vertex );
}
- // Reverse winding
- for ( uint32_t i = 0; i < meshRecord.mMesh.mIndices.Size() / 3; ++i )
- {
- uint32_t index = i * 3;
- normIndexList.PushBack( meshRecord.mMesh.mIndices[ index + 2 ] );
- normIndexList.PushBack( meshRecord.mMesh.mIndices[ index + 1 ] );
- normIndexList.PushBack( meshRecord.mMesh.mIndices[ index ] );
- }
-
PropertyBuffer normVertices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadVertexFormat, normVertexList.Size() );
PropertyBuffer normVertices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadVertexFormat, normVertexList.Size() );
- PropertyBuffer normIndices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadIndexFormat, normIndexList.Size() >> 1 );
+ PropertyBuffer normIndices = PropertyBuffer::New( PropertyBuffer::STATIC, mQuadIndexFormat, meshRecord.mMesh.mIndices.Size() );
normVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &normVertexList[ 0 ] ) );
normVertices.SetData( const_cast< AtlasManager::Vertex2D* >( &normVertexList[ 0 ] ) );
- normIndices.SetData( const_cast< unsigned short* >( &normIndexList[ 0 ] ) );
+ normIndices.SetData( const_cast< unsigned int* >( &meshRecord.mMesh.mIndices[ 0 ] ) );
Geometry normGeometry = Geometry::New();
normGeometry.AddVertexBuffer( normVertices );
normGeometry.SetIndexBuffer( normIndices );
Geometry normGeometry = Geometry::New();
normGeometry.AddVertexBuffer( normVertices );
normGeometry.SetIndexBuffer( normIndices );
- Material normMaterial = mGlyphManager.GetMaterial( meshRecord.mAtlasId );
- normMaterial.SetShader( mShadowShader );
+ Material normMaterial = Material::New( mShadowShader );
+ Sampler normSampler = mGlyphManager.GetSampler( meshRecord.mAtlasId );
+ normMaterial.AddSampler( normSampler );
Dali::Renderer normRenderer = Dali::Renderer::New( normGeometry, normMaterial );
Actor subActor = Actor::New();
subActor.AddRenderer( normRenderer );
Dali::Renderer normRenderer = Dali::Renderer::New( normGeometry, normMaterial );
Actor subActor = Actor::New();
subActor.AddRenderer( normRenderer );
task.SetTargetFrameBuffer( meshRecord.mBuffer );
task.SetSourceActor( subActor );
task.SetClearEnabled( true );
task.SetTargetFrameBuffer( meshRecord.mBuffer );
task.SetSourceActor( subActor );
task.SetClearEnabled( true );
- task.SetClearColor( Vector4( 0.0f, 0.0f, 0.0f, 1.0f ) );
- //task.SetClearColor( Color::BLUE );
+ task.SetClearColor( Vector4::ZERO );
task.SetExclusive( true );
task.SetRefreshRate( RenderTask::REFRESH_ONCE );
task.FinishedSignal().Connect( this, &AtlasRenderer::Impl::RenderComplete );
actor.Add( subActor );
task.SetExclusive( true );
task.SetRefreshRate( RenderTask::REFRESH_ONCE );
task.FinishedSignal().Connect( this, &AtlasRenderer::Impl::RenderComplete );
actor.Add( subActor );