| OLD | NEW |
| 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 |
| 6 /* From ppb_graphics_2d.idl modified Sat Jul 16 16:50:26 2011. */ |
| 7 |
| 5 #ifndef PPAPI_C_PPB_GRAPHICS_2D_H_ | 8 #ifndef PPAPI_C_PPB_GRAPHICS_2D_H_ |
| 6 #define PPAPI_C_PPB_GRAPHICS_2D_H_ | 9 #define PPAPI_C_PPB_GRAPHICS_2D_H_ |
| 7 | 10 |
| 8 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
| 9 #include "ppapi/c/pp_completion_callback.h" | 12 #include "ppapi/c/pp_completion_callback.h" |
| 10 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
| 14 #include "ppapi/c/pp_macros.h" |
| 11 #include "ppapi/c/pp_point.h" | 15 #include "ppapi/c/pp_point.h" |
| 12 #include "ppapi/c/pp_rect.h" | 16 #include "ppapi/c/pp_rect.h" |
| 13 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
| 14 #include "ppapi/c/pp_size.h" | 18 #include "ppapi/c/pp_size.h" |
| 15 #include "ppapi/c/pp_stdint.h" | 19 #include "ppapi/c/pp_stdint.h" |
| 16 | 20 |
| 17 | |
| 18 #define PPB_GRAPHICS_2D_INTERFACE_0_4 "PPB_Graphics2D;0.4" | |
| 19 #define PPB_GRAPHICS_2D_INTERFACE_1_0 "PPB_Graphics2D;1.0" | |
| 20 #define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_1_0 | |
| 21 | |
| 22 /** | 21 /** |
| 23 * @file | 22 * @file |
| 24 * Defines the <code>PPB_Graphics2D</code> struct representing a 2D graphics | 23 * Defines the <code>PPB_Graphics2D</code> struct representing a 2D graphics |
| 25 * context within the browser. | 24 * context within the browser. |
| 26 */ | 25 */ |
| 27 | 26 |
| 27 |
| 28 /** | 28 /** |
| 29 * @addtogroup Interfaces | 29 * @addtogroup Interfaces |
| 30 * @{ | 30 * @{ |
| 31 */ | 31 */ |
| 32 | |
| 33 /** | 32 /** |
| 34 * <code>PPB_Graphics2D</code> defines the interface for a 2D graphics context. | 33 * <code>PPB_Graphics2D</code> defines the interface for a 2D graphics context. |
| 35 */ | 34 */ |
| 35 #define PPB_GRAPHICS_2D_INTERFACE_0_4 "PPB_Graphics2D;0.4" |
| 36 #define PPB_GRAPHICS_2D_INTERFACE_1_0 "PPB_Graphics2D;1.0" |
| 37 #define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_1_0 |
| 38 |
| 36 struct PPB_Graphics2D { | 39 struct PPB_Graphics2D { |
| 37 /** | 40 /** |
| 38 * Create() creates a 2D graphics context. The returned graphics context will | 41 * Create() creates a 2D graphics context. The returned graphics context will |
| 39 * not be bound to the module instance on creation (call BindGraphics() on | 42 * not be bound to the module instance on creation (call BindGraphics() on |
| 40 * the module instance to bind the returned graphics context to the module | 43 * the module instance to bind the returned graphics context to the module |
| 41 * instance). | 44 * instance). |
| 42 * | 45 * |
| 43 * @param[in] instance The module instance. | 46 * @param[in] instance The module instance. |
| 44 * @param[in] size The size of the graphic context. | 47 * @param[in] size The size of the graphic context. |
| 45 * @param[in] is_always_opaque Set the <code>is_always_opaque</code> flag to | 48 * @param[in] is_always_opaque Set the <code>is_always_opaque</code> flag to |
| 46 * <code>PP_TRUE</code> if you know that you will be painting only opaque | 49 * <code>PP_TRUE</code> if you know that you will be painting only opaque |
| 47 * data to this context. This option will disable blending when compositing | 50 * data to this context. This option will disable blending when compositing |
| 48 * the module with the web page, which might give higher performance on some | 51 * the module with the web page, which might give higher performance on some |
| 49 * computers. | 52 * computers. |
| 50 * | 53 * |
| 51 * If you set <code>is_always_opaque</code>, your alpha channel should always | 54 * If you set <code>is_always_opaque</code>, your alpha channel should always |
| 52 * be set to 0xFF or there may be painting artifacts. The alpha values | 55 * be set to 0xFF or there may be painting artifacts. The alpha values |
| 53 * overwrite the destination alpha values without blending when | 56 * overwrite the destination alpha values without blending when |
| 54 * <code>is_always_opaque</code> is true. | 57 * <code>is_always_opaque</code> is true. |
| 55 * | 58 * |
| 56 * @return A <code>PP_Resource</code> containing the 2D graphics context if | 59 * @return A <code>PP_Resource</code> containing the 2D graphics context if |
| 57 * successful or 0 if unsuccessful. | 60 * successful or 0 if unsuccessful. |
| 58 */ | 61 */ |
| 59 PP_Resource (*Create)(PP_Instance instance, | 62 PP_Resource (*Create)(PP_Instance instance, |
| 60 const struct PP_Size* size, | 63 const struct PP_Size* size, |
| 61 PP_Bool is_always_opaque); | 64 PP_Bool is_always_opaque); |
| 62 | |
| 63 /** | 65 /** |
| 64 * IsGraphics2D() determines if the given resource is a valid | 66 * IsGraphics2D() determines if the given resource is a valid |
| 65 * <code>Graphics2D</code>. | 67 * <code>Graphics2D</code>. |
| 66 * | 68 * |
| 67 * @param[in] resource A <code>Graphics2D</code> context resource. | 69 * @param[in] resource A <code>Graphics2D</code> context resource. |
| 68 * | 70 * |
| 69 * @return PP_TRUE if the given resource is a valid <code>Graphics2D</code>, | 71 * @return PP_TRUE if the given resource is a valid <code>Graphics2D</code>, |
| 70 * <code>PP_FALSE</code> if it is an invalid resource or is a resource of | 72 * <code>PP_FALSE</code> if it is an invalid resource or is a resource of |
| 71 * another type. | 73 * another type. |
| 72 */ | 74 */ |
| 73 PP_Bool (*IsGraphics2D)(PP_Resource resource); | 75 PP_Bool (*IsGraphics2D)(PP_Resource resource); |
| 74 | |
| 75 /** | 76 /** |
| 76 * Describe() retrieves the configuration for the given graphics context, | 77 * Describe() retrieves the configuration for the given graphics context, |
| 77 * filling the given values (which must not be <code>NULL</code>). | 78 * filling the given values (which must not be <code>NULL</code>). |
| 78 * | 79 * |
| 79 * @param[in] resource The 2D Graphics resource. | 80 * @param[in] resource The 2D Graphics resource. |
| 80 * @param[in,out] size The size of the 2D graphics context in the browser. | 81 * @param[in,out] size The size of the 2D graphics context in the browser. |
| 81 * @param[in,out] is_always_opaque Identifies whether only opaque data | 82 * @param[in,out] is_always_opaque Identifies whether only opaque data |
| 82 * will be painted. | 83 * will be painted. |
| 83 * | 84 * |
| 84 * @return Returns <code>PP_TRUE</code> on succes or <code>PP_FALSE</code> if | 85 * @return Returns <code>PP_TRUE</code> on succes or <code>PP_FALSE</code> if |
| 85 * the resource is invalid. The output parameters will be set to 0 on a | 86 * the resource is invalid. The output parameters will be set to 0 on a |
| 86 * <code>PP_FALSE</code>. | 87 * <code>PP_FALSE</code>. |
| 87 */ | 88 */ |
| 88 PP_Bool (*Describe)(PP_Resource graphics_2d, | 89 PP_Bool (*Describe)(PP_Resource graphics_2d, |
| 89 struct PP_Size* size, | 90 struct PP_Size* size, |
| 90 PP_Bool* is_always_opqaue); | 91 PP_Bool* is_always_opqaue); |
| 91 | |
| 92 /** | 92 /** |
| 93 * PaintImageData() enqueues a paint of the given image into the context. | 93 * PaintImageData() enqueues a paint of the given image into the context. |
| 94 * This function has no effect until you call Flush() As a result, what | 94 * This function has no effect until you call Flush() As a result, what |
| 95 * counts is the contents of the bitmap when you call Flush(), not when | 95 * counts is the contents of the bitmap when you call Flush(), not when |
| 96 * you call this function. | 96 * you call this function. |
| 97 * | 97 * |
| 98 * The provided image will be placed at <code>top_left</code> from the top | 98 * The provided image will be placed at <code>top_left</code> from the top |
| 99 * left of the context's internal backing store. Then the pixels contained | 99 * left of the context's internal backing store. Then the pixels contained |
| 100 * in <code>src_rect</code> will be copied into the backing store. This | 100 * in <code>src_rect</code> will be copied into the backing store. This |
| 101 * means that the rectangle being painted will be at <code>src_rect</code> | 101 * means that the rectangle being painted will be at <code>src_rect</code> |
| (...skipping 23 matching lines...) Expand all Loading... |
| 125 * @param[in] top_left A <code>Point</code> representing the | 125 * @param[in] top_left A <code>Point</code> representing the |
| 126 * <code>top_left</code> location where the <code>ImageData</code> will be | 126 * <code>top_left</code> location where the <code>ImageData</code> will be |
| 127 * painted. | 127 * painted. |
| 128 * @param[in] src_rect The rectangular area where the <code>ImageData</code> | 128 * @param[in] src_rect The rectangular area where the <code>ImageData</code> |
| 129 * will be painted. | 129 * will be painted. |
| 130 */ | 130 */ |
| 131 void (*PaintImageData)(PP_Resource graphics_2d, | 131 void (*PaintImageData)(PP_Resource graphics_2d, |
| 132 PP_Resource image_data, | 132 PP_Resource image_data, |
| 133 const struct PP_Point* top_left, | 133 const struct PP_Point* top_left, |
| 134 const struct PP_Rect* src_rect); | 134 const struct PP_Rect* src_rect); |
| 135 | |
| 136 /** | 135 /** |
| 137 * Scroll() enqueues a scroll of the context's backing store. This | 136 * Scroll() enqueues a scroll of the context's backing store. This |
| 138 * function has no effect until you call Flush(). The data within the | 137 * function has no effect until you call Flush(). The data within the |
| 139 * provided clipping rectangle will be shifted by (dx, dy) pixels. | 138 * provided clipping rectangle will be shifted by (dx, dy) pixels. |
| 140 * | 139 * |
| 141 * This function will result in some exposed region which will have undefined | 140 * This function will result in some exposed region which will have undefined |
| 142 * contents. The module should call PaintImageData() on these exposed regions | 141 * contents. The module should call PaintImageData() on these exposed regions |
| 143 * to give the correct contents. | 142 * to give the correct contents. |
| 144 * | 143 * |
| 145 * The scroll can be larger than the area of the clipping rectangle, which | 144 * The scroll can be larger than the area of the clipping rectangle, which |
| 146 * means the current image will be scrolled out of the rectangle. This | 145 * means the current image will be scrolled out of the rectangle. This |
| 147 * scenario is not an error but will result in a no-op. | 146 * scenario is not an error but will result in a no-op. |
| 148 * | 147 * |
| 149 * @param[in] graphics_2d The 2D Graphics resource. | 148 * @param[in] graphics_2d The 2D Graphics resource. |
| 150 * @param[in] clip The clipping rectangle. | 149 * @param[in] clip The clipping rectangle. |
| 151 * @param[in] amount The amount the area in the clipping rectangle will | 150 * @param[in] amount The amount the area in the clipping rectangle will |
| 152 * shifted. | 151 * shifted. |
| 153 */ | 152 */ |
| 154 void (*Scroll)(PP_Resource graphics_2d, | 153 void (*Scroll)(PP_Resource graphics_2d, |
| 155 const struct PP_Rect* clip_rect, | 154 const struct PP_Rect* clip_rect, |
| 156 const struct PP_Point* amount); | 155 const struct PP_Point* amount); |
| 157 | |
| 158 /** | 156 /** |
| 159 * ReplaceContents() provides a slightly more efficient way to paint the | 157 * ReplaceContents() provides a slightly more efficient way to paint the |
| 160 * entire module's image. Normally, calling PaintImageData() requires that | 158 * entire module's image. Normally, calling PaintImageData() requires that |
| 161 * the browser copy the pixels out of the image and into the graphics | 159 * the browser copy the pixels out of the image and into the graphics |
| 162 * context's backing store. This function replaces the graphics context's | 160 * context's backing store. This function replaces the graphics context's |
| 163 * backing store with the given image, avoiding the copy. | 161 * backing store with the given image, avoiding the copy. |
| 164 * | 162 * |
| 165 * The new image must be the exact same size as this graphics context. If the | 163 * The new image must be the exact same size as this graphics context. If the |
| 166 * new image uses a different image format than the browser's native bitmap | 164 * new image uses a different image format than the browser's native bitmap |
| 167 * format (use <code>PPB_ImageData.GetNativeImageDataFormat()</code> to | 165 * format (use <code>PPB_ImageData.GetNativeImageDataFormat()</code> to |
| (...skipping 13 matching lines...) Expand all Loading... |
| 181 * before allocating this bitmap. This gives the browser the option of | 179 * before allocating this bitmap. This gives the browser the option of |
| 182 * caching the previous backing store and handing it back to you (assuming | 180 * caching the previous backing store and handing it back to you (assuming |
| 183 * the sizes match). In the optimal case, this means no bitmaps are allocated | 181 * the sizes match). In the optimal case, this means no bitmaps are allocated |
| 184 * during the animation, and the backing store and "front buffer" (which the | 182 * during the animation, and the backing store and "front buffer" (which the |
| 185 * plugin is painting into) are just being swapped back and forth. | 183 * plugin is painting into) are just being swapped back and forth. |
| 186 * | 184 * |
| 187 * @param[in] graphics_2d The 2D Graphics resource. | 185 * @param[in] graphics_2d The 2D Graphics resource. |
| 188 * @param[in] image The <code>ImageData</code> to be painted. | 186 * @param[in] image The <code>ImageData</code> to be painted. |
| 189 */ | 187 */ |
| 190 void (*ReplaceContents)(PP_Resource graphics_2d, PP_Resource image_data); | 188 void (*ReplaceContents)(PP_Resource graphics_2d, PP_Resource image_data); |
| 191 | |
| 192 /** | 189 /** |
| 193 * Flush() flushes any enqueued paint, scroll, and replace commands to the | 190 * Flush() flushes any enqueued paint, scroll, and replace commands to the |
| 194 * backing store. This function actually executes the updates, and causes a | 191 * backing store. This function actually executes the updates, and causes a |
| 195 * repaint of the webpage, assuming this graphics context is bound to a module | 192 * repaint of the webpage, assuming this graphics context is bound to a module |
| 196 * instance. | 193 * instance. |
| 197 * | 194 * |
| 198 * Flush() runs in asynchronous mode. Specify a callback function and the | 195 * Flush() runs in asynchronous mode. Specify a callback function and the |
| 199 * argument for that callback function. The callback function will be | 196 * argument for that callback function. The callback function will be |
| 200 * executed on the calling thread when the image has been painted to the | 197 * executed on the calling thread when the image has been painted to the |
| 201 * screen. While you are waiting for a flush callback, additional calls to | 198 * screen. While you are waiting for a flush callback, additional calls to |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 * the image has been painted on the screen. | 239 * the image has been painted on the screen. |
| 243 * | 240 * |
| 244 * @return Returns <code>PP_OK</code> on success or | 241 * @return Returns <code>PP_OK</code> on success or |
| 245 * <code>PP_Error_BadResource</code> if the graphics context is invalid, | 242 * <code>PP_Error_BadResource</code> if the graphics context is invalid, |
| 246 * <code>PP_Error_BadArgument</code> if the callback is null and flush is | 243 * <code>PP_Error_BadArgument</code> if the callback is null and flush is |
| 247 * being called from the main thread of the module, or | 244 * being called from the main thread of the module, or |
| 248 * <code>PP_Error_InProgress</code> if a flush is already pending that has | 245 * <code>PP_Error_InProgress</code> if a flush is already pending that has |
| 249 * not issued its callback yet. In the failure case, nothing will be updated | 246 * not issued its callback yet. In the failure case, nothing will be updated |
| 250 * and no callback will be scheduled. | 247 * and no callback will be scheduled. |
| 251 */ | 248 */ |
| 252 | |
| 253 /* | 249 /* |
| 254 * TODO(darin): We should ensure that the completion callback always runs, so | 250 * TODO(darin): We should ensure that the completion callback always runs, so |
| 255 * that it is easier for consumers to manage memory referenced by a callback. | 251 * that it is easier for consumers to manage memory referenced by a callback. |
| 256 */ | 252 */ |
| 257 | |
| 258 /* | 253 /* |
| 259 * TODO(): Add back in the synchronous mode description once we have support | 254 * TODO(): Add back in the synchronous mode description once we have support |
| 260 * for it. | 255 * for it. |
| 261 */ | 256 */ |
| 262 int32_t (*Flush)(PP_Resource graphics_2d, | 257 int32_t (*Flush)(PP_Resource graphics_2d, |
| 263 struct PP_CompletionCallback callback); | 258 struct PP_CompletionCallback callback); |
| 264 | |
| 265 }; | 259 }; |
| 266 | |
| 267 /** | 260 /** |
| 268 * @} | 261 * @} |
| 269 */ | 262 */ |
| 263 |
| 270 #endif /* PPAPI_C_PPB_GRAPHICS_2D_H_ */ | 264 #endif /* PPAPI_C_PPB_GRAPHICS_2D_H_ */ |
| 265 |
| OLD | NEW |