| OLD | NEW |
| 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> |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 void WebPluginDelegateImpl::UpdateGeometry( | 167 void WebPluginDelegateImpl::UpdateGeometry( |
| 168 const gfx::Rect& window_rect, | 168 const gfx::Rect& window_rect, |
| 169 const gfx::Rect& clip_rect) { | 169 const gfx::Rect& clip_rect) { |
| 170 if (windowless_) { | 170 if (windowless_) { |
| 171 WindowlessUpdateGeometry(window_rect, clip_rect); | 171 WindowlessUpdateGeometry(window_rect, clip_rect); |
| 172 } else { | 172 } else { |
| 173 WindowedUpdateGeometry(window_rect, clip_rect); | 173 WindowedUpdateGeometry(window_rect, clip_rect); |
| 174 } | 174 } |
| 175 } | 175 } |
| 176 | 176 |
| 177 void WebPluginDelegateImpl::Paint(cairo_surface_t* context, | 177 void WebPluginDelegateImpl::Paint(cairo_t* context, |
| 178 const gfx::Rect& rect) { | 178 const gfx::Rect& rect) { |
| 179 if (windowless_) | 179 if (windowless_) |
| 180 WindowlessPaint(context, rect); | 180 WindowlessPaint(context, rect); |
| 181 } | 181 } |
| 182 | 182 |
| 183 void WebPluginDelegateImpl::Print(cairo_surface_t* context) { | 183 void WebPluginDelegateImpl::Print(cairo_t* context) { |
| 184 NOTIMPLEMENTED(); | 184 NOTIMPLEMENTED(); |
| 185 } | 185 } |
| 186 | 186 |
| 187 NPObject* WebPluginDelegateImpl::GetPluginScriptableObject() { | 187 NPObject* WebPluginDelegateImpl::GetPluginScriptableObject() { |
| 188 return instance_->GetPluginScriptableObject(); | 188 return instance_->GetPluginScriptableObject(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 void WebPluginDelegateImpl::DidFinishLoadWithReason(NPReason reason) { | 191 void WebPluginDelegateImpl::DidFinishLoadWithReason(NPReason reason) { |
| 192 instance()->DidFinishLoadWithReason(reason); | 192 instance()->DidFinishLoadWithReason(reason); |
| 193 } | 193 } |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 cairo_set_source_rgba(cairo, r, g, b, 0.5); | 392 cairo_set_source_rgba(cairo, r, g, b, 0.5); |
| 393 cairo_rectangle(cairo, rect.x(), rect.y(), | 393 cairo_rectangle(cairo, rect.x(), rect.y(), |
| 394 rect.width(), rect.height()); | 394 rect.width(), rect.height()); |
| 395 cairo_stroke(cairo); | 395 cairo_stroke(cairo); |
| 396 cairo_destroy(cairo); | 396 cairo_destroy(cairo); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace | 399 } // namespace |
| 400 #endif | 400 #endif |
| 401 | 401 |
| 402 void WebPluginDelegateImpl::WindowlessPaint(cairo_surface_t* context, | 402 void WebPluginDelegateImpl::WindowlessPaint(cairo_t* context, |
| 403 const gfx::Rect& damage_rect) { | 403 const gfx::Rect& damage_rect) { |
| 404 // Compare to: | 404 // Compare to: |
| 405 // http://mxr.mozilla.org/firefox/source/layout/generic/nsObjectFrame.cpp: | 405 // http://mxr.mozilla.org/firefox/source/layout/generic/nsObjectFrame.cpp: |
| 406 // nsPluginInstanceOwner::Renderer::NativeDraw(). | 406 // nsPluginInstanceOwner::Renderer::NativeDraw(). |
| 407 | 407 |
| 408 DCHECK(context); | 408 DCHECK(context); |
| 409 | 409 |
| 410 // TODO(darin): we should avoid calling NPP_SetWindow here since it may | 410 // TODO(darin): we should avoid calling NPP_SetWindow here since it may |
| 411 // cause page layout to be invalidated. | 411 // cause page layout to be invalidated. |
| 412 | 412 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 519 |
| 520 gfx::Rect pixmap_rect(0, 0, | 520 gfx::Rect pixmap_rect(0, 0, |
| 521 draw_rect.x() + offset_x + draw_rect.width(), | 521 draw_rect.x() + offset_x + draw_rect.width(), |
| 522 draw_rect.y() + offset_y + draw_rect.height()); | 522 draw_rect.y() + offset_y + draw_rect.height()); |
| 523 | 523 |
| 524 EnsurePixmapAtLeastSize(pixmap_rect.width(), pixmap_rect.height()); | 524 EnsurePixmapAtLeastSize(pixmap_rect.width(), pixmap_rect.height()); |
| 525 | 525 |
| 526 // Copy the current image into the pixmap, so the plugin can draw over | 526 // Copy the current image into the pixmap, so the plugin can draw over |
| 527 // this background. | 527 // this background. |
| 528 cairo_t* cairo = gdk_cairo_create(pixmap_); | 528 cairo_t* cairo = gdk_cairo_create(pixmap_); |
| 529 cairo_set_source_surface(cairo, context, offset_x, offset_y); | 529 cairo_set_source_surface(cairo, cairo_get_target(context), |
| 530 offset_x, offset_y); |
| 530 cairo_rectangle(cairo, draw_rect.x() + offset_x, draw_rect.y() + offset_y, | 531 cairo_rectangle(cairo, draw_rect.x() + offset_x, draw_rect.y() + offset_y, |
| 531 draw_rect.width(), draw_rect.height()); | 532 draw_rect.width(), draw_rect.height()); |
| 532 cairo_clip(cairo); | 533 cairo_clip(cairo); |
| 533 cairo_paint(cairo); | 534 cairo_paint(cairo); |
| 534 cairo_destroy(cairo); | 535 cairo_destroy(cairo); |
| 535 | 536 |
| 536 // Construct the paint message, targeting the pixmap. | 537 // Construct the paint message, targeting the pixmap. |
| 537 NPEvent np_event = {0}; | 538 NPEvent np_event = {0}; |
| 538 XGraphicsExposeEvent &event = np_event.xgraphicsexpose; | 539 XGraphicsExposeEvent &event = np_event.xgraphicsexpose; |
| 539 event.type = GraphicsExpose; | 540 event.type = GraphicsExpose; |
| 540 event.display = GDK_DISPLAY(); | 541 event.display = GDK_DISPLAY(); |
| 541 event.drawable = GDK_PIXMAP_XID(pixmap_); | 542 event.drawable = GDK_PIXMAP_XID(pixmap_); |
| 542 event.x = draw_rect.x() + offset_x; | 543 event.x = draw_rect.x() + offset_x; |
| 543 event.y = draw_rect.y() + offset_y; | 544 event.y = draw_rect.y() + offset_y; |
| 544 event.width = draw_rect.width(); | 545 event.width = draw_rect.width(); |
| 545 event.height = draw_rect.height(); | 546 event.height = draw_rect.height(); |
| 546 | 547 |
| 547 // Tell the plugin to paint into the pixmap. | 548 // Tell the plugin to paint into the pixmap. |
| 548 static StatsRate plugin_paint("Plugin.Paint"); | 549 static StatsRate plugin_paint("Plugin.Paint"); |
| 549 StatsScope<StatsRate> scope(plugin_paint); | 550 StatsScope<StatsRate> scope(plugin_paint); |
| 550 NPError err = instance()->NPP_HandleEvent(&np_event); | 551 NPError err = instance()->NPP_HandleEvent(&np_event); |
| 551 DCHECK_EQ(err, NPERR_NO_ERROR); | 552 DCHECK_EQ(err, NPERR_NO_ERROR); |
| 552 | 553 |
| 553 // Now copy the rendered image pixmap back into the drawing buffer. | 554 // Now copy the rendered image pixmap back into the drawing buffer. |
| 554 cairo = cairo_create(context); | 555 gdk_cairo_set_source_pixmap(context, pixmap_, -offset_x, -offset_y); |
| 555 gdk_cairo_set_source_pixmap(cairo, pixmap_, -offset_x, -offset_y); | 556 cairo_rectangle(context, draw_rect.x(), draw_rect.y(), |
| 556 cairo_rectangle(cairo, draw_rect.x(), draw_rect.y(), | |
| 557 draw_rect.width(), draw_rect.height()); | 557 draw_rect.width(), draw_rect.height()); |
| 558 cairo_clip(cairo); | 558 cairo_clip(context); |
| 559 cairo_paint(cairo); | 559 cairo_paint(context); |
| 560 cairo_destroy(cairo); | 560 cairo_destroy(context); |
| 561 | 561 |
| 562 #ifdef DEBUG_RECTANGLES | 562 #ifdef DEBUG_RECTANGLES |
| 563 // Draw some debugging rectangles. | 563 // Draw some debugging rectangles. |
| 564 // Pixmap rect = blue. | 564 // Pixmap rect = blue. |
| 565 DrawDebugRectangle(context, pixmap_rect, 0, 0, 1); | 565 DrawDebugRectangle(context, pixmap_rect, 0, 0, 1); |
| 566 // Drawing rect = red. | 566 // Drawing rect = red. |
| 567 DrawDebugRectangle(context, draw_rect, 1, 0, 0); | 567 DrawDebugRectangle(context, draw_rect, 1, 0, 0); |
| 568 #endif | 568 #endif |
| 569 } | 569 } |
| 570 | 570 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 return stream; | 845 return stream; |
| 846 } | 846 } |
| 847 | 847 |
| 848 void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, | 848 void WebPluginDelegateImpl::URLRequestRouted(const std::string&url, |
| 849 bool notify_needed, | 849 bool notify_needed, |
| 850 intptr_t notify_data) { | 850 intptr_t notify_data) { |
| 851 if (notify_needed) { | 851 if (notify_needed) { |
| 852 instance()->SetURLLoadData(GURL(url.c_str()), notify_data); | 852 instance()->SetURLLoadData(GURL(url.c_str()), notify_data); |
| 853 } | 853 } |
| 854 } | 854 } |
| OLD | NEW |