OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "webkit/glue/plugins/pepper_plugin_instance.h" | 5 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "gfx/rect.h" | 9 #include "gfx/rect.h" |
10 #include "third_party/ppapi/c/pp_instance.h" | 10 #include "third_party/ppapi/c/pp_instance.h" |
11 #include "third_party/ppapi/c/pp_event.h" | 11 #include "third_party/ppapi/c/pp_event.h" |
12 #include "third_party/ppapi/c/pp_rect.h" | 12 #include "third_party/ppapi/c/pp_rect.h" |
13 #include "third_party/ppapi/c/pp_resource.h" | 13 #include "third_party/ppapi/c/pp_resource.h" |
14 #include "third_party/ppapi/c/pp_var.h" | 14 #include "third_party/ppapi/c/pp_var.h" |
15 #include "third_party/ppapi/c/ppb_instance.h" | 15 #include "third_party/ppapi/c/ppb_instance.h" |
16 #include "third_party/ppapi/c/ppp_instance.h" | 16 #include "third_party/ppapi/c/ppp_instance.h" |
17 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 17 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
18 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" | 18 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" |
19 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 19 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
20 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 20 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
21 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" |
22 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" |
23 #include "webkit/glue/plugins/pepper_device_context_2d.h" | 23 #include "webkit/glue/plugins/pepper_device_context_2d.h" |
24 #include "webkit/glue/plugins/pepper_plugin_delegate.h" | 24 #include "webkit/glue/plugins/pepper_plugin_delegate.h" |
25 #include "webkit/glue/plugins/pepper_plugin_module.h" | 25 #include "webkit/glue/plugins/pepper_plugin_module.h" |
26 #include "webkit/glue/plugins/pepper_resource_tracker.h" | |
27 #include "webkit/glue/plugins/pepper_var.h" | 26 #include "webkit/glue/plugins/pepper_var.h" |
28 | 27 |
29 using WebKit::WebFrame; | 28 using WebKit::WebFrame; |
30 using WebKit::WebInputEvent; | 29 using WebKit::WebInputEvent; |
31 using WebKit::WebPluginContainer; | 30 using WebKit::WebPluginContainer; |
32 | 31 |
33 namespace pepper { | 32 namespace pepper { |
34 | 33 |
35 namespace { | 34 namespace { |
36 | 35 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 if (!device_id) { | 206 if (!device_id) { |
208 // Special-case clearing the current device. | 207 // Special-case clearing the current device. |
209 if (device_context_2d_) { | 208 if (device_context_2d_) { |
210 device_context_2d_->BindToInstance(NULL); | 209 device_context_2d_->BindToInstance(NULL); |
211 device_context_2d_ = NULL; | 210 device_context_2d_ = NULL; |
212 InvalidateRect(gfx::Rect()); | 211 InvalidateRect(gfx::Rect()); |
213 } | 212 } |
214 return true; | 213 return true; |
215 } | 214 } |
216 | 215 |
217 scoped_refptr<Resource> device_resource = | 216 scoped_refptr<DeviceContext2D> device_2d = |
218 ResourceTracker::Get()->GetResource(device_id); | 217 Resource::GetAs<DeviceContext2D>(device_id); |
219 if (!device_resource.get()) | |
220 return false; | |
221 | 218 |
222 DeviceContext2D* device_2d = device_resource->AsDeviceContext2D(); | |
223 if (device_2d) { | 219 if (device_2d) { |
224 if (!device_2d->BindToInstance(this)) | 220 if (!device_2d->BindToInstance(this)) |
225 return false; // Can't bind to more than one instance. | 221 return false; // Can't bind to more than one instance. |
226 device_context_2d_ = device_2d; | 222 device_context_2d_ = device_2d; |
227 // BindToInstance will have invalidated the plugin if necessary. | 223 // BindToInstance will have invalidated the plugin if necessary. |
228 } | 224 } |
229 | 225 |
230 return true; | 226 return true; |
231 } | 227 } |
232 | 228 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 if (device_context_2d_) | 312 if (device_context_2d_) |
317 device_context_2d_->ViewInitiatedPaint(); | 313 device_context_2d_->ViewInitiatedPaint(); |
318 } | 314 } |
319 | 315 |
320 void PluginInstance::ViewFlushedPaint() { | 316 void PluginInstance::ViewFlushedPaint() { |
321 if (device_context_2d_) | 317 if (device_context_2d_) |
322 device_context_2d_->ViewFlushedPaint(); | 318 device_context_2d_->ViewFlushedPaint(); |
323 } | 319 } |
324 | 320 |
325 } // namespace pepper | 321 } // namespace pepper |
OLD | NEW |