OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/plugin_ppb_widget.h" | 5 #include "native_client/src/shared/ppapi_proxy/plugin_ppb_widget.h" |
6 | 6 |
7 #include "native_client/src/include/portability.h" | 7 #include "native_client/src/include/portability.h" |
8 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" | 8 #include "native_client/src/shared/ppapi_proxy/plugin_callback.h" |
9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" | 9 #include "native_client/src/shared/ppapi_proxy/plugin_globals.h" |
10 #include "native_client/src/shared/ppapi_proxy/utility.h" | 10 #include "native_client/src/shared/ppapi_proxy/utility.h" |
11 #include "ppapi/c/dev/ppb_scrollbar_dev.h" | 11 #include "ppapi/c/dev/ppb_scrollbar_dev.h" |
12 #include "ppapi/c/pp_completion_callback.h" | 12 #include "ppapi/c/pp_completion_callback.h" |
13 #include "ppapi/c/pp_errors.h" | 13 #include "ppapi/c/pp_errors.h" |
14 #include "ppapi/c/pp_input_event.h" | 14 #include "ppapi/c/pp_input_event.h" |
15 #include "ppapi/c/pp_rect.h" | 15 #include "ppapi/c/pp_rect.h" |
16 #include "srpcgen/ppb_rpc.h" | 16 #include "srpcgen/ppb_rpc.h" |
17 | 17 |
18 namespace ppapi_proxy { | 18 namespace ppapi_proxy { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 const nacl_abi_size_t kPPRectBytes = | 22 const nacl_abi_size_t kPPRectBytes = |
23 static_cast<nacl_abi_size_t>(sizeof(struct PP_Rect)); | 23 static_cast<nacl_abi_size_t>(sizeof(struct PP_Rect)); |
24 | 24 |
25 PP_Bool IsWidget(PP_Resource resource) { | 25 PP_Bool IsWidget(PP_Resource resource) { |
26 DebugPrintf("PPB_Widget::IsWidget: " | 26 DebugPrintf("PPB_Widget::IsWidget: " |
27 "resource=%"NACL_PRIu32"\n", resource); | 27 "resource=%"NACL_PRId32"\n", resource); |
28 | 28 |
29 int32_t is_widget = 0; | 29 int32_t is_widget = 0; |
30 NaClSrpcError srpc_result = | 30 NaClSrpcError srpc_result = |
31 PpbWidgetRpcClient::PPB_Widget_IsWidget( | 31 PpbWidgetRpcClient::PPB_Widget_IsWidget( |
32 GetMainSrpcChannel(), | 32 GetMainSrpcChannel(), |
33 resource, | 33 resource, |
34 &is_widget); | 34 &is_widget); |
35 | 35 |
36 DebugPrintf("PPB_Widget::IsWidget: %s\n", | 36 DebugPrintf("PPB_Widget::IsWidget: %s\n", |
37 NaClSrpcErrorString(srpc_result)); | 37 NaClSrpcErrorString(srpc_result)); |
38 | 38 |
39 if (srpc_result == NACL_SRPC_RESULT_OK && is_widget) | 39 if (srpc_result == NACL_SRPC_RESULT_OK && is_widget) |
40 return PP_TRUE; | 40 return PP_TRUE; |
41 return PP_FALSE; | 41 return PP_FALSE; |
42 } | 42 } |
43 | 43 |
44 PP_Bool Paint( | 44 PP_Bool Paint( |
45 PP_Resource widget, | 45 PP_Resource widget, |
46 const struct PP_Rect* rect, | 46 const struct PP_Rect* rect, |
47 PP_Resource image) { | 47 PP_Resource image) { |
48 DebugPrintf("PPB_Widget::Paint: " | 48 DebugPrintf("PPB_Widget::Paint: " |
49 "widget=%"NACL_PRIu32"\n", widget); | 49 "widget=%"NACL_PRId32"\n", widget); |
50 | 50 |
51 int32_t success = 0; | 51 int32_t success = 0; |
52 NaClSrpcError srpc_result = | 52 NaClSrpcError srpc_result = |
53 PpbWidgetRpcClient::PPB_Widget_Paint( | 53 PpbWidgetRpcClient::PPB_Widget_Paint( |
54 GetMainSrpcChannel(), | 54 GetMainSrpcChannel(), |
55 widget, | 55 widget, |
56 kPPRectBytes, | 56 kPPRectBytes, |
57 reinterpret_cast<char*>(const_cast<struct PP_Rect*>(rect)), | 57 reinterpret_cast<char*>(const_cast<struct PP_Rect*>(rect)), |
58 image, | 58 image, |
59 &success); | 59 &success); |
(...skipping 23 matching lines...) Expand all Loading... |
83 | 83 |
84 if (srpc_result == NACL_SRPC_RESULT_OK && handled) | 84 if (srpc_result == NACL_SRPC_RESULT_OK && handled) |
85 return PP_TRUE; | 85 return PP_TRUE; |
86 return PP_FALSE; | 86 return PP_FALSE; |
87 } | 87 } |
88 | 88 |
89 PP_Bool GetLocation( | 89 PP_Bool GetLocation( |
90 PP_Resource widget, | 90 PP_Resource widget, |
91 struct PP_Rect* location) { | 91 struct PP_Rect* location) { |
92 DebugPrintf("PPB_Widget::GetLocation: " | 92 DebugPrintf("PPB_Widget::GetLocation: " |
93 "widget=%"NACL_PRIu32"\n", widget); | 93 "widget=%"NACL_PRId32"\n", widget); |
94 | 94 |
95 int32_t visible = 0; | 95 int32_t visible = 0; |
96 nacl_abi_size_t location_size = kPPRectBytes; | 96 nacl_abi_size_t location_size = kPPRectBytes; |
97 NaClSrpcError srpc_result = | 97 NaClSrpcError srpc_result = |
98 PpbWidgetRpcClient::PPB_Widget_GetLocation( | 98 PpbWidgetRpcClient::PPB_Widget_GetLocation( |
99 GetMainSrpcChannel(), | 99 GetMainSrpcChannel(), |
100 widget, | 100 widget, |
101 &location_size, | 101 &location_size, |
102 reinterpret_cast<char*>(location), | 102 reinterpret_cast<char*>(location), |
103 &visible); | 103 &visible); |
104 | 104 |
105 DebugPrintf("PPB_Widget::GetLocation: %s\n", | 105 DebugPrintf("PPB_Widget::GetLocation: %s\n", |
106 NaClSrpcErrorString(srpc_result)); | 106 NaClSrpcErrorString(srpc_result)); |
107 | 107 |
108 if (srpc_result == NACL_SRPC_RESULT_OK && visible && | 108 if (srpc_result == NACL_SRPC_RESULT_OK && visible && |
109 location_size == kPPRectBytes) | 109 location_size == kPPRectBytes) |
110 return PP_TRUE; | 110 return PP_TRUE; |
111 return PP_FALSE; | 111 return PP_FALSE; |
112 } | 112 } |
113 | 113 |
114 void SetLocation( | 114 void SetLocation( |
115 PP_Resource widget, | 115 PP_Resource widget, |
116 const struct PP_Rect* location) { | 116 const struct PP_Rect* location) { |
117 DebugPrintf("PPB_Widget::SetLocation: " | 117 DebugPrintf("PPB_Widget::SetLocation: " |
118 "widget=%"NACL_PRIu32"\n", widget); | 118 "widget=%"NACL_PRId32"\n", widget); |
119 | 119 |
120 NaClSrpcError srpc_result = | 120 NaClSrpcError srpc_result = |
121 PpbWidgetRpcClient::PPB_Widget_SetLocation( | 121 PpbWidgetRpcClient::PPB_Widget_SetLocation( |
122 GetMainSrpcChannel(), | 122 GetMainSrpcChannel(), |
123 widget, | 123 widget, |
124 kPPRectBytes, | 124 kPPRectBytes, |
125 reinterpret_cast<char*>(const_cast<struct PP_Rect*>(location))); | 125 reinterpret_cast<char*>(const_cast<struct PP_Rect*>(location))); |
126 | 126 |
127 DebugPrintf("PPB_Widget::SetLocation: %s\n", | 127 DebugPrintf("PPB_Widget::SetLocation: %s\n", |
128 NaClSrpcErrorString(srpc_result)); | 128 NaClSrpcErrorString(srpc_result)); |
129 } | 129 } |
130 | 130 |
131 } // namespace | 131 } // namespace |
132 | 132 |
133 const PPB_Widget_Dev* PluginWidget::GetInterface() { | 133 const PPB_Widget_Dev* PluginWidget::GetInterface() { |
134 static const PPB_Widget_Dev widget_interface = { | 134 static const PPB_Widget_Dev widget_interface = { |
135 IsWidget, | 135 IsWidget, |
136 Paint, | 136 Paint, |
137 HandleEvent, | 137 HandleEvent, |
138 GetLocation, | 138 GetLocation, |
139 SetLocation | 139 SetLocation |
140 }; | 140 }; |
141 return &widget_interface; | 141 return &widget_interface; |
142 } | 142 } |
143 | 143 |
144 } // namespace ppapi_proxy | 144 } // namespace ppapi_proxy |
145 | |
OLD | NEW |