/*
- * 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)
};
GestureManager& gestureManager, ResourcePolicy::DataRetention dataRetentionPolicy)
: mRenderController( renderController ),
mPlatform(platform),
- mGestureEventProcessor(NULL),
- mEventProcessor(NULL),
- mUpdateManager(NULL),
- mRenderManager(NULL),
- mDiscardQueue(NULL),
- mNotificationManager(NULL),
- mShaderFactory(NULL),
mIsActive(true),
mProcessingEvent(false)
{
// remove (last?) reference to stage
mStage.Reset();
- delete mEventProcessor;
- delete mGestureEventProcessor;
- delete mNotificationManager;
- delete mShaderFactory;
- delete mDiscardQueue;
- delete mUpdateManager;
- delete mRenderManager;
- delete mRenderTaskProcessor;
}
Integration::ContextNotifierInterface* Core::GetContextNotifier()
Integration::PlatformAbstraction& mPlatform; ///< The interface providing platform specific services.
IntrusivePtr<Stage> mStage; ///< The current stage
- GestureEventProcessor* mGestureEventProcessor; ///< The gesture event processor
- EventProcessor* mEventProcessor; ///< The event processor
- SceneGraph::UpdateManager* mUpdateManager; ///< Update manager
- SceneGraph::RenderManager* mRenderManager; ///< Render manager
- SceneGraph::DiscardQueue* mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
- NotificationManager* mNotificationManager; ///< Notification manager
AnimationPlaylistOwner mAnimationPlaylist; ///< For 'Fire and forget' animation support
OwnerPointer<PropertyNotificationManager> mPropertyNotificationManager; ///< For safe signal emmision of property changed notifications
- ShaderFactory* mShaderFactory; ///< Shader resource factory
IntrusivePtr< RelayoutController > mRelayoutController; ///< Size negotiation relayout controller
- SceneGraph::RenderTaskProcessor* mRenderTaskProcessor; ///< Handles the processing of render tasks
bool mIsActive : 1; ///< Whether Core is active or suspended
bool mProcessingEvent : 1; ///< True during ProcessEvents()
+ OwnerPointer<SceneGraph::RenderTaskProcessor> mRenderTaskProcessor; ///< Handles the processing of render tasks
+ OwnerPointer<SceneGraph::RenderManager> mRenderManager; ///< Render manager
+ OwnerPointer<SceneGraph::UpdateManager> mUpdateManager; ///< Update manager
+ OwnerPointer<SceneGraph::DiscardQueue> mDiscardQueue; ///< Used to cleanup nodes & resources when no longer in use.
+ OwnerPointer<ShaderFactory> mShaderFactory; ///< Shader resource factory
+ OwnerPointer<NotificationManager> mNotificationManager; ///< Notification manager
+ OwnerPointer<GestureEventProcessor> mGestureEventProcessor; ///< The gesture event processor
+ OwnerPointer<EventProcessor> mEventProcessor; ///< The event processor
+
friend class ThreadLocalStorage;
};
* Default constructor. Creates an OwnerPointer that does not own any object.
*/
OwnerPointer()
+ : mObject(NULL)
{
- mObject = NULL;
}
/**
* @param[in] object A pointer to a heap allocated object.
*/
OwnerPointer( T* object )
+ : mObject(object)
{
- mObject = object;
}
/**
* @param[in] other The pointer that gives away the ownership.
*/
OwnerPointer( OwnerPointer& other )
+ : mObject(NULL)
{
- Init( other );
+ Swap( other );
}
/**
{
if( this != &other ) // no self-assignment
{
- Reset();
- Init( other );
+ // Creation of temportaty object to prevent premature deletion of object
+ OwnerPointer(other).Swap(*this);
}
// return self
return mObject;
}
+ /**
+ * Swap owned objects
+ */
+ void Swap( OwnerPointer& other )
+ {
+ T* tmp = mObject;
+ mObject = other.mObject;
+ other.mObject = tmp;
+ }
+
// Handle comparisons - This is a variation of the safe bool idiom
/**
*/
void ThisIsSaferThanReturningVoidStar() const {}
-private:
-
- /**
- * Initialise this pointer from another one.
- * ownerPointer parameter looses ownership.
- * @param ownerPointer owner pointer
- */
- void Init( OwnerPointer& ownerPointer )
- {
- mObject = ownerPointer.mObject;
- ownerPointer.mObject = NULL;
- }
-
// data
T* mObject; ///< Raw pointer to the object
};
/*
- * 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
if( textureSet == mImpl->textureSets[i] )
{
mImpl->textureSets.Remove( mImpl->textureSets.Begin() + i );
+
+ // Update manager has ownership of the TextureSet
+ delete textureSet;
return;
}
}
/*
- * 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;
mResendFlag |= RESEND_DATA_PROVIDER;
}
+void Renderer::TextureSetDeleted()
+{
+ mTextureSet = NULL;
+
+ mResendFlag |= RESEND_DATA_PROVIDER;
+}
void Renderer::ConnectionsChanged( PropertyOwner& object )
{
// One of our child objects has changed it's connections. Ensure the uniform
void Renderer::ObservedObjectDestroyed(PropertyOwner& owner)
{
- if( reinterpret_cast<PropertyOwner*>(mTextureSet) == &owner )
- {
- mTextureSet = NULL;
- }
- else if( reinterpret_cast<PropertyOwner*>(mShader) == &owner )
+ if( reinterpret_cast<PropertyOwner*>(mShader) == &owner )
{
mShader = NULL;
}
#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.
*/
void TextureSetChanged();
+ /**
+ * Called by the TextureSet to notify to the renderer that it is about to be deleted
+ */
+ void TextureSetDeleted();
+
public: // Implementation of ObjectOwnerContainer template methods
/**
* Connect the object to the scene graph
*/
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
TextureSet::~TextureSet()
{
+ size_t rendererCount = mRenderers.Size();
+ for( size_t i(0); i<rendererCount; ++i )
+ {
+ mRenderers[i]->TextureSetDeleted();
+ }
}
void TextureSet::operator delete( void* ptr )
template<typename Type>
const Type& Get() const
{
-
if ( NULL == mContainer )
{
AssertAlways( "Any::Get(). mContainer is NULL" );
}
-
- // Check if the value has the same value than the Any type.
- if( mContainer->GetType() != typeid( Type ) )
+ else if( mContainer->GetType() != typeid( Type ) ) // Check if the value has the same value than the Any type.
{
AssertAlways( "Any::Get(). Trying to retrieve a value of a different type than the template one." );
}
};
+/**
+ * @brief This namespace provides a convenient function to create an object with a custom "weight" property.
+ * @SINCE_1_0.0
+ */
namespace WeightObject
{
cd build/tizen
%make_install DALI_DATA_RW_DIR="%{dali_data_rw_dir}" DALI_DATA_RO_DIR="%{dali_data_ro_dir}"
-# LICENSE
-mkdir -p %{buildroot}/usr/share/license
-cp -af %{_builddir}/%{name}-%{version}/LICENSE %{buildroot}/usr/share/license/%{name}
##############################
%defattr(-,root,root,-)
%{_libdir}/lib%{name}-core.so*
%defattr(-,app,app,-)
-%{_datadir}/license/%{name}
+%license LICENSE
%files devel
%defattr(-,root,root,-)