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 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ | 5 #ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ |
6 #define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ | 6 #define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "gfx/rect.h" |
13 #include "third_party/ppapi/c/pp_instance.h" | 14 #include "third_party/ppapi/c/pp_instance.h" |
14 #include "third_party/ppapi/c/pp_resource.h" | 15 #include "third_party/ppapi/c/pp_resource.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" | 16 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" |
16 | 17 |
17 typedef struct _pp_Var PP_Var; | 18 typedef struct _pp_Var PP_Var; |
18 typedef struct _ppb_Instance PPB_Instance; | 19 typedef struct _ppb_Instance PPB_Instance; |
19 typedef struct _ppp_Instance PPP_Instance; | 20 typedef struct _ppp_Instance PPP_Instance; |
20 | 21 |
21 namespace gfx { | 22 namespace gfx { |
22 class Rect; | 23 class Rect; |
(...skipping 19 matching lines...) Expand all Loading... |
42 ~PluginInstance(); | 43 ~PluginInstance(); |
43 | 44 |
44 static const PPB_Instance* GetInterface(); | 45 static const PPB_Instance* GetInterface(); |
45 | 46 |
46 // Converts the given instance ID to an actual instance object. | 47 // Converts the given instance ID to an actual instance object. |
47 static PluginInstance* FromPPInstance(PP_Instance instance); | 48 static PluginInstance* FromPPInstance(PP_Instance instance); |
48 | 49 |
49 PluginDelegate* delegate() const { return delegate_; } | 50 PluginDelegate* delegate() const { return delegate_; } |
50 PluginModule* module() const { return module_.get(); } | 51 PluginModule* module() const { return module_.get(); } |
51 | 52 |
| 53 const gfx::Rect& position() const { return position_; } |
| 54 const gfx::Rect& clip() const { return clip_; } |
| 55 |
52 PP_Instance GetPPInstance(); | 56 PP_Instance GetPPInstance(); |
53 | 57 |
| 58 // Paints the current backing store to the web page. |
54 void Paint(WebKit::WebCanvas* canvas, | 59 void Paint(WebKit::WebCanvas* canvas, |
55 const gfx::Rect& plugin_rect, | 60 const gfx::Rect& plugin_rect, |
56 const gfx::Rect& paint_rect); | 61 const gfx::Rect& paint_rect); |
57 | 62 |
| 63 // Schedules a paint of the page for the given region. The coordinates are |
| 64 // relative to the top-left of the plugin. This does nothing if the plugin |
| 65 // has not yet been positioned. You can supply an empty gfx::Rect() to |
| 66 // invalidate the entire plugin. |
| 67 void InvalidateRect(const gfx::Rect& rect); |
| 68 |
58 // PPB_Instance implementation. | 69 // PPB_Instance implementation. |
59 PP_Var GetWindowObject(); | 70 PP_Var GetWindowObject(); |
60 PP_Var GetOwnerElementObject(); | 71 PP_Var GetOwnerElementObject(); |
61 bool BindGraphicsDeviceContext(PP_Resource device_id); | 72 bool BindGraphicsDeviceContext(PP_Resource device_id); |
62 | 73 |
63 // PPP_Instance pass-through. | 74 // PPP_Instance pass-through. |
64 void Delete(); | 75 void Delete(); |
65 bool Initialize(WebKit::WebPluginContainer* container, | 76 bool Initialize(WebKit::WebPluginContainer* container, |
66 const std::vector<std::string>& arg_names, | 77 const std::vector<std::string>& arg_names, |
67 const std::vector<std::string>& arg_values); | 78 const std::vector<std::string>& arg_values); |
68 bool HandleInputEvent(const WebKit::WebInputEvent& event, | 79 bool HandleInputEvent(const WebKit::WebInputEvent& event, |
69 WebKit::WebCursorInfo* cursor_info); | 80 WebKit::WebCursorInfo* cursor_info); |
70 PP_Var GetInstanceObject(); | 81 PP_Var GetInstanceObject(); |
71 void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip); | 82 void ViewChanged(const gfx::Rect& position, const gfx::Rect& clip); |
72 | 83 |
| 84 // Notifications that the view has rendered the page and that it has been |
| 85 // flushed to the screen. These messages are used to send Flush callbacks to |
| 86 // the plugin for DeviceContext2D. |
| 87 void ViewInitiatedPaint(); |
| 88 void ViewFlushedPaint(); |
| 89 |
73 private: | 90 private: |
74 PluginDelegate* delegate_; | 91 PluginDelegate* delegate_; |
75 scoped_refptr<PluginModule> module_; | 92 scoped_refptr<PluginModule> module_; |
76 const PPP_Instance* instance_interface_; | 93 const PPP_Instance* instance_interface_; |
77 | 94 |
78 // NULL until we have been initialized. | 95 // NULL until we have been initialized. |
79 WebKit::WebPluginContainer* container_; | 96 WebKit::WebPluginContainer* container_; |
80 | 97 |
| 98 // Position in the viewport (which moves as the page is scrolled) of this |
| 99 // plugin. This will be a 0-sized rectangle if the plugin has not yet been |
| 100 // laid out. |
| 101 gfx::Rect position_; |
| 102 |
| 103 // Current clip rect. This will be empty if the plugin is not currently |
| 104 // visible. This is in the plugin's coordinate system, so fully visible will |
| 105 // be (0, 0, w, h) regardless of scroll position. |
| 106 gfx::Rect clip_; |
| 107 |
81 // The current device context for painting in 2D. | 108 // The current device context for painting in 2D. |
82 scoped_refptr<DeviceContext2D> device_context_2d_; | 109 scoped_refptr<DeviceContext2D> device_context_2d_; |
83 | 110 |
84 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 111 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
85 }; | 112 }; |
86 | 113 |
87 } // namespace pepper | 114 } // namespace pepper |
88 | 115 |
89 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ | 116 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ |
OLD | NEW |