-#ifndef __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H__
-#define __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H__
+#ifndef DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H
+#define DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H
/*
- * 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.
*
*/
-
// EXTERNAL INCLUDES
+#include <dali/public-api/images/image-operations.h>
#include <dali/public-api/object/base-object.h>
+#include <dali/public-api/rendering/shader.h>
-#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+// INTERNAL INCLUDES
#include <dali-toolkit/devel-api/controls/renderer-factory/control-renderer.h>
+#include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
+#include <dali-toolkit/internal/controls/renderers/renderer-factory-cache.h>
namespace Dali
{
namespace Internal
{
-class RendererFactoryCache;
-
/**
* Base class for all Control rendering logic. A control may have multiple control renderers.
*
* Note: The control renderer responds to the the Actor::COLOR by blending it with the 'Multiply' operator.
+ *
+ * The following properties are optional
+ *
+ * | %Property Name | Type |
+ * |-------------------------|------------------|
+ * | customShader | MAP |
+ *
+ * where custom-shader is a map with the following properties:
+ * | %Property Name | Type |
+ * |-------------------------|------------------|
+ * | vertexShader | STRING |
+ * | fragmentShader | STRING |
+ * | subdivideGridX | INT |
+ * | subdivideGridY | INT |
+ * | shaderHints | INT |
*/
class ControlRenderer : public BaseObject
{
* request the geometry and shader from the cache, if not available, create and save to the cache for sharing;
* record the property values.
*
- * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
* @param[in] propertyMap The properties for the requested ControlRenderer object.
*/
- virtual void Initialize( RendererFactoryCache& factoryCache, const Property::Map& propertyMap ) = 0;
+ void Initialize( Actor& actor, const Property::Map& propertyMap );
/**
* @copydoc Toolkit::ControlRenderer::SetSize
virtual void SetSize( const Vector2& size );
/**
+ * @copydoc Toolkit::ControlRenderer::GetSize
+ */
+ const Vector2& GetSize() const;
+
+ /**
+ * @copydoc Toolkit::ControlRenderer::GetNaturalSize
+ */
+ virtual void GetNaturalSize( Vector2& naturalSize ) const;
+
+ /**
* ToDo: Add this function to Toolkit::ControlRenderer when it is fully implemented.
*
* Set the clip rectangular of this renderer.
void SetDepthIndex( float index );
/**
+ * @copydoc Toolkit::ControlRenderer::GetDepthIndex
+ */
+ float GetDepthIndex() const;
+
+ /**
* @copydoc Toolkit::ControlRenderer::SetOnStage
* @pre Impl->mGeometry must be created before this method is called
*/
/**
* @copydoc Toolkit::ControlRenderer::CreatePropertyMap
*/
- virtual void CreatePropertyMap( Property::Map& map ) const = 0;
+ void CreatePropertyMap( Property::Map& map ) const;
+
+ /**
+ * @brief Set whether the Pre-multiplied Alpha Blending is required
+ *
+ * @param[in] preMultipled whether alpha is pre-multiplied.
+ */
+ void EnablePreMultipliedAlpha( bool preMultipled );
+
+ /**
+ * @brief Query whether alpha is pre-multiplied.
+ *
+ * @return True is alpha is pre-multiplied, false otherwise.
+ */
+ bool IsPreMultipliedAlphaEnabled() const;
+
+ /**
+ * @brief Sets properties of custom shader
+ * @param[in] propertyMap Property map containing the custom shader data
+ */
+ void SetCustomShader( const Property::Map& propertyMap );
protected:
/**
* @brief Constructor.
+ *
+ * @param[in] factoryCache A pointer pointing to the RendererFactoryCache object
*/
- ControlRenderer();
+ ControlRenderer( RendererFactoryCache& factoryCache );
/**
* @brief A reference counted object may only be deleted by calling Unreference().
virtual ~ControlRenderer();
protected:
+ /**
+ * @brief Called by CreatePropertyMap() allowing sub classes to respond to the CreatePropertyMap event
+ *
+ * @param[out] map The renderer property map.
+ */
+ virtual void DoCreatePropertyMap( Property::Map& map ) const = 0;
/**
- * Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
+ * @brief Called by Initialize() allowing sub classes to respond to the Initialize event
+ *
+ * @param[in] actor The Actor the renderer is applied to if, empty if the renderer has not been applied to any Actor
+ * @param[in] propertyMap The properties for the requested ControlRenderer object.
+ */
+ virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap ) {};
+
+protected:
+
+ /**
+ * @brief Called by SetOnStage() allowing sub classes to respond to the SetOnStage event
*
* @param[in] actor The actor applying this renderer.
*/
virtual void DoSetOnStage( Actor& actor );
/**
- * Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
+ * @brief Called by SetOffStage() allowing sub classes to respond to the SetOffStage event
*
* @param[in] actor The actor applying this renderer.
*/
virtual void DoSetOffStage( Actor& actor );
+protected:
+ /**
+ * @brief Gets the on stage state for this ControlRenderer
+ *
+ * @return Returns true if this ControlRenderer is on stage, false if it is off the stage
+ */
+ bool GetIsOnStage() const;
+
+ /**
+ * @brief Gets whether the Dali::Renderer is from a shared cache (and therefore any modifications will affect other users of that renderer)
+ *
+ * @return Returns true if the renderer is from shared cache, false otherwise
+ */
+ bool GetIsFromCache() const;
+
private:
// Undefined
ControlRenderer& operator=( const ControlRenderer& renderer );
protected:
-
struct Impl;
Impl* mImpl;
+ RendererFactoryCache& mFactoryCache;
};
} // namespace Internal
} // namespace Dali
-#endif /* __DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H___ */
+#endif // DALI_TOOLKIT_INTERNAL_CONTROL_RENDERER_H