drm/rect: Add drm_rect_translate_to()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 30 Sep 2019 13:42:11 +0000 (16:42 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 1 Oct 2019 14:45:20 +0000 (17:45 +0300)
Add a helper to translate a rectangle to an absolute position.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190930134214.24702-1-ville.syrjala@linux.intel.com
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
include/drm/drm_rect.h

index 6195820..fc7c146 100644 (file)
@@ -107,6 +107,20 @@ static inline void drm_rect_translate(struct drm_rect *r, int dx, int dy)
 }
 
 /**
+ * drm_rect_translate_to - translate the rectangle to an absolute position
+ * @r: rectangle to be tranlated
+ * @x: horizontal position
+ * @y: vertical position
+ *
+ * Move rectangle @r to @x in the horizontal direction,
+ * and to @y in the vertical direction.
+ */
+static inline void drm_rect_translate_to(struct drm_rect *r, int x, int y)
+{
+       drm_rect_translate(r, x - r->x1, y - r->y1);
+}
+
+/**
  * drm_rect_downscale - downscale a rectangle
  * @r: rectangle to be downscaled
  * @horz: horizontal downscale factor