Home | History | Annotate | Download | only in api
      1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file.
      4  */
      5 
      6 /**
      7  * This file defines the APIs for creating a 2 dimensional rectangle.
      8  */
      9 
     10 /**
     11  * The <code>PP_Rect</code> struct contains the size and location of a 2D
     12  * rectangle.
     13  */
     14 [assert_size(16)]
     15 struct PP_Rect {
     16   /**
     17    * This value represents the x and y coordinates of the upper-left corner of
     18    * the rectangle.
     19    */
     20   PP_Point point;
     21 
     22   /** This value represents the width and height of the rectangle. */
     23   PP_Size size;
     24 };
     25 
     26 /**
     27  * The <code>PP_FloatRect</code> struct contains the size and location of a 2D
     28  * rectangle.
     29  */
     30 struct PP_FloatRect {
     31   /**
     32    * This value represents the x and y coordinates of the upper-left corner of
     33    * the rectangle.
     34    */
     35   PP_FloatPoint point;
     36 
     37   /** This value represents the width and height of the rectangle. */
     38   PP_FloatSize size;
     39 };
     40 
     41 #inline c
     42 
     43 /**
     44  * @addtogroup Functions
     45  * @{
     46  */
     47 
     48 /**
     49  * PP_MakeRectFromXYWH() creates a <code>PP_Rect</code> given x and y
     50  * coordinates and width and height dimensions as int32_t values.
     51  *
     52  * @param[in] x An int32_t value representing a horizontal coordinate of a
     53  * point, starting with 0 as the left-most coordinate.
     54  * @param[in] y An int32_t value representing a vertical coordinate of a point,
     55  * starting with 0 as the top-most coordinate.
     56  * @param[in] w An int32_t value representing a width.
     57  * @param[in] h An int32_t value representing a height.
     58  *
     59  * @return A <code>PP_Rect</code> structure.
     60  */
     61 PP_INLINE struct PP_Rect PP_MakeRectFromXYWH(int32_t x, int32_t y,
     62                                              int32_t w, int32_t h) {
     63   struct PP_Rect ret;
     64   ret.point.x = x;
     65   ret.point.y = y;
     66   ret.size.width = w;
     67   ret.size.height = h;
     68   return ret;
     69 }
     70 
     71 /**
     72  * PP_MakeFloatRectFromXYWH() creates a <code>PP_FloatRect</code> given x and y
     73  * coordinates and width and height dimensions as float values.
     74  *
     75  * @param[in] x An float value representing a horizontal coordinate of a
     76  * point, starting with 0 as the left-most coordinate.
     77  * @param[in] y An float value representing a vertical coordinate of a point,
     78  * starting with 0 as the top-most coordinate.
     79  * @param[in] w An float value representing a width.
     80  * @param[in] h An float value representing a height.
     81  *
     82  * @return A <code>PP_FloatRect</code> structure.
     83  */
     84 PP_INLINE struct PP_FloatRect PP_MakeFloatRectFromXYWH(float x, float y,
     85                                                        float w, float h) {
     86   struct PP_FloatRect ret;
     87   ret.point.x = x;
     88   ret.point.y = y;
     89   ret.size.width = w;
     90   ret.size.height = h;
     91   return ret;
     92 }
     93 
     94 /**
     95  * @}
     96  */
     97 
     98 #endinl
     99 
    100