diff options
author | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 18:51:50 +0000 |
---|---|---|
committer | apatrick@google.com <apatrick@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-13 18:51:50 +0000 |
commit | d8cafdf39a84559f2ce223d1710bf91950415215 (patch) | |
tree | dde721bddfd4de569d06831fad16195c7ead07c5 /o3d/gpu_plugin/command_buffer.cc | |
parent | b75dca87f3ff3ee3ab003960276ec7bb49d4c734 (diff) | |
download | chromium_src-d8cafdf39a84559f2ce223d1710bf91950415215.zip chromium_src-d8cafdf39a84559f2ce223d1710bf91950415215.tar.gz chromium_src-d8cafdf39a84559f2ce223d1710bf91950415215.tar.bz2 |
Moved responsibility for creating ring buffer from CommandBuffer to GPUPluginObject.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/264041
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/gpu_plugin/command_buffer.cc')
-rw-r--r-- | o3d/gpu_plugin/command_buffer.cc | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/o3d/gpu_plugin/command_buffer.cc b/o3d/gpu_plugin/command_buffer.cc index 293235ce..3dc35b8 100644 --- a/o3d/gpu_plugin/command_buffer.cc +++ b/o3d/gpu_plugin/command_buffer.cc @@ -22,41 +22,24 @@ CommandBuffer::CommandBuffer(NPP npp) CommandBuffer::~CommandBuffer() { } -bool CommandBuffer::Initialize(int32 size) { - // Check the size will not overflow when it is converted from count of int32s - // to count of bytes. - int32 num_bytes = static_cast<int32>(size * sizeof(int32)); - if (num_bytes / sizeof(int32) != size) - return false; - +bool CommandBuffer::Initialize(NPObjectPointer<NPObject> ring_buffer) { + // Fail if already initialized. if (ring_buffer_.Get()) return false; - NPObjectPointer<NPObject> window = NPObjectPointer<NPObject>::FromReturned( - NPBrowser::get()->GetWindowNPObject(npp_)); - if (!window.Get()) + if (!ring_buffer.Get()) return false; - NPObjectPointer<NPObject> chromium; - if (!NPGetProperty(npp_, window, "chromium", &chromium)) { + int32 size_in_bytes; + if (!NPInvoke(npp_, ring_buffer, "getSize", &size_in_bytes)) return false; - } - NPObjectPointer<NPObject> system; - if (!NPGetProperty(npp_, chromium, "system", &system)) { + if (size_in_bytes < 0) return false; - } - if (!NPInvoke(npp_, system, "createSharedMemory", num_bytes, - &ring_buffer_)) { - return false; - } - - if (!ring_buffer_.Get()) { - return false; - } + size_ = size_in_bytes / sizeof(int32); + ring_buffer_ = ring_buffer; - size_ = size; return true; } |