OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 The Native Client Authors. All rights reserved. | 2 * Copyright 2010 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 #include "native_client/src/shared/ppapi_proxy/plugin_image_data.h" | 7 #include "native_client/src/shared/ppapi_proxy/plugin_image_data.h" |
8 | 8 |
9 #include <stdio.h> | 9 #include <stdio.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 return (result ? PP_TRUE : PP_FALSE); | 46 return (result ? PP_TRUE : PP_FALSE); |
47 } else { | 47 } else { |
48 return PP_FALSE; | 48 return PP_FALSE; |
49 } | 49 } |
50 } | 50 } |
51 | 51 |
52 PP_Resource Create(PP_Module module, | 52 PP_Resource Create(PP_Module module, |
53 PP_ImageDataFormat format, | 53 PP_ImageDataFormat format, |
54 const struct PP_Size* size, | 54 const struct PP_Size* size, |
55 PP_Bool init_to_zero) { | 55 PP_Bool init_to_zero) { |
56 int64_t resource; | 56 PP_Resource resource; |
57 NaClSrpcError retval = | 57 NaClSrpcError retval = |
58 PpbImageDataRpcClient::PPB_ImageData_Create( | 58 PpbImageDataRpcClient::PPB_ImageData_Create( |
59 GetMainSrpcChannel(), | 59 GetMainSrpcChannel(), |
60 static_cast<int64_t>(module), | 60 module, |
61 static_cast<int32_t>(format), | 61 static_cast<int32_t>(format), |
62 static_cast<nacl_abi_size_t>(sizeof(struct PP_Size)), | 62 static_cast<nacl_abi_size_t>(sizeof(struct PP_Size)), |
63 reinterpret_cast<int32_t*>(const_cast<struct PP_Size*>(size)), | 63 reinterpret_cast<int32_t*>(const_cast<struct PP_Size*>(size)), |
64 (init_to_zero == PP_TRUE), | 64 (init_to_zero == PP_TRUE), |
65 &resource); | 65 &resource); |
66 if (retval == NACL_SRPC_RESULT_OK) { | 66 if (retval == NACL_SRPC_RESULT_OK) { |
polina
2010/12/23 21:58:30
we can get rid of this if-else now if we set resou
noelallen_use_chromium
2010/12/23 22:23:23
I'm not convinced we can count on the function not
polina
2010/12/23 22:33:14
We implement the server code, so we know exactly h
| |
67 return static_cast<PP_Resource>(resource); | 67 return resource; |
68 } else { | 68 } else { |
69 return kInvalidResourceId; | 69 return kInvalidResourceId; |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 PP_Bool IsImageData(PP_Resource resource) { | 73 PP_Bool IsImageData(PP_Resource resource) { |
74 return PluginResource::GetAs<PluginImageData>(resource).get() | 74 return PluginResource::GetAs<PluginImageData>(resource).get() |
75 ? PP_TRUE : PP_FALSE; | 75 ? PP_TRUE : PP_FALSE; |
76 } | 76 } |
77 | 77 |
78 PP_Bool Describe(PP_Resource resource, | 78 PP_Bool Describe(PP_Resource resource, |
79 struct PP_ImageDataDesc* desc) { | 79 struct PP_ImageDataDesc* desc) { |
80 int32_t result; | 80 int32_t result; |
81 nacl_abi_size_t desc_size = kPpImageDataDescBytes; | 81 nacl_abi_size_t desc_size = kPpImageDataDescBytes; |
82 NaClSrpcError retval = | 82 NaClSrpcError retval = |
83 PpbImageDataRpcClient::PPB_ImageData_Describe( | 83 PpbImageDataRpcClient::PPB_ImageData_Describe( |
84 GetMainSrpcChannel(), | 84 GetMainSrpcChannel(), |
85 static_cast<int64_t>(resource), | 85 resource, |
86 &desc_size, | 86 &desc_size, |
87 reinterpret_cast<int32_t*>(desc), | 87 reinterpret_cast<int32_t*>(desc), |
88 &result); | 88 &result); |
89 if (retval == NACL_SRPC_RESULT_OK) { | 89 if (retval == NACL_SRPC_RESULT_OK) { |
90 return (result ? PP_TRUE : PP_FALSE); | 90 return (result ? PP_TRUE : PP_FALSE); |
91 } else { | 91 } else { |
92 return PP_FALSE; | 92 return PP_FALSE; |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
(...skipping 21 matching lines...) Expand all Loading... | |
117 Create, | 117 Create, |
118 IsImageData, | 118 IsImageData, |
119 Describe, | 119 Describe, |
120 Map, | 120 Map, |
121 Unmap, | 121 Unmap, |
122 }; | 122 }; |
123 return &intf; | 123 return &intf; |
124 } | 124 } |
125 | 125 |
126 } // namespace ppapi_proxy | 126 } // namespace ppapi_proxy |
OLD | NEW |