Index: gpu/pgl/command_buffer_pepper.cc |
=================================================================== |
--- gpu/pgl/command_buffer_pepper.cc (revision 0) |
+++ gpu/pgl/command_buffer_pepper.cc (working copy) |
@@ -1,76 +1,54 @@ |
-// Copyright (c) 2009 The Chromium Authors. All rights reserved. |
+// Copyright (c) 2010 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. |
-#include "webkit/tools/pepper_test_plugin/command_buffer_pepper.h" |
+#include "gpu/pgl/command_buffer_pepper.h" |
#include "base/logging.h" |
using base::SharedMemory; |
using gpu::Buffer; |
-CommandBufferPepper::CommandBufferPepper(NPP npp, NPNetscapeFuncs* browser) |
+CommandBufferPepper::CommandBufferPepper(NPP npp, |
+ NPDevice* device, |
+ NPDeviceContext3D* context) |
: npp_(npp), |
- browser_(browser), |
- extensions_(NULL), |
- device_(NULL) { |
+ device_(device), |
+ context_(context) { |
} |
CommandBufferPepper::~CommandBufferPepper() { |
- if (device_) { |
- device_->destroyContext(npp_, &context_); |
- device_ = NULL; |
- } |
} |
+// Not implemented in CommandBufferPepper. |
bool CommandBufferPepper::Initialize(int32 size) { |
- if (device_) |
- return false; |
- |
- // Get the pepper extensions. |
- browser_->getvalue(npp_, |
- NPNVPepperExtensions, |
- reinterpret_cast<void*>(&extensions_)); |
- CHECK(extensions_); |
- |
- // Acquire a 3D device. |
- device_ = extensions_->acquireDevice(npp_, NPPepper3DDevice); |
- if (device_) { |
- NPDeviceContext3DConfig config; |
- config.commandBufferEntries = size; |
- if (NPERR_NO_ERROR == device_->initializeContext(npp_, |
- &config, |
- &context_)) { |
- return true; |
- } |
- } |
- |
+ NOTREACHED(); |
return false; |
} |
Buffer CommandBufferPepper::GetRingBuffer() { |
Buffer buffer; |
- buffer.ptr = context_.commandBuffer; |
- buffer.size = context_.commandBufferEntries * sizeof(int32); |
+ buffer.ptr = context_->commandBuffer; |
+ buffer.size = context_->commandBufferEntries * sizeof(int32); |
return buffer; |
} |
int32 CommandBufferPepper::GetSize() { |
- return context_.commandBufferEntries; |
+ return context_->commandBufferEntries; |
} |
int32 CommandBufferPepper::SyncOffsets(int32 put_offset) { |
- context_.putOffset = put_offset; |
- if (NPERR_NO_ERROR != device_->flushContext(npp_, &context_, NULL, NULL)) |
+ context_->putOffset = put_offset; |
+ if (NPERR_NO_ERROR != device_->flushContext(npp_, context_, NULL, NULL)) |
return -1; |
- return context_.getOffset; |
+ return context_->getOffset; |
} |
int32 CommandBufferPepper::GetGetOffset() { |
int32 value; |
if (NPERR_NO_ERROR != device_->getStateContext( |
npp_, |
- &context_, |
+ context_, |
NPDeviceContext3DState_GetOffset, |
&value)) { |
return -1; |
@@ -88,7 +66,7 @@ |
int32 value; |
if (NPERR_NO_ERROR != device_->getStateContext( |
npp_, |
- &context_, |
+ context_, |
NPDeviceContext3DState_PutOffset, |
&value)) { |
return -1; |
@@ -99,19 +77,19 @@ |
int32 CommandBufferPepper::CreateTransferBuffer(size_t size) { |
int32 id; |
- if (NPERR_NO_ERROR != device_->createBuffer(npp_, &context_, size, &id)) |
+ if (NPERR_NO_ERROR != device_->createBuffer(npp_, context_, size, &id)) |
return -1; |
return id; |
} |
void CommandBufferPepper::DestroyTransferBuffer(int32 id) { |
- device_->destroyBuffer(npp_, &context_, id); |
+ device_->destroyBuffer(npp_, context_, id); |
} |
Buffer CommandBufferPepper::GetTransferBuffer(int32 id) { |
NPDeviceBuffer np_buffer; |
- if (NPERR_NO_ERROR != device_->mapBuffer(npp_, &context_, id, &np_buffer)) |
+ if (NPERR_NO_ERROR != device_->mapBuffer(npp_, context_, id, &np_buffer)) |
return Buffer(); |
Buffer buffer; |
@@ -124,7 +102,7 @@ |
int32 value; |
if (NPERR_NO_ERROR != device_->getStateContext( |
npp_, |
- &context_, |
+ context_, |
NPDeviceContext3DState_Token, |
&value)) { |
return -1; |
@@ -142,7 +120,7 @@ |
int32 value; |
if (NPERR_NO_ERROR != device_->getStateContext( |
npp_, |
- &context_, |
+ context_, |
NPDeviceContext3DState_ParseError, |
&value)) { |
return -1; |
@@ -160,7 +138,7 @@ |
int32 value; |
if (NPERR_NO_ERROR != device_->getStateContext( |
npp_, |
- &context_, |
+ context_, |
NPDeviceContext3DState_ErrorStatus, |
&value)) { |
return value != 0; |