Index: ppapi/api/dev/ppb_var_array_buffer_dev.idl |
diff --git a/ppapi/api/dev/ppb_var_array_buffer_dev.idl b/ppapi/api/dev/ppb_var_array_buffer_dev.idl |
index 909ad715862da5634087fa458fe61b61bacc3fcb..308173822bfad985db6f098098d8537cd6059e85 100644 |
--- a/ppapi/api/dev/ppb_var_array_buffer_dev.idl |
+++ b/ppapi/api/dev/ppb_var_array_buffer_dev.idl |
@@ -8,7 +8,7 @@ |
*/ |
label Chrome { |
- M17 = 0.1 |
+ M18 = 0.2 |
}; |
/** |
@@ -23,25 +23,62 @@ interface PPB_VarArrayBuffer_Dev { |
/** |
* Create a zero-initialized VarArrayBuffer. |
* |
- * @param[in] size_in_bytes The size of the array buffer that will be created. |
+ * @param[in] size_in_bytes The size of the ArrayBuffer that will be created. |
* |
* @return A PP_Var which represents an VarArrayBuffer of the requested size |
bbudge
2012/01/26 17:20:26
an/a
dmichael (off chromium)
2012/01/26 18:33:48
Done.
|
* with a reference count of 1. |
*/ |
PP_Var Create([in] uint32_t size_in_bytes); |
+ |
/** |
- * Returns the length of the VarArrayBuffer in bytes. |
+ * Retrieves the length of the VarArrayBuffer in bytes. On success, |
+ * byte_length is set to the length of the given ArrayBuffer var. On failure, |
+ * byte_length is unchanged (this could happen, for instance, if the given |
+ * PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER). Note that ByteLength() will |
+ * successfully retrieve the the size of an ArrayBuffer even if the |
+ * ArrayBuffer is not currently mapped. |
+ * |
+ * @param[in] array The ArrayBuffer whose length should be returned. |
+ * |
+ * @param[out] byte_length A variable which is set to the length of the given |
+ * ArrayBuffer on success. |
* |
- * @return The length of the VarArrayBuffer in bytes. |
+ * @return PP_TRUE on success, PP_FALSE on failure. |
*/ |
- uint32_t ByteLength([in] PP_Var array); |
+ PP_Bool ByteLength([in] PP_Var array, [out] uint32_t byte_length); |
+ |
/** |
- * Returns a pointer to the beginning of the buffer for the given array. |
+ * Maps the ArrayBuffer in to the module's address space and returns a pointer |
+ * to the beginning of the buffer for the given ArrayBuffer PP_Var. Note that |
+ * calling Map() can be a relatively expensive operation. Use care when |
+ * calling it in performance-critical code. For example, you should call it |
+ * only once when looping over an ArrayBuffer: |
+ * |
+ * <code> |
+ * char* data = (char*)(array_buffer_if.Map(array_buffer_var)); |
+ * uint32_t byte_length = 0; |
+ * PP_Bool ok = array_buffer_if.ByteLength(array_buffer_var, &byte_length); |
+ * if (!ok) |
+ * return DoSomethingBecauseMyVarIsNotAnArrayBuffer(); |
+ * for (uint32_t i = 0; i < byte_length; ++i) |
+ * data[i] = 'A'; |
+ * </code> |
* |
- * @param[in] array The array whose buffer should be returned. |
+ * @param[in] array The ArrayBuffer whose internal buffer should be returned. |
* |
- * @return A pointer to the buffer for this array. |
+ * @return A pointer to the internal buffer for this ArrayBuffer. Returns NULL |
+ * if the given PP_Var is not of type PP_VARTYPE_ARRAY_BUFFER. |
*/ |
mem_t Map([in] PP_Var array); |
+ |
+ /** |
+ * Unmaps the given ArrayBuffer var from the module address space. Use this if |
+ * you want to save memory but might want to Map the buffer again later. The |
+ * PP_Var remains valid and should still be released using PPB_Var when you |
+ * are done with the ArrayBuffer. |
+ * |
+ * @param[in] array The ArrayBuffer which should be released. |
+ */ |
+ void Unmap([in] PP_Var array); |
}; |