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 const PPB_View* view_interface = PPBViewInterface(); |
111 position_array[1] = position->point.y; | 112 view_interface->GetRect(view, &view_data.viewport_rect); |
112 position_array[2] = position->size.width; | 113 view_data.is_fullscreen = view_interface->IsFullscreen(view); |
113 position_array[3] = position->size.height; | 114 view_data.is_page_visible = view_interface->IsPageVisible(view); |
114 int32_t clip_array[4]; | 115 view_interface->GetClipRect(view, &view_data.clip_rect); |
115 const uint32_t kClipArraySize = NACL_ARRAY_SIZE(clip_array); | 116 |
116 clip_array[0] = clip->point.x; | |
117 clip_array[1] = clip->point.y; | |
118 clip_array[2] = clip->size.width; | |
119 clip_array[3] = clip->size.height; | |
120 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidChangeView( | 117 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidChangeView( |
121 GetMainSrpcChannel(instance), | 118 GetMainSrpcChannel(instance), |
122 instance, | 119 instance, |
123 kPositionArraySize, | 120 view, |
124 position_array, | 121 sizeof(ViewData), |
125 kClipArraySize, | 122 reinterpret_cast<char*>(&view_data)); |
126 clip_array, | |
127 static_cast<int32_t>(PPBFullscreenInterface()->IsFullscreen(instance))); | |
128 DebugPrintf("PPP_Instance::DidChangeView: %s\n", | 123 DebugPrintf("PPP_Instance::DidChangeView: %s\n", |
129 NaClSrpcErrorString(srpc_result)); | 124 NaClSrpcErrorString(srpc_result)); |
130 } | 125 } |
131 | 126 |
132 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { | 127 void DidChangeFocus(PP_Instance instance, PP_Bool has_focus) { |
133 DebugPrintf("PPP_Instance::DidChangeFocus: instance=%"NACL_PRIu32", " | 128 DebugPrintf("PPP_Instance::DidChangeFocus: instance=%"NACL_PRIu32", " |
134 "has_focus = %d\n", instance, has_focus); | 129 "has_focus = %d\n", instance, has_focus); |
135 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidChangeFocus( | 130 NaClSrpcError srpc_result = PppInstanceRpcClient::PPP_Instance_DidChangeFocus( |
136 GetMainSrpcChannel(instance), | 131 GetMainSrpcChannel(instance), |
137 instance, | 132 instance, |
(...skipping 28 matching lines...) Expand all Loading... |
166 DidCreate, | 161 DidCreate, |
167 DidDestroy, | 162 DidDestroy, |
168 DidChangeView, | 163 DidChangeView, |
169 DidChangeFocus, | 164 DidChangeFocus, |
170 HandleDocumentLoad | 165 HandleDocumentLoad |
171 }; | 166 }; |
172 return &instance_interface; | 167 return &instance_interface; |
173 } | 168 } |
174 | 169 |
175 } // namespace ppapi_proxy | 170 } // namespace ppapi_proxy |
OLD | NEW |