OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h" | 7 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_graphics_3d.h" |
8 | 8 |
9 #include "gpu/command_buffer/client/gles2_implementation.h" | 9 #include "gpu/command_buffer/client/gles2_implementation.h" |
10 #include "gpu/command_buffer/client/transfer_buffer.h" | 10 #include "gpu/command_buffer/client/transfer_buffer.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 namespace ppapi_proxy { | 25 namespace ppapi_proxy { |
26 | 26 |
27 namespace { | 27 namespace { |
28 | 28 |
29 const size_t kRingBufferSize = 4 * 1024 * 1024; | 29 const size_t kRingBufferSize = 4 * 1024 * 1024; |
30 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; | 30 const size_t kStartTransferBufferSize = 4 * 1024 * 1024; |
31 const size_t kMinTransferBufferSize = 256 * 1024; | 31 const size_t kMinTransferBufferSize = 256 * 1024; |
32 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; | 32 const size_t kMaxTransferBufferSize = 16 * 1024 * 1024; |
33 | 33 |
34 int32_t GetNumAttribs(const int32_t* attrib_list) { | 34 int32_t GetNumAttribs(const int32_t attrib_list[]) { |
35 int32_t num = 0; | 35 int32_t num = 0; |
36 if (attrib_list) { | 36 if (attrib_list) { |
37 // skip over attrib pairs | 37 // skip over attrib pairs |
38 while (attrib_list[num] != PP_GRAPHICS3DATTRIB_NONE) | 38 while (attrib_list[num] != PP_GRAPHICS3DATTRIB_NONE) |
39 num += 2; | 39 num += 2; |
40 // Add one more for PP_GRAPHICS3DATTRIB_NONE. | 40 // Add one more for PP_GRAPHICS3DATTRIB_NONE. |
41 num += 1; | 41 num += 1; |
42 } | 42 } |
43 return num; | 43 return num; |
44 } | 44 } |
(...skipping 12 matching lines...) Expand all Loading... |
57 attrib_value, | 57 attrib_value, |
58 &pp_error); | 58 &pp_error); |
59 if (retval != NACL_SRPC_RESULT_OK) { | 59 if (retval != NACL_SRPC_RESULT_OK) { |
60 return PP_ERROR_BADARGUMENT; | 60 return PP_ERROR_BADARGUMENT; |
61 } | 61 } |
62 return pp_error; | 62 return pp_error; |
63 } | 63 } |
64 | 64 |
65 PP_Resource Create(PP_Instance instance, | 65 PP_Resource Create(PP_Instance instance, |
66 PP_Resource share_context, | 66 PP_Resource share_context, |
67 const int32_t* attrib_list) { | 67 const int32_t attrib_list[]) { |
68 DebugPrintf("PPB_Graphics3D::Create: instance=%"NACL_PRId32"\n", instance); | 68 DebugPrintf("PPB_Graphics3D::Create: instance=%"NACL_PRId32"\n", instance); |
69 PP_Resource graphics3d_id = kInvalidResourceId; | 69 PP_Resource graphics3d_id = kInvalidResourceId; |
70 nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); | 70 nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); |
71 NaClSrpcError retval = | 71 NaClSrpcError retval = |
72 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_CreateRaw( | 72 PpbGraphics3DRpcClient::PPB_Graphics3DTrusted_CreateRaw( |
73 GetMainSrpcChannel(), | 73 GetMainSrpcChannel(), |
74 instance, | 74 instance, |
75 share_context, | 75 share_context, |
76 num_attribs, const_cast<int32_t *>(attrib_list), | 76 num_attribs, const_cast<int32_t *>(attrib_list), |
77 &graphics3d_id); | 77 &graphics3d_id); |
78 if (retval == NACL_SRPC_RESULT_OK) { | 78 if (retval == NACL_SRPC_RESULT_OK) { |
79 scoped_refptr<PluginGraphics3D> graphics_3d = | 79 scoped_refptr<PluginGraphics3D> graphics_3d = |
80 PluginResource::AdoptAs<PluginGraphics3D>(graphics3d_id); | 80 PluginResource::AdoptAs<PluginGraphics3D>(graphics3d_id); |
81 if (graphics_3d.get()) { | 81 if (graphics_3d.get()) { |
82 graphics_3d->set_instance_id(instance); | 82 graphics_3d->set_instance_id(instance); |
83 return graphics3d_id; | 83 return graphics3d_id; |
84 } | 84 } |
85 } | 85 } |
86 return kInvalidResourceId; | 86 return kInvalidResourceId; |
87 } | 87 } |
88 | 88 |
89 PP_Bool IsGraphics3D(PP_Resource resource) { | 89 PP_Bool IsGraphics3D(PP_Resource resource) { |
90 DebugPrintf("PPB_Graphics3D::IsGraphics3D: resource=%"NACL_PRId32"\n", | 90 DebugPrintf("PPB_Graphics3D::IsGraphics3D: resource=%"NACL_PRId32"\n", |
91 resource); | 91 resource); |
92 return PP_FromBool(PluginResource::GetAs<PluginGraphics3D>(resource).get()); | 92 return PP_FromBool(PluginResource::GetAs<PluginGraphics3D>(resource).get()); |
93 } | 93 } |
94 | 94 |
95 int32_t GetAttribs(PP_Resource graphics3d_id, | 95 int32_t GetAttribs(PP_Resource graphics3d_id, |
96 int32_t* attrib_list) { | 96 int32_t attrib_list[]) { |
97 int32_t pp_error; | 97 int32_t pp_error; |
98 nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); | 98 nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); |
99 NaClSrpcError retval = | 99 NaClSrpcError retval = |
100 PpbGraphics3DRpcClient::PPB_Graphics3D_GetAttribs( | 100 PpbGraphics3DRpcClient::PPB_Graphics3D_GetAttribs( |
101 GetMainSrpcChannel(), | 101 GetMainSrpcChannel(), |
102 graphics3d_id, | 102 graphics3d_id, |
103 num_attribs, attrib_list, | 103 num_attribs, attrib_list, |
104 &num_attribs, attrib_list, | 104 &num_attribs, attrib_list, |
105 &pp_error); | 105 &pp_error); |
106 if (retval != NACL_SRPC_RESULT_OK) { | 106 if (retval != NACL_SRPC_RESULT_OK) { |
107 return PP_ERROR_BADARGUMENT; | 107 return PP_ERROR_BADARGUMENT; |
108 } | 108 } |
109 return pp_error; | 109 return pp_error; |
110 } | 110 } |
111 | 111 |
112 int32_t SetAttribs(PP_Resource graphics3d_id, | 112 int32_t SetAttribs(PP_Resource graphics3d_id, |
113 int32_t* attrib_list) { | 113 const int32_t attrib_list[]) { |
114 int32_t pp_error; | 114 int32_t pp_error; |
115 nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); | 115 nacl_abi_size_t num_attribs = GetNumAttribs(attrib_list); |
116 NaClSrpcError retval = | 116 NaClSrpcError retval = |
117 PpbGraphics3DRpcClient::PPB_Graphics3D_SetAttribs( | 117 PpbGraphics3DRpcClient::PPB_Graphics3D_SetAttribs( |
118 GetMainSrpcChannel(), | 118 GetMainSrpcChannel(), |
119 graphics3d_id, | 119 graphics3d_id, |
120 num_attribs, attrib_list, | 120 num_attribs, const_cast<int32_t *>(attrib_list), |
121 &pp_error); | 121 &pp_error); |
122 if (retval != NACL_SRPC_RESULT_OK) { | 122 if (retval != NACL_SRPC_RESULT_OK) { |
123 return PP_ERROR_BADARGUMENT; | 123 return PP_ERROR_BADARGUMENT; |
124 } | 124 } |
125 return pp_error; | 125 return pp_error; |
126 } | 126 } |
127 | 127 |
128 int32_t GetError(PP_Resource graphics3d_id) { | 128 int32_t GetError(PP_Resource graphics3d_id) { |
129 DebugPrintf("PPB_Graphics3D::GetError: graphics3d_id=%"NACL_PRId32"\n", | 129 DebugPrintf("PPB_Graphics3D::GetError: graphics3d_id=%"NACL_PRId32"\n", |
130 graphics3d_id); | 130 graphics3d_id); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 &GetAttribs, | 267 &GetAttribs, |
268 &SetAttribs, | 268 &SetAttribs, |
269 &GetError, | 269 &GetError, |
270 &ResizeBuffers, | 270 &ResizeBuffers, |
271 &SwapBuffs, | 271 &SwapBuffs, |
272 }; | 272 }; |
273 return &intf; | 273 return &intf; |
274 } | 274 } |
275 | 275 |
276 } // namespace ppapi_proxy | 276 } // namespace ppapi_proxy |
OLD | NEW |