Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: ppapi/native_client/src/shared/ppapi_proxy/command_buffer_nacl.cc

Issue 8865008: Revert 113479 - Revert "Revert 113250 - Add CommandBuffer::SetGetBuffer" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "native_client/src/shared/ppapi_proxy/command_buffer_nacl.h" 5 #include "native_client/src/shared/ppapi_proxy/command_buffer_nacl.h"
6 6
7 #include <sys/mman.h> 7 #include <sys/mman.h>
8 #include "gpu/command_buffer/common/logging.h" 8 #include "gpu/command_buffer/common/logging.h"
9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" 9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h"
10 #include "native_client/src/shared/ppapi_proxy/utility.h" 10 #include "native_client/src/shared/ppapi_proxy/utility.h"
11 #include "ppapi/c/ppb_core.h" 11 #include "ppapi/c/ppb_core.h"
12 12
13 #include "srpcgen/ppb_rpc.h" 13 #include "srpcgen/ppb_rpc.h"
14 14
15 using ppapi_proxy::DebugPrintf; 15 using ppapi_proxy::DebugPrintf;
16 16
17 CommandBufferNacl::CommandBufferNacl(PP_Resource graphics_3d, 17 CommandBufferNacl::CommandBufferNacl(PP_Resource graphics_3d,
18 const PPB_Core* iface_core) 18 const PPB_Core* iface_core)
19 : graphics_3d_(graphics_3d), iface_core_(iface_core) { 19 : graphics_3d_(graphics_3d), iface_core_(iface_core) {
20 iface_core_->AddRefResource(graphics_3d_); 20 iface_core_->AddRefResource(graphics_3d_);
21 } 21 }
22 22
23 CommandBufferNacl::~CommandBufferNacl() { 23 CommandBufferNacl::~CommandBufferNacl() {
24 DebugPrintf("CommandBufferNacl::~CommandBufferNacl()\n"); 24 DebugPrintf("CommandBufferNacl::~CommandBufferNacl()\n");
25 iface_core_->ReleaseResource(graphics_3d_); 25 iface_core_->ReleaseResource(graphics_3d_);
26 } 26 }
27 27
28 bool CommandBufferNacl::Initialize() { 28 bool CommandBufferNacl::Initialize(int32 size) {
29 DebugPrintf("CommandBufferNacl::Initialize\n"); 29 DebugPrintf("CommandBufferNacl::Initialize\n");
30 int32_t success; 30 int32_t success;
31 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 31 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
32 NaClSrpcError retval = 32 NaClSrpcError retval =
33 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_InitCommandBuffer( 33 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_InitCommandBuffer(
34 channel, graphics_3d_, &success); 34 channel, graphics_3d_, size, &success);
35 DebugPrintf("CommandBufferNaCl::Initialize returned success=%s\n", 35 DebugPrintf("CommandBufferNaCl::Initialize returned success=%s\n",
36 (PP_TRUE == success) ? "TRUE" : "FALSE"); 36 (PP_TRUE == success) ? "TRUE" : "FALSE");
37 return NACL_SRPC_RESULT_OK == retval && PP_TRUE == success; 37 return NACL_SRPC_RESULT_OK == retval && PP_TRUE == success;
38 } 38 }
39 39
40 gpu::Buffer CommandBufferNacl::GetRingBuffer() {
41 DebugPrintf("CommandBufferNacl::GetRingBuffer\n");
42 if (!buffer_.ptr) {
43 DebugPrintf("CommandBufferNacl::GetRingBuffer: Fetching\n");
44 int shm_handle = -1;
45 int32_t shm_size = 0;
46
47 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
48 NaClSrpcError retval =
49 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_GetRingBuffer(
50 channel, graphics_3d_, &shm_handle, &shm_size);
51 if (NACL_SRPC_RESULT_OK != retval) {
52 shm_handle = -1;
53 }
54 buffer_ = BufferFromShm(shm_handle, shm_size);
55 }
56
57 return buffer_;
58 }
59
40 gpu::CommandBuffer::State CommandBufferNacl::GetState() { 60 gpu::CommandBuffer::State CommandBufferNacl::GetState() {
41 DebugPrintf("CommandBufferNacl::GetState\n"); 61 DebugPrintf("CommandBufferNacl::GetState\n");
42 PP_Graphics3DTrustedState state; 62 PP_Graphics3DTrustedState state;
43 nacl_abi_size_t state_size = static_cast<nacl_abi_size_t>(sizeof(state)); 63 nacl_abi_size_t state_size = static_cast<nacl_abi_size_t>(sizeof(state));
44 64
45 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel(); 65 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
46 NaClSrpcError retval = 66 NaClSrpcError retval =
47 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_GetState( 67 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_GetState(
48 channel, graphics_3d_, &state_size, reinterpret_cast<char*>(&state)); 68 channel, graphics_3d_, &state_size, reinterpret_cast<char*>(&state));
49 if (NACL_SRPC_RESULT_OK != retval 69 if (NACL_SRPC_RESULT_OK != retval
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 reinterpret_cast<char*>(&state)); 103 reinterpret_cast<char*>(&state));
84 if (NACL_SRPC_RESULT_OK != retval 104 if (NACL_SRPC_RESULT_OK != retval
85 || state_size != static_cast<nacl_abi_size_t>(sizeof(state))) { 105 || state_size != static_cast<nacl_abi_size_t>(sizeof(state))) {
86 return ErrorGpuState(); 106 return ErrorGpuState();
87 } 107 }
88 108
89 last_state_ = PpapiToGpuState(state); 109 last_state_ = PpapiToGpuState(state);
90 return last_state_; 110 return last_state_;
91 } 111 }
92 112
93 void CommandBufferNacl::SetGetBuffer(int32 transfer_buffer_id) {
94 DebugPrintf("CommandBufferNacl::SetGetBuffer\n");
95 NaClSrpcChannel* channel = ppapi_proxy::GetMainSrpcChannel();
96 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_SetGetBuffer(
97 channel, graphics_3d_, transfer_buffer_id);
98 }
99
100 void CommandBufferNacl::SetGetOffset(int32 get_offset) { 113 void CommandBufferNacl::SetGetOffset(int32 get_offset) {
101 DebugPrintf("CommandBufferNacl::SetGetOffset\n"); 114 DebugPrintf("CommandBufferNacl::SetGetOffset\n");
102 // Not implemented by proxy. 115 // Not implemented by proxy.
103 GPU_NOTREACHED(); 116 GPU_NOTREACHED();
104 } 117 }
105 118
106 int32 CommandBufferNacl::CreateTransferBuffer(size_t size, int32 id_request) { 119 int32 CommandBufferNacl::CreateTransferBuffer(size_t size, int32 id_request) {
107 DebugPrintf("CommandBufferNacl::CreateTransferBuffer\n"); 120 DebugPrintf("CommandBufferNacl::CreateTransferBuffer\n");
108 int32_t id; 121 int32_t id;
109 122
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 gpu::CommandBuffer::State CommandBufferNacl::PpapiToGpuState( 198 gpu::CommandBuffer::State CommandBufferNacl::PpapiToGpuState(
186 PP_Graphics3DTrustedState s) { 199 PP_Graphics3DTrustedState s) {
187 gpu::CommandBuffer::State state; 200 gpu::CommandBuffer::State state;
188 state.num_entries = s.num_entries; 201 state.num_entries = s.num_entries;
189 state.get_offset = s.get_offset; 202 state.get_offset = s.get_offset;
190 state.put_offset = s.put_offset; 203 state.put_offset = s.put_offset;
191 state.token = s.token; 204 state.token = s.token;
192 state.error = static_cast<gpu::error::Error>(s.error); 205 state.error = static_cast<gpu::error::Error>(s.error);
193 return state; 206 return state;
194 } 207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698