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 <stdlib.h> | 5 #include <stdlib.h> |
6 #include <string.h> | 6 #include <string.h> |
7 | 7 |
8 #include "ppapi/c/pp_completion_callback.h" | 8 #include "ppapi/c/pp_completion_callback.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/pp_instance.h" | 10 #include "ppapi/c/pp_instance.h" |
11 #include "ppapi/c/pp_module.h" | 11 #include "ppapi/c/pp_module.h" |
12 #include "ppapi/c/pp_size.h" | 12 #include "ppapi/c/pp_rect.h" |
13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
14 #include "ppapi/c/ppb.h" | 14 #include "ppapi/c/ppb.h" |
15 #include "ppapi/c/ppb_core.h" | 15 #include "ppapi/c/ppb_core.h" |
16 #include "ppapi/c/ppb_graphics_2d.h" | 16 #include "ppapi/c/ppb_graphics_2d.h" |
17 #include "ppapi/c/ppb_image_data.h" | 17 #include "ppapi/c/ppb_image_data.h" |
18 #include "ppapi/c/ppb_instance.h" | 18 #include "ppapi/c/ppb_instance.h" |
| 19 #include "ppapi/c/ppb_view.h" |
19 #include "ppapi/c/ppp.h" | 20 #include "ppapi/c/ppp.h" |
20 #include "ppapi/c/ppp_instance.h" | 21 #include "ppapi/c/ppp_instance.h" |
21 | 22 |
22 PPB_GetInterface g_get_browser_interface = NULL; | 23 PPB_GetInterface g_get_browser_interface = NULL; |
23 | 24 |
24 const struct PPB_Core* g_core_interface; | 25 const struct PPB_Core* g_core_interface; |
25 const struct PPB_Graphics2D* g_graphics_2d_interface; | 26 const struct PPB_Graphics2D* g_graphics_2d_interface; |
26 const struct PPB_ImageData* g_image_data_interface; | 27 const struct PPB_ImageData* g_image_data_interface; |
27 const struct PPB_Instance* g_instance_interface; | 28 const struct PPB_Instance* g_instance_interface; |
| 29 const struct PPB_View* g_view_interface; |
28 | 30 |
29 /* PPP_Instance implementation -----------------------------------------------*/ | 31 /* PPP_Instance implementation -----------------------------------------------*/ |
30 | 32 |
31 struct InstanceInfo { | 33 struct InstanceInfo { |
32 PP_Instance pp_instance; | 34 PP_Instance pp_instance; |
33 struct PP_Size last_size; | 35 struct PP_Size last_size; |
34 | 36 |
35 struct InstanceInfo* next; | 37 struct InstanceInfo* next; |
36 }; | 38 }; |
37 | 39 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 if (instance == cur->pp_instance) { | 134 if (instance == cur->pp_instance) { |
133 *prev_ptr = cur->next; | 135 *prev_ptr = cur->next; |
134 free(cur); | 136 free(cur); |
135 return; | 137 return; |
136 } | 138 } |
137 prev_ptr = &cur->next; | 139 prev_ptr = &cur->next; |
138 } | 140 } |
139 } | 141 } |
140 | 142 |
141 void Instance_DidChangeView(PP_Instance pp_instance, | 143 void Instance_DidChangeView(PP_Instance pp_instance, |
142 const struct PP_Rect* position, | 144 PP_Resource view) { |
143 const struct PP_Rect* clip) { | 145 struct PP_Rect position; |
144 struct InstanceInfo* info = FindInstance(pp_instance); | 146 struct InstanceInfo* info = FindInstance(pp_instance); |
145 if (!info) | 147 if (!info) |
146 return; | 148 return; |
147 | 149 |
148 if (info->last_size.width != position->size.width || | 150 if (g_view_interface->GetRect(view, &position) == PP_FALSE) |
149 info->last_size.height != position->size.height) { | 151 return; |
| 152 |
| 153 if (info->last_size.width != position.size.width || |
| 154 info->last_size.height != position.size.height) { |
150 /* Got a resize, repaint the plugin. */ | 155 /* Got a resize, repaint the plugin. */ |
151 Repaint(info, &position->size); | 156 Repaint(info, &position.size); |
152 info->last_size.width = position->size.width; | 157 info->last_size.width = position.size.width; |
153 info->last_size.height = position->size.height; | 158 info->last_size.height = position.size.height; |
154 } | 159 } |
155 } | 160 } |
156 | 161 |
157 void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { | 162 void Instance_DidChangeFocus(PP_Instance pp_instance, PP_Bool has_focus) { |
158 } | 163 } |
159 | 164 |
160 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, | 165 PP_Bool Instance_HandleDocumentLoad(PP_Instance pp_instance, |
161 PP_Resource pp_url_loader) { | 166 PP_Resource pp_url_loader) { |
162 return PP_FALSE; | 167 return PP_FALSE; |
163 } | 168 } |
(...skipping 14 matching lines...) Expand all Loading... |
178 g_get_browser_interface = get_browser_interface; | 183 g_get_browser_interface = get_browser_interface; |
179 | 184 |
180 g_core_interface = (const struct PPB_Core*) | 185 g_core_interface = (const struct PPB_Core*) |
181 get_browser_interface(PPB_CORE_INTERFACE); | 186 get_browser_interface(PPB_CORE_INTERFACE); |
182 g_instance_interface = (const struct PPB_Instance*) | 187 g_instance_interface = (const struct PPB_Instance*) |
183 get_browser_interface(PPB_INSTANCE_INTERFACE); | 188 get_browser_interface(PPB_INSTANCE_INTERFACE); |
184 g_image_data_interface = (const struct PPB_ImageData*) | 189 g_image_data_interface = (const struct PPB_ImageData*) |
185 get_browser_interface(PPB_IMAGEDATA_INTERFACE); | 190 get_browser_interface(PPB_IMAGEDATA_INTERFACE); |
186 g_graphics_2d_interface = (const struct PPB_Graphics2D*) | 191 g_graphics_2d_interface = (const struct PPB_Graphics2D*) |
187 get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); | 192 get_browser_interface(PPB_GRAPHICS_2D_INTERFACE); |
| 193 g_view_interface = (const struct PPB_View*) |
| 194 get_browser_interface(PPB_VIEW_INTERFACE); |
188 if (!g_core_interface || !g_instance_interface || !g_image_data_interface || | 195 if (!g_core_interface || !g_instance_interface || !g_image_data_interface || |
189 !g_graphics_2d_interface) | 196 !g_graphics_2d_interface || !g_view_interface) |
190 return -1; | 197 return -1; |
191 | 198 |
192 return PP_OK; | 199 return PP_OK; |
193 } | 200 } |
194 | 201 |
195 PP_EXPORT void PPP_ShutdownModule() { | 202 PP_EXPORT void PPP_ShutdownModule() { |
196 } | 203 } |
197 | 204 |
198 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { | 205 PP_EXPORT const void* PPP_GetInterface(const char* interface_name) { |
199 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) | 206 if (strcmp(interface_name, PPP_INSTANCE_INTERFACE) == 0) |
200 return &instance_interface; | 207 return &instance_interface; |
201 return NULL; | 208 return NULL; |
202 } | 209 } |
203 | 210 |
OLD | NEW |