| OLD | NEW |
| 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/browser_ppp_instance.h" | 5 #include "native_client/src/shared/ppapi_proxy/browser_ppp_instance.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| 11 #include "native_client/src/include/checked_cast.h" | 11 #include "native_client/src/include/checked_cast.h" |
| 12 #include "native_client/src/include/nacl_scoped_ptr.h" | 12 #include "native_client/src/include/nacl_scoped_ptr.h" |
| 13 #include "native_client/src/include/portability.h" | 13 #include "native_client/src/include/portability.h" |
| 14 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" | 14 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
| 15 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" | 15 #include "native_client/src/shared/ppapi_proxy/browser_ppp.h" |
| 16 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h" | 16 #include "native_client/src/shared/ppapi_proxy/trusted/srpcgen/ppp_rpc.h" |
| 17 #include "native_client/src/shared/ppapi_proxy/utility.h" | 17 #include "native_client/src/shared/ppapi_proxy/utility.h" |
| 18 #include "native_client/src/shared/ppapi_proxy/view_data.h" |
| 18 #include "ppapi/c/pp_resource.h" | 19 #include "ppapi/c/pp_resource.h" |
| 19 #include "ppapi/c/pp_var.h" | 20 #include "ppapi/c/pp_var.h" |
| 20 #include "ppapi/c/ppp_instance.h" | 21 #include "ppapi/c/ppp_instance.h" |
| 22 #include "ppapi/c/ppb_view.h" |
| 21 | 23 |
| 22 using nacl::scoped_array; | 24 using nacl::scoped_array; |
| 25 using ppapi_proxy::ViewData; |
| 23 | 26 |
| 24 namespace ppapi_proxy { | 27 namespace ppapi_proxy { |
| 25 | 28 |
| 26 namespace { | 29 namespace { |
| 27 | 30 |
| 28 char* ArgArraySerialize(int argc, | 31 char* ArgArraySerialize(int argc, |
| 29 const char* array[], | 32 const char* array[], |
| 30 uint32_t* serial_size) { | 33 uint32_t* serial_size) { |
| 31 uint32_t used = 0; | 34 uint32_t used = 0; |
| 32 for (int i = 0; i < argc; ++i) { | 35 for (int i = 0; i < argc; ++i) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 } | 96 } |
| 94 | 97 |
| 95 void DidDestroy(PP_Instance instance) { | 98 void DidDestroy(PP_Instance instance) { |
| 96 DebugPrintf("PPP_Instance::DidDestroy: instance=%"NACL_PRIu32"\n", instance); | 99 DebugPrintf("PPP_Instance::DidDestroy: instance=%"NACL_PRIu32"\n", instance); |
| 97 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidDestroy( | 100 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidDestroy( |
| 98 GetMainSrpcChannel(instance), instance); | 101 GetMainSrpcChannel(instance), instance); |
| 99 DebugPrintf("PPP_Instance::DidDestroy: %s\n", | 102 DebugPrintf("PPP_Instance::DidDestroy: %s\n", |
| 100 NaClSrpcErrorString(srpc_result)); | 103 NaClSrpcErrorString(srpc_result)); |
| 101 } | 104 } |
| 102 | 105 |
| 103 void DidChangeView(PP_Instance instance, | 106 void DidChangeView(PP_Instance instance, PP_Resource view) { |
| 104 const PP_Rect* position, | |
| 105 const PP_Rect* clip) { | |
| 106 DebugPrintf("PPP_Instance::DidChangeView: instance=%"NACL_PRIu32"\n", | 107 DebugPrintf("PPP_Instance::DidChangeView: instance=%"NACL_PRIu32"\n", |
| 107 instance); | 108 instance); |
| 108 int32_t position_array[4]; | 109 ViewData view_data; |
| 109 const uint32_t kPositionArraySize = NACL_ARRAY_SIZE(position_array); | 110 |
| 110 position_array[0] = position->point.x; | 111 // We only send the new view info. The plugin side keeps track of the |
| 111 position_array[1] = position->point.y; | 112 // previous state it sent out, so can do the "changed" part itself. |
| 112 position_array[2] = position->size.width; | 113 const PPB_View* view_interface = static_cast<const PPB_View*>( |
| 113 position_array[3] = position->size.height; | 114 GetBrowserInterface(PPB_VIEW_INTERFACE)); |
| 114 int32_t clip_array[4]; | 115 view_interface->GetRect(view, &view_data.viewport_rect); |
| 115 const uint32_t kClipArraySize = NACL_ARRAY_SIZE(clip_array); | 116 view_data.is_fullscreen = view_interface->IsFullscreen(view); |
| 116 clip_array[0] = clip->point.x; | 117 view_data.is_page_visible = view_interface->IsPageVisible(view); |
| 117 clip_array[1] = clip->point.y; | 118 view_interface->GetClipRect(view, &view_data.clip_rect); |
| 118 clip_array[2] = clip->size.width; | 119 |
| 119 clip_array[3] = clip->size.height; | |
| 120 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidChangeView( | 120 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidChangeView( |
| 121 GetMainSrpcChannel(instance), | 121 GetMainSrpcChannel(instance), |
| 122 instance, | 122 instance, |
| 123 kPositionArraySize, | 123 view, |
| 124 position_array, | 124 sizeof(ViewData), |
| 125 kClipArraySize, | 125 reinterpret_cast<char*>(&view_data)); |
| 126 clip_array, | |
| 127 static_cast<int32_t>(PPBFullscreenInterface()->IsFullscreen(instance))); | |
| 128 DebugPrintf("PPP_Instance::DidChangeView: %s\n", | 126 DebugPrintf("PPP_Instance::DidChangeView: %s\n", |
| 129 NaClSrpcErrorString(srpc_result)); | 127 NaClSrpcErrorString(srpc_result)); |
| 130 } | 128 } |
| 131 | 129 |
| 132 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { | 130 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { |
| 133 DebugPrintf("PPP_Instance::DidChangeFocus: instance=%"NACL_PRIu32", " | 131 DebugPrintf("PPP_Instance::DidChangeFocus: instance=%"NACL_PRIu32", " |
| 134 "has_focus = %d\n", instance, has_focus); | 132 "has_focus = %d\n", instance, has_focus); |
| 135 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidChangeFocus( | 133 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidChangeFocus( |
| 136 GetMainSrpcChannel(instance), | 134 GetMainSrpcChannel(instance), |
| 137 instance, | 135 instance, |
| (...skipping 28 matching lines...) Expand all Loading... |
| 166 DidCreate, | 164 DidCreate, |
| 167 DidDestroy, | 165 DidDestroy, |
| 168 DidChangeView, | 166 DidChangeView, |
| 169 DidChangeFocus, | 167 DidChangeFocus, |
| 170 HandleDocumentLoad | 168 HandleDocumentLoad |
| 171 }; | 169 }; |
| 172 return &instance_interface; | 170 return &instance_interface; |
| 173 } | 171 } |
| 174 | 172 |
| 175 } // namespace ppapi_proxy | 173 } // namespace ppapi_proxy |
| OLD | NEW |