return SceneGraph::ImageAttachment::New( 0u );
}
-const SceneGraph::RenderableAttachment& ImageAttachment::GetSceneObject() const
+const SceneGraph::ImageAttachment& ImageAttachment::GetSceneObject() const
{
DALI_ASSERT_DEBUG( mSceneObject != NULL );
return *mSceneObject;
}
-
void ImageAttachment::SetSortModifier(float modifier)
{
// Cache for actor-side getters
/**
* @copydoc Dali::Internal::RenderableAttachment::GetSceneObject()
*/
- virtual const SceneGraph::RenderableAttachment& GetSceneObject() const;
+ const SceneGraph::ImageAttachment& GetSceneObject() const;
protected:
*/
virtual void OnStageDisconnection2() = 0;
- /**
- * For derived classes to provide a corresponding scene-graph object
- * @return The scene-object.
- */
- virtual const SceneGraph::RenderableAttachment& GetSceneObject() const = 0;
-
private: // Data, cached for actor-thread getters
};
}
/**
+ * @return True if the fragment shader outputs only 1.0 on the alpha channel
+ *
+ * @note Shaders that can output any value on the alpha channel
+ * including 1.0 should return false for this.
+ */
+ bool IsOutputOpaque();
+
+ /**
+ * @return True if the fragment shader can output any value but 1.0 on the alpha channel
+ *
+ * @note Shaders that can output any value on the alpha channel
+ * including 1.0 should return false for this
+ */
+ bool IsOutputTransparent();
+
+ /**
* @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties
*/
virtual void ResetDefaultProperties( BufferIndex updateBufferIndex )
return mMinFilter[bufferIndex];
}
-Sampler::FilterMode Sampler::GetMagifyFilterMode( BufferIndex bufferIndex )
+Sampler::FilterMode Sampler::GetMagnifyFilterMode( BufferIndex bufferIndex )
{
// @todo MESH_REWORK
return mMagFilter[bufferIndex];
return mVWrapMode[bufferIndex];
}
+bool Sampler::IsFullyOpaque()
+{
+ return true; // @todo MESH_REWORK - check the actual image. For the moment, pretend it's opaque
+}
+
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
* @param[in] bufferIndex The buffer index to use
* @return The magnify filter mode
*/
- virtual FilterMode GetMagifyFilterMode( BufferIndex bufferIndex );
+ virtual FilterMode GetMagnifyFilterMode( BufferIndex bufferIndex );
/**
* Get the horizontal wrap mode
*/
virtual WrapMode GetVWrapMode( BufferIndex bufferIndex );
+ /**
+ * @return true if the texture is fully opaque.
+ * @todo MESH_REWORK Requires access to ResourceManager::GetBitmapMetadata()
+ */
+ bool IsFullyOpaque();
+
private:
std::string mUniformName; ///< The name of the uniform referencing this sampler
ResourceId mTextureId; ///< The identity of the associated texture
mRefreshMeshData( true ),
mIsPixelAreaSet( false ),
mPreviousRefreshHints( 0 ),
- mStyle( Dali::ImageActor::STYLE_QUAD )
+ mStyle( Dali::ImageActor::STYLE_QUAD ),
+ mCullFaceMode( CullNone )
{
}
// Construct message in the render queue memory; note that delete should not be called on the return value
new (slot) DerivedType( mImageRenderer, &ImageRenderer::SetTextureId, mTextureId );
}
+
+ // After derived classes have (potentially) created their renderer
+ Renderer& renderer = GetRenderer();
+ renderer.SetCullFace( mCullFaceMode );
+
+ // set the default shader here as well
+ renderer.SetShader( mShader );
}
void ImageAttachment::OnDestroy2()
}
}
+void ImageAttachment::SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options )
+{
+ // Blending options are forwarded to renderer in render-thread
+ typedef MessageValue1< Renderer, unsigned int > DerivedType;
+
+ // Reserve some memory inside the render queue
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &GetRenderer(), &Renderer::SetBlendingOptions, options );
+}
+
+void ImageAttachment::SetBlendColor( BufferIndex updateBufferIndex, const Vector4& color )
+{
+ // Blend color is forwarded to renderer in render-thread
+ typedef MessageValue1< Renderer, Vector4 > DerivedType;
+
+ // Reserve some memory inside the render queue
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &GetRenderer(), &Renderer::SetBlendColor, color );
+}
+
+void ImageAttachment::SetCullFace( BufferIndex updateBufferIndex, CullFaceMode mode )
+{
+ DALI_ASSERT_DEBUG(mSceneController);
+ DALI_ASSERT_DEBUG(mode >= CullNone && mode <= CullFrontAndBack);
+
+ mCullFaceMode = mode;
+
+ typedef MessageValue1< Renderer, CullFaceMode > DerivedType;
+
+ // Reserve some memory inside the render queue
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &GetRenderer(), &Renderer::SetCullFace, mode );
+}
+
+void ImageAttachment::SetSampler( BufferIndex updateBufferIndex, unsigned int samplerBitfield )
+{
+ DALI_ASSERT_DEBUG(mSceneController);
+
+ typedef MessageValue1< Renderer, unsigned int > DerivedType;
+
+ // Reserve some memory inside the render queue
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &GetRenderer(), &Renderer::SetSampler, samplerBitfield );
+}
+
+void ImageAttachment::ApplyShader( BufferIndex updateBufferIndex, Shader* shader )
+{
+ mShader = shader;
+
+ // send the message to renderer
+ SendShaderChangeMessage( updateBufferIndex );
+
+ // tell derived class to do something
+ ShaderChanged( updateBufferIndex );
+}
+
+void ImageAttachment::RemoveShader( BufferIndex updateBufferIndex )
+{
+ // return to default shader
+ mShader = NULL;
+
+ // send the message to renderer
+ SendShaderChangeMessage( updateBufferIndex );
+
+ // tell derived class to do something
+ ShaderChanged( updateBufferIndex );
+}
+
+
void ImageAttachment::ShaderChanged( BufferIndex updateBufferIndex )
{
DALI_ASSERT_DEBUG( mSceneController );
return opaque;
}
+void ImageAttachment::SendShaderChangeMessage( BufferIndex updateBufferIndex )
+{
+ typedef MessageValue1< Renderer, Shader* > DerivedType;
+ // Reserve memory inside the render queue
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+ // Construct message in the mRenderer queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &GetRenderer(), &Renderer::SetShader, mShader );
+}
+
+
+
} // namespace SceneGraph
} // namespace Internal
void SetBorder( BufferIndex updateBufferIndex, const Vector4& border, bool inPixels );
/**
- * @copydoc RenderableAttachment::ShaderChanged()
+ * Set the blending options. This should only be called from the update-thread.
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] options A bitmask of blending options.
+ */
+ void SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options );
+
+ /**
+ * Set the blend-color. This should only be called from the update-thread.
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] color The new blend-color.
+ */
+ void SetBlendColor( BufferIndex updateBufferIndex, const Vector4& color );
+
+ /**
+ * Set the face-culling mode.
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] mode The face-culling mode.
+ */
+ void SetCullFace( BufferIndex updateBufferIndex, CullFaceMode mode );
+
+ /**
+ * Set the sampler used to render the texture for this renderable.
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] samplerBitfield The image sampler packed options to set.
+ */
+ void SetSampler( BufferIndex updateBufferIndex, unsigned int samplerBitfield );
+
+ /**
+ * Apply a shader on the renderable
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] shader to apply.
+ */
+ void ApplyShader( BufferIndex updateBufferIndex, Shader* shader );
+
+ /**
+ * Remove the shader from the renderable
+ * @param[in] updateBufferIndex The current update buffer index.
+ */
+ void RemoveShader( BufferIndex updateBufferIndex );
+
+ /**
+ * Called to notify that the shader might have been changed
+ * The implementation should recalculate geometry and scale based on the
+ * hints from the new shader
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @return Return true if the geometry changed.
*/
virtual void ShaderChanged( BufferIndex updateBufferIndex );
ImageAttachment( unsigned int textureId );
private:
+ /**
+ * Sends the shader to the renderer
+ * @param updateBufferIndex for the message buffer
+ */
+ void SendShaderChangeMessage( BufferIndex updateBufferIndex );
/**
* @copydoc RenderableAttachment::ConnectToSceneGraph2().
bool mIsPixelAreaSet : 1; ///< Whether pixel area is set, cached for image actor to be able to ask for it
int mPreviousRefreshHints : 4; ///< The shader geometry hints, when the vertex buffer was last refreshed, 4 bits is enough as there's 4 flags
Style mStyle : 2; ///< rendering style, 2 bits is enough as only 2 values in the enum
+ CullFaceMode mCullFaceMode : 3; ///< Cullface mode, 3 bits is enough for 4 values
BitmapMetadata mBitmapMetadata;///< The bitmap metadata
Vector2 mGeometrySize; ///< The size of the currently used geometry
new (slot) LocalType( &attachment, &ImageAttachment::SetBorder, border, inPixels );
}
+inline void SetSortModifierMessage( EventToUpdate& eventToUpdate, const ImageAttachment& attachment, float modifier )
+{
+ typedef MessageValue1< ImageAttachment, float > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &attachment, &ImageAttachment::SetSortModifier, modifier );
+}
+
+inline void SetCullFaceMessage( EventToUpdate& eventToUpdate, const ImageAttachment& attachment, CullFaceMode mode )
+{
+ typedef MessageDoubleBuffered1< ImageAttachment, CullFaceMode > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &attachment, &ImageAttachment::SetCullFace, mode );
+}
+
+inline void SetBlendingOptionsMessage( EventToUpdate& eventToUpdate, const ImageAttachment& attachment, unsigned int options )
+{
+ typedef MessageDoubleBuffered1< ImageAttachment, unsigned int > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ new (slot) LocalType( &attachment, &ImageAttachment::SetBlendingOptions, options );
+}
+
+inline void SetBlendColorMessage( EventToUpdate& eventToUpdate, const ImageAttachment& attachment, const Vector4& color )
+{
+ typedef MessageDoubleBuffered1< ImageAttachment, Vector4 > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ new (slot) LocalType( &attachment, &ImageAttachment::SetBlendColor, color );
+}
+
+inline void SetSamplerMessage( EventToUpdate& eventToUpdate, const ImageAttachment& attachment, unsigned int samplerBitfield )
+{
+ typedef MessageDoubleBuffered1< ImageAttachment, unsigned int > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &attachment, &ImageAttachment::SetSampler, samplerBitfield );
+}
+
+inline void ApplyShaderMessage( EventToUpdate& eventToUpdate, const ImageAttachment& attachment, const Shader& constShader )
+{
+ // Update thread can edit the object
+ Shader& shader = const_cast< Shader& >( constShader );
+
+ typedef MessageDoubleBuffered1< ImageAttachment, Shader* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &attachment, &ImageAttachment::ApplyShader, &shader );
+}
+
+inline void RemoveShaderMessage( EventToUpdate& eventToUpdate, const ImageAttachment& attachment )
+{
+ typedef MessageDoubleBuffered0< ImageAttachment > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &attachment, &ImageAttachment::RemoveShader );
+}
+
} // namespace SceneGraph
} // namespace Internal
namespace SceneGraph
{
-void RenderableAttachment::SetSortModifier(float modifier)
-{
- // Setting sort modifier makes the node dirty, i.e. we cannot reuse previous frames render items
- if( mParent )
- {
- // only do this if we are on-stage
- mParent->SetDirtyFlag( SortModifierFlag );
- }
- mSortModifier = modifier;
-}
-
void RenderableAttachment::SetBlendingMode( BlendingMode::Type mode )
{
mBlendingMode = mode;
return mBlendingMode;
}
-void RenderableAttachment::ChangeBlending( BufferIndex updateBufferIndex, bool useBlend )
-{
- if ( mUseBlend != useBlend )
- {
- mUseBlend = useBlend;
-
- // Enable/disable blending in the next render
- typedef MessageValue1< Renderer, bool > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &GetRenderer(), &Renderer::SetUseBlend, useBlend );
- }
-}
-
-void RenderableAttachment::SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options )
-{
- // Blending options are forwarded to renderer in render-thread
- typedef MessageValue1< Renderer, unsigned int > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &GetRenderer(), &Renderer::SetBlendingOptions, options );
-}
-
-void RenderableAttachment::SetBlendColor( BufferIndex updateBufferIndex, const Vector4& color )
-{
- // Blend color is forwarded to renderer in render-thread
- typedef MessageValue1< Renderer, Vector4 > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &GetRenderer(), &Renderer::SetBlendColor, color );
-}
void RenderableAttachment::PrepareResources( BufferIndex updateBufferIndex, ResourceManager& resourceManager )
{
}
}
-void RenderableAttachment::SetCullFace( BufferIndex updateBufferIndex, CullFaceMode mode )
-{
- DALI_ASSERT_DEBUG(mSceneController);
- DALI_ASSERT_DEBUG(mode >= CullNone && mode <= CullFrontAndBack);
-
- mCullFaceMode = mode;
-
- typedef MessageValue1< Renderer, CullFaceMode > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &GetRenderer(), &Renderer::SetCullFace, mode );
-}
-
-void RenderableAttachment::SetSampler( BufferIndex updateBufferIndex, unsigned int samplerBitfield )
-{
- DALI_ASSERT_DEBUG(mSceneController);
-
- typedef MessageValue1< Renderer, unsigned int > DerivedType;
-
- // Reserve some memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
-
- // Construct message in the render queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &GetRenderer(), &Renderer::SetSampler, samplerBitfield );
-}
void RenderableAttachment::SetRecalculateScaleForSize()
{
mScaleForSizeDirty = false;
}
-void RenderableAttachment::ApplyShader( BufferIndex updateBufferIndex, Shader* shader )
-{
- mShader = shader;
-
- // send the message to renderer
- SendShaderChangeMessage( updateBufferIndex );
-
- // tell derived class to do something
- ShaderChanged( updateBufferIndex );
-}
-
-void RenderableAttachment::RemoveShader( BufferIndex updateBufferIndex )
-{
- // return to default shader
- mShader = NULL;
-
- // send the message to renderer
- SendShaderChangeMessage( updateBufferIndex );
-
- // tell derived class to do something
- ShaderChanged( updateBufferIndex );
-}
-
bool RenderableAttachment::ResolveVisibility( BufferIndex updateBufferIndex )
{
mHasSizeAndColorFlag = false;
return blend;
}
+void RenderableAttachment::ChangeBlending( BufferIndex updateBufferIndex, bool useBlend )
+{
+ if ( mUseBlend != useBlend )
+ {
+ mUseBlend = useBlend;
+
+ // Enable/disable blending in the next render
+ typedef MessageValue1< Renderer, bool > DerivedType;
+
+ // Reserve some memory inside the render queue
+ unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
+
+ // Construct message in the render queue memory; note that delete should not be called on the return value
+ new (slot) DerivedType( &GetRenderer(), &Renderer::SetUseBlend, useBlend );
+ }
+}
+
void RenderableAttachment::PrepareRender( BufferIndex updateBufferIndex )
{
// call the derived class first as it might change its state regarding blending
mHasSizeAndColorFlag( false ),
mResourcesReady( false ),
mFinishedResourceAcquisition( false ),
- mHasUntrackedResources( false ),
- mCullFaceMode( CullNone )
+ mHasUntrackedResources( false )
{
}
// Chain to derived attachments
ConnectToSceneGraph2( updateBufferIndex );
- // After derived classes have (potentially) created their renderer
- Renderer& renderer = GetRenderer();
- renderer.SetCullFace( mCullFaceMode );
-
- // set the default shader here as well
- renderer.SetShader( mShader );
+ // @todo MESH_REWORK: removed: renderer.SetCullFace & renderer.SetShader;
}
void RenderableAttachment::OnDestroy()
return this;
}
-void RenderableAttachment::SendShaderChangeMessage( BufferIndex updateBufferIndex )
+void RenderableAttachment::SetSortModifier(float modifier)
{
- typedef MessageValue1< Renderer, Shader* > DerivedType;
- // Reserve memory inside the render queue
- unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
- // Construct message in the mRenderer queue memory; note that delete should not be called on the return value
- new (slot) DerivedType( &GetRenderer(), &Renderer::SetShader, mShader );
+ // Setting sort modifier makes the node dirty, i.e. we cannot reuse previous frames render items
+ if( mParent )
+ {
+ // only do this if we are on-stage
+ mParent->SetDirtyFlag( SortModifierFlag );
+ }
+ mSortModifier = modifier;
}
+
} // namespace SceneGraph
} // namespace Internal
public: // API
/**
- * Set the sort-modifier for the attachment.
- * @param[in] modifier The depth-sort modifier.
- */
- void SetSortModifier(float modifier);
-
- /**
- * Retrieve the sort-modifier for the attachment.
- * @return The sort-modifier.
- */
- float GetSortModifier() const
- {
- // inlined as its called a lot when sorting transparent renderers
- return mSortModifier;
- }
-
- /**
* @See Dali::RenderableActor::SetBlendMode().
*/
void SetBlendingMode( BlendingMode::Type mode );
BlendingMode::Type GetBlendingMode() const;
/**
- * Check if the blending mode has changed - if it has, send message to renderer
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] useBlending True if the renderer should use blending option
- */
- void ChangeBlending( BufferIndex updateBufferIndex, bool useBlending );
-
- /**
- * Set the blending options. This should only be called from the update-thread.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] options A bitmask of blending options.
- */
- void SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options );
-
- /**
- * Set the blend-color. This should only be called from the update-thread.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] color The new blend-color.
- */
- void SetBlendColor( BufferIndex updateBufferIndex, const Vector4& color );
-
- /**
- * Set the face-culling mode.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] mode The face-culling mode.
- */
- void SetCullFace( BufferIndex updateBufferIndex, CullFaceMode mode );
-
- /**
- * Set the sampler used to render the texture for this renderable.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] samplerBitfield The image sampler packed options to set.
- */
- void SetSampler( BufferIndex updateBufferIndex, unsigned int samplerBitfield );
-
- /**
* Flag to check if any geometry scaling is needed, inlined as called from update algorithm often
* @return true if the derived renderable uses geometry scaling
*/
*/
void GetScaleForSize( const Vector3& nodeSize, Vector3& scaling );
- /**
- * Apply a shader on the renderable
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] shader to apply.
- */
- void ApplyShader( BufferIndex updateBufferIndex, Shader* shader );
-
- /**
- * Remove the shader from the renderable
- * @param[in] updateBufferIndex The current update buffer index.
- */
- void RemoveShader( BufferIndex updateBufferIndex );
public: // For use during in the update algorithm only
bool IsBlendingOn( BufferIndex updateBufferIndex );
/**
+ * Check if the blending mode has changed - if it has, send message to renderer
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] useBlending True if the renderer should use blending option
+ */
+ void ChangeBlending( BufferIndex updateBufferIndex, bool useBlending );
+
+ /**
* Prepare the object for rendering.
* This is called by the UpdateManager when an object is due to be rendered in the current frame.
* @param[in] updateBufferIndex The current update buffer index.
virtual bool IsFullyOpaque( BufferIndex updateBufferIndex ) = 0;
/**
- * Called to notify that the shader might have been changed
- * The implementation should recalculate geometry and scale based on the
- * hints from the new shader
- * @param[in] updateBufferIndex The current update buffer index.
- * @return Return true if the geometry changed.
- */
- virtual void ShaderChanged( BufferIndex updateBufferIndex ) = 0;
-
- /**
* Called to notify that the size has been changed
- * The implementation may tell the renderer to recalculate geometry and scale based on the new size
+ * The implementation may tell the renderer to recalculate scale
+ * based on the new size
* @param[in] updateBufferIndex The current update buffer index.
*/
virtual void SizeChanged( BufferIndex updateBufferIndex ) = 0;
*/
virtual void DoGetScaleForSize( const Vector3& nodeSize, Vector3& scaling );
+
+ /**
+ * Set the sort-modifier for the attachment.
+ * @param[in] modifier The depth-sort modifier.
+ */
+ void SetSortModifier(float modifier);
+
+ /**
+ * Retrieve the sort-modifier for the attachment.
+ * @return The sort-modifier.
+ */
+ float GetSortModifier() const
+ {
+ // inlined as its called a lot when sorting transparent renderers
+ return mSortModifier;
+ }
+
protected:
/**
*/
virtual bool DoPrepareResources( BufferIndex updateBufferIndex, ResourceManager& resourceManager ) = 0;
- /**
- * Sends the shader to the renderer
- * @param updateBufferIndex for the message buffer
- */
- void SendShaderChangeMessage( BufferIndex updateBufferIndex );
-
// Undefined
RenderableAttachment( const RenderableAttachment& );
RenderableAttachment& operator=( const RenderableAttachment& rhs );
protected:
-
SceneController* mSceneController; ///< Used for initializing renderers whilst attached
Shader* mShader; ///< A pointer to the shader
bool mResourcesReady:1; ///< Set during the Update algorithm; true if the attachment has resources ready for the current frame.
bool mFinishedResourceAcquisition:1; ///< Set during DoPrepareResources; true if ready & all resource acquisition has finished (successfully or otherwise)
bool mHasUntrackedResources:1; ///< Set during PrepareResources, true if have tried to follow untracked resources
- CullFaceMode mCullFaceMode:3; ///< Cullface mode, 3 bits is enough for 4 values
-
};
// Messages for RenderableAttachment
-inline void SetSortModifierMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment, float modifier )
-{
- typedef MessageValue1< RenderableAttachment, float > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &RenderableAttachment::SetSortModifier, modifier );
-}
-
-inline void SetCullFaceMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment, CullFaceMode mode )
-{
- typedef MessageDoubleBuffered1< RenderableAttachment, CullFaceMode > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &RenderableAttachment::SetCullFace, mode );
-}
-
inline void SetBlendingModeMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment, BlendingMode::Type mode )
{
typedef MessageValue1< RenderableAttachment, BlendingMode::Type > LocalType;
new (slot) LocalType( &attachment, &RenderableAttachment::SetBlendingMode, mode );
}
-inline void SetBlendingOptionsMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment, unsigned int options )
-{
- typedef MessageDoubleBuffered1< RenderableAttachment, unsigned int > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- new (slot) LocalType( &attachment, &RenderableAttachment::SetBlendingOptions, options );
-}
-
-inline void SetBlendColorMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment, const Vector4& color )
-{
- typedef MessageDoubleBuffered1< RenderableAttachment, Vector4 > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- new (slot) LocalType( &attachment, &RenderableAttachment::SetBlendColor, color );
-}
-
-inline void SetSamplerMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment, unsigned int samplerBitfield )
-{
- typedef MessageDoubleBuffered1< RenderableAttachment, unsigned int > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &RenderableAttachment::SetSampler, samplerBitfield );
-}
-
-inline void ApplyShaderMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment, const Shader& constShader )
-{
- // Update thread can edit the object
- Shader& shader = const_cast< Shader& >( constShader );
-
- typedef MessageDoubleBuffered1< RenderableAttachment, Shader* > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &RenderableAttachment::ApplyShader, &shader );
-}
-
-inline void RemoveShaderMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment )
-{
- typedef MessageDoubleBuffered0< RenderableAttachment > LocalType;
-
- // Reserve some memory inside the message queue
- unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
-
- // Construct message in the message queue memory; note that delete should not be called on the return value
- new (slot) LocalType( &attachment, &RenderableAttachment::RemoveShader );
-}
-
} // namespace SceneGraph
} // namespace Internal