/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
BlendingOptions::~BlendingOptions()
{
- delete mBlendColor;
}
void BlendingOptions::SetBitmask( unsigned int bitmask )
void BlendingOptions::SetBlendColor( const Vector4& color )
{
- if( Vector4::ZERO == color )
+ if( Color::TRANSPARENT == color )
{
- if( mBlendColor )
- {
- // Discard unnecessary vector
- delete mBlendColor;
- mBlendColor = NULL;
- }
- return;
- }
-
- if( mBlendColor )
- {
- *mBlendColor = color;
+ mBlendColor = NULL;
}
else
{
- // Lazy allocation when non-default is set
- mBlendColor = new Vector4( color );
+ if( mBlendColor )
+ {
+ *mBlendColor = color;
+ }
+ else
+ {
+ // Lazy allocation when non-default is set
+ mBlendColor = new Vector4( color );
+ }
}
}
const Vector4* BlendingOptions::GetBlendColor() const
{
- return mBlendColor;
+ return mBlendColor.Get();
}
} // namespace Internal
#define DALI_BLENDING_OPTIONS_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
// INTERNAL INCLUDES
#include <dali/public-api/rendering/renderer.h>
#include <dali/public-api/math/vector4.h>
+#include <dali/internal/common/owner-pointer.h>
namespace Dali
{
unsigned int mBitmask; ///< A bitmask of blending options
- Vector4* mBlendColor; ///< A heap-allocated color (owned)
+ OwnerPointer< Vector4> mBlendColor; ///< A heap-allocated color (owned)
};
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
}
-void Renderer::SetBlendColor( const Vector4& color )
-{
- if( !mBlendColor )
- {
- mBlendColor = new Vector4();
- }
- if( *mBlendColor != color )
- {
- *mBlendColor = color;
- SetBlendColorMessage( GetEventThreadServices(), *mSceneObject, *mBlendColor );
- }
-}
-
-Vector4 Renderer::GetBlendColor() const
-{
- if( mBlendColor )
- {
- return *mBlendColor;
- }
- return Color::TRANSPARENT; // GL default
-}
-
void Renderer::SetIndexedDrawFirstElement( size_t firstElement )
{
if( firstElement != mIndexedDrawFirstElement )
}
case Dali::Renderer::Property::BLEND_COLOR:
{
- if( mBlendColor )
- {
- value = *mBlendColor;
- }
- else
- {
- value = Color::TRANSPARENT;
- }
+ value = GetBlendColor();
break;
}
case Dali::Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA:
Renderer::Renderer()
: mSceneObject(NULL ),
- mBlendColor( NULL ),
mDepthIndex( 0 ),
mIndexedDrawFirstElement( 0 ),
mIndexedDrawElementCount( 0 ),
eventThreadServices.RegisterObject( this );
}
+void Renderer::SetBlendColor( const Vector4& blendColor )
+{
+ mBlendingOptions.SetBlendColor( blendColor );
+ SetBlendColorMessage( GetEventThreadServices(), *mSceneObject, GetBlendColor() );
+}
+
+const Vector4& Renderer::GetBlendColor() const
+{
+ const Vector4* blendColor = mBlendingOptions.GetBlendColor();
+ if( blendColor )
+ {
+ return *blendColor;
+ }
+ return Color::TRANSPARENT; // GL default
+}
+
Renderer::~Renderer()
{
if( EventThreadServices::IsCoreRunning() )
#define DALI_INTERNAL_RENDERER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
void GetBlendEquation( BlendEquation::Type& equationRgb, BlendEquation::Type& equationAlpha ) const;
/**
- * @copydoc Dali::Renderer::SetBlendColor()
- */
- void SetBlendColor( const Vector4& color );
-
- /**
- * @copydoc Dali::Renderer::GetBlendColor()
- */
- Vector4 GetBlendColor() const;
-
- /**
* @copydoc Dali::Renderer::SetIndexedDrawFirstElement
*/
void SetIndexedDrawFirstElement( size_t firstElement );
virtual int GetPropertyComponentIndex( Property::Index index ) const;
private: // implementation
+
+ /**
+ * @brief Default constructor.
+ */
Renderer();
+ /**
+ * @brief Initializes the Renderer.
+ */
void Initialize();
+ /**
+ * @brief Sets the blend color.
+ * @param[in] blendColor The blend color to set.
+ */
+ void SetBlendColor( const Vector4& blendColor );
+
+ /**
+ * @brief Retrieves the blend-color.
+ * @return A const reference to the blend-color
+ */
+ const Vector4& GetBlendColor() const;
+
protected:
/**
* A reference counted object may only be deleted by calling Unreference()
Renderer& operator=( const Renderer& );
private: // data
- SceneGraph::Renderer* mSceneObject;
- Vector4* mBlendColor; ///< Local copy of blend color, pointer only as its rarely used
- GeometryPtr mGeometry; ///< Connector that holds the geometry used by this renderer
- TextureSetPtr mTextureSet; ///< Connector that holds the texture set used by this renderer
- ShaderPtr mShader; ///< Connector that holds the shader used by this renderer
-
- int mDepthIndex;
-
- size_t mIndexedDrawFirstElement; ///< Offset of first element to draw from bound index buffer
- size_t mIndexedDrawElementCount; ///< Number of elements to draw
-
- Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
- BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
-
- DepthFunction::Type mDepthFunction:3; ///< Local copy of the depth function
- FaceCullingMode::Type mFaceCullingMode:2; ///< Local copy of the mode of face culling
- BlendMode::Type mBlendMode:2; ///< Local copy of the mode of blending
- DepthWriteMode::Type mDepthWriteMode:2; ///< Local copy of the depth write mode
- DepthTestMode::Type mDepthTestMode:2; ///< Local copy of the depth test mode
- bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
+ SceneGraph::Renderer* mSceneObject;
+ GeometryPtr mGeometry; ///< Connector that holds the geometry used by this renderer
+ TextureSetPtr mTextureSet; ///< Connector that holds the texture set used by this renderer
+ ShaderPtr mShader; ///< Connector that holds the shader used by this renderer
+
+ int mDepthIndex;
+
+ size_t mIndexedDrawFirstElement; ///< Offset of first element to draw from bound index buffer
+ size_t mIndexedDrawElementCount; ///< Number of elements to draw
+
+ Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
+ BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
+
+ DepthFunction::Type mDepthFunction:3; ///< Local copy of the depth function
+ FaceCullingMode::Type mFaceCullingMode:2; ///< Local copy of the mode of face culling
+ BlendMode::Type mBlendMode:2; ///< Local copy of the mode of blending
+ DepthWriteMode::Type mDepthWriteMode:2; ///< Local copy of the depth write mode
+ DepthTestMode::Type mDepthTestMode:2; ///< Local copy of the depth test mode
+ bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
};
} // namespace Internal
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
Renderer* Renderer::New( SceneGraph::RenderDataProvider* dataProvider,
Render::Geometry* geometry,
unsigned int blendingBitmask,
- const Vector4* blendColor,
+ const Vector4& blendColor,
FaceCullingMode::Type faceCullingMode,
bool preMultipliedAlphaEnabled,
DepthWriteMode::Type depthWriteMode,
Renderer::Renderer( SceneGraph::RenderDataProvider* dataProvider,
Render::Geometry* geometry,
unsigned int blendingBitmask,
- const Vector4* blendColor,
+ const Vector4& blendColor,
FaceCullingMode::Type faceCullingMode,
bool preMultipliedAlphaEnabled,
DepthWriteMode::Type depthWriteMode,
mUpdateAttributesLocation( true ),
mPremultipledAlphaEnabled( preMultipliedAlphaEnabled )
{
- if( blendingBitmask != 0u )
+ if( blendingBitmask != 0u )
{
mBlendingOptions.SetBitmask( blendingBitmask );
}
- if( blendColor )
- {
- mBlendingOptions.SetBlendColor( *blendColor );
- }
+ mBlendingOptions.SetBlendColor( blendColor );
}
void Renderer::Initialize( Context& context )
mBlendingOptions.SetBitmask( bitmask );
}
-void Renderer::SetBlendColor( const Vector4* color )
+void Renderer::SetBlendColor( const Vector4& color )
{
- mBlendingOptions.SetBlendColor( *color );
+ mBlendingOptions.SetBlendColor( color );
}
void Renderer::SetIndexedDrawFirstElement( size_t firstElement )
#define DALI_INTERNAL_RENDER_RENDERER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
static Renderer* New( SceneGraph::RenderDataProvider* dataProviders,
Render::Geometry* geometry,
unsigned int blendingBitmask,
- const Vector4* blendColor,
+ const Vector4& blendColor,
FaceCullingMode::Type faceCullingMode,
bool preMultipliedAlphaEnabled,
DepthWriteMode::Type depthWriteMode,
Renderer( SceneGraph::RenderDataProvider* dataProviders,
Render::Geometry* geometry,
unsigned int blendingBitmask,
- const Vector4* blendColor,
+ const Vector4& blendColor,
FaceCullingMode::Type faceCullingMode,
bool preMultipliedAlphaEnabled,
DepthWriteMode::Type depthWriteMode,
* Set the blend color for blending options
* @param[in] blendColor The blend color to pass to GL
*/
- void SetBlendColor( const Vector4* color );
+ void SetBlendColor( const Vector4& color );
/**
* Set the first element index to draw by the indexed draw
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
if( mResendFlag & RESEND_BLEND_COLOR )
{
- typedef MessageValue1< Render::Renderer, const Vector4* > DerivedType;
+ typedef MessageValue1< Render::Renderer, Vector4 > DerivedType;
unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- new (slot) DerivedType( mRenderer, &Render::Renderer::SetBlendColor, mBlendColor );
+ new (slot) DerivedType( mRenderer, &Render::Renderer::SetBlendColor, GetBlendColor() );
}
if( mResendFlag & RESEND_PREMULTIPLIED_ALPHA )
void Renderer::SetBlendColor( const Vector4& blendColor )
{
- if( !mBlendColor )
+ if( blendColor == Color::TRANSPARENT )
{
- mBlendColor = new Vector4( blendColor );
+ mBlendColor = NULL;
}
else
{
- *mBlendColor = blendColor;
+ if( !mBlendColor )
+ {
+ mBlendColor = new Vector4( blendColor );
+ }
+ else
+ {
+ *mBlendColor = blendColor;
+ }
}
mResendFlag |= RESEND_BLEND_COLOR;
mSceneController = &sceneController;
RenderDataProvider* dataProvider = NewRenderDataProvider();
- mRenderer = Render::Renderer::New( dataProvider, mGeometry, mBlendBitmask, mBlendColor, static_cast< FaceCullingMode::Type >( mFaceCullingMode ),
+ mRenderer = Render::Renderer::New( dataProvider, mGeometry, mBlendBitmask, GetBlendColor(), static_cast< FaceCullingMode::Type >( mFaceCullingMode ),
mPremultipledAlphaEnabled, mDepthWriteMode, mDepthTestMode, mDepthFunction, mStencilParameters );
mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer );
return dataProvider;
}
+const Vector4& Renderer::GetBlendColor() const
+{
+ if( mBlendColor )
+ {
+ return *mBlendColor;
+ }
+ return Color::TRANSPARENT;
+}
+
Render::Renderer& Renderer::GetRenderer()
{
return *mRenderer;
#define DALI_INTERNAL_SCENE_GRAPH_RENDERER_H
/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
*/
RenderDataProvider* NewRenderDataProvider();
+ /**
+ * Helper function to retrieve the blend color.
+ * @return The blend color.
+ */
+ const Vector4& GetBlendColor() const;
+
private:
CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps collected by the renderer
TextureSet* mTextureSet; ///< The texture set this renderer uses. (Not owned)
Render::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned)
Shader* mShader; ///< The shader this renderer uses. (Not owned)
- Vector4* mBlendColor; ///< The blend color for blending operation
+ OwnerPointer< Vector4 > mBlendColor; ///< The blend color for blending operation
Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options