Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2010 The Native Client 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/include/portability.h" | 5 #include "native_client/src/include/portability.h" |
| 6 #include "native_client/src/include/nacl_macros.h" | 6 #include "native_client/src/include/nacl_macros.h" |
| 7 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 7 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
| 8 #include "native_client/src/shared/ppapi_proxy/utility.h" | 8 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 9 #include "ppapi/c/ppb_graphics_2d.h" | 9 #include "ppapi/c/ppb_graphics_2d.h" |
| 10 #include "ppapi/c/pp_point.h" | 10 #include "ppapi/c/pp_point.h" |
| 11 #include "ppapi/c/pp_rect.h" | 11 #include "ppapi/c/pp_rect.h" |
| 12 #include "ppapi/c/pp_size.h" | 12 #include "ppapi/c/pp_size.h" |
| 13 #include "srpcgen/ppb_rpc.h" | 13 #include "srpcgen/ppb_rpc.h" |
| 14 | 14 |
| 15 // | 15 // |
| 16 // The following methods are the SRPC dispatchers for ppapi/c/ppb_graphics_2d.h. | 16 // The following methods are the SRPC dispatchers for ppapi/c/ppb_graphics_2d.h. |
| 17 // | 17 // |
| 18 | 18 |
| 19 void PpbGraphics2DRpcServer::PPB_Graphics2D_Create(NaClSrpcRpc* rpc, | 19 void PpbGraphics2DRpcServer::PPB_Graphics2D_Create(NaClSrpcRpc* rpc, |
| 20 NaClSrpcClosure* done, | 20 NaClSrpcClosure* done, |
| 21 int64_t module, | 21 PP_Module module, |
| 22 nacl_abi_size_t size_bytes, | 22 nacl_abi_size_t size_bytes, |
| 23 int32_t* size, | 23 int32_t* size, |
| 24 int32_t is_always_opaque, | 24 int32_t is_always_opaque, |
| 25 int64_t* resource) { | 25 PP_Resource* resource) { |
| 26 NaClSrpcClosureRunner runner(done); | 26 NaClSrpcClosureRunner runner(done); |
| 27 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 27 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 28 *resource = ppapi_proxy::kInvalidResourceId; | 28 *resource = ppapi_proxy::kInvalidResourceId; |
| 29 if (size_bytes != sizeof(struct PP_Size)) { | 29 if (size_bytes != sizeof(struct PP_Size)) { |
| 30 return; | 30 return; |
| 31 } | 31 } |
| 32 PP_Resource pp_resource = ppapi_proxy::PPBGraphics2DInterface()->Create( | 32 *resource = ppapi_proxy::PPBGraphics2DInterface()->Create( |
| 33 static_cast<PP_Module>(module), | 33 module, |
| 34 const_cast<const struct PP_Size*>( | 34 const_cast<const struct PP_Size*>( |
| 35 reinterpret_cast<struct PP_Size*>(size)), | 35 reinterpret_cast<struct PP_Size*>(size)), |
| 36 (is_always_opaque ? PP_TRUE : PP_FALSE)); | 36 (is_always_opaque ? PP_TRUE : PP_FALSE)); |
| 37 *resource = static_cast<int64_t>(pp_resource); | |
| 38 rpc->result = NACL_SRPC_RESULT_OK; | 37 rpc->result = NACL_SRPC_RESULT_OK; |
| 39 } | 38 } |
| 40 | 39 |
| 41 void PpbGraphics2DRpcServer::PPB_Graphics2D_IsGraphics2D(NaClSrpcRpc* rpc, | 40 void PpbGraphics2DRpcServer::PPB_Graphics2D_IsGraphics2D(NaClSrpcRpc* rpc, |
| 42 NaClSrpcClosure* done, | 41 NaClSrpcClosure* done, |
| 43 int64_t resource, | 42 PP_Resource resource, |
| 44 int32_t* success) { | 43 int32_t* success) { |
| 45 NaClSrpcClosureRunner runner(done); | 44 NaClSrpcClosureRunner runner(done); |
| 46 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 45 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 47 *success = 0; | 46 *success = 0; |
| 48 PP_Bool pp_success = | 47 PP_Bool pp_success = |
| 49 ppapi_proxy::PPBGraphics2DInterface()->IsGraphics2D( | 48 ppapi_proxy::PPBGraphics2DInterface()->IsGraphics2D(resource); |
| 50 static_cast<PP_Resource>(resource)); | |
| 51 *success = (pp_success == PP_TRUE); | 49 *success = (pp_success == PP_TRUE); |
| 52 rpc->result = NACL_SRPC_RESULT_OK; | 50 rpc->result = NACL_SRPC_RESULT_OK; |
| 53 } | 51 } |
| 54 | 52 |
| 55 void PpbGraphics2DRpcServer::PPB_Graphics2D_Describe( | 53 void PpbGraphics2DRpcServer::PPB_Graphics2D_Describe( |
| 56 NaClSrpcRpc* rpc, | 54 NaClSrpcRpc* rpc, |
| 57 NaClSrpcClosure* done, | 55 NaClSrpcClosure* done, |
| 58 int64_t graphics_2d, | 56 PP_Resource graphics_2d, |
| 59 nacl_abi_size_t* size_bytes, | 57 nacl_abi_size_t* size_bytes, |
| 60 int32_t* size, | 58 int32_t* size, |
| 61 int32_t* is_always_opaque, | 59 int32_t* is_always_opaque, |
| 62 int32_t* success) { | 60 int32_t* success) { |
| 63 NaClSrpcClosureRunner runner(done); | 61 NaClSrpcClosureRunner runner(done); |
| 64 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 62 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 65 *success = 0; | 63 *success = 0; |
| 66 if (*size_bytes != sizeof(struct PP_Size)) { | 64 if (*size_bytes != sizeof(struct PP_Size)) { |
| 67 return; | 65 return; |
| 68 } | 66 } |
| 69 PP_Bool is_opaque; | 67 PP_Bool is_opaque; |
| 70 PP_Bool pp_success = ppapi_proxy::PPBGraphics2DInterface()->Describe( | 68 PP_Bool pp_success = ppapi_proxy::PPBGraphics2DInterface()->Describe( |
| 71 static_cast<PP_Resource>(graphics_2d), | 69 graphics_2d, |
|
nfullagar
2010/12/23 21:37:00
line above and two below might fit on single line
noelallen_use_chromium
2010/12/23 22:23:23
Done.
| |
| 72 reinterpret_cast<struct PP_Size*>(size), | 70 reinterpret_cast<struct PP_Size*>(size), |
| 73 &is_opaque); | 71 &is_opaque); |
| 74 *is_always_opaque = (is_opaque == PP_TRUE); | 72 *is_always_opaque = (is_opaque == PP_TRUE); |
| 75 *success = (pp_success == PP_TRUE); | 73 *success = (pp_success == PP_TRUE); |
| 76 rpc->result = NACL_SRPC_RESULT_OK; | 74 rpc->result = NACL_SRPC_RESULT_OK; |
| 77 } | 75 } |
| 78 | 76 |
| 79 void PpbGraphics2DRpcServer::PPB_Graphics2D_PaintImageData( | 77 void PpbGraphics2DRpcServer::PPB_Graphics2D_PaintImageData( |
| 80 NaClSrpcRpc* rpc, | 78 NaClSrpcRpc* rpc, |
| 81 NaClSrpcClosure* done, | 79 NaClSrpcClosure* done, |
| 82 int64_t graphics_2d, | 80 PP_Resource graphics_2d, |
| 83 int64_t image, | 81 PP_Resource image, |
| 84 nacl_abi_size_t top_left_bytes, | 82 nacl_abi_size_t top_left_bytes, |
| 85 int32_t* top_left, | 83 int32_t* top_left, |
| 86 nacl_abi_size_t src_rect_bytes, | 84 nacl_abi_size_t src_rect_bytes, |
| 87 int32_t* src_rect) { | 85 int32_t* src_rect) { |
| 88 NaClSrpcClosureRunner runner(done); | 86 NaClSrpcClosureRunner runner(done); |
| 89 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 87 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 90 if (top_left_bytes != sizeof(struct PP_Point) || | 88 if (top_left_bytes != sizeof(struct PP_Point) || |
| 91 src_rect_bytes != sizeof(struct PP_Rect)) { | 89 src_rect_bytes != sizeof(struct PP_Rect)) { |
| 92 return; | 90 return; |
| 93 } | 91 } |
| 94 ppapi_proxy::PPBGraphics2DInterface()->PaintImageData( | 92 ppapi_proxy::PPBGraphics2DInterface()->PaintImageData( |
| 95 static_cast<PP_Resource>(graphics_2d), | 93 graphics_2d, |
| 96 static_cast<PP_Resource>(image), | 94 image, |
| 97 const_cast<const struct PP_Point*>( | 95 const_cast<const struct PP_Point*>( |
| 98 reinterpret_cast<struct PP_Point*>(top_left)), | 96 reinterpret_cast<struct PP_Point*>(top_left)), |
| 99 const_cast<const struct PP_Rect*>( | 97 const_cast<const struct PP_Rect*>( |
| 100 reinterpret_cast<struct PP_Rect*>(src_rect))); | 98 reinterpret_cast<struct PP_Rect*>(src_rect))); |
| 101 rpc->result = NACL_SRPC_RESULT_OK; | 99 rpc->result = NACL_SRPC_RESULT_OK; |
| 102 } | 100 } |
| 103 | 101 |
| 104 void PpbGraphics2DRpcServer::PPB_Graphics2D_Scroll( | 102 void PpbGraphics2DRpcServer::PPB_Graphics2D_Scroll( |
| 105 NaClSrpcRpc* rpc, | 103 NaClSrpcRpc* rpc, |
| 106 NaClSrpcClosure* done, | 104 NaClSrpcClosure* done, |
| 107 int64_t graphics_2d, | 105 PP_Resource graphics_2d, |
| 108 nacl_abi_size_t clip_rect_bytes, | 106 nacl_abi_size_t clip_rect_bytes, |
| 109 int32_t* clip_rect, | 107 int32_t* clip_rect, |
| 110 nacl_abi_size_t amount_bytes, | 108 nacl_abi_size_t amount_bytes, |
| 111 int32_t* amount) { | 109 int32_t* amount) { |
| 112 NaClSrpcClosureRunner runner(done); | 110 NaClSrpcClosureRunner runner(done); |
| 113 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 111 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 114 if (clip_rect_bytes != sizeof(struct PP_Rect) || | 112 if (clip_rect_bytes != sizeof(struct PP_Rect) || |
| 115 amount_bytes != sizeof(struct PP_Point)) { | 113 amount_bytes != sizeof(struct PP_Point)) { |
| 116 return; | 114 return; |
| 117 } | 115 } |
| 118 ppapi_proxy::PPBGraphics2DInterface()->Scroll( | 116 ppapi_proxy::PPBGraphics2DInterface()->Scroll( |
| 119 static_cast<PP_Resource>(graphics_2d), | 117 graphics_2d, |
| 120 const_cast<const struct PP_Rect*>( | 118 const_cast<const struct PP_Rect*>( |
| 121 reinterpret_cast<struct PP_Rect*>(clip_rect)), | 119 reinterpret_cast<struct PP_Rect*>(clip_rect)), |
| 122 const_cast<const struct PP_Point*>( | 120 const_cast<const struct PP_Point*>( |
| 123 reinterpret_cast<struct PP_Point*>(amount))); | 121 reinterpret_cast<struct PP_Point*>(amount))); |
| 124 rpc->result = NACL_SRPC_RESULT_OK; | 122 rpc->result = NACL_SRPC_RESULT_OK; |
| 125 } | 123 } |
| 126 | 124 |
| 127 void PpbGraphics2DRpcServer::PPB_Graphics2D_ReplaceContents( | 125 void PpbGraphics2DRpcServer::PPB_Graphics2D_ReplaceContents( |
| 128 NaClSrpcRpc* rpc, | 126 NaClSrpcRpc* rpc, |
| 129 NaClSrpcClosure* done, | 127 NaClSrpcClosure* done, |
| 130 int64_t graphics_2d, | 128 PP_Resource graphics_2d, |
| 131 int64_t image) { | 129 PP_Resource image) { |
| 132 NaClSrpcClosureRunner runner(done); | 130 NaClSrpcClosureRunner runner(done); |
| 133 rpc->result = NACL_SRPC_RESULT_APP_ERROR; | 131 rpc->result = NACL_SRPC_RESULT_APP_ERROR; |
| 134 ppapi_proxy::PPBGraphics2DInterface()->ReplaceContents( | 132 ppapi_proxy::PPBGraphics2DInterface()->ReplaceContents(graphics_2d, image); |
| 135 static_cast<PP_Resource>(graphics_2d), | |
| 136 static_cast<PP_Resource>(image)); | |
| 137 rpc->result = NACL_SRPC_RESULT_OK; | 133 rpc->result = NACL_SRPC_RESULT_OK; |
| 138 } | 134 } |
| 139 | 135 |
| 140 // Flush is handled on the upcall thread, where another RPC service | 136 // Flush is handled on the upcall thread, where another RPC service |
| 141 // (PppUpcallRpcServer) is exported. | 137 // (PppUpcallRpcServer) is exported. |
| OLD | NEW |