| 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_var_array_buffer.idl modified Thu Jan 26 14:50:50 2012. */ | 6 /* From ppb_var_array_buffer.idl modified Thu Feb 16 14:06:44 2012. */ |
| 7 | 7 |
| 8 #ifndef PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ | 8 #ifndef PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ |
| 9 #define PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ | 9 #define PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ |
| 10 | 10 |
| 11 #include "ppapi/c/pp_bool.h" | 11 #include "ppapi/c/pp_bool.h" |
| 12 #include "ppapi/c/pp_macros.h" | 12 #include "ppapi/c/pp_macros.h" |
| 13 #include "ppapi/c/pp_stdint.h" | 13 #include "ppapi/c/pp_stdint.h" |
| 14 #include "ppapi/c/pp_var.h" | 14 #include "ppapi/c/pp_var.h" |
| 15 | 15 |
| 16 #define PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0 "PPB_VarArrayBuffer;1.0" | 16 #define PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0 "PPB_VarArrayBuffer;1.0" |
| 17 #define PPB_VAR_ARRAY_BUFFER_INTERFACE PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0 | 17 #define PPB_VAR_ARRAY_BUFFER_INTERFACE PPB_VAR_ARRAY_BUFFER_INTERFACE_1_0 |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * @file | 20 * @file |
| 21 * This file defines the <code>PPB_VarArrayBuffer</code> struct. | 21 * This file defines the <code>PPB_VarArrayBuffer</code> struct providing |
| 22 * a way to interact with JavaScript ArrayBuffers. |
| 22 */ | 23 */ |
| 23 | 24 |
| 24 | 25 |
| 25 /** | 26 /** |
| 26 * @addtogroup Interfaces | 27 * @addtogroup Interfaces |
| 27 * @{ | 28 * @{ |
| 28 */ | 29 */ |
| 29 /** | 30 /** |
| 30 * PPB_VarArrayBuffer API. This provides a way to interact with JavaScript | 31 * The <code>PPB_VarArrayBuffer</code> interface provides a way to interact |
| 31 * ArrayBuffers, which represent a contiguous sequence of bytes. To manage the | 32 * with JavaScript ArrayBuffers, which represent a contiguous sequence of |
| 32 * reference count for a VarArrayBuffer, please see PPB_Var. Note that | 33 * bytes. Use <code>PPB_Var</code> to manage the reference count for a |
| 33 * these Vars are not part of the embedding page's DOM, and can only be shared | 34 * <code>VarArrayBuffer</code>. Note that these Vars are not part of the |
| 34 * with JavaScript via pp::Instance's PostMessage and HandleMessage functions. | 35 * embedding page's DOM, and can only be shared with JavaScript using the |
| 36 * <code>PostMessage</code> and <code>HandleMessage</code> functions of |
| 37 * <code>pp::Instance</code>. |
| 35 */ | 38 */ |
| 36 struct PPB_VarArrayBuffer_1_0 { | 39 struct PPB_VarArrayBuffer_1_0 { |
| 37 /** | 40 /** |
| 38 * Create a zero-initialized VarArrayBuffer. | 41 * Create() creates a zero-initialized <code>VarArrayBuffer</code>. |
| 39 * | 42 * |
| 40 * @param[in] size_in_bytes The size of the ArrayBuffer that will be created. | 43 * @param[in] size_in_bytes The size of the <code>ArrayBuffer</code> to |
| 44 * be created. |
| 41 * | 45 * |
| 42 * @return A PP_Var which represents a VarArrayBuffer of the requested size | 46 * @return A <code>PP_Var</code> representing a <code>VarArrayBuffer</code> |
| 43 * with a reference count of 1. | 47 * of the requested size and with a reference count of 1. |
| 44 */ | 48 */ |
| 45 struct PP_Var (*Create)(uint32_t size_in_bytes); | 49 struct PP_Var (*Create)(uint32_t size_in_bytes); |
| 46 /** | 50 /** |
| 47 * Retrieves the length of the VarArrayBuffer in bytes. On success, | 51 * ByteLength() retrieves the length of the <code>VarArrayBuffer</code> in |
| 48 * byte_length is set to the length of the given ArrayBuffer var. On failure, | 52 * bytes. On success, <code>byte_length</code> is set to the length of the |
| 49 * byte_length is unchanged (this could happen, for instance, if the given | 53 * given <code>ArrayBuffer</code> var. On failure, <code>byte_length</code> |
| 50 * PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER). Note that ByteLength() will | 54 * is unchanged (this could happen, for instance, if the given |
| 51 * successfully retrieve the the size of an ArrayBuffer even if the | 55 * <code>PP_Var</code> is not of type <code>PP_VARTYPE_ARRAY_BUFFER</code>). |
| 52 * ArrayBuffer is not currently mapped. | 56 * Note that ByteLength() will successfully retrieve the size of an |
| 57 * <code>ArrayBuffer</code> even if the <code>ArrayBuffer</code> is not |
| 58 * currently mapped. |
| 53 * | 59 * |
| 54 * @param[in] array The ArrayBuffer whose length should be returned. | 60 * @param[in] array The <code>ArrayBuffer</code> whose length should be |
| 61 * returned. |
| 55 * | 62 * |
| 56 * @param[out] byte_length A variable which is set to the length of the given | 63 * @param[out] byte_length A variable which is set to the length of the given |
| 57 * ArrayBuffer on success. | 64 * <code>ArrayBuffer</code> on success. |
| 58 * | 65 * |
| 59 * @return PP_TRUE on success, PP_FALSE on failure. | 66 * @return <code>PP_TRUE</code> on success, <code>PP_FALSE</code> on failure. |
| 60 */ | 67 */ |
| 61 PP_Bool (*ByteLength)(struct PP_Var array, uint32_t* byte_length); | 68 PP_Bool (*ByteLength)(struct PP_Var array, uint32_t* byte_length); |
| 62 /** | 69 /** |
| 63 * Maps the ArrayBuffer in to the module's address space and returns a pointer | 70 * Map() maps the <code>ArrayBuffer</code> in to the module's address space |
| 64 * to the beginning of the buffer for the given ArrayBuffer PP_Var. Note that | 71 * and returns a pointer to the beginning of the buffer for the given |
| 65 * calling Map() can be a relatively expensive operation. Use care when | 72 * <code>ArrayBuffer PP_Var</code>. Note that calling Map() can be a |
| 66 * calling it in performance-critical code. For example, you should call it | 73 * relatively expensive operation. Use care when calling it in |
| 67 * only once when looping over an ArrayBuffer: | 74 * performance-critical code. For example, you should call it only once when |
| 75 * looping over an <code>ArrayBuffer</code>. |
| 68 * | 76 * |
| 69 * <code> | 77 * <strong>Example:</strong> |
| 70 * char* data = (char*)(array_buffer_if.Map(array_buffer_var)); | |
| 71 * uint32_t byte_length = 0; | |
| 72 * PP_Bool ok = array_buffer_if.ByteLength(array_buffer_var, &byte_length); | |
| 73 * if (!ok) | |
| 74 * return DoSomethingBecauseMyVarIsNotAnArrayBuffer(); | |
| 75 * for (uint32_t i = 0; i < byte_length; ++i) | |
| 76 * data[i] = 'A'; | |
| 77 * </code> | |
| 78 * | 78 * |
| 79 * @param[in] array The ArrayBuffer whose internal buffer should be returned. | 79 * @code |
| 80 * char* data = (char*)(array_buffer_if.Map(array_buffer_var)); |
| 81 * uint32_t byte_length = 0; |
| 82 * PP_Bool ok = array_buffer_if.ByteLength(array_buffer_var, &byte_length); |
| 83 * if (!ok) |
| 84 * return DoSomethingBecauseMyVarIsNotAnArrayBuffer(); |
| 85 * for (uint32_t i = 0; i < byte_length; ++i) |
| 86 * data[i] = 'A'; |
| 87 * @endcode |
| 80 * | 88 * |
| 81 * @return A pointer to the internal buffer for this ArrayBuffer. Returns NULL | 89 * @param[in] array The <code>ArrayBuffer</code> whose internal buffer should |
| 82 * if the given PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER. | 90 * be returned. |
| 91 * |
| 92 * @return A pointer to the internal buffer for this |
| 93 * <code>ArrayBuffer</code>. Returns <code>NULL</code> |
| 94 * if the given <code>PP_Var</code> is not of type |
| 95 * <code>PP_VARTYPE_ARRAY_BUFFER</code>. |
| 83 */ | 96 */ |
| 84 void* (*Map)(struct PP_Var array); | 97 void* (*Map)(struct PP_Var array); |
| 85 /** | 98 /** |
| 86 * Unmaps the given ArrayBuffer var from the module address space. Use this if | 99 * Unmap() unmaps the given <code>ArrayBuffer</code> var from the module |
| 87 * you want to save memory but might want to Map the buffer again later. The | 100 * address space. Use this if you want to save memory but might want to call |
| 88 * PP_Var remains valid and should still be released using PPB_Var when you | 101 * Map() to map the buffer again later. The <code>PP_Var</code> remains valid |
| 89 * are done with the ArrayBuffer. | 102 * and should still be released using <code>PPB_Var</code> when you are done |
| 103 * with the <code>ArrayBuffer</code>. |
| 90 * | 104 * |
| 91 * @param[in] array The ArrayBuffer which should be released. | 105 * @param[in] array The <code>ArrayBuffer</code> to be released. |
| 92 */ | 106 */ |
| 93 void (*Unmap)(struct PP_Var array); | 107 void (*Unmap)(struct PP_Var array); |
| 94 }; | 108 }; |
| 95 | 109 |
| 96 typedef struct PPB_VarArrayBuffer_1_0 PPB_VarArrayBuffer; | 110 typedef struct PPB_VarArrayBuffer_1_0 PPB_VarArrayBuffer; |
| 97 /** | 111 /** |
| 98 * @} | 112 * @} |
| 99 */ | 113 */ |
| 100 | 114 |
| 101 #endif /* PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ */ | 115 #endif /* PPAPI_C_PPB_VAR_ARRAY_BUFFER_H_ */ |
| 102 | 116 |
| OLD | NEW |