(Layer) Clipbox is now from the top-left 12/27612/3
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 16 Sep 2014 14:42:53 +0000 (15:42 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 16 Sep 2014 15:04:30 +0000 (08:04 -0700)
[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
dali/public-api/actors/layer.h

index e0cd271..a91c052 100644 (file)
@@ -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 );
   }
 }
 
index 4053a99..5ca44ee 100644 (file)
@@ -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.
    */