| Index: ppapi/cpp/dev/var_array_buffer_dev.h
|
| diff --git a/ppapi/cpp/dev/var_array_buffer_dev.h b/ppapi/cpp/dev/var_array_buffer_dev.h
|
| index 6f8c9590294ed5edc88d57bdab7988cf1d40b171..605a131dc904f8b5c9b5f7b5daad17121af6cc86 100644
|
| --- a/ppapi/cpp/dev/var_array_buffer_dev.h
|
| +++ b/ppapi/cpp/dev/var_array_buffer_dev.h
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| @@ -20,18 +20,28 @@ namespace pp {
|
| class VarArrayBuffer_Dev : public Var {
|
| public:
|
| /// Contruct a VarArrayBuffer_Dev given a var for which is_array_buffer() is
|
| - /// true. This will refer to the same buffer as var, but allows you to access
|
| - /// methods specific to VarArrayBuffer_Dev.
|
| + /// true. This will refer to the same ArrayBuffer as var, but allows you to
|
| + /// access methods specific to VarArrayBuffer_Dev.
|
| ///
|
| - /// @param[in] var An array buffer Var.
|
| + /// @param[in] var An ArrayBuffer Var.
|
| explicit VarArrayBuffer_Dev(const Var& var);
|
|
|
| + /// Copy constructor.
|
| VarArrayBuffer_Dev(const VarArrayBuffer_Dev& buffer) : Var(buffer) {}
|
|
|
| + virtual ~VarArrayBuffer_Dev() {}
|
| +
|
| + /// This function assigns one VarArrayBuffer to another VarArrayBuffer.
|
| + ///
|
| + /// @param[in] other The VarArrayBuffer to be assigned.
|
| + ///
|
| + /// @return The resulting VarArrayBuffer.
|
| + VarArrayBuffer_Dev& operator=(const VarArrayBuffer_Dev& other);
|
| +
|
| /// Construct a new VarArrayBuffer_Dev which is size_in_bytes bytes long and
|
| /// initialized to zero.
|
| ///
|
| - /// @param[in] size_in_bytes The size of the constructed array in bytes.
|
| + /// @param[in] size_in_bytes The size of the constructed ArrayBuffer in bytes.
|
| VarArrayBuffer_Dev(uint32_t size_in_bytes);
|
|
|
| /// Return the length of the VarArrayBuffer_Dev in bytes.
|
| @@ -39,17 +49,26 @@ class VarArrayBuffer_Dev : public Var {
|
| /// @return The length of the VarArrayBuffer_Dev in bytes.
|
| uint32_t ByteLength() const;
|
|
|
| - /// Return a pointer to the buffer associated with this VarArrayBuffer_Dev.
|
| + /// Maps the ArrayBuffer in to the module's address space and returns a
|
| + /// pointer to the internal buffer for this ArrayBuffer.
|
| ///
|
| - /// @return A pointer to the buffer associated with this VarArrayBuffer_Dev.
|
| + /// 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 = static_cast<char*>(array_buffer_var.Map());
|
| + /// uint32_t byte_length = array_buffer_var.ByteLength();
|
| + /// for (uint32_t i = 0; i < byte_length; ++i)
|
| + /// data[i] = 'A';
|
| + /// </code>
|
| + ///
|
| + /// @return A pointer to the internal buffer for this ArrayBuffer.
|
| void* Map();
|
| - const void* Map() const;
|
| -
|
| - virtual ~VarArrayBuffer_Dev() {}
|
|
|
| - private:
|
| - // We cache the buffer so that repeated calls to Map() are quick.
|
| - void* buffer_;
|
| + /// Unmaps this ArrayBuffer var from the module address space. Use this if
|
| + /// you want to save memory but might want to Map the buffer again later.
|
| + void Unmap();
|
| };
|
|
|
| } // namespace pp
|
|
|