void VRegion::FromRect (const VRect& inRect) { _Release(); #if !USE_GDIPLUS #if DEBUG_GDI_LIMITS assert(inRect.GetWidth() <= kMAX_GDI_RGN_COORD); assert(inRect.GetHeight() <= kMAX_GDI_RGN_COORD); #endif VRect bounds(inRect); bounds.NormalizeToInt(); //normalize to prevent artifacts due to invalidating or clipping region being cropped down // Make sure region isn't too big for GDI sLONG newWidth = Min((sLONG)bounds.GetWidth(), (sLONG)kMAX_GDI_RGN_COORD); sLONG newHeight = Min((sLONG)bounds.GetHeight(), (sLONG)kMAX_GDI_RGN_COORD); fRegion = ::CreateRectRgn(0, 0, newWidth, newHeight); fOffset.SetPosTo(bounds.GetX(), bounds.GetY()); #else Gdiplus::RectF r(inRect.GetX(),inRect.GetY(),inRect.GetWidth(),inRect.GetHeight()); fRegion = new Gdiplus::Region(r); #endif _ComputeBounds(); }
void VRect::Intersect (const VRect& inRect) { GReal newLeft = Max(fX, inRect.GetX()); GReal newTop = Max(fY, inRect.GetY()); GReal newRight = Min(GetRight(), inRect.GetRight()); GReal newBottom = Min(GetBottom(), inRect.GetBottom()); if (newRight > newLeft && newBottom > newTop) SetCoords(newLeft, newTop, newRight - newLeft, newBottom - newTop); else SetCoords(0, 0, 0, 0); }