summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-07 22:06:18 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-07 22:06:18 +0000
commitbb62ce3d7922d0bd07b066f6460c7cd00f946011 (patch)
tree22657f3db7f64c7b8ace37bb2a3d4d1e2426cba0 /ppapi
parent481a6d899f7c9a4d3e029fa6553f6bec589b5564 (diff)
downloadchromium_src-bb62ce3d7922d0bd07b066f6460c7cd00f946011.zip
chromium_src-bb62ce3d7922d0bd07b066f6460c7cd00f946011.tar.gz
chromium_src-bb62ce3d7922d0bd07b066f6460c7cd00f946011.tar.bz2
Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer"
This reverts commit bd45bd252aeb8babac62547a5c605fbf64287cd3. TEST=ran webkit tests in DRT and webgl tests in chrome BUG=103989 Review URL: http://codereview.chromium.org/8758026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113479 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/trusted/ppb_graphics_3d_trusted.h8
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc26
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.cc31
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h8
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc7
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppb_graphics_3d.srpc15
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc14
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc13
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h6
-rw-r--r--ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h6
-rw-r--r--ppapi/proxy/ppapi_messages.h7
-rw-r--r--ppapi/proxy/ppb_graphics_3d_proxy.cc89
-rw-r--r--ppapi/proxy/ppb_graphics_3d_proxy.h10
-rw-r--r--ppapi/thunk/ppb_graphics_3d_api.h5
-rw-r--r--ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc12
15 files changed, 87 insertions, 170 deletions
diff --git a/ppapi/c/trusted/ppb_graphics_3d_trusted.h b/ppapi/c/trusted/ppb_graphics_3d_trusted.h
index d6a6481..353b6dd 100644
--- a/ppapi/c/trusted/ppb_graphics_3d_trusted.h
+++ b/ppapi/c/trusted/ppb_graphics_3d_trusted.h
@@ -59,12 +59,10 @@ struct PPB_Graphics3DTrusted {
const int32_t* attrib_list);
// Initializes the command buffer with the given size.
- PP_Bool (*InitCommandBuffer)(PP_Resource context_id, int32_t size);
+ PP_Bool (*InitCommandBuffer)(PP_Resource context_id);
- // Gets the ring buffer for the command buffer.
- PP_Bool (*GetRingBuffer)(PP_Resource context_id,
- int* shm_handle,
- uint32_t* shm_size);
+ // Sets the buffer used for commands.
+ PP_Bool (*SetGetBuffer)(PP_Resource context, int32_t transfer_buffer_id);
// Returns the current state.
struct PP_Graphics3DTrustedState (*GetState)(PP_Resource context);
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc
index 62ea1eb..f678be1 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/browser_ppb_graphics_3d_rpc_server.cc
@@ -244,40 +244,26 @@ void PpbGraphics3DRpcServer::PPB_Graphics3DTrusted_InitCommandBuffer(
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
PP_Resource resource_id,
- int32_t size,
int32_t* success) {
DebugPrintf("PPB_Graphics3DTrusted_InitCommandBuffer(...) resource_id: %d\n",
resource_id);
NaClSrpcClosureRunner runner(done);
rpc->result = NACL_SRPC_RESULT_APP_ERROR;
- if ((size > kMaxAllowedBufferSize) || (size < 0))
- return;
*success = ppapi_proxy::PPBGraphics3DTrustedInterface()->InitCommandBuffer(
- resource_id, size);
+ resource_id);
rpc->result = NACL_SRPC_RESULT_OK;
}
-
-void PpbGraphics3DRpcServer::PPB_Graphics3DTrusted_GetRingBuffer(
+void PpbGraphics3DRpcServer::PPB_Graphics3DTrusted_SetGetBuffer(
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
PP_Resource resource_id,
- NaClSrpcImcDescType* shm_desc,
- int32_t* shm_size) {
- DebugPrintf("PPB_Graphics3DTrusted_GetRingBuffer\n");
- nacl::DescWrapperFactory factory;
- nacl::scoped_ptr<nacl::DescWrapper> desc_wrapper;
+ int32_t transfer_buffer_id) {
+ DebugPrintf("PPB_Graphics3DTrusted_SetGetBuffer\n");
NaClSrpcClosureRunner runner(done);
rpc->result = NACL_SRPC_RESULT_APP_ERROR;
-
- int native_handle = 0;
- uint32_t native_size = 0;
- ppapi_proxy::PPBGraphics3DTrustedInterface()->GetRingBuffer(
- resource_id, &native_handle, &native_size);
- desc_wrapper.reset(factory.ImportShmHandle(
- (NaClHandle)native_handle, native_size));
- *shm_desc = desc_wrapper->desc();
- *shm_size = native_size;
+ ppapi_proxy::PPBGraphics3DTrustedInterface()->SetGetBuffer(
+ resource_id, transfer_buffer_id);
rpc->result = NACL_SRPC_RESULT_OK;
}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.cc b/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.cc
index e151312..4a83a04 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.cc
@@ -25,38 +25,18 @@ CommandBufferNacl::~CommandBufferNacl() {
iface_core_->ReleaseResource(graphics_3d_);
}
-bool CommandBufferNacl::Initialize(int32 size) {
+bool CommandBufferNacl::Initialize() {
DebugPrintf("CommandBufferNacl::Initialize\n");
int32_t success;
NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
NaClSrpcError retval =
PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_InitCommandBuffer(
- channel, graphics_3d_, size, &success);
+ channel, graphics_3d_, &success);
DebugPrintf("CommandBufferNaCl::Initialize returned success=%s\n",
(PP_TRUE == success) ? "TRUE" : "FALSE");
return NACL_SRPC_RESULT_OK == retval && PP_TRUE == success;
}
-gpu::Buffer CommandBufferNacl::GetRingBuffer() {
- DebugPrintf("CommandBufferNacl::GetRingBuffer\n");
- if (!buffer_.ptr) {
- DebugPrintf("CommandBufferNacl::GetRingBuffer: Fetching\n");
- int shm_handle = -1;
- int32_t shm_size = 0;
-
- NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
- NaClSrpcError retval =
- PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_GetRingBuffer(
- channel, graphics_3d_, &shm_handle, &shm_size);
- if (NACL_SRPC_RESULT_OK != retval) {
- shm_handle = -1;
- }
- buffer_ = BufferFromShm(shm_handle, shm_size);
- }
-
- return buffer_;
-}
-
gpu::CommandBuffer::State CommandBufferNacl::GetState() {
DebugPrintf("CommandBufferNacl::GetState\n");
PP_Graphics3DTrustedState state;
@@ -110,6 +90,13 @@ gpu::CommandBuffer::State CommandBufferNacl::FlushSync(int32 put_offset,
return last_state_;
}
+void CommandBufferNacl::SetGetBuffer(int32 transfer_buffer_id) {
+ DebugPrintf("CommandBufferNacl::SetGetBuffer\n");
+ NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
+ PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_SetGetBuffer(
+ channel, graphics_3d_, transfer_buffer_id);
+}
+
void CommandBufferNacl::SetGetOffset(int32 get_offset) {
DebugPrintf("CommandBufferNacl::SetGetOffset\n");
// Not implemented by proxy.
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h b/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h
index a699241..20e3836 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.h
@@ -22,16 +22,12 @@ class CommandBufferNacl : public gpu::CommandBuffer {
virtual ~CommandBufferNacl();
// CommandBuffer implementation.
- virtual bool Initialize(int32 size);
- virtual bool Initialize(base::SharedMemory* buffer, int32 size) {
- // TODO(neb): support for nacl if neccessary
- return false;
- }
- virtual gpu::Buffer GetRingBuffer();
+ virtual bool Initialize();
virtual State GetState();
virtual State GetLastState();
virtual void Flush(int32 put_offset);
virtual State FlushSync(int32 put_offset, int32 last_known_get);
+ virtual void SetGetBuffer(int32 transfer_buffer_id);
virtual void SetGetOffset(int32 get_offset);
virtual int32 CreateTransferBuffer(size_t size, int32 id_request);
virtual int32 RegisterTransferBuffer(base::SharedMemory* buffer,
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc
index c77902b..ead08dd 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.cc
@@ -212,12 +212,9 @@ bool PluginGraphics3D::InitFromBrowserResource(PP_Resource res) {
// Create and initialize the objects required to issue GLES2 calls.
command_buffer_.reset(new CommandBufferNacl(res, PluginCore::GetInterface()));
- if (command_buffer_->Initialize(kRingBufferSize)) {
+ if (command_buffer_->Initialize()) {
gles2_helper_.reset(new gpu::gles2::GLES2CmdHelper(command_buffer_.get()));
- gpu::Buffer buffer = command_buffer_->GetRingBuffer();
- DebugPrintf("PluginGraphics3D::InitFromBrowserResource: buffer size: %d\n",
- buffer.size);
- if (gles2_helper_->Initialize(buffer.size)) {
+ if (gles2_helper_->Initialize(kRingBufferSize)) {
// Request id -1 to signify 'don't care'
int32 transfer_buffer_id =
command_buffer_->CreateTransferBuffer(kTransferBufferSize, -1);
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_graphics_3d.srpc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_graphics_3d.srpc
index fe0b499..0cb9b57 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_graphics_3d.srpc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_graphics_3d.srpc
@@ -77,16 +77,15 @@
# Initialize the command buffer.
{'name': 'PPB_Graphics3DTrusted_InitCommandBuffer',
'inputs': [['resource_id', 'PP_Resource'],
- ['size', 'int32_t']
],
'outputs': [['success', 'int32_t']] # PP_Bool
},
- # Get the ring buffer.
- {'name': 'PPB_Graphics3DTrusted_GetRingBuffer',
- 'inputs': [['resource_id', 'PP_Resource']],
- 'outputs': [['shm_desc', 'handle'],
- ['shm_size', 'int32_t']
- ]
+ # Set the buffer used for commands.
+ {'name': 'PPB_Graphics3DTrusted_SetGetBuffer',
+ 'inputs': [['resource_id', 'PP_Resource'],
+ ['shm_id', 'int32_t'],
+ ],
+ 'outputs': []
},
# Get command buffer state.
{'name': 'PPB_Graphics3DTrusted_GetState',
@@ -142,6 +141,6 @@
['shm_size', 'int32_t']
]
},
- # End of PPB_Graphics3DTrusted
+ # End of PPB_Graphics3DTrusted
]
}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc
index 20ebd55..e5739ba 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_client.cc
@@ -1435,7 +1435,6 @@ NaClSrpcError PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_CreateRaw(
NaClSrpcError PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_InitCommandBuffer(
NaClSrpcChannel* channel,
PP_Resource resource_id,
- int32_t size,
int32_t* success) {
VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(),
("%s: PPAPI calls are not supported off the main thread\n",
@@ -1443,29 +1442,26 @@ NaClSrpcError PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_InitCommandBuffer(
NaClSrpcError retval;
retval = NaClSrpcInvokeBySignature(
channel,
- "PPB_Graphics3DTrusted_InitCommandBuffer:ii:i",
+ "PPB_Graphics3DTrusted_InitCommandBuffer:i:i",
resource_id,
- size,
success
);
return retval;
}
-NaClSrpcError PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_GetRingBuffer(
+NaClSrpcError PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_SetGetBuffer(
NaClSrpcChannel* channel,
PP_Resource resource_id,
- NaClSrpcImcDescType* shm_desc,
- int32_t* shm_size) {
+ int32_t transfer_buffer_id) {
VCHECK(ppapi_proxy::PPBCoreInterface()->IsMainThread(),
("%s: PPAPI calls are not supported off the main thread\n",
__FUNCTION__));
NaClSrpcError retval;
retval = NaClSrpcInvokeBySignature(
channel,
- "PPB_Graphics3DTrusted_GetRingBuffer:i:hi",
+ "PPB_Graphics3DTrusted_SetGetBuffer:ii:",
resource_id,
- shm_desc,
- shm_size
+ transfer_buffer_id
);
return retval;
}
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc
index 54187d0..b40fd2d 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc
+++ b/ppapi/native_client/src/shared/ppapi_proxy/ppb_rpc_server.cc
@@ -1160,23 +1160,22 @@ static void PPB_Graphics3DTrusted_InitCommandBufferDispatcher(
rpc,
done,
inputs[0]->u.ival,
- inputs[1]->u.ival,
&(outputs[0]->u.ival)
);
}
-static void PPB_Graphics3DTrusted_GetRingBufferDispatcher(
+static void PPB_Graphics3DTrusted_SetGetBufferDispatcher(
NaClSrpcRpc* rpc,
NaClSrpcArg** inputs,
NaClSrpcArg** outputs,
NaClSrpcClosure* done
) {
- PpbGraphics3DRpcServer::PPB_Graphics3DTrusted_GetRingBuffer(
+ UNREFERENCED_PARAMETER(outputs);
+ PpbGraphics3DRpcServer::PPB_Graphics3DTrusted_SetGetBuffer(
rpc,
done,
inputs[0]->u.ival,
- &(outputs[0]->u.hval),
- &(outputs[1]->u.ival)
+ inputs[1]->u.ival
);
}
@@ -2619,8 +2618,8 @@ NaClSrpcHandlerDesc PpbRpcs::srpc_methods[] = {
{ "PPB_Graphics3D_GetError:i:i", PPB_Graphics3D_GetErrorDispatcher },
{ "PPB_Graphics3D_SwapBuffers:ii:i", PPB_Graphics3D_SwapBuffersDispatcher },
{ "PPB_Graphics3DTrusted_CreateRaw:iiI:i", PPB_Graphics3DTrusted_CreateRawDispatcher },
- { "PPB_Graphics3DTrusted_InitCommandBuffer:ii:i", PPB_Graphics3DTrusted_InitCommandBufferDispatcher },
- { "PPB_Graphics3DTrusted_GetRingBuffer:i:hi", PPB_Graphics3DTrusted_GetRingBufferDispatcher },
+ { "PPB_Graphics3DTrusted_InitCommandBuffer:i:i", PPB_Graphics3DTrusted_InitCommandBufferDispatcher },
+ { "PPB_Graphics3DTrusted_SetGetBuffer:ii:", PPB_Graphics3DTrusted_SetGetBufferDispatcher },
{ "PPB_Graphics3DTrusted_GetState:i:C", PPB_Graphics3DTrusted_GetStateDispatcher },
{ "PPB_Graphics3DTrusted_Flush:ii:", PPB_Graphics3DTrusted_FlushDispatcher },
{ "PPB_Graphics3DTrusted_FlushSync:ii:C", PPB_Graphics3DTrusted_FlushSyncDispatcher },
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h
index 25feea6..588be46 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppb_rpc.h
@@ -590,14 +590,12 @@ class PpbGraphics3DRpcServer {
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
PP_Resource resource_id,
- int32_t size,
int32_t* success);
- static void PPB_Graphics3DTrusted_GetRingBuffer(
+ static void PPB_Graphics3DTrusted_SetGetBuffer(
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
PP_Resource resource_id,
- NaClSrpcImcDescType* shm_desc,
- int32_t* shm_size);
+ int32_t shm_id);
static void PPB_Graphics3DTrusted_GetState(
NaClSrpcRpc* rpc,
NaClSrpcClosure* done,
diff --git a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h
index aa2f7d0..1eee263 100644
--- a/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h
+++ b/ppapi/native_client/src/shared/ppapi_proxy/untrusted/srpcgen/ppb_rpc.h
@@ -515,13 +515,11 @@ class PpbGraphics3DRpcClient {
static NaClSrpcError PPB_Graphics3DTrusted_InitCommandBuffer(
NaClSrpcChannel* channel,
PP_Resource resource_id,
- int32_t size,
int32_t* success);
- static NaClSrpcError PPB_Graphics3DTrusted_GetRingBuffer(
+ static NaClSrpcError PPB_Graphics3DTrusted_SetGetBuffer(
NaClSrpcChannel* channel,
PP_Resource resource_id,
- NaClSrpcImcDescType* shm_desc,
- int32_t* shm_size);
+ int32_t shm_id);
static NaClSrpcError PPB_Graphics3DTrusted_GetState(
NaClSrpcChannel* channel,
PP_Resource resource_id,
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index b894db9..b4e3ec67 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -781,10 +781,11 @@ IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBGraphics3D_Create,
PP_Instance /* instance */,
std::vector<int32_t> /* attrib_list */,
ppapi::HostResource /* result */)
-IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer,
+IPC_SYNC_MESSAGE_ROUTED1_0(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer,
+ ppapi::HostResource /* context */)
+IPC_SYNC_MESSAGE_ROUTED2_0(PpapiHostMsg_PPBGraphics3D_SetGetBuffer,
ppapi::HostResource /* context */,
- int32 /* size */,
- base::SharedMemoryHandle /* ring_buffer */)
+ int32 /* transfer_buffer_id */)
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBGraphics3D_GetState,
ppapi::HostResource /* context */,
gpu::CommandBuffer::State /* state */)
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.cc b/ppapi/proxy/ppb_graphics_3d_proxy.cc
index 8203e8d..b5a2dee 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.cc
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.cc
@@ -31,13 +31,12 @@ class CommandBuffer : public gpu::CommandBuffer {
virtual ~CommandBuffer();
// gpu::CommandBuffer implementation:
- virtual bool Initialize(int32 size);
- virtual bool Initialize(base::SharedMemory* buffer, int32 size);
- virtual gpu::Buffer GetRingBuffer();
+ virtual bool Initialize();
virtual State GetState();
virtual State GetLastState();
virtual void Flush(int32 put_offset);
virtual State FlushSync(int32 put_offset, int32 last_known_get);
+ virtual void SetGetBuffer(int32 transfer_buffer_id);
virtual void SetGetOffset(int32 get_offset);
virtual int32 CreateTransferBuffer(size_t size, int32 id_request);
virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory,
@@ -53,9 +52,6 @@ class CommandBuffer : public gpu::CommandBuffer {
bool Send(IPC::Message* msg);
void UpdateState(const gpu::CommandBuffer::State& state);
- int32 num_entries_;
- scoped_ptr<base::SharedMemory> ring_buffer_;
-
typedef base::hash_map<int32, gpu::Buffer> TransferBufferMap;
TransferBufferMap transfer_buffers_;
@@ -69,8 +65,7 @@ class CommandBuffer : public gpu::CommandBuffer {
CommandBuffer::CommandBuffer(const HostResource& resource,
PluginDispatcher* dispatcher)
- : num_entries_(0),
- resource_(resource),
+ : resource_(resource),
dispatcher_(dispatcher) {
}
@@ -84,47 +79,9 @@ CommandBuffer::~CommandBuffer() {
}
}
-bool CommandBuffer::Initialize(int32 size) {
- DCHECK(!ring_buffer_.get());
-
- // Initialize the service. Assuming we are sandboxed, the GPU
- // process is responsible for duplicating the handle. This might not be true
- // for NaCl.
- base::SharedMemoryHandle handle;
- if (Send(new PpapiHostMsg_PPBGraphics3D_InitCommandBuffer(
- API_ID_PPB_GRAPHICS_3D, resource_, size, &handle)) &&
- base::SharedMemory::IsHandleValid(handle)) {
- ring_buffer_.reset(new base::SharedMemory(handle, false));
- if (ring_buffer_->Map(size)) {
- num_entries_ = size / sizeof(gpu::CommandBufferEntry);
- return true;
- }
-
- ring_buffer_.reset();
- }
-
- return false;
-}
-
-bool CommandBuffer::Initialize(base::SharedMemory* buffer, int32 size) {
- // Not implemented in proxy.
- NOTREACHED();
- return false;
-}
-
-gpu::Buffer CommandBuffer::GetRingBuffer() {
- // Return locally cached ring buffer.
- gpu::Buffer buffer;
- if (ring_buffer_.get()) {
- buffer.ptr = ring_buffer_->memory();
- buffer.size = num_entries_ * sizeof(gpu::CommandBufferEntry);
- buffer.shared_memory = ring_buffer_.get();
- } else {
- buffer.ptr = NULL;
- buffer.size = 0;
- buffer.shared_memory = NULL;
- }
- return buffer;
+bool CommandBuffer::Initialize() {
+ return Send(new PpapiHostMsg_PPBGraphics3D_InitCommandBuffer(
+ API_ID_PPB_GRAPHICS_3D, resource_));
}
gpu::CommandBuffer::State CommandBuffer::GetState() {
@@ -175,6 +132,13 @@ gpu::CommandBuffer::State CommandBuffer::FlushSync(int32 put_offset,
return last_state_;
}
+void CommandBuffer::SetGetBuffer(int32 transfer_buffer_id) {
+ if (last_state_.error == gpu::error::kNoError) {
+ Send(new PpapiHostMsg_PPBGraphics3D_SetGetBuffer(
+ API_ID_PPB_GRAPHICS_3D, resource_, transfer_buffer_id));
+ }
+}
+
void CommandBuffer::SetGetOffset(int32 get_offset) {
// Not implemented in proxy.
NOTREACHED();
@@ -338,17 +302,17 @@ bool Graphics3D::Init() {
return false;
command_buffer_.reset(new CommandBuffer(host_resource(), dispatcher));
- if (!command_buffer_->Initialize(kCommandBufferSize))
+ if (!command_buffer_->Initialize())
return false;
return CreateGLES2Impl(kCommandBufferSize, kTransferBufferSize);
}
-PP_Bool Graphics3D::InitCommandBuffer(int32_t size) {
+PP_Bool Graphics3D::InitCommandBuffer() {
return PP_FALSE;
}
-PP_Bool Graphics3D::GetRingBuffer(int* shm_handle, uint32_t* shm_size) {
+PP_Bool Graphics3D::SetGetBuffer(int32_t /* transfer_buffer_id */) {
return PP_FALSE;
}
@@ -449,6 +413,8 @@ bool PPB_Graphics3D_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnMsgCreate)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_InitCommandBuffer,
OnMsgInitCommandBuffer)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_SetGetBuffer,
+ OnMsgSetGetBuffer)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_GetState,
OnMsgGetState)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBGraphics3D_Flush,
@@ -488,22 +454,21 @@ void PPB_Graphics3D_Proxy::OnMsgCreate(PP_Instance instance,
}
void PPB_Graphics3D_Proxy::OnMsgInitCommandBuffer(
- const HostResource& context,
- int32 size,
- base::SharedMemoryHandle* ring_buffer) {
- *ring_buffer = base::SharedMemory::NULLHandle();
+ const HostResource& context) {
EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
if (enter.failed())
return;
- if (!enter.object()->InitCommandBuffer(size))
+ if (!enter.object()->InitCommandBuffer())
return;
+}
- int shm_handle;
- uint32_t shm_size;
- if (!enter.object()->GetRingBuffer(&shm_handle, &shm_size))
- return;
- *ring_buffer = TransportSHMHandleFromInt(dispatcher(), shm_handle);
+void PPB_Graphics3D_Proxy::OnMsgSetGetBuffer(
+ const HostResource& context,
+ int32 transfer_buffer_id) {
+ EnterHostFromHostResource<PPB_Graphics3D_API> enter(context);
+ if (enter.succeeded())
+ enter.object()->SetGetBuffer(transfer_buffer_id);
}
void PPB_Graphics3D_Proxy::OnMsgGetState(const HostResource& context,
diff --git a/ppapi/proxy/ppb_graphics_3d_proxy.h b/ppapi/proxy/ppb_graphics_3d_proxy.h
index 887ae46..5a6c334 100644
--- a/ppapi/proxy/ppb_graphics_3d_proxy.h
+++ b/ppapi/proxy/ppb_graphics_3d_proxy.h
@@ -36,8 +36,8 @@ class Graphics3D : public Resource, public PPB_Graphics3D_Shared {
}
// Graphics3DTrusted API. These are not implemented in the proxy.
- virtual PP_Bool InitCommandBuffer(int32_t size) OVERRIDE;
- virtual PP_Bool GetRingBuffer(int* shm_handle, uint32_t* shm_size) OVERRIDE;
+ virtual PP_Bool InitCommandBuffer() OVERRIDE;
+ virtual PP_Bool SetGetBuffer(int32_t shm_id) OVERRIDE;
virtual PP_Graphics3DTrustedState GetState() OVERRIDE;
virtual PP_Bool Flush(int32_t put_offset) OVERRIDE;
virtual PP_Graphics3DTrustedState FlushSync(int32_t put_offset) OVERRIDE;
@@ -79,9 +79,9 @@ class PPB_Graphics3D_Proxy : public InterfaceProxy {
void OnMsgCreate(PP_Instance instance,
const std::vector<int32_t>& attribs,
HostResource* result);
- void OnMsgInitCommandBuffer(const HostResource& context,
- int32 size,
- base::SharedMemoryHandle* ring_buffer);
+ void OnMsgInitCommandBuffer(const HostResource& context);
+ void OnMsgSetGetBuffer(const HostResource& context,
+ int32 id);
void OnMsgGetState(const HostResource& context,
gpu::CommandBuffer::State* state);
void OnMsgFlush(const HostResource& context,
diff --git a/ppapi/thunk/ppb_graphics_3d_api.h b/ppapi/thunk/ppb_graphics_3d_api.h
index 73e8178..4e1980a 100644
--- a/ppapi/thunk/ppb_graphics_3d_api.h
+++ b/ppapi/thunk/ppb_graphics_3d_api.h
@@ -25,9 +25,8 @@ class PPAPI_THUNK_EXPORT PPB_Graphics3D_API {
virtual int32_t SwapBuffers(PP_CompletionCallback callback) = 0;
// Graphics3DTrusted API.
- virtual PP_Bool InitCommandBuffer(int32_t size) = 0;
- virtual PP_Bool GetRingBuffer(int* shm_handle,
- uint32_t* shm_size) = 0;
+ virtual PP_Bool InitCommandBuffer() = 0;
+ virtual PP_Bool SetGetBuffer(int32_t shm_id) = 0;
virtual PP_Graphics3DTrustedState GetState() = 0;
virtual int32_t CreateTransferBuffer(uint32_t size) = 0;
virtual PP_Bool DestroyTransferBuffer(int32_t id) = 0;
diff --git a/ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc b/ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc
index 5cc9661..bea32ab 100644
--- a/ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc
+++ b/ppapi/thunk/ppb_graphics_3d_trusted_thunk.cc
@@ -30,20 +30,18 @@ PP_Resource CreateRaw(PP_Instance instance,
instance, share_context, attrib_list);
}
-PP_Bool InitCommandBuffer(PP_Resource context, int32_t size) {
+PP_Bool InitCommandBuffer(PP_Resource context) {
EnterGraphics3D enter(context, true);
if (enter.failed())
return PP_FALSE;
- return enter.object()->InitCommandBuffer(size);
+ return enter.object()->InitCommandBuffer();
}
-PP_Bool GetRingBuffer(PP_Resource context,
- int* shm_handle,
- uint32_t* shm_size) {
+PP_Bool SetGetBuffer(PP_Resource context, int32_t transfer_buffer_id) {
EnterGraphics3D enter(context, true);
if (enter.failed())
return PP_FALSE;
- return enter.object()->GetRingBuffer(shm_handle, shm_size);
+ return enter.object()->SetGetBuffer(transfer_buffer_id);
}
PP_Graphics3DTrustedState GetState(PP_Resource context) {
@@ -103,7 +101,7 @@ PP_Graphics3DTrustedState FlushSyncFast(PP_Resource context,
const PPB_Graphics3DTrusted g_ppb_graphics_3d_trusted_thunk = {
&CreateRaw,
&InitCommandBuffer,
- &GetRingBuffer,
+ &SetGetBuffer,
&GetState,
&CreateTransferBuffer,
&DestroyTransferBuffer,