*/
inline void ProcessRenderList( const RenderList& renderList,
Context& context,
+ SceneGraph::TextureCache& textureCache,
SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex,
float frameTime,
SceneGraph::Renderer* renderer = const_cast< SceneGraph::Renderer* >( item.GetRenderer() );
const Matrix& modelViewMatrix = item.GetModelViewMatrix();
- renderer->Render( bufferIndex, defaultShader, modelViewMatrix, viewMatrix, projectionMatrix, frameTime, cullMode );
+ renderer->Render( context, textureCache, bufferIndex, defaultShader, modelViewMatrix, viewMatrix, projectionMatrix, frameTime, cullMode );
}
}
void ProcessRenderInstruction( const RenderInstruction& instruction,
Context& context,
+ SceneGraph::TextureCache& textureCache,
SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex,
float frameTime )
if( renderList &&
!renderList->IsEmpty() )
{
- ProcessRenderList( *renderList, context, defaultShader, bufferIndex, frameTime, *viewMatrix, *projectionMatrix, instruction.mCullMode );
+ ProcessRenderList( *renderList, context, textureCache, defaultShader, bufferIndex, frameTime, *viewMatrix, *projectionMatrix, instruction.mCullMode );
}
}
}
{
class RenderInstruction;
class Shader;
+class TextureCache;
}
namespace Render
* Process a render-instruction.
* @param[in] instruction The render-instruction to process.
* @param[in] context The GL context.
+ * @param[in] textureCache The texture cache used to get textures.
* @param[in] defaultShader The default shader.
* @param[in] buffer The current render buffer index (previous update buffer)
* @param[in] frameTime The elapsed time between the last two updates.
*/
void ProcessRenderInstruction( const SceneGraph::RenderInstruction& instruction,
Context& context,
+ SceneGraph::TextureCache& textureCache,
SceneGraph::Shader& defaultShader,
BufferIndex bufferIndex,
float frameTime );
Render::ProcessRenderInstruction( instruction,
mImpl->context,
+ mImpl->textureCache,
defaultShader,
mImpl->renderBufferIndex,
elapsedTime );
}
void RenderGeometry::UploadAndDraw(
- Context* context,
+ Context& context,
Program& program,
BufferIndex bufferIndex,
const GeometryDataProvider& geometryDataProvider )
}
void RenderGeometry::UploadVertexData(
- Context* context,
+ Context& context,
BufferIndex bufferIndex,
const GeometryDataProvider& geometry )
{
}
void RenderGeometry::DoUpload(
- Context* context,
+ Context& context,
BufferIndex bufferIndex,
const GeometryDataProvider& geometry)
{
const PropertyBuffer* vertexBuffer = vertexBuffers[i];
// @todo MESH_REWORK STATIC_DRAW or DYNAMIC_DRAW depends on property buffer type (static / animated)
- GpuBuffer* vertexGpuBuffer = new GpuBuffer( *context, GpuBuffer::ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
+ GpuBuffer* vertexGpuBuffer = new GpuBuffer( context, GpuBuffer::ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
std::size_t dataSize = vertexBuffer->GetDataSize( bufferIndex );
vertexGpuBuffer->UpdateDataBuffer( dataSize, vertexBuffer->GetData( bufferIndex ) );
const PropertyBuffer* indexBuffer = geometry.GetIndexBuffer();
if( indexBuffer )
{
- GpuBuffer* indexGpuBuffer = new GpuBuffer( *context, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
+ GpuBuffer* indexGpuBuffer = new GpuBuffer( context, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
unsigned int dataSize = indexBuffer->GetDataSize( bufferIndex );
indexGpuBuffer->UpdateDataBuffer( dataSize, indexBuffer->GetData( bufferIndex ) );
}
}
-void RenderGeometry::EnableVertexAttributes( Context* context, Program& program )
+void RenderGeometry::EnableVertexAttributes( Context& context, Program& program )
{
// @todo Loop thru the array of vertex buffers
// @todo Use AttributeDataProvider to get the attrs and enable them
unsigned int gpuBufferIndex = 0;
GLint positionLoc = program.GetAttribLocation( Program::ATTRIB_POSITION );
- context->VertexAttribPointer( positionLoc,
+ context.VertexAttribPointer( positionLoc,
2, // 2D position
GL_FLOAT,
GL_FALSE, // Not normalized
mVertexBuffers[gpuBufferIndex]->GetStride(),
&vertex->x );
- context->EnableVertexAttributeArray( positionLoc );
+ context.EnableVertexAttributeArray( positionLoc );
GLint textureCoordsLoc = program.GetAttribLocation( Program::ATTRIB_TEXCOORD );
- context->VertexAttribPointer( textureCoordsLoc,
+ context.VertexAttribPointer( textureCoordsLoc,
2, // Texture Coords = U, V
GL_FLOAT,
GL_FALSE,
mVertexBuffers[gpuBufferIndex]->GetStride(),
&vertex->z );
- context->EnableVertexAttributeArray( textureCoordsLoc );
+ context.EnableVertexAttributeArray( textureCoordsLoc );
}
-void RenderGeometry::DisableVertexAttributes( Context* context, Program& program )
+void RenderGeometry::DisableVertexAttributes( Context& context, Program& program )
{
// @todo Loop thru the array of vertex buffers
// @todo Use AttributeDataProvider to get the attrs and disable them
GLint positionLoc = program.GetAttribLocation( Program::ATTRIB_POSITION );
GLint textureCoordsLoc = program.GetAttribLocation( Program::ATTRIB_TEXCOORD );
- context->DisableVertexAttributeArray( positionLoc );
- context->DisableVertexAttributeArray( textureCoordsLoc );
+ context.DisableVertexAttributeArray( positionLoc );
+ context.DisableVertexAttributeArray( textureCoordsLoc );
}
-void RenderGeometry::Draw( Context* context, BufferIndex bufferIndex, const GeometryDataProvider& geometry )
+void RenderGeometry::Draw( Context& context, BufferIndex bufferIndex, const GeometryDataProvider& geometry )
{
GeometryDataProvider::GeometryType type = geometry.GetGeometryType( bufferIndex );
{
case Dali::Geometry::TRIANGLES:
{
- context->DrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, 0);
+ context.DrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, 0);
break;
}
case Dali::Geometry::LINES:
{
- context->DrawElements(GL_LINES, numIndices, GL_UNSIGNED_SHORT, 0);
+ context.DrawElements(GL_LINES, numIndices, GL_UNSIGNED_SHORT, 0);
break;
}
case Dali::Geometry::POINTS:
numVertices = firstVertexBuffer->GetBufferSize() / stride;
}
- context->DrawArrays(GL_POINTS, 0, numVertices );
+ context.DrawArrays(GL_POINTS, 0, numVertices );
break;
}
default:
* @param[in] bufferIndex The current buffer index
* @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
*/
- void UploadAndDraw(Context* context,
+ void UploadAndDraw(Context& context,
Program& program,
BufferIndex bufferIndex,
const GeometryDataProvider& geometryDataProvider );
* @param[in] bufferIndex The current buffer index
* @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
*/
- void UploadVertexData( Context* context,
+ void UploadVertexData( Context& context,
BufferIndex bufferIndex,
const GeometryDataProvider& geometryDataProvider );
* @param[in] bufferIndex The current buffer index
* @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
*/
- void DoUpload( Context* context,
+ void DoUpload( Context& context,
BufferIndex bufferIndex,
const GeometryDataProvider& geometryDataProvider );
* @param[in] context The GL context
* @param[in] program The shader program to query for attribute locations
*/
- void EnableVertexAttributes( Context* context, Program& progam );
+ void EnableVertexAttributes( Context& context, Program& progam );
/**
* Disable the vertex attributes for each vertex buffer from the corresponding
* @param[in] context The GL context
* @param[in] program The shader program to query for attribute locations
*/
- void DisableVertexAttributes( Context* context, Program& program );
+ void DisableVertexAttributes( Context& context, Program& program );
/**
* Perform the correct draw call corresponding to the geometry type
* @param[in] bufferIndex The current buffer index
* @param[in] geometryDataProvider The geometry data provider (to fetch geometry from)
*/
- void Draw( Context* context,
+ void Draw( Context& context,
BufferIndex bufferIndex,
const GeometryDataProvider& geometry );
// Do nothing
}
-bool NewRenderer::IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix )
+bool NewRenderer::IsOutsideClipSpace( Context& context, const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix )
{
// @todo MESH_REWORK Add clipping
return false;
}
-void NewRenderer::DoSetUniforms( Shader* shader, Context* context, Program* program, BufferIndex bufferIndex, unsigned int programIndex, ShaderSubTypes subType )
+void NewRenderer::DoSetUniforms( Context& context, BufferIndex bufferIndex, Shader* shader, Program* program, unsigned int programIndex, ShaderSubTypes subType )
{
// Do nothing, we're going to set up the uniforms with our own code instead
}
-void NewRenderer::DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
+void NewRenderer::DoRender( Context& context, TextureCache& textureCache, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
{
- BindTextures( bufferIndex, program, mMaterialDataProvider->GetSamplers() );
+ BindTextures( textureCache, bufferIndex, program, mMaterialDataProvider->GetSamplers() );
SetUniforms( bufferIndex, program );
- mRenderGeometry.UploadAndDraw( mContext, program, bufferIndex, *mGeometryDataProvider );
+ mRenderGeometry.UploadAndDraw( context, program, bufferIndex, *mGeometryDataProvider );
}
void NewRenderer::GlContextDestroyed()
}
void NewRenderer::BindTextures(
- BufferIndex bufferIndex,
- Program& program,
- const MaterialDataProvider::Samplers& samplers )
+ TextureCache& textureCache,
+ BufferIndex bufferIndex,
+ Program& program,
+ const MaterialDataProvider::Samplers& samplers )
{
// @todo MESH_REWORK Write a cache of texture units to commonly used sampler textures
unsigned int textureUnit = 0;
{
const SamplerDataProvider* sampler = *iter;
ResourceId textureId = sampler->GetTextureId(bufferIndex);
- Texture* texture = mTextureCache->GetTexture( textureId );
+ Texture* texture = textureCache.GetTexture( textureId );
if( texture != NULL )
{
unsigned int textureUnitUniformIndex = GetTextureUnitUniformIndex( program, *sampler );
TextureUnit theTextureUnit = static_cast<TextureUnit>(textureUnit);
- BindTexture( program, textureId, texture, theTextureUnit, textureUnitUniformIndex );
+ BindTexture( textureCache, program, textureId, texture, theTextureUnit, textureUnitUniformIndex );
ApplySampler( bufferIndex, texture, theTextureUnit, *sampler );
}
}
void NewRenderer::BindTexture(
- Program& program,
- ResourceId id,
- Texture* texture,
- TextureUnit textureUnit,
- unsigned int textureUnitUniformIndex )
+ TextureCache& textureCache,
+ Program& program,
+ ResourceId id,
+ Texture* texture,
+ TextureUnit textureUnit,
+ unsigned int textureUnitUniformIndex )
{
- DALI_ASSERT_DEBUG( NULL != mTextureCache );
-
if( texture != NULL )
{
- mTextureCache->BindTexture( texture, id, GL_TEXTURE_2D, textureUnit );
+ textureCache.BindTexture( texture, id, GL_TEXTURE_2D, textureUnit );
// Set sampler uniform location for the texture
GLint textureUnitLoc = program.GetUniformLocation( textureUnitUniformIndex );
/**
* @copydoc SceneGraph::Renderer::IsOutsideClipSpace()
*/
- virtual bool IsOutsideClipSpace( const Matrix& modelMatrix,
+ virtual bool IsOutsideClipSpace( Context& context,
+ const Matrix& modelMatrix,
const Matrix& modelViewProjectionMatrix );
/**
* @copydoc SceneGraph::Renderer::DoSetUniforms()
*/
- virtual void DoSetUniforms(Shader* shader, Context* context, Program* program, BufferIndex bufferIndex, unsigned int programIndex, ShaderSubTypes subType );
+ virtual void DoSetUniforms( Context& context, BufferIndex bufferIndex, Shader* shader, Program* program, unsigned int programIndex, ShaderSubTypes subType );
/**
* @copydoc SceneGraph::Renderer::DoRender()
*/
- virtual void DoRender( BufferIndex bufferIndex,
+ virtual void DoRender( Context& context,
+ TextureCache& textureCache,
+ BufferIndex bufferIndex,
Program& program,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix );
/**
* Bind the material textures in the samplers and setup the samplers
+ * @param[in] textureCache The texture cache
* @param[in] bufferIndex The buffer index
* @param[in] program The shader program
* @param[in] samplers The samplers to bind
*/
- void BindTextures( BufferIndex bufferIndex,
+ void BindTextures( TextureCache& textureCache,
+ BufferIndex bufferIndex,
Program& program,
const MaterialDataProvider::Samplers& samplers );
/**
* Bind a material texture to a texture unit, and set the sampler's texture uniform
* to that texture unit.
+ * @param[in] textureCache The texture cache
* @param[in] program The shader program
* @param[in] id The resource id of the texture to bind
* @param[in] texture The texture to bind
* @param[in] textureUnit The texture unit index to use
* @param[in] nameIndex The index of the texture uniform in the program
*/
- void BindTexture( Program& program,
+ void BindTexture( TextureCache& textureCache,
+ Program& program,
ResourceId id,
Texture* texture,
TextureUnit textureUnit,
{
if ( mTextureId > 0 )
{
- mTextureCache->RemoveObserver(mTextureId, this);
+ mTextureCacheDELETEME->RemoveObserver(mTextureId, this);
}
GlCleanup();
{
if ( mTextureId > 0 )
{
- mTextureCache->RemoveObserver(mTextureId, this);
+ mTextureCacheDELETEME->RemoveObserver(mTextureId, this);
}
mTextureId = textureId;
if ( textureId > 0 )
{
- mTextureCache->AddObserver(textureId, this);
+ mTextureCacheDELETEME->AddObserver(textureId, this);
}
}
{
if( mTexture == NULL )
{
- mTexture = mTextureCache->GetTexture( mTextureId );
+ mTexture = mTextureCacheDELETEME->GetTexture( mTextureId );
}
if( mTexture == NULL )
Integration::ResourceId shaderTextureId = mShader->GetTextureIdToRender() ;
- if( shaderTextureId && mTextureCache->GetTexture( shaderTextureId ) == NULL )
+ if( shaderTextureId && mTextureCacheDELETEME->GetTexture( shaderTextureId ) == NULL )
{
return false;
}
outSubType = SHADER_DEFAULT;
}
-bool ImageRenderer::IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix )
+bool ImageRenderer::IsOutsideClipSpace( Context& context, const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix )
{
- mContext->IncrementRendererCount();
+ context.IncrementRendererCount();
Rect<float> boundingBox( mGeometrySize.x * -0.5f, mGeometrySize.y * -0.5f, mGeometrySize.x, mGeometrySize.y );
if(Is2dBoxOutsideClipSpace( modelMatrix, modelViewProjectionMatrix, boundingBox ) )
{
- mContext->IncrementCulledCount();
+ context.IncrementCulledCount();
return true;
}
return false;
}
-void ImageRenderer::DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
+void ImageRenderer::DoRender( Context& context, TextureCache& textureCache, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
{
DALI_LOG_INFO( gImageRenderFilter, Debug::Verbose, "DoRender() textureId=%d texture:%p\n", mTextureId, mTexture);
DALI_ASSERT_DEBUG( mVertexBuffer );
- mTextureCache->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TEXTURE_UNIT_IMAGE );
+ mTextureCacheDELETEME->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TEXTURE_UNIT_IMAGE );
if( mTexture->GetTextureId() == 0 )
{
if ( positionLoc != -1 )
{
- mContext->EnableVertexAttributeArray( positionLoc );
+ context.EnableVertexAttributeArray( positionLoc );
const int stride = 4 * sizeof(float);
- mContext->VertexAttribPointer( positionLoc, 2, GL_FLOAT, GL_FALSE, stride, 0 );
+ context.VertexAttribPointer( positionLoc, 2, GL_FLOAT, GL_FALSE, stride, 0 );
}
if ( texCoordLoc != -1 )
{
- mContext->EnableVertexAttributeArray( texCoordLoc );
+ context.EnableVertexAttributeArray( texCoordLoc );
const int stride = 4 * sizeof(float);
- mContext->VertexAttribPointer( texCoordLoc, 2, GL_FLOAT, GL_FALSE, stride, (const void*) (sizeof(float)*2) );
+ context.VertexAttribPointer( texCoordLoc, 2, GL_FLOAT, GL_FALSE, stride, (const void*) (sizeof(float)*2) );
}
switch(mMeshType)
case NINE_PATCH_NO_CENTER:
{
const GLsizei vertexCount = mVertexBuffer->GetBufferSize() / sizeof(Vertex2D); // compiler will optimize this to >> if possible
- mContext->DrawArrays( GL_TRIANGLE_STRIP, 0, vertexCount );
+ context.DrawArrays( GL_TRIANGLE_STRIP, 0, vertexCount );
break;
}
case GRID_QUAD:
{
const GLsizei indexCount = mIndexBuffer->GetBufferSize() / sizeof(GLushort); // compiler will optimize this to >> if possible
mIndexBuffer->Bind();
- mContext->DrawElements( GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, 0 );
+ context.DrawElements( GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, 0 );
break;
}
}
if ( positionLoc != -1 )
{
- mContext->DisableVertexAttributeArray( positionLoc );
+ context.DisableVertexAttributeArray( positionLoc );
}
if ( texCoordLoc != -1 )
{
- mContext->DisableVertexAttributeArray( texCoordLoc );
+ context.DisableVertexAttributeArray( texCoordLoc );
}
}
-void ImageRenderer::UpdateVertexBuffer( GLsizeiptr size, const GLvoid *data )
+void ImageRenderer::UpdateVertexBuffer( Context& context, GLsizeiptr size, const GLvoid *data )
{
// create/destroy if needed/not needed.
if ( size && !mVertexBuffer )
{
- mVertexBuffer = new GpuBuffer( *mContext, GpuBuffer::ARRAY_BUFFER, GpuBuffer::DYNAMIC_DRAW );
+ mVertexBuffer = new GpuBuffer( context, GpuBuffer::ARRAY_BUFFER, GpuBuffer::DYNAMIC_DRAW );
}
else if ( !size && mVertexBuffer )
{
}
}
-void ImageRenderer::UpdateIndexBuffer( GLsizeiptr size, const GLvoid *data )
+void ImageRenderer::UpdateIndexBuffer( Context& context, GLsizeiptr size, const GLvoid *data )
{
// create/destroy if needed/not needed.
if ( size && !mIndexBuffer )
{
- mIndexBuffer = new GpuBuffer( *mContext, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
+ mIndexBuffer = new GpuBuffer( context, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
}
else if ( !size && mIndexBuffer )
{
texture->MapUV( sizeof(verts)/sizeof(Vertex2D), verts, pixelArea );
- UpdateVertexBuffer( sizeof(verts), verts );
- UpdateIndexBuffer( 0, NULL );
+ UpdateVertexBuffer( *mContextDELETEME, sizeof(verts), verts );
+ UpdateIndexBuffer( *mContextDELETEME, 0, NULL );
}
void ImageRenderer::SetNinePatchMeshData( Texture* texture, const Vector2& size, const Vector4& border, bool borderInPixels, const PixelArea* pixelArea, bool noCenter )
const size_t vertsSize = sizeof( vertsWithCenter );
const unsigned int vertexCount = vertsSize / sizeof( vertsWithCenter[0] );
texture->MapUV( vertexCount, vertsWithCenter, pixelArea );
- UpdateVertexBuffer( vertsSize, vertsWithCenter );
+ UpdateVertexBuffer( *mContextDELETEME, vertsSize, vertsWithCenter );
}
else
{
const size_t vertsSize = sizeof( vertsWithNoCenter );
const unsigned int vertexCount = vertsSize / sizeof( vertsWithNoCenter[0] );
texture->MapUV( vertexCount, vertsWithNoCenter, pixelArea );
- UpdateVertexBuffer( vertsSize, vertsWithNoCenter );
+ UpdateVertexBuffer( *mContextDELETEME, vertsSize, vertsWithNoCenter );
}
// not using an index buffer
- UpdateIndexBuffer( 0, NULL );
+ UpdateIndexBuffer( *mContextDELETEME, 0, NULL );
}
texture->MapUV( totalVertices, vertices, pixelArea );
- UpdateVertexBuffer( totalVertices * sizeof(Vertex2D) , vertices );
- UpdateIndexBuffer( totalIndices * sizeof(GLushort), indices );
+ UpdateVertexBuffer( *mContextDELETEME, totalVertices * sizeof(Vertex2D) , vertices );
+ UpdateIndexBuffer( *mContextDELETEME, totalIndices * sizeof(GLushort), indices );
delete[] vertices;
delete[] indices;
/**
* @copydoc Dali::Internal::SceneGraph::Renderer::IsOutsideClipSpace()
*/
- virtual bool IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix );
+ virtual bool IsOutsideClipSpace( Context& context, const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix );
/**
* @copydoc Dali::Internal::SceneGraph::Renderer::DoRender()
*/
- virtual void DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix );
+ virtual void DoRender( Context& context, TextureCache& textureCache, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix );
protected: // TextureObserver implementation
/**
* Helper to update the vertex buffer.
*/
- void UpdateVertexBuffer( GLsizeiptr size, const GLvoid *data );
+ void UpdateVertexBuffer( Context& context, GLsizeiptr size, const GLvoid *data );
/**
* Helper to update the index buffer.
*/
- void UpdateIndexBuffer( GLsizeiptr size, const GLvoid *data );
+ void UpdateIndexBuffer( Context& context, GLsizeiptr size, const GLvoid *data );
/**
* Helper to generate mesh data when required
void Renderer::Initialize( Context& context, TextureCache& textureCache )
{
- mContext = &context;
- mTextureCache = &textureCache;
+ mContextDELETEME = &context;
+ mTextureCacheDELETEME = &textureCache;
}
Renderer::~Renderer()
mSamplerBitfield = samplerBitfield;
}
-void Renderer::Render( BufferIndex bufferIndex,
+void Renderer::Render( Context& context,
+ TextureCache& textureCache,
+ BufferIndex bufferIndex,
Shader& defaultShader,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
float frametime,
bool cull )
{
- DALI_ASSERT_DEBUG( mContext && "Renderer::Render. Renderer not initialised!! (mContext == NULL)." );
-
// @todo MESH_REWORK Fix when merging! :D
NewRenderer* renderer = dynamic_cast<NewRenderer*>(this);
if( renderer )
ShaderSubTypes subType=SHADER_DEFAULT;
ResolveGeometryTypes( bufferIndex, geometryType, subType );
unsigned int programIndex = 0;
- Program* program = mShader->GetProgram( *mContext, geometryType, subType, programIndex );
+ Program* program = mShader->GetProgram( context, geometryType, subType, programIndex );
if( !program )
{
// if program is NULL it means this is a custom shader with non matching geometry type so we need to use default shaders program
- program = defaultShader.GetProgram( *mContext, geometryType, subType, programIndex );
+ program = defaultShader.GetProgram( context, geometryType, subType, programIndex );
DALI_ASSERT_ALWAYS( program && "Default shader is missing a geometry type!!" );
}
// Check culling (does not need the program to be in use)
if( cull && ! program->ModifiesGeometry() )
{
- if( IsOutsideClipSpace( modelMatrix, gModelViewProjectionMatrix ) )
+ if( IsOutsideClipSpace( context, modelMatrix, gModelViewProjectionMatrix ) )
{
// don't do any further gl state changes as this renderer is not visible
return;
program->Use();
// Enables/disables blending mode.
- mContext->SetBlend( mUseBlend );
+ context.SetBlend( mUseBlend );
// Set face culling mode
- mContext->CullFace( mCullFaceMode );
+ context.CullFace( mCullFaceMode );
// Set the blend color
const Vector4* const customColor = mBlendingOptions.GetBlendColor();
if( customColor )
{
- mContext->SetCustomBlendColor( *customColor );
+ context.SetCustomBlendColor( *customColor );
}
else
{
- mContext->SetDefaultBlendColor();
+ context.SetDefaultBlendColor();
}
// Set blend source & destination factors
- mContext->BlendFuncSeparate( mBlendingOptions.GetBlendSrcFactorRgb(),
+ context.BlendFuncSeparate( mBlendingOptions.GetBlendSrcFactorRgb(),
mBlendingOptions.GetBlendDestFactorRgb(),
mBlendingOptions.GetBlendSrcFactorAlpha(),
mBlendingOptions.GetBlendDestFactorAlpha() );
// Set blend equations
- mContext->BlendEquationSeparate( mBlendingOptions.GetBlendEquationRgb(),
+ context.BlendEquationSeparate( mBlendingOptions.GetBlendEquationRgb(),
mBlendingOptions.GetBlendEquationAlpha() );
// Ignore missing uniforms - custom shaders and flat color shaders don't have SAMPLER
program->SetUniform1f( loc, frametime );
}
- DoSetUniforms(mShader, mContext, program, bufferIndex, programIndex, subType );
+ DoSetUniforms(context, bufferIndex, mShader, program, programIndex, subType );
// subclass rendering and actual draw call
- DoRender( bufferIndex, *program, modelViewMatrix, viewMatrix );
+ DoRender( context, textureCache, bufferIndex, *program, modelViewMatrix, viewMatrix );
}
// can be overridden by deriving class
-void Renderer::DoSetUniforms(Shader* shader, Context* context, Program* program, BufferIndex bufferIndex, unsigned int programIndex, ShaderSubTypes subType )
+void Renderer::DoSetUniforms(Context& context, BufferIndex bufferIndex, Shader* shader, Program* program, unsigned int programIndex, ShaderSubTypes subType )
{
- shader->SetUniforms( *context, *program, bufferIndex, programIndex, subType );
+ shader->SetUniforms( context, *program, bufferIndex, programIndex, subType );
}
Renderer::Renderer( NodeDataProvider& dataprovider )
: mDataProvider( dataprovider ),
- mContext( NULL ),
-
- mTextureCache( NULL ),
+ mContextDELETEME(NULL),
+ mTextureCacheDELETEME( NULL ),
mShader( NULL ),
mSamplerBitfield( ImageSampler::PackBitfield( FilterMode::DEFAULT, FilterMode::DEFAULT ) ),
mUseBlend( false ),
/**
* Second-phase construction.
* This is called when the renderer is inside render thread
- * @param[in] context to use
* @param[in] textureCache to use
*/
void Initialize( Context& context, TextureCache& textureCache );
/**
* Called to render during RenderManager::Render().
+ * @param[in] context The context used for rendering
+ * @param[in] textureCache The texture cache used to get textures
* @param[in] bufferIndex The index of the previous update buffer.
* @param[in] defaultShader in case there is no custom shader
* @param[in] modelViewMatrix The model-view matrix.
* @param[in] frametime The elapsed time between the last two updates.
* @param[in] cull Whether to frustum cull this renderer
*/
- void Render( BufferIndex bufferIndex,
+ void Render( Context& context,
+ TextureCache& textureCache,
+ BufferIndex bufferIndex,
Shader& defaultShader,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
* @param[in] modelViewProjectionMatrix The MVP matrix.
* @return \e true if it is. Otherwise \e false.
*/
- virtual bool IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix ) = 0;
+ virtual bool IsOutsideClipSpace( Context& context, const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix ) = 0;
/**
* Called from Render prior to DoRender().
* @todo MESH_REWORK Remove after merge
*/
- virtual void DoSetUniforms(Shader* shader, Context* context, Program* program, BufferIndex bufferIndex, unsigned int programIndex, ShaderSubTypes subType );
+ virtual void DoSetUniforms(Context& context, BufferIndex bufferIndex, Shader* shader, Program* program, unsigned int programIndex, ShaderSubTypes subType );
/**
* Called from Render; implemented in derived classes.
+ * @param[in] context The context used for rendering
+ * @param[in] textureCache The texture cache used to get textures
* @param[in] bufferIndex The index of the previous update buffer.
* @param[in] program to use.
* @param[in] modelViewMatrix The model-view matrix.
* @param[in] viewMatrix The view matrix.
*/
- virtual void DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix ) = 0;
+ virtual void DoRender( Context& context, TextureCache& textureCache, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix ) = 0;
protected:
NodeDataProvider& mDataProvider;
- Context* mContext;
- TextureCache* mTextureCache;
+
+ Context* mContextDELETEME; // TODO: MESH_REWORK DELETE THIS
+ TextureCache* mTextureCacheDELETEME; // TODO: MESH_REWORK DELETE THIS
Shader* mShader;
unsigned int mSamplerBitfield; ///< Sampler options used for texture filtering
{
if(mTextureId > 0)
{
- mTextureCache->RemoveObserver(mTextureId, this);
+ mTextureCacheDELETEME->RemoveObserver(mTextureId, this);
}
GlCleanup();
if(mTextureId > 0)
{
- mTextureCache->RemoveObserver(mTextureId, this);
+ mTextureCacheDELETEME->RemoveObserver(mTextureId, this);
}
mTextureId = textureId;
if(textureId > 0)
{
- mTextureCache->AddObserver(textureId, this);
+ mTextureCacheDELETEME->AddObserver(textureId, this);
}
}
{
SetTextureId(vertexData->mTextureId);
+ DALI_ASSERT_DEBUG(mContextDELETEME);
if ( !mVertexBuffer )
{
- mVertexBuffer = new GpuBuffer( *mContext, GpuBuffer::ARRAY_BUFFER, GpuBuffer::DYNAMIC_DRAW );
+ mVertexBuffer = new GpuBuffer( *mContextDELETEME, GpuBuffer::ARRAY_BUFFER, GpuBuffer::DYNAMIC_DRAW );
}
if ( !mIndexBuffer )
{
- mIndexBuffer = new GpuBuffer( *mContext, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
+ mIndexBuffer = new GpuBuffer( *mContextDELETEME, GpuBuffer::ELEMENT_ARRAY_BUFFER, GpuBuffer::STATIC_DRAW );
}
mVertexBuffer->UpdateDataBuffer( vertexData->mVertices.size() * sizeof(TextVertex2D), &vertexData->mVertices[0] );
if( mTexture == NULL )
{
- mTexture = mTextureCache->GetTexture( mTextureId );
+ mTexture = mTextureCacheDELETEME->GetTexture( mTextureId );
if( mTexture == NULL )
{
}
}
-bool TextRenderer::IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix )
+bool TextRenderer::IsOutsideClipSpace( Context& context, const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix )
{
- mContext->IncrementRendererCount();
+ context.IncrementRendererCount();
Rect<float> boundingBox(mGeometryExtent.width*-0.5f, mGeometryExtent.height*-0.5f, mGeometryExtent.width, mGeometryExtent.height);
DEBUG_BOUNDING_BOX( *mContext, boundingBox, modelViewProjectionMatrix );
if(Is2dBoxOutsideClipSpace( modelMatrix, modelViewProjectionMatrix, boundingBox ) )
{
- mContext->IncrementCulledCount();
+ context.IncrementCulledCount();
return true;
}
return false;
}
-void TextRenderer::DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
+void TextRenderer::DoRender( Context& context, TextureCache& textureCache, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
{
DALI_ASSERT_DEBUG( NULL != mTexture && "TextRenderer::DoRender. mTexture == NULL." );
if( NULL == mTexture )
DALI_LOG_INFO( gTextFilter, Debug::General, "TextRenderer::DoRender(this: %p) textureId:%d\n", this, mTextureId );
- mTextureCache->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TEXTURE_UNIT_TEXT );
+ mTextureCacheDELETEME->BindTexture( mTexture, mTextureId, GL_TEXTURE_2D, TEXTURE_UNIT_TEXT );
if( mTexture->GetTextureId() == 0 )
{
return; // early out if we haven't got a GL texture yet (e.g. due to context loss)
const GLint positionLoc = program.GetAttribLocation(Program::ATTRIB_POSITION);
const GLint texCoordLoc = program.GetAttribLocation(Program::ATTRIB_TEXCOORD);
- mContext->EnableVertexAttributeArray( positionLoc );
- mContext->EnableVertexAttributeArray( texCoordLoc );
+ context.EnableVertexAttributeArray( positionLoc );
+ context.EnableVertexAttributeArray( texCoordLoc );
// bind the buffers
DALI_ASSERT_DEBUG( mVertexBuffer->BufferIsValid() );
mIndexBuffer->Bind();
TextVertex2D* v = 0;
- mContext->VertexAttribPointer(positionLoc, 2, GL_FLOAT, GL_FALSE, sizeof(TextVertex2D), &v->mX);
- mContext->VertexAttribPointer(texCoordLoc, 4, GL_FLOAT, GL_FALSE, sizeof(TextVertex2D), &v->mU);
+ context.VertexAttribPointer(positionLoc, 2, GL_FLOAT, GL_FALSE, sizeof(TextVertex2D), &v->mX);
+ context.VertexAttribPointer(texCoordLoc, 4, GL_FLOAT, GL_FALSE, sizeof(TextVertex2D), &v->mU);
const GLsizei indexCount = mIndexBuffer->GetBufferSize() / sizeof(GLushort); // compiler will optimize this to >> if possible
- mContext->DrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, (void *) 0);
+ context.DrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, (void *) 0);
- mContext->DisableVertexAttributeArray( positionLoc );
- mContext->DisableVertexAttributeArray( texCoordLoc );
+ context.DisableVertexAttributeArray( positionLoc );
+ context.DisableVertexAttributeArray( texCoordLoc );
}
/**
* @copydoc Dali::Internal::SceneGraph::Renderer::IsOutsideClipSpace()
*/
- virtual bool IsOutsideClipSpace( const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix );
+ virtual bool IsOutsideClipSpace( Context& context, const Matrix& modelMatrix, const Matrix& modelViewProjectionMatrix );
/**
* @copydoc Dali::Internal::SceneGraph::Renderer::DoRender()
*/
- virtual void DoRender( BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix );
+ virtual void DoRender( Context& context, TextureCache& textureCache, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix );
protected: // TextureObserver implementation
/**