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 CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ | 5 #ifndef CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ |
6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ | 6 #define CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/id_map.h" | 14 #include "base/id_map.h" |
15 #include "base/ref_counted.h" | 15 #include "base/ref_counted.h" |
16 #include "base/weak_ptr.h" | 16 #include "base/weak_ptr.h" |
17 #include "base/task.h" | 17 #include "base/task.h" |
18 #include "chrome/renderer/pepper_devices.h" | 18 #include "chrome/renderer/pepper_devices.h" |
| 19 #include "chrome/renderer/command_buffer_proxy.h" |
19 #include "third_party/npapi/bindings/npapi.h" | 20 #include "third_party/npapi/bindings/npapi.h" |
20 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserComplet
ion.h" |
22 #include "ui/gfx/native_widget_types.h" | 23 #include "ui/gfx/native_widget_types.h" |
23 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
24 #include "webkit/plugins/npapi/webplugin_delegate.h" | 25 #include "webkit/plugins/npapi/webplugin_delegate.h" |
25 | 26 |
26 class FilePath; | 27 class FilePath; |
27 class RenderView; | 28 class RenderView; |
28 class WebCursor; | 29 class WebCursor; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 void RenderViewFlushedPaint(); | 206 void RenderViewFlushedPaint(); |
206 | 207 |
207 Graphics2DDeviceContext* GetGraphicsContext(NPDeviceContext2D* context); | 208 Graphics2DDeviceContext* GetGraphicsContext(NPDeviceContext2D* context); |
208 | 209 |
209 private: | 210 private: |
210 WebPluginDelegatePepper( | 211 WebPluginDelegatePepper( |
211 const base::WeakPtr<RenderView>& render_view, | 212 const base::WeakPtr<RenderView>& render_view, |
212 webkit::npapi::PluginInstance *instance); | 213 webkit::npapi::PluginInstance *instance); |
213 ~WebPluginDelegatePepper(); | 214 ~WebPluginDelegatePepper(); |
214 | 215 |
| 216 // Set a task that calls the repaint callback the next time the window |
| 217 // is invalid and needs to be repainted. |
| 218 void ScheduleHandleRepaint(NPP npp, NPDeviceContext3D* context); |
| 219 |
215 //----------------------------------------- | 220 //----------------------------------------- |
216 // used for windowed and windowless plugins | 221 // used for windowed and windowless plugins |
217 | 222 |
218 // Closes down and destroys our plugin instance. | 223 // Closes down and destroys our plugin instance. |
219 void DestroyInstance(); | 224 void DestroyInstance(); |
220 | 225 |
221 void ForwardSetWindow(); | 226 void ForwardSetWindow(); |
222 | 227 |
223 // A helper method that invokes the plugin's Print extensions to calculate | 228 // A helper method that invokes the plugin's Print extensions to calculate |
224 // the size needed in pixels to render the given page in a raster format. | 229 // the size needed in pixels to render the given page in a raster format. |
(...skipping 13 matching lines...) Expand all Loading... |
238 const gfx::Rect& printable_area, | 243 const gfx::Rect& printable_area, |
239 WebKit::WebCanvas* canvas); | 244 WebKit::WebCanvas* canvas); |
240 #endif // OS_WIN | 245 #endif // OS_WIN |
241 #if defined(OS_MACOSX) | 246 #if defined(OS_MACOSX) |
242 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting | 247 // Draws the given kARGB_8888_Config bitmap to the specified canvas starting |
243 // at the specified destination rect. | 248 // at the specified destination rect. |
244 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas, | 249 void DrawSkBitmapToCanvas(const SkBitmap& bitmap, WebKit::WebCanvas* canvas, |
245 const gfx::Rect& dest_rect, int canvas_height); | 250 const gfx::Rect& dest_rect, int canvas_height); |
246 #endif // OS_MACOSX | 251 #endif // OS_MACOSX |
247 | 252 |
| 253 #if defined(ENABLE_GPU) |
| 254 |
| 255 void ForwardHandleRepaint(NPP npp, NPDeviceContext3D* context); |
| 256 |
| 257 // Synchronize a 3D context state with the service. |
| 258 void Synchronize3DContext(NPDeviceContext3D* context, |
| 259 const gpu::CommandBuffer::State& state); |
| 260 |
| 261 // Synchronize the 3D context state with the proxy and invoke the async |
| 262 // flush callback. |
| 263 void Device3DUpdateState(NPP npp, |
| 264 NPDeviceContext3D* context, |
| 265 NPDeviceFlushContextCallbackPtr callback, |
| 266 void* user_data); |
| 267 #endif |
| 268 |
| 269 // Tells the browser out-of-band where the nested delegate lives on |
| 270 // the page. |
| 271 void SendNestedDelegateGeometryToBrowser(const gfx::Rect& window_rect, |
| 272 const gfx::Rect& clip_rect); |
| 273 |
248 // Returns the selection. If nothing is selected, returns an empty string. | 274 // Returns the selection. If nothing is selected, returns an empty string. |
249 // If html is true, it will return a string only if html data is available. | 275 // If html is true, it will return a string only if html data is available. |
250 string16 GetSelectedText(bool html) const; | 276 string16 GetSelectedText(bool html) const; |
251 | 277 |
252 base::WeakPtr<RenderView> render_view_; | 278 base::WeakPtr<RenderView> render_view_; |
253 | 279 |
254 webkit::npapi::WebPlugin* plugin_; | 280 webkit::npapi::WebPlugin* plugin_; |
255 scoped_refptr<webkit::npapi::PluginInstance> instance_; | 281 scoped_refptr<webkit::npapi::PluginInstance> instance_; |
256 | 282 |
257 NPWindow window_; | 283 NPWindow window_; |
258 gfx::Rect window_rect_; | 284 gfx::Rect window_rect_; |
259 gfx::Rect clip_rect_; | 285 gfx::Rect clip_rect_; |
260 std::vector<gfx::Rect> cutout_rects_; | 286 std::vector<gfx::Rect> cutout_rects_; |
261 | 287 |
262 // Open device contexts | 288 // Open device contexts |
263 typedef IDMap<Graphics2DDeviceContext, IDMapOwnPointer> Graphics2DMap; | 289 typedef IDMap<Graphics2DDeviceContext, IDMapOwnPointer> Graphics2DMap; |
264 Graphics2DMap graphic2d_contexts_; | 290 Graphics2DMap graphic2d_contexts_; |
265 IDMap<AudioDeviceContext, IDMapOwnPointer> audio_contexts_; | 291 IDMap<AudioDeviceContext, IDMapOwnPointer> audio_contexts_; |
266 | 292 |
267 // Plugin graphics context implementation | 293 // Plugin graphics context implementation |
268 SkBitmap committed_bitmap_; | 294 SkBitmap committed_bitmap_; |
269 | 295 |
270 // The url with which the plugin was instantiated. | 296 // The url with which the plugin was instantiated. |
271 std::string plugin_url_; | 297 std::string plugin_url_; |
272 | 298 |
| 299 // The nested GPU plugin. |
| 300 WebPluginDelegateProxy* nested_delegate_; |
| 301 |
273 // The last printable_area passed in to PrintBegin. We remember this because | 302 // The last printable_area passed in to PrintBegin. We remember this because |
274 // we need to stretch the printed raster bitmap to these dimensions. It is | 303 // we need to stretch the printed raster bitmap to these dimensions. It is |
275 // cleared in PrintEnd. | 304 // cleared in PrintEnd. |
276 gfx::Rect current_printable_area_; | 305 gfx::Rect current_printable_area_; |
277 int current_printer_dpi_; | 306 int current_printer_dpi_; |
278 #if defined(OS_MACOSX) | 307 #if defined(OS_MACOSX) |
279 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary | 308 // On the Mac, when we draw the bitmap to the PDFContext, it seems necessary |
280 // to keep the pixels valid until CGContextEndPage is called. We use this | 309 // to keep the pixels valid until CGContextEndPage is called. We use this |
281 // variable to hold on to the pixels. | 310 // variable to hold on to the pixels. |
282 SkBitmap last_printed_page_; | 311 SkBitmap last_printed_page_; |
283 #endif // defined(OS_MACOSX) | 312 #endif // defined(OS_MACOSX) |
284 #if defined (OS_LINUX) | 313 #if defined (OS_LINUX) |
285 // On Linux, we always send all pages from the renderer to the browser. | 314 // On Linux, we always send all pages from the renderer to the browser. |
286 // So, if the plugin supports printPagesAsPDF we print the entire output | 315 // So, if the plugin supports printPagesAsPDF we print the entire output |
287 // in one shot in the first call to PrintPage. | 316 // in one shot in the first call to PrintPage. |
288 // (This is a temporary hack until we change the WebFrame and WebPlugin print | 317 // (This is a temporary hack until we change the WebFrame and WebPlugin print |
289 // interfaces). | 318 // interfaces). |
290 // Specifies the total number of pages to be printed. It it set in PrintBegin. | 319 // Specifies the total number of pages to be printed. It it set in PrintBegin. |
291 int32 num_pages_; | 320 int32 num_pages_; |
292 // Specifies whether we have already output all pages. This is used to ignore | 321 // Specifies whether we have already output all pages. This is used to ignore |
293 // subsequent PrintPage requests. | 322 // subsequent PrintPage requests. |
294 bool pdf_output_done_; | 323 bool pdf_output_done_; |
295 #endif // defined(OS_LINUX) | 324 #endif // defined(OS_LINUX) |
296 | 325 |
| 326 #if defined(ENABLE_GPU) |
| 327 // The command buffer used to issue commands to the nested GPU plugin. |
| 328 CommandBufferProxy* command_buffer_; |
| 329 |
| 330 // Runnable methods that must be cancelled when the 3D context is destroyed. |
| 331 ScopedRunnableMethodFactory<WebPluginDelegatePepper> method_factory3d_; |
| 332 #endif |
| 333 |
297 // The id of the current find operation, or -1 if none is in process. | 334 // The id of the current find operation, or -1 if none is in process. |
298 int find_identifier_; | 335 int find_identifier_; |
299 | 336 |
300 // When a choose file operation is outstanding, this will contain a | 337 // When a choose file operation is outstanding, this will contain a |
301 // pointer to the callback specified by the plugin. Will be NULL otherwise. | 338 // pointer to the callback specified by the plugin. Will be NULL otherwise. |
302 NPChooseFileCallback current_choose_file_callback_; | 339 NPChooseFileCallback current_choose_file_callback_; |
303 void* current_choose_file_user_data_; | 340 void* current_choose_file_user_data_; |
304 | 341 |
305 scoped_ptr<WebKit::WebCursorInfo> cursor_; | 342 scoped_ptr<WebKit::WebCursorInfo> cursor_; |
306 | 343 |
307 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepper); | 344 DISALLOW_COPY_AND_ASSIGN(WebPluginDelegatePepper); |
308 }; | 345 }; |
309 | 346 |
310 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ | 347 #endif // CHROME_RENDERER_WEBPLUGIN_DELEGATE_PEPPER_H_ |
OLD | NEW |