OLD | NEW |
1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 | 5 |
6 /* From ppb_graphics_2d.idl modified Mon Mar 19 11:35:04 2012. */ | 6 /* From ppb_graphics_2d.idl modified Thu Mar 21 11:26:54 2013. */ |
7 | 7 |
8 #ifndef PPAPI_C_PPB_GRAPHICS_2D_H_ | 8 #ifndef PPAPI_C_PPB_GRAPHICS_2D_H_ |
9 #define PPAPI_C_PPB_GRAPHICS_2D_H_ | 9 #define PPAPI_C_PPB_GRAPHICS_2D_H_ |
10 | 10 |
11 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
12 #include "ppapi/c/pp_completion_callback.h" | 12 #include "ppapi/c/pp_completion_callback.h" |
13 #include "ppapi/c/pp_instance.h" | 13 #include "ppapi/c/pp_instance.h" |
14 #include "ppapi/c/pp_macros.h" | 14 #include "ppapi/c/pp_macros.h" |
15 #include "ppapi/c/pp_point.h" | 15 #include "ppapi/c/pp_point.h" |
16 #include "ppapi/c/pp_rect.h" | 16 #include "ppapi/c/pp_rect.h" |
17 #include "ppapi/c/pp_resource.h" | 17 #include "ppapi/c/pp_resource.h" |
18 #include "ppapi/c/pp_size.h" | 18 #include "ppapi/c/pp_size.h" |
19 #include "ppapi/c/pp_stdint.h" | 19 #include "ppapi/c/pp_stdint.h" |
20 | 20 |
21 #define PPB_GRAPHICS_2D_INTERFACE_1_0 "PPB_Graphics2D;1.0" | 21 #define PPB_GRAPHICS_2D_INTERFACE_1_0 "PPB_Graphics2D;1.0" |
22 #define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_1_0 | 22 #define PPB_GRAPHICS_2D_INTERFACE_1_1 "PPB_Graphics2D;1.1" |
| 23 #define PPB_GRAPHICS_2D_INTERFACE PPB_GRAPHICS_2D_INTERFACE_1_1 |
23 | 24 |
24 /** | 25 /** |
25 * @file | 26 * @file |
26 * Defines the <code>PPB_Graphics2D</code> struct representing a 2D graphics | 27 * Defines the <code>PPB_Graphics2D</code> struct representing a 2D graphics |
27 * context within the browser. | 28 * context within the browser. |
28 */ | 29 */ |
29 | 30 |
30 | 31 |
31 /** | 32 /** |
32 * @addtogroup Interfaces | 33 * @addtogroup Interfaces |
33 * @{ | 34 * @{ |
34 */ | 35 */ |
35 /** | 36 /** |
36 * <code>PPB_Graphics2D</code> defines the interface for a 2D graphics context. | 37 * <code>PPB_Graphics2D</code> defines the interface for a 2D graphics context. |
37 */ | 38 */ |
38 struct PPB_Graphics2D_1_0 { | 39 struct PPB_Graphics2D_1_1 { |
39 /** | 40 /** |
40 * Create() creates a 2D graphics context. The returned graphics context will | 41 * Create() creates a 2D graphics context. The returned graphics context will |
41 * 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 |
42 * 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 |
43 * instance). | 44 * instance). |
44 * | 45 * |
45 * @param[in] instance The module instance. | 46 * @param[in] instance The module instance. |
46 * @param[in] size The size of the graphic context. | 47 * @param[in] size The size of the graphic context. |
47 * @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 |
48 * <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 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 * @return Returns <code>PP_OK</code> on success or | 241 * @return Returns <code>PP_OK</code> on success or |
241 * <code>PP_ERROR_BADRESOURCE</code> if the graphics context is invalid, | 242 * <code>PP_ERROR_BADRESOURCE</code> if the graphics context is invalid, |
242 * <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 |
243 * being called from the main thread of the module, or | 244 * being called from the main thread of the module, or |
244 * <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 |
245 * 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 |
246 * and no callback will be scheduled. | 247 * and no callback will be scheduled. |
247 */ | 248 */ |
248 int32_t (*Flush)(PP_Resource graphics_2d, | 249 int32_t (*Flush)(PP_Resource graphics_2d, |
249 struct PP_CompletionCallback callback); | 250 struct PP_CompletionCallback callback); |
| 251 /** |
| 252 * SetScale() sets the scale factor that will be applied when painting the |
| 253 * graphics context onto the output device. Typically, if rendering at device |
| 254 * resolution is desired, the context would be created with the width and |
| 255 * height scaled up by the view's GetDeviceScale and SetScale called with a |
| 256 * scale of 1.0 / GetDeviceScale(). For example, if the view resource passed |
| 257 * to DidChangeView has a rectangle of (w=200, h=100) and a device scale of |
| 258 * 2.0, one would call Create with a size of (w=400, h=200) and then call |
| 259 * SetScale with 0.5. One would then treat each pixel in the context as a |
| 260 * single device pixel. |
| 261 * |
| 262 * @param[in] resource A <code>Graphics2D</code> context resource. |
| 263 * @param[in] scale The scale to apply when painting. |
| 264 * |
| 265 * @return Returns <code>PP_TRUE</code> on success or <code>PP_FALSE</code> if |
| 266 * the resource is invalid or the scale factor is 0 or less. |
| 267 */ |
| 268 PP_Bool (*SetScale)(PP_Resource resource, float scale); |
| 269 /*** |
| 270 * GetScale() gets the scale factor that will be applied when painting the |
| 271 * graphics context onto the output device. |
| 272 * |
| 273 * @param[in] resource A <code>Graphics2D</code> context resource. |
| 274 * |
| 275 * @return Returns the scale factor for the graphics context. If the resource |
| 276 * is not a valid <code>Graphics2D</code> context, this will return 0.0. |
| 277 */ |
| 278 float (*GetScale)(PP_Resource resource); |
250 }; | 279 }; |
251 | 280 |
252 typedef struct PPB_Graphics2D_1_0 PPB_Graphics2D; | 281 typedef struct PPB_Graphics2D_1_1 PPB_Graphics2D; |
| 282 |
| 283 struct PPB_Graphics2D_1_0 { |
| 284 PP_Resource (*Create)(PP_Instance instance, |
| 285 const struct PP_Size* size, |
| 286 PP_Bool is_always_opaque); |
| 287 PP_Bool (*IsGraphics2D)(PP_Resource resource); |
| 288 PP_Bool (*Describe)(PP_Resource graphics_2d, |
| 289 struct PP_Size* size, |
| 290 PP_Bool* is_always_opqaue); |
| 291 void (*PaintImageData)(PP_Resource graphics_2d, |
| 292 PP_Resource image_data, |
| 293 const struct PP_Point* top_left, |
| 294 const struct PP_Rect* src_rect); |
| 295 void (*Scroll)(PP_Resource graphics_2d, |
| 296 const struct PP_Rect* clip_rect, |
| 297 const struct PP_Point* amount); |
| 298 void (*ReplaceContents)(PP_Resource graphics_2d, PP_Resource image_data); |
| 299 int32_t (*Flush)(PP_Resource graphics_2d, |
| 300 struct PP_CompletionCallback callback); |
| 301 }; |
253 /** | 302 /** |
254 * @} | 303 * @} |
255 */ | 304 */ |
256 | 305 |
257 #endif /* PPAPI_C_PPB_GRAPHICS_2D_H_ */ | 306 #endif /* PPAPI_C_PPB_GRAPHICS_2D_H_ */ |
258 | 307 |
OLD | NEW |