X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Frenderers%2Frender-renderer.cpp;h=021c10648c830b86425217f94bf1d958ce844139;hb=9ac94c145f620fc90c39a0f3dadbd88cc4b01940;hp=9e83849b200173ac4e920f128afbf5469bda795c;hpb=6595100a16e71e0e324087a782187f4c182a4235;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/renderers/render-renderer.cpp b/dali/internal/render/renderers/render-renderer.cpp index 9e83849..021c106 100644 --- a/dali/internal/render/renderers/render-renderer.cpp +++ b/dali/internal/render/renderers/render-renderer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Samsung Electronics Co., Ltd. + * 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. @@ -18,7 +18,6 @@ // CLASS HEADER #include - // INTERNAL INCLUDES #include #include @@ -26,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -118,9 +116,12 @@ Renderer* Renderer::New( SceneGraph::RenderDataProvider* dataProvider, bool preMultipliedAlphaEnabled, DepthWriteMode::Type depthWriteMode, DepthTestMode::Type depthTestMode, - DepthFunction::Type depthFunction ) + DepthFunction::Type depthFunction, + StencilParameters& stencilParameters ) { - return new Renderer( dataProvider, geometry, blendingBitmask, blendColor, faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode, depthTestMode, depthFunction ); + return new Renderer( dataProvider, geometry, blendingBitmask, blendColor, + faceCullingMode, preMultipliedAlphaEnabled, depthWriteMode, depthTestMode, + depthFunction, stencilParameters ); } Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider, @@ -131,19 +132,20 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider, bool preMultipliedAlphaEnabled, DepthWriteMode::Type depthWriteMode, DepthTestMode::Type depthTestMode, - DepthFunction::Type depthFunction ) + DepthFunction::Type depthFunction, + StencilParameters& stencilParameters ) : mRenderDataProvider( dataProvider ), - mContext(NULL), + mContext( NULL), mTextureCache( NULL ), - mUniformNameCache( NULL ), mGeometry( geometry ), mUniformIndexMap(), mAttributesLocation(), + mStencilParameters( stencilParameters ), mBlendingOptions(), - mFaceCullingMode( faceCullingMode ), - mDepthFunction( depthFunction ), mIndexedDrawFirstElement( 0 ), mIndexedDrawElementsCount( 0 ), + mDepthFunction( depthFunction ), + mFaceCullingMode( faceCullingMode ), mDepthWriteMode( depthWriteMode ), mDepthTestMode( depthTestMode ), mUpdateAttributesLocation( true ), @@ -160,11 +162,10 @@ Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider, } } -void Renderer::Initialize( Context& context, SceneGraph::TextureCache& textureCache, Render::UniformNameCache& uniformNameCache ) +void Renderer::Initialize( Context& context, SceneGraph::TextureCache& textureCache ) { mContext = &context; mTextureCache = &textureCache; - mUniformNameCache = &uniformNameCache; } Renderer::~Renderer() @@ -369,23 +370,29 @@ bool Renderer::BindTextures( Context& context, SceneGraph::TextureCache& texture Internal::Texture* texture = textureCache.GetTexture( textureId ); if( texture ) { - result = program.GetSamplerUniformLocation( i, uniformLocation ) && - textureCache.BindTexture( texture, textureId, GL_TEXTURE_2D, (TextureUnit)textureUnit ); + result = textureCache.BindTexture( texture, textureId, GL_TEXTURE_2D, (TextureUnit)textureUnit ); - if( result && Program::UNIFORM_UNKNOWN != uniformLocation ) + if( result ) { - program.SetUniform1i( uniformLocation, textureUnit ); + GLint uniformLocation; - unsigned int samplerBitfield(ImageSampler::DEFAULT_BITFIELD); - const Render::Sampler* sampler( samplers[i] ); - if( sampler ) + //TODO : This is a bug, result variable is being shadowed. Fix it! + bool result = program.GetSamplerUniformLocation( i, uniformLocation ); + if( result && Program::UNIFORM_UNKNOWN != uniformLocation ) { - samplerBitfield = sampler->mBitfield; - } + program.SetUniform1i( uniformLocation, textureUnit ); - texture->ApplySampler( (TextureUnit)textureUnit, samplerBitfield ); + unsigned int samplerBitfield(ImageSampler::DEFAULT_BITFIELD); + const Render::Sampler* sampler( samplers[i] ); + if( sampler ) + { + samplerBitfield = sampler->mBitfield; + } - ++textureUnit; + texture->ApplySampler( (TextureUnit)textureUnit, samplerBitfield ); + + ++textureUnit; + } } } } @@ -469,6 +476,86 @@ DepthFunction::Type Renderer::GetDepthFunction() const return mDepthFunction; } +void Renderer::SetRenderMode( RenderMode::Type renderMode ) +{ + mStencilParameters.renderMode = renderMode; +} + +RenderMode::Type Renderer::GetRenderMode() const +{ + return mStencilParameters.renderMode; +} + +void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction ) +{ + mStencilParameters.stencilFunction = stencilFunction; +} + +StencilFunction::Type Renderer::GetStencilFunction() const +{ + return mStencilParameters.stencilFunction; +} + +void Renderer::SetStencilFunctionMask( int stencilFunctionMask ) +{ + mStencilParameters.stencilFunctionMask = stencilFunctionMask; +} + +int Renderer::GetStencilFunctionMask() const +{ + return mStencilParameters.stencilFunctionMask; +} + +void Renderer::SetStencilFunctionReference( int stencilFunctionReference ) +{ + mStencilParameters.stencilFunctionReference = stencilFunctionReference; +} + +int Renderer::GetStencilFunctionReference() const +{ + return mStencilParameters.stencilFunctionReference; +} + +void Renderer::SetStencilMask( int stencilMask ) +{ + mStencilParameters.stencilMask = stencilMask; +} + +int Renderer::GetStencilMask() const +{ + return mStencilParameters.stencilMask; +} + +void Renderer::SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail ) +{ + mStencilParameters.stencilOperationOnFail = stencilOperationOnFail; +} + +StencilOperation::Type Renderer::GetStencilOperationOnFail() const +{ + return mStencilParameters.stencilOperationOnFail; +} + +void Renderer::SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail ) +{ + mStencilParameters.stencilOperationOnZFail = stencilOperationOnZFail; +} + +StencilOperation::Type Renderer::GetStencilOperationOnZFail() const +{ + return mStencilParameters.stencilOperationOnZFail; +} + +void Renderer::SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass ) +{ + mStencilParameters.stencilOperationOnZPass = stencilOperationOnZPass; +} + +StencilOperation::Type Renderer::GetStencilOperationOnZPass() const +{ + return mStencilParameters.stencilOperationOnZPass; +} + void Renderer::Render( Context& context, SceneGraph::TextureCache& textureCache, BufferIndex bufferIndex, @@ -490,7 +577,7 @@ void Renderer::Render( Context& context, DALI_ASSERT_DEBUG( program && "Default shader should always have a program available." ); if( !program ) { - DALI_LOG_ERROR( "Failed to get program for shader at address %p.", (void*)&mRenderDataProvider->GetShader() ); + DALI_LOG_ERROR( "Failed to get program for shader at address %p.\n", (void*)&mRenderDataProvider->GetShader() ); return; } } @@ -538,7 +625,7 @@ void Renderer::Render( Context& context, } } -void Renderer::SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RendererWithSortAttributes& sortAttributes ) const +void Renderer::SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes ) const { sortAttributes.shader = &( mRenderDataProvider->GetShader() ); const std::vector& textures( mRenderDataProvider->GetTextures() );