From 4c6c5e1a840483c59036fa185f3ce4dc4afea615 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 16 Sep 2014 15:42:53 +0100 Subject: [PATCH] (Layer) Clipbox is now from the top-left [Problem] Setting a clip-box on a layer is from the bottom-left as poer the GL API, this is very confusing as it is different to the rest of our coordinate system [Solution] Use top-left instead and do a conversion to the GL coordinate system internally for the GL API call. Change-Id: I205fadf7bfd2448b9a3cb47ec1a2d28efdc5c590 --- dali/internal/event/actors/layer-impl.cpp | 6 +++++- dali/public-api/actors/layer.h | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/dali/internal/event/actors/layer-impl.cpp b/dali/internal/event/actors/layer-impl.cpp index e0cd271..a91c052 100644 --- a/dali/internal/event/actors/layer-impl.cpp +++ b/dali/internal/event/actors/layer-impl.cpp @@ -238,8 +238,12 @@ void Layer::SetClippingBox(int x, int y, int width, int height) // Clipping box is not animatable; this is the most up-to-date value mClippingBox.Set(x, y, width, height); + // Convert mClippingBox to GL based coordinates (from bottom-left) + ClippingBox clippingBox( mClippingBox ); + clippingBox.y = mStage->GetSize().height - clippingBox.y - clippingBox.height; + // layerNode is being used in a separate thread; queue a message to set the value - SetClippingBoxMessage( mStage->GetUpdateInterface(), GetSceneLayerOnStage(), mClippingBox ); + SetClippingBoxMessage( mStage->GetUpdateInterface(), GetSceneLayerOnStage(), clippingBox ); } } diff --git a/dali/public-api/actors/layer.h b/dali/public-api/actors/layer.h index 4053a99..5ca44ee 100644 --- a/dali/public-api/actors/layer.h +++ b/dali/public-api/actors/layer.h @@ -221,6 +221,8 @@ public: * * Clipping is initially disabled; see also SetClippingBox(). * @param [in] enabled True if clipping is enabled. + * + * @note When clipping is enabled, the default clipping box is empty (0,0,0,0) which means everything is clipped. */ void SetClipping(bool enabled); @@ -234,11 +236,11 @@ public: * @brief Sets the clipping box of a layer, in window coordinates. * * The contents of the layer will not be visible outside this box, when clipping is - * enabled. The default clipping box is empty (0,0,0,0). - * This has the limitation that it only applies to rectangles on a window. + * enabled. The default clipping box is empty (0,0,0,0) which means everything is clipped. + * You can only do rectangular clipping using this API in window coordinates. * For other kinds of clipping, @see Dali::Actor::SetDrawMode(). - * @param [in] x The X-coordinate of the lower-left corner. - * @param [in] y The Y-coordinate of the lower-left corner. + * @param [in] x The X-coordinate of the top-left corner of the box. + * @param [in] y The Y-coordinate of the top-left corner of the box. * @param [in] width The width of the box. * @param [in] height The height of the box. */ -- 2.7.4