| 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 "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
| 14 #include "base/string16.h" | 14 #include "base/string16.h" |
| 15 #include "gfx/rect.h" | 15 #include "gfx/rect.h" |
| 16 #include "third_party/ppapi/c/dev/pp_cursor_type_dev.h" | 16 #include "third_party/ppapi/c/dev/pp_cursor_type_dev.h" |
| 17 #include "third_party/ppapi/c/dev/ppp_graphics_3d_dev.h" |
| 18 #include "third_party/ppapi/c/dev/ppp_printing_dev.h" |
| 17 #include "third_party/ppapi/c/pp_instance.h" | 19 #include "third_party/ppapi/c/pp_instance.h" |
| 18 #include "third_party/ppapi/c/pp_resource.h" | 20 #include "third_party/ppapi/c/pp_resource.h" |
| 19 #include "third_party/ppapi/c/ppp_printing.h" | |
| 20 #include "third_party/ppapi/c/ppp_graphics_3d.h" | |
| 21 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
| 22 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h" |
| 23 | 23 |
| 24 typedef struct _pp_Var PP_Var; | 24 struct PP_Var; |
| 25 typedef struct _ppb_Instance PPB_Instance; | 25 struct PPB_Instance; |
| 26 typedef struct _ppb_Find PPB_Find; | 26 struct PPB_Find_Dev; |
| 27 typedef struct _ppp_Find PPP_Find; | 27 struct PPP_Find_Dev; |
| 28 typedef struct _ppp_Instance PPP_Instance; | 28 struct PPP_Instance; |
| 29 typedef struct _ppp_Zoom PPP_Zoom; | 29 struct PPP_Zoom_Dev; |
| 30 | 30 |
| 31 class SkBitmap; | 31 class SkBitmap; |
| 32 | 32 |
| 33 namespace gfx { | 33 namespace gfx { |
| 34 class Rect; | 34 class Rect; |
| 35 } | 35 } |
| 36 | 36 |
| 37 namespace WebKit { | 37 namespace WebKit { |
| 38 struct WebCursorInfo; | 38 struct WebCursorInfo; |
| 39 class WebInputEvent; | 39 class WebInputEvent; |
| 40 class WebPluginContainer; | 40 class WebPluginContainer; |
| 41 } | 41 } |
| 42 | 42 |
| 43 namespace pepper { | 43 namespace pepper { |
| 44 | 44 |
| 45 class DeviceContext2D; | 45 class Graphics2D; |
| 46 class ImageData; | 46 class ImageData; |
| 47 class PluginDelegate; | 47 class PluginDelegate; |
| 48 class PluginModule; | 48 class PluginModule; |
| 49 class URLLoader; | 49 class URLLoader; |
| 50 | 50 |
| 51 class PluginInstance : public base::RefCounted<PluginInstance> { | 51 class PluginInstance : public base::RefCounted<PluginInstance> { |
| 52 public: | 52 public: |
| 53 PluginInstance(PluginDelegate* delegate, | 53 PluginInstance(PluginDelegate* delegate, |
| 54 PluginModule* module, | 54 PluginModule* module, |
| 55 const PPP_Instance* instance_interface); | 55 const PPP_Instance* instance_interface); |
| 56 ~PluginInstance(); | 56 ~PluginInstance(); |
| 57 | 57 |
| 58 static const PPB_Instance* GetInterface(); | 58 static const PPB_Instance* GetInterface(); |
| 59 | 59 |
| 60 // Converts the given instance ID to an actual instance object. | 60 // Converts the given instance ID to an actual instance object. |
| 61 static PluginInstance* FromPPInstance(PP_Instance instance); | 61 static PluginInstance* FromPPInstance(PP_Instance instance); |
| 62 | 62 |
| 63 // Returns a pointer to the interface implementing PPB_Find that is | 63 // Returns a pointer to the interface implementing PPB_Find that is |
| 64 // exposed to the plugin. | 64 // exposed to the plugin. |
| 65 static const PPB_Find* GetFindInterface(); | 65 static const PPB_Find_Dev* GetFindInterface(); |
| 66 | 66 |
| 67 PluginDelegate* delegate() const { return delegate_; } | 67 PluginDelegate* delegate() const { return delegate_; } |
| 68 PluginModule* module() const { return module_.get(); } | 68 PluginModule* module() const { return module_.get(); } |
| 69 | 69 |
| 70 WebKit::WebPluginContainer* container() const { return container_; } | 70 WebKit::WebPluginContainer* container() const { return container_; } |
| 71 | 71 |
| 72 const gfx::Rect& position() const { return position_; } | 72 const gfx::Rect& position() const { return position_; } |
| 73 const gfx::Rect& clip() const { return clip_; } | 73 const gfx::Rect& clip() const { return clip_; } |
| 74 | 74 |
| 75 int find_identifier() const { return find_identifier_; } | 75 int find_identifier() const { return find_identifier_; } |
| 76 | 76 |
| 77 PP_Instance GetPPInstance(); | 77 PP_Instance GetPPInstance(); |
| 78 | 78 |
| 79 // Paints the current backing store to the web page. | 79 // Paints the current backing store to the web page. |
| 80 void Paint(WebKit::WebCanvas* canvas, | 80 void Paint(WebKit::WebCanvas* canvas, |
| 81 const gfx::Rect& plugin_rect, | 81 const gfx::Rect& plugin_rect, |
| 82 const gfx::Rect& paint_rect); | 82 const gfx::Rect& paint_rect); |
| 83 | 83 |
| 84 // Schedules a paint of the page for the given region. The coordinates are | 84 // Schedules a paint of the page for the given region. The coordinates are |
| 85 // relative to the top-left of the plugin. This does nothing if the plugin | 85 // relative to the top-left of the plugin. This does nothing if the plugin |
| 86 // has not yet been positioned. You can supply an empty gfx::Rect() to | 86 // has not yet been positioned. You can supply an empty gfx::Rect() to |
| 87 // invalidate the entire plugin. | 87 // invalidate the entire plugin. |
| 88 void InvalidateRect(const gfx::Rect& rect); | 88 void InvalidateRect(const gfx::Rect& rect); |
| 89 | 89 |
| 90 // PPB_Instance implementation. | 90 // PPB_Instance implementation. |
| 91 PP_Var GetWindowObject(); | 91 PP_Var GetWindowObject(); |
| 92 PP_Var GetOwnerElementObject(); | 92 PP_Var GetOwnerElementObject(); |
| 93 bool BindGraphicsDeviceContext(PP_Resource device_id); | 93 bool BindGraphics(PP_Resource device_id); |
| 94 bool full_frame() const { return full_frame_; } | 94 bool full_frame() const { return full_frame_; } |
| 95 bool SetCursor(PP_CursorType_Dev type); | 95 bool SetCursor(PP_CursorType_Dev type); |
| 96 | 96 |
| 97 // PPP_Instance pass-through. | 97 // PPP_Instance pass-through. |
| 98 void Delete(); | 98 void Delete(); |
| 99 bool Initialize(WebKit::WebPluginContainer* container, | 99 bool Initialize(WebKit::WebPluginContainer* container, |
| 100 const std::vector<std::string>& arg_names, | 100 const std::vector<std::string>& arg_names, |
| 101 const std::vector<std::string>& arg_values, | 101 const std::vector<std::string>& arg_values, |
| 102 bool full_frame); | 102 bool full_frame); |
| 103 bool HandleDocumentLoad(URLLoader* loader); | 103 bool HandleDocumentLoad(URLLoader* loader); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 127 | 127 |
| 128 void Graphics3DContextLost(); | 128 void Graphics3DContextLost(); |
| 129 | 129 |
| 130 private: | 130 private: |
| 131 bool LoadFindInterface(); | 131 bool LoadFindInterface(); |
| 132 bool LoadZoomInterface(); | 132 bool LoadZoomInterface(); |
| 133 | 133 |
| 134 // Queries the plugin for supported print formats and sets |format| to the | 134 // Queries the plugin for supported print formats and sets |format| to the |
| 135 // best format to use. Returns false if the plugin does not support any | 135 // best format to use. Returns false if the plugin does not support any |
| 136 // print format that we can handle (we can handle raster and PDF). | 136 // print format that we can handle (we can handle raster and PDF). |
| 137 bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat* format); | 137 bool GetPreferredPrintOutputFormat(PP_PrintOutputFormat_Dev* format); |
| 138 bool PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); | 138 bool PrintPDFOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); |
| 139 bool PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); | 139 bool PrintRasterOutput(PP_Resource print_output, WebKit::WebCanvas* canvas); |
| 140 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
| 141 bool DrawJPEGToPlatformDC(const SkBitmap& bitmap, | 141 bool DrawJPEGToPlatformDC(const SkBitmap& bitmap, |
| 142 const gfx::Rect& printable_area, | 142 const gfx::Rect& printable_area, |
| 143 WebKit::WebCanvas* canvas); | 143 WebKit::WebCanvas* canvas); |
| 144 #elif defined(OS_MACOSX) | 144 #elif defined(OS_MACOSX) |
| 145 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting | 145 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting |
| 146 // at the specified destination rect. | 146 // at the specified destination rect. |
| 147 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas, | 147 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 163 // plugin. This will be a 0-sized rectangle if the plugin has not yet been | 163 // plugin. This will be a 0-sized rectangle if the plugin has not yet been |
| 164 // laid out. | 164 // laid out. |
| 165 gfx::Rect position_; | 165 gfx::Rect position_; |
| 166 | 166 |
| 167 // Current clip rect. This will be empty if the plugin is not currently | 167 // Current clip rect. This will be empty if the plugin is not currently |
| 168 // visible. This is in the plugin's coordinate system, so fully visible will | 168 // visible. This is in the plugin's coordinate system, so fully visible will |
| 169 // be (0, 0, w, h) regardless of scroll position. | 169 // be (0, 0, w, h) regardless of scroll position. |
| 170 gfx::Rect clip_; | 170 gfx::Rect clip_; |
| 171 | 171 |
| 172 // The current device context for painting in 2D. | 172 // The current device context for painting in 2D. |
| 173 scoped_refptr<DeviceContext2D> device_context_2d_; | 173 scoped_refptr<Graphics2D> bound_graphics_2d_; |
| 174 | 174 |
| 175 // The id of the current find operation, or -1 if none is in process. | 175 // The id of the current find operation, or -1 if none is in process. |
| 176 int find_identifier_; | 176 int find_identifier_; |
| 177 | 177 |
| 178 // The plugin find and zoom interfaces. | 178 // The plugin find and zoom interfaces. |
| 179 const PPP_Find* plugin_find_interface_; | 179 const PPP_Find_Dev* plugin_find_interface_; |
| 180 const PPP_Zoom* plugin_zoom_interface_; | 180 const PPP_Zoom_Dev* plugin_zoom_interface_; |
| 181 | 181 |
| 182 // This is only valid between a successful PrintBegin call and a PrintEnd | 182 // This is only valid between a successful PrintBegin call and a PrintEnd |
| 183 // call. | 183 // call. |
| 184 PP_PrintSettings current_print_settings_; | 184 PP_PrintSettings_Dev current_print_settings_; |
| 185 #if defined(OS_MACOSX) | 185 #if defined(OS_MACOSX) |
| 186 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary | 186 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary |
| 187 // to keep the pixels valid until CGContextEndPage is called. We use this | 187 // to keep the pixels valid until CGContextEndPage is called. We use this |
| 188 // variable to hold on to the pixels. | 188 // variable to hold on to the pixels. |
| 189 scoped_refptr<ImageData> last_printed_page_; | 189 scoped_refptr<ImageData> last_printed_page_; |
| 190 #elif defined(OS_LINUX) | 190 #elif defined(OS_LINUX) |
| 191 // On Linux, we always send all pages from the renderer to the browser. | 191 // On Linux, we always send all pages from the renderer to the browser. |
| 192 // So, if the plugin supports printPagesAsPDF we print the entire output | 192 // So, if the plugin supports printPagesAsPDF we print the entire output |
| 193 // in one shot in the first call to PrintPage. | 193 // in one shot in the first call to PrintPage. |
| 194 // (This is a temporary hack until we change the WebFrame and WebPlugin print | 194 // (This is a temporary hack until we change the WebFrame and WebPlugin print |
| 195 // interfaces). | 195 // interfaces). |
| 196 // Specifies the total number of pages to be printed. It it set in PrintBegin. | 196 // Specifies the total number of pages to be printed. It it set in PrintBegin. |
| 197 int32 num_pages_; | 197 int32 num_pages_; |
| 198 // Specifies whether we have already output all pages. This is used to ignore | 198 // Specifies whether we have already output all pages. This is used to ignore |
| 199 // subsequent PrintPage requests. | 199 // subsequent PrintPage requests. |
| 200 bool pdf_output_done_; | 200 bool pdf_output_done_; |
| 201 #endif // defined(OS_LINUX) | 201 #endif // defined(OS_LINUX) |
| 202 | 202 |
| 203 // The plugin print interface. | 203 // The plugin print interface. |
| 204 const PPP_Printing* plugin_print_interface_; | 204 const PPP_Printing_Dev* plugin_print_interface_; |
| 205 | 205 |
| 206 // The plugin 3D interface. | 206 // The plugin 3D interface. |
| 207 const PPP_Graphics3D* plugin_graphics_3d_interface_; | 207 const PPP_Graphics3D_Dev* plugin_graphics_3d_interface_; |
| 208 | 208 |
| 209 // Containes the cursor if it's set by the plugin. | 209 // Containes the cursor if it's set by the plugin. |
| 210 scoped_ptr<WebKit::WebCursorInfo> cursor_; | 210 scoped_ptr<WebKit::WebCursorInfo> cursor_; |
| 211 | 211 |
| 212 DISALLOW_COPY_AND_ASSIGN(PluginInstance); | 212 DISALLOW_COPY_AND_ASSIGN(PluginInstance); |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 } // namespace pepper | 215 } // namespace pepper |
| 216 | 216 |
| 217 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ | 217 #endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_ |
| OLD | NEW |