Home | History | Annotate | Download | only in dev
      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 /* From dev/ppb_graphics_2d_dev.idl modified Tue Nov 12 11:22:26 2013. */
      7 
      8 #ifndef PPAPI_C_DEV_PPB_GRAPHICS_2D_DEV_H_
      9 #define PPAPI_C_DEV_PPB_GRAPHICS_2D_DEV_H_
     10 
     11 #include "ppapi/c/pp_bool.h"
     12 #include "ppapi/c/pp_macros.h"
     13 #include "ppapi/c/pp_point.h"
     14 #include "ppapi/c/pp_resource.h"
     15 #include "ppapi/c/pp_stdint.h"
     16 
     17 #define PPB_GRAPHICS2D_DEV_INTERFACE_0_1 "PPB_Graphics2D(Dev);0.1"
     18 #define PPB_GRAPHICS2D_DEV_INTERFACE_0_2 "PPB_Graphics2D(Dev);0.2"
     19 #define PPB_GRAPHICS2D_DEV_INTERFACE PPB_GRAPHICS2D_DEV_INTERFACE_0_2
     20 
     21 /**
     22  * @file
     23  * This file contains the <code>PPB_Graphics2D_Dev</code> interface. */
     24 
     25 
     26 /**
     27  * @addtogroup Enums
     28  * @{
     29  */
     30 /**
     31  * These options affect how the existing graphics context is displayed when a
     32  * plugin is resized.
     33  */
     34 typedef enum {
     35   /**
     36    * In this mode, the context does not change size or offset. If the backing
     37    * store is the same size as the plugin element, this will result in the
     38    * pixels on the right side of the plugin element being unavailable, revealing
     39    * the contents underneath it.
     40    */
     41   PP_GRAPHICS2D_DEV_RESIZEMODE_DEFAULT,
     42   /**
     43    * In this mode, the context and its offset are scaled relative to how much
     44    * the plugin element has been resized.
     45    */
     46   PP_GRAPHICS2D_DEV_RESIZEMODE_STRETCH
     47 } PP_Graphics2D_Dev_ResizeMode;
     48 PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_Graphics2D_Dev_ResizeMode, 4);
     49 /**
     50  * @}
     51  */
     52 
     53 /**
     54  * @addtogroup Interfaces
     55  * @{
     56  */
     57 /* PPB_Graphics2D_Dev interface */
     58 struct PPB_Graphics2D_Dev_0_2 {
     59   /**
     60    * SetScale() sets the scale factor that will be applied when painting the
     61    * graphics context onto the output device. Typically, if rendering at device
     62    * resolution is desired, the context would be created with the width and
     63    * height scaled up by the view's GetDeviceScale and SetScale called with a
     64    * scale of 1.0 / GetDeviceScale(). For example, if the view resource passed
     65    * to DidChangeView has a rectangle of (w=200, h=100) and a device scale of
     66    * 2.0, one would call Create with a size of (w=400, h=200) and then call
     67    * SetScale with 0.5. One would then treat each pixel in the context as a
     68    * single device pixel.
     69    *
     70    * @param[in] resource A <code>Graphics2D</code> context resource.
     71    * @param[in] scale The scale to apply when painting.
     72    *
     73    * @return Returns <code>PP_TRUE</code> on success or <code>PP_FALSE</code> if
     74    * the resource is invalid or the scale factor is 0 or less.
     75    */
     76   PP_Bool (*SetScale)(PP_Resource resource, float scale);
     77   /***
     78    * GetScale() gets the scale factor that will be applied when painting the
     79    * graphics context onto the output device.
     80    *
     81    * @param[in] resource A <code>Graphics2D</code> context resource.
     82    *
     83    * @return Returns the scale factor for the graphics context. If the resource
     84    * is not a valid <code>Graphics2D</code> context, this will return 0.0.
     85    */
     86   float (*GetScale)(PP_Resource resource);
     87   /***
     88    * Sets the offset into the plugin element at which the graphics context is
     89    * painted. This allows a portion of the plugin element to be painted to.
     90    * The new offset will only be applied after Flush() has been called.
     91    *
     92    * @param[in] resource A <code>Graphics2D</code> context resource.
     93    * @param[in] offset The offset at which the context should be painted.
     94    */
     95   void (*SetOffset)(PP_Resource resource, const struct PP_Point* offset);
     96   /***
     97    * Sets the resize mode for the graphics context. When a plugin element is
     98    * resized in the DOM, it takes time for the plugin to update the graphics
     99    * context in the renderer. These options affect how the existing context is
    100    * displayed until the backing store is updated by the plugin.
    101    *
    102    * @param[in] resource A <code>Graphics2D</code> context resource.
    103    * @param[in] resize_mode The resize mode to change this context to.
    104    */
    105   void (*SetResizeMode)(PP_Resource resource,
    106                         PP_Graphics2D_Dev_ResizeMode resize_mode);
    107 };
    108 
    109 typedef struct PPB_Graphics2D_Dev_0_2 PPB_Graphics2D_Dev;
    110 
    111 struct PPB_Graphics2D_Dev_0_1 {
    112   PP_Bool (*SetScale)(PP_Resource resource, float scale);
    113   float (*GetScale)(PP_Resource resource);
    114   void (*SetResizeMode)(PP_Resource resource,
    115                         PP_Graphics2D_Dev_ResizeMode resize_mode);
    116 };
    117 /**
    118  * @}
    119  */
    120 
    121 #endif  /* PPAPI_C_DEV_PPB_GRAPHICS_2D_DEV_H_ */
    122 
    123