From 8f8d481b44fc486e7190c6e2db8077226d53c969 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Fri, 18 May 2018 10:19:05 -0400 Subject: Add SkIRect::adjust method Change-Id: Ib18d1a82944524e20d5d72912d8db7a823c470de Reviewed-on: https://skia-review.googlesource.com/128884 Commit-Queue: Robert Phillips Reviewed-by: Cary Clark --- include/core/SkRect.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/core/SkRect.h b/include/core/SkRect.h index d4a9c05c68..7b8e0032e5 100644 --- a/include/core/SkRect.h +++ b/include/core/SkRect.h @@ -413,6 +413,25 @@ struct SK_API SkIRect { */ void outset(int32_t dx, int32_t dy) { this->inset(-dx, -dy); } + /** Adjust SkIRect by adding dL to fLeft, dT to fTop, dR to fRight and fB to fBottom. + + If dL is positive, narrows SkIRect on the left. If negative, widens it on the left. + If dT is positive, shrinks SkIRect on the top. If negative, lengthens it on the top. + If dR is positive, narrows SkIRect on the right. If negative, widens it on the right. + If dB is positive, shrinks SkIRect on the bottom. If negative, lengthens it on the bottom. + + @param dL offset added to fLeft + @param dT offset added to fTop + @param dR offset added to fRight + @param dB offset added to fBottom + */ + void adjust(int32_t dL, int32_t dT, int32_t dR, int32_t dB) { + fLeft = Sk32_sat_add(fLeft, dL); + fTop = Sk32_sat_add(fTop, dT); + fRight = Sk32_sat_add(fRight, dR); + fBottom = Sk32_sat_add(fBottom, dB); + } + /** Returns true if: fLeft <= x < fRight && fTop <= y < fBottom. Returns false if SkIRect is empty. -- cgit v1.2.3