glAbstraction.EnableCullFaceCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
- std::ostringstream out;
- out << GL_DEPTH_TEST;
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
+// TODO: Not supported yes
+// TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+// std::ostringstream out;
+// out << GL_DEPTH_TEST;
+// DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
DALI_TEST_EQUALS( geometry.GetRequiresDepthTesting(), true, TEST_LOCATION );
glAbstraction.EnableCullFaceCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
- std::ostringstream out;
- out << GL_DEPTH_TEST;
- DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
+// TODO: Not supported yes
+// TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+// std::ostringstream out;
+// out << GL_DEPTH_TEST;
+// DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
DALI_TEST_EQUALS( geometry.GetProperty<bool>(Geometry::Property::REQUIRES_DEPTH_TEST), true, TEST_LOCATION );
std::vector<Property::Index> indices;
indices.push_back(Layer::Property::CLIPPING_ENABLE);
indices.push_back(Layer::Property::CLIPPING_BOX);
+ indices.push_back(Layer::Property::BEHAVIOR);
DALI_TEST_CHECK(actor.GetPropertyCount() == ( Actor::New().GetPropertyCount() + indices.size() ) );
DALI_TEST_CHECK( actor.GetClippingBox() == testBox );
+
+ Property::Value behavior = actor.GetProperty(Layer::Property::BEHAVIOR);
+ DALI_TEST_CHECK( std::strcmp( behavior.Get<std::string>().c_str(), "LAYER_2D") );
+
END_TEST;
}
tet_infoline("Testing Dali::Layer::SetDepthTestDisabled() ");
Layer actor = Layer::New();
+ DALI_TEST_CHECK( actor.IsDepthTestDisabled() );
+ actor.SetBehavior( Layer::LAYER_3D );
DALI_TEST_CHECK( !actor.IsDepthTestDisabled() );
actor.SetDepthTestDisabled( true );
DALI_TEST_EQUALS( testBox.height, glScissorParams.height, TEST_LOCATION );
END_TEST;
}
+
+int UtcDaliLayerBehaviour(void)
+{
+ TestApplication application;
+ Layer layer = Layer::New();
+
+ DALI_TEST_EQUALS( layer.GetBehavior(), Dali::Layer::LAYER_2D, TEST_LOCATION );
+ layer.SetBehavior( Dali::Layer::LAYER_3D );
+ DALI_TEST_EQUALS( layer.GetBehavior(), Dali::Layer::LAYER_3D, TEST_LOCATION );
+ END_TEST;
+}
// EXTERNAL INCLUDES
// INTERNAL INCLUDES
+#include <dali/public-api/actors/layer.h>
#include <dali/public-api/common/dali-common.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/internal/event/actors/layer-list.h>
namespace Dali
{
+namespace
+{
+typedef Dali::Layer::Behavior Behavior;
+
+DALI_ENUM_TO_STRING_TABLE_BEGIN( Behavior )
+DALI_ENUM_TO_STRING( Dali::Layer::LAYER_2D )
+DALI_ENUM_TO_STRING( Dali::Layer::LAYER_3D )
+DALI_ENUM_TO_STRING_TABLE_END( Behavior )
+} // namespace
+
namespace Internal
{
DALI_PROPERTY_TABLE_BEGIN
DALI_PROPERTY( "clipping-enable", BOOLEAN, true, false, true, Dali::Layer::Property::CLIPPING_ENABLE )
DALI_PROPERTY( "clipping-box", RECTANGLE, true, false, true, Dali::Layer::Property::CLIPPING_BOX )
+DALI_PROPERTY( "behavior", STRING, true, false, false, Dali::Layer::Property::BEHAVIOR )
DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX )
// Actions
} // unnamed namespace
+
LayerPtr Layer::New()
{
LayerPtr layer( new Layer( Actor::LAYER ) );
}
}
+void Layer::SetBehavior( Dali::Layer::Behavior behavior )
+{
+ mBehavior = behavior;
+
+ // notify update side object
+ SetBehaviorMessage( GetEventThreadServices(), GetSceneLayerOnStage(), behavior );
+}
+
void Layer::SetClipping(bool enabled)
{
if (enabled != mIsClipping)
bool Layer::IsDepthTestDisabled() const
{
- return mDepthTestDisabled;
+ return mDepthTestDisabled || (mBehavior == Dali::Layer::LAYER_2D);
}
void Layer::SetSortFunction(Dali::Layer::SortFunctionType function)
SetClippingBox( clippingBox.x, clippingBox.y, clippingBox.width, clippingBox.height );
break;
}
+ case Dali::Layer::Property::BEHAVIOR:
+ {
+ Behavior behavior = Scripting::GetEnumeration< Behavior >( propertyValue.Get< std::string >().c_str(), BehaviorTable, BehaviorTableCount );
+ SetBehavior( behavior );
+ break;
+ }
default:
{
DALI_LOG_WARNING( "Unknown property (%d)\n", index );
ret = mClippingBox;
break;
}
+ case Dali::Layer::Property::BEHAVIOR:
+ {
+ ret = Scripting::GetLinearEnumerationName< Behavior >( GetBehavior(), BehaviorTable, BehaviorTableCount );
+ break;
+ }
default:
{
DALI_LOG_WARNING( "Unknown property (%d)\n", index );
* It is useful for 2D user interfaces, and it's used to sort translucent renderers.
*
* Only the Z signed distance from the camera is considererd, lower values will be drawn on top.
- *
+ *
* @param[in] position position of actor in view space
* @return depth
*/
}
/**
+ * @copydoc Dali::Layer::SetBehavior()
+ */
+ void SetBehavior( Dali::Layer::Behavior behavior );
+
+ /**
+ * @copydoc Dali::Layer::GetBehavior()
+ */
+ Dali::Layer::Behavior GetBehavior() const
+ {
+ return mBehavior;
+ }
+
+ /**
* @copydoc Dali::Layer::SetDepthTestDisabled()
*/
void SetDepthTestDisabled( bool disable );
ClippingBox mClippingBox; ///< The clipping box, in window coordinates
Dali::Layer::SortFunctionType mSortFunction; ///< Used to sort semi-transparent geometry
+ Dali::Layer::Behavior mBehavior; ///< Behavior of the layer
+
bool mIsClipping:1; ///< True when clipping is enabled
bool mDepthTestDisabled:1; ///< Whether depth test is disabled.
bool mTouchConsumed:1; ///< Whether we should consume touch (including gesture).
// INTERNAL INCLUDES
#include <dali/integration-api/bitmap.h>
+#include <dali/devel-api/scripting/scripting.h>
namespace Dali
{
* { "SIZE_EQUAL_TO_PARENT", SIZE_EQUAL_TO_PARENT },
* }; const unsigned int SizeModeTableCount = sizeof( SizeModeTable ) / sizeof( SizeModeTable[0] );
*/
-#define DALI_ENUM_TO_STRING_TABLE_BEGIN( t ) const Scripting::StringEnum< t > t##Table[] = {
+#define DALI_ENUM_TO_STRING_TABLE_BEGIN( t ) const Dali::Scripting::StringEnum< t > t##Table[] = {
#define DALI_ENUM_TO_STRING_TABLE_END( t ) }; const unsigned int t##TableCount = sizeof( t##Table ) / sizeof( t##Table[0] );
#define DALI_ENUM_TO_STRING( s ) { #s, s },
* @param cameraAttachment to use the view frustum
* @param transparentRenderersExist is true if there is transparent renderers in this layer
* @param stencilRenderablesExist is true if there are stencil renderers on this layer
+ * @param disableDepthTest is true if depth test should be disabled on this layer
* @param instruction to fill in
* @param tryReuseRenderList whether to try to reuse the cached items from the instruction
*/
SceneGraph::CameraAttachment& cameraAttachment,
bool transparentRenderablesExist,
bool stencilRenderablesExist,
+ bool disableDepthTest,
RenderInstruction& instruction,
RendererSortingHelper& sortingHelper,
bool tryReuseRenderList )
{
// reset the flags as other layers might have changed
// opaque flags can only be set after renderers are added
- SetOpaqueRenderFlags(opaqueRenderList, transparentRenderablesExist, stencilRenderablesExist, layer.IsDepthTestDisabled() );
+ SetOpaqueRenderFlags( opaqueRenderList, transparentRenderablesExist, stencilRenderablesExist, disableDepthTest );
return;
}
}
AddRenderersToRenderList( updateBufferIndex, opaqueRenderList, layer.opaqueRenderables, viewMatrix, cameraAttachment );
// opaque flags can only be set after renderers are added
- SetOpaqueRenderFlags(opaqueRenderList, transparentRenderablesExist, stencilRenderablesExist, layer.IsDepthTestDisabled() );
+ SetOpaqueRenderFlags(opaqueRenderList, transparentRenderablesExist, stencilRenderablesExist, disableDepthTest );
// sorting is only needed if more than 1 item
if( renderableCount > 1 )
const bool opaqueRenderablesExist( !layer.opaqueRenderables.empty() );
const bool transparentRenderablesExist( !layer.transparentRenderables.empty() );
const bool overlayRenderablesExist( !layer.overlayRenderables.empty() );
+ const bool disableDepthTest( layer.IsDepthTestDisabled() );
const bool tryReuseRenderList( viewMatrixHasNotChanged && layer.CanReuseRenderers(renderTask.GetCamera()) );
// Ignore stencils if there's nothing to test
cameraAttachment,
transparentRenderablesExist,
stencilRenderablesExist,
+ disableDepthTest,
instruction,
sortingHelper,
tryReuseRenderList );
Layer::Layer()
: mSortFunction( Internal::Layer::ZValue ),
mClippingBox( 0,0,0,0 ),
- mLastCamera(0),
+ mLastCamera( NULL ),
+ mBehavior( Dali::Layer::LAYER_2D ),
mIsClipping( false ),
mDepthTestDisabled( false ),
mIsDefaultSortFunction( true )
mClippingBox.Set(box.x, box.y, box.width, box.height);
}
+void Layer::SetBehavior( Dali::Layer::Behavior behavior )
+{
+ mBehavior = behavior;
+}
+
void Layer::SetDepthTestDisabled( bool disable )
{
mDepthTestDisabled = disable;
bool Layer::IsDepthTestDisabled() const
{
- return mDepthTestDisabled;
+ return ( mBehavior == Dali::Layer::LAYER_2D ) || mDepthTestDisabled;
}
} // namespace SceneGraph
// value types used by messages
template <> struct ParameterType< Dali::Layer::SortFunctionType >
: public BasicType< Dali::Layer::SortFunctionType > {};
+template <> struct ParameterType< Dali::Layer::Behavior >
+: public BasicType< Dali::Layer::Behavior > {};
namespace SceneGraph
{
}
/**
+ * Sets the behavior of the layer
+ * @param [in] behavior The behavior of the layer
+ */
+ void SetBehavior( Dali::Layer::Behavior behavior );
+
+ /**
+ * Retrieves the behavior of the layer.
+ * @return The behavior
+ */
+ Dali::Layer::Behavior GetBehavior() const
+ {
+ return mBehavior;
+ }
+
+ /**
* @copydoc Dali::Layer::SetDepthTestDisabled()
*/
void SetDepthTestDisabled( bool disable );
ClippingBox mClippingBox; ///< The clipping box, in window coordinates
Node* mLastCamera; ///< Pointer to the last camera that has rendered the layer
+ Dali::Layer::Behavior mBehavior; ///< The behavior of the layer
+
bool mAllChildTransformsClean[ 2 ]; ///< True if all child nodes transforms are clean,
/// double buffered as we need two clean frames before we can reuse N-1 for N+1
/// this allows us to cache render items when layer is "static"
}
/**
+ * Create a message to set the behavior of a layer
+ * @param[in] layer The layer
+ * @param[in] behavior The behavior
+ */
+inline void SetBehaviorMessage( EventThreadServices& eventThreadServices,
+ const Layer& layer,
+ Dali::Layer::Behavior behavior )
+{
+ typedef MessageValue1< Layer, Dali::Layer::Behavior > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &layer, &Layer::SetBehavior, behavior );
+}
+
+/**
* Create a message for disabling/enabling depth test.
*
* @see Dali::Layer::SetDepthTestDisabled().
*
* @param[in] layer The layer
- * @param[in] disable \e true disables depth test. \e false sets the default behaviour.
+ * @param[in] disable \e true disables depth test. \e false sets the default behavior.
*/
inline void SetDepthTestDisabledMessage( EventThreadServices& eventThreadServices, const Layer& layer, bool disable )
{
GetImplementation(*this).MoveBelow( GetImplementation( target ) );
}
+void Layer::SetBehavior( Behavior behavior )
+{
+ GetImplementation(*this).SetBehavior( behavior );
+}
+
+Layer::Behavior Layer::GetBehavior() const
+{
+ return GetImplementation(*this).GetBehavior();
+}
+
void Layer::SetClipping(bool enabled)
{
GetImplementation(*this).SetClipping(enabled);
{
CLIPPING_ENABLE = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, ///< name "clipping-enable", type bool
CLIPPING_BOX, ///< name "clipping-box", type Rect<int>
+ BEHAVIOR, ///< name "behavior", type String
};
};
/**
+ * @brief Enumeration for the behavior of the layer.
+ *
+ * Check each value to see how it affects the layer.
+ */
+ enum Behavior
+ {
+ /**
+ * @brief Layer doesn't make use of the depth test.
+ *
+ * This mode is expected to have better performance than the 3D mode.
+ * When using this mode any ordering would be with respect to depth-index property of Renderers.
+ */
+ LAYER_2D,
+
+ /**
+ * @brief Layer will use depth test and do several clears.
+ *
+ * When using this mode depth depth test will be used. A depth clear will happen for each distinct
+ * depth-index value in the layer, opaque renderers are drawn first and write to the depth buffer.
+ * Then transparent renderers are drawn with depth test enabled but depth write switched off.
+ */
+ LAYER_3D,
+ };
+
+ /**
* @brief The sort function type.
*
* @param[in] position this is the actor translation from camera.
void MoveBelow( Layer target );
/**
+ * @brief Set the behavior of the layer
+ *
+ * @param[in] behavior The desired behavior
+ */
+ void SetBehavior( Behavior behavior );
+
+ /**
+ * @brief Get the behavior of the layer
+ *
+ * @return The behavior of the layer
+ */
+ Behavior GetBehavior() const;
+
+ /**
* @brief Sets whether clipping is enabled for a layer.
*
* Clipping is initially disabled; see also SetClippingBox().
* By default a layer enables depth test if there is more than one opaque actor or if there is one opaque actor and one, or more, transparent actors.
* However, it's possible to disable the depth test by calling this method.
*
- * @param[in] disable \e true disables depth test. \e false sets the default behaviour.
+ * @param[in] disable \e true disables depth test. \e false sets the default behavior.
*/
void SetDepthTestDisabled( bool disable );