/** @inheritDoc */ public override Rect GetBounds(DisplayObject targetSpace) { Rect bounds = base.GetBounds(targetSpace); // if we have a scissor rect, intersect it with our bounds if (_clipRect != null) { Rect clip = GetClipRect(targetSpace); bounds = ToolSet.Intersection(ref bounds, ref clip); } return(bounds); }
/** The clipping rectangle can be used to limit rendering in the current render target to * a certain area. This method expects the rectangle in stage coordinates. Internally, * it uses the 'scissorRectangle' of stage3D, which works with pixel coordinates. * Any pushed rectangle is intersected with the previous rectangle; the method returns * that intersection. */ //public Rectangle PushClipRect(Rectangle rectangle) //{ // if (mClipRectStack.Count < mClipRectStackSize + 1) // mClipRectStack.Add(new Rectangle()); // mClipRectStack[mClipRectStackSize].copyFrom(rectangle); // rectangle = mClipRectStack[mClipRectStackSize]; // // intersect with the last pushed clip rect // if (mClipRectStackSize > 0) // rectangle.intersect(mClipRectStack[mClipRectStackSize-1], // rectangle); // ++mClipRectStackSize; // ApplyClipRect(); // // return the intersected clip rect so callers can skip draw calls if it's empty // return rectangle; //} public Rect PushClipRect(Rect rectangle) { if (mClipRectStack.Count < mClipRectStackSize + 1) { mClipRectStack.Add(new Rect()); } mClipRectStack[mClipRectStackSize] = rectangle; // intersect with the last pushed clip rect if (mClipRectStackSize > 0) { Rect clip = mClipRectStack[mClipRectStackSize - 1]; rectangle = ToolSet.Intersection(ref clip, ref rectangle); mClipRectStack[mClipRectStackSize] = rectangle; } ++mClipRectStackSize; ApplyClipRect(); // return the intersected clip rect so callers can skip draw calls if it's empty return(rectangle); }