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