Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: webkit/glue/plugins/webplugin_delegate_impl_gtk.cc

Issue 159190: Refactor blits (Closed)
Patch Set: remove ScopedNativeDrawingContext Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/webplugin_delegate_proxy.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/webplugin_delegate_impl.h" 5 #include "webkit/glue/plugins/webplugin_delegate_impl.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include <gtk/gtk.h> 10 #include <gtk/gtk.h>
11 #include <gdk/gdkx.h> 11 #include <gdk/gdkx.h>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/gfx/blit.h"
15 #include "base/message_loop.h" 16 #include "base/message_loop.h"
16 #include "base/process_util.h" 17 #include "base/process_util.h"
17 #include "base/stats_counters.h" 18 #include "base/stats_counters.h"
18 #include "base/string_util.h" 19 #include "base/string_util.h"
19 #include "webkit/api/public/WebCursorInfo.h" 20 #include "webkit/api/public/WebCursorInfo.h"
20 #include "webkit/api/public/WebInputEvent.h" 21 #include "webkit/api/public/WebInputEvent.h"
21 // #include "webkit/default_plugin/plugin_impl.h" 22 // #include "webkit/default_plugin/plugin_impl.h"
22 #include "webkit/glue/glue_util.h" 23 #include "webkit/glue/glue_util.h"
23 #include "webkit/glue/webplugin.h" 24 #include "webkit/glue/webplugin.h"
24 #include "webkit/glue/plugins/gtk_plugin_container.h" 25 #include "webkit/glue/plugins/gtk_plugin_container.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 window_.height = window_rect_.height(); 510 window_.height = window_rect_.height();
510 window_.width = window_rect_.width(); 511 window_.width = window_rect_.width();
511 window_.x = window_rect_.x() - draw_rect.x(); 512 window_.x = window_rect_.x() - draw_rect.x();
512 window_.y = window_rect_.y() - draw_rect.y(); 513 window_.y = window_rect_.y() - draw_rect.y();
513 window_.type = NPWindowTypeDrawable; 514 window_.type = NPWindowTypeDrawable;
514 DCHECK(window_.ws_info); 515 DCHECK(window_.ws_info);
515 NPError err = instance()->NPP_SetWindow(&window_); 516 NPError err = instance()->NPP_SetWindow(&window_);
516 DCHECK_EQ(err, NPERR_NO_ERROR); 517 DCHECK_EQ(err, NPERR_NO_ERROR);
517 } 518 }
518 519
520 gfx::Rect pixmap_draw_rect = draw_rect;
521 pixmap_draw_rect.Offset(offset_x, offset_y);
522
519 gfx::Rect pixmap_rect(0, 0, 523 gfx::Rect pixmap_rect(0, 0,
520 draw_rect.x() + offset_x + draw_rect.width(), 524 pixmap_draw_rect.right(),
521 draw_rect.y() + offset_y + draw_rect.height()); 525 pixmap_draw_rect.bottom());
522 526
523 EnsurePixmapAtLeastSize(pixmap_rect.width(), pixmap_rect.height()); 527 EnsurePixmapAtLeastSize(pixmap_rect.width(), pixmap_rect.height());
524 528
525 // Copy the current image into the pixmap, so the plugin can draw over 529 // Copy the current image into the pixmap, so the plugin can draw over
526 // this background. 530 // this background.
527 cairo_t* cairo = gdk_cairo_create(pixmap_); 531 cairo_t* cairo = gdk_cairo_create(pixmap_);
528 double surface_x = -offset_x; 532 BlitContextToContext(cairo, pixmap_draw_rect, context, draw_rect.origin());
529 double surface_y = -offset_y;
530 cairo_user_to_device(context, &surface_x, &surface_y);
531 cairo_set_source_surface(cairo, cairo_get_target(context),
532 -surface_x, -surface_y);
533 cairo_rectangle(cairo, draw_rect.x() + offset_x, draw_rect.y() + offset_y,
534 draw_rect.width(), draw_rect.height());
535 cairo_clip(cairo);
536 cairo_paint(cairo);
537 cairo_destroy(cairo); 533 cairo_destroy(cairo);
538 534
539 // Construct the paint message, targeting the pixmap. 535 // Construct the paint message, targeting the pixmap.
540 NPEvent np_event = {0}; 536 NPEvent np_event = {0};
541 XGraphicsExposeEvent &event = np_event.xgraphicsexpose; 537 XGraphicsExposeEvent &event = np_event.xgraphicsexpose;
542 event.type = GraphicsExpose; 538 event.type = GraphicsExpose;
543 event.display = GDK_DISPLAY(); 539 event.display = GDK_DISPLAY();
544 event.drawable = GDK_PIXMAP_XID(pixmap_); 540 event.drawable = GDK_PIXMAP_XID(pixmap_);
545 event.x = draw_rect.x() + offset_x; 541 event.x = pixmap_draw_rect.x();
546 event.y = draw_rect.y() + offset_y; 542 event.y = pixmap_draw_rect.y();
547 event.width = draw_rect.width(); 543 event.width = pixmap_draw_rect.width();
548 event.height = draw_rect.height(); 544 event.height = pixmap_draw_rect.height();
549 545
550 // Tell the plugin to paint into the pixmap. 546 // Tell the plugin to paint into the pixmap.
551 static StatsRate plugin_paint("Plugin.Paint"); 547 static StatsRate plugin_paint("Plugin.Paint");
552 StatsScope<StatsRate> scope(plugin_paint); 548 StatsScope<StatsRate> scope(plugin_paint);
553 NPError err = instance()->NPP_HandleEvent(&np_event); 549 NPError err = instance()->NPP_HandleEvent(&np_event);
554 DCHECK_EQ(err, NPERR_NO_ERROR); 550 DCHECK_EQ(err, NPERR_NO_ERROR);
555 551
556 cairo_save(context); 552 cairo_save(context);
557 // Now copy the rendered image pixmap back into the drawing buffer. 553 // Now copy the rendered image pixmap back into the drawing buffer.
558 gdk_cairo_set_source_pixmap(context, pixmap_, -offset_x, -offset_y); 554 gdk_cairo_set_source_pixmap(context, pixmap_, -offset_x, -offset_y);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 return stream; 844 return stream;
849 } 845 }
850 846
851 void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, 847 void WebPluginDelegateImpl::URLRequestRouted(const std::string&url,
852 bool notify_needed, 848 bool notify_needed,
853 intptr_t notify_data) { 849 intptr_t notify_data) {
854 if (notify_needed) { 850 if (notify_needed) {
855 instance()->SetURLLoadData(GURL(url.c_str()), notify_data); 851 instance()->SetURLLoadData(GURL(url.c_str()), notify_data);
856 } 852 }
857 } 853 }
OLDNEW
« no previous file with comments | « chrome/renderer/webplugin_delegate_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698