[Spice-devel,v2,spice-common,1/5] rect: add rect_contains

Submitted by Yonit Halperin on April 17, 2012, 10:12 a.m.

Details

Message ID 1334657534-5015-1-git-send-email-yhalperi@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Yonit Halperin April 17, 2012, 10:12 a.m.
---
 common/rect.h |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

Patch hide | download patch | download mbox

diff --git a/common/rect.h b/common/rect.h
index a63d785..655e9e8 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -74,6 +74,12 @@  static INLINE int rect_is_same_size(const SpiceRect *r1, const SpiceRect *r2)
            r1->bottom - r1->top == r2->bottom - r2->top;
 }
 
+static INLINE int rect_contains(const SpiceRect *big, const SpiceRect *small)
+{
+    return big->left <= small->left && big->right >= small->right &&
+           big->top <= small->top && big->bottom >= small->bottom;
+}
+
 SPICE_END_DECLS
 
 #ifdef __cplusplus
@@ -113,6 +119,11 @@  static inline int rect_is_same_size(const SpiceRect& r1, const SpiceRect& r2)
     return rect_is_same_size(&r1, &r2);
 }
 
+static inline int rect_contains(const SpiceRect& big, const SpiceRect& small)
+{
+    return rect_contains(&big, &small);
+}
+
 #endif /* __cplusplus */
 
 #endif

Comments

Series looks good.

Christophe


On Tue, Apr 17, 2012 at 01:12:10PM +0300, Yonit Halperin wrote:
> ---
>  common/rect.h |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
> 
> diff --git a/common/rect.h b/common/rect.h
> index a63d785..655e9e8 100644
> --- a/common/rect.h
> +++ b/common/rect.h
> @@ -74,6 +74,12 @@ static INLINE int rect_is_same_size(const SpiceRect *r1, const SpiceRect *r2)
>             r1->bottom - r1->top == r2->bottom - r2->top;
>  }
>  
> +static INLINE int rect_contains(const SpiceRect *big, const SpiceRect *small)
> +{
> +    return big->left <= small->left && big->right >= small->right &&
> +           big->top <= small->top && big->bottom >= small->bottom;
> +}
> +
>  SPICE_END_DECLS
>  
>  #ifdef __cplusplus
> @@ -113,6 +119,11 @@ static inline int rect_is_same_size(const SpiceRect& r1, const SpiceRect& r2)
>      return rect_is_same_size(&r1, &r2);
>  }
>  
> +static inline int rect_contains(const SpiceRect& big, const SpiceRect& small)
> +{
> +    return rect_contains(&big, &small);
> +}
> +
>  #endif /* __cplusplus */
>  
>  #endif
> -- 
> 1.7.7.6
>