OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/plugin/webplugin_proxy.h" | 5 #include "chrome/plugin/webplugin_proxy.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include "app/win_util.h" | 10 #include "app/win_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/plugin/plugin_thread.h" | 25 #include "chrome/plugin/plugin_thread.h" |
26 #include "gfx/blit.h" | 26 #include "gfx/blit.h" |
27 #include "gfx/canvas.h" | 27 #include "gfx/canvas.h" |
28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 #include "gfx/gdi_util.h" | 29 #include "gfx/gdi_util.h" |
30 #endif | 30 #endif |
31 #include "skia/ext/platform_device.h" | 31 #include "skia/ext/platform_device.h" |
32 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" | 32 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" |
33 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 33 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
34 | 34 |
| 35 #if defined(USE_X11) |
| 36 #include "app/x11_util_internal.h" |
| 37 #endif |
| 38 |
35 using WebKit::WebBindings; | 39 using WebKit::WebBindings; |
36 using webkit_glue::WebPluginResourceClient; | 40 using webkit_glue::WebPluginResourceClient; |
37 | 41 |
38 typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap; | 42 typedef std::map<CPBrowsingContext, WebPluginProxy*> ContextMap; |
39 static ContextMap& GetContextMap() { | 43 static ContextMap& GetContextMap() { |
40 return *Singleton<ContextMap>::get(); | 44 return *Singleton<ContextMap>::get(); |
41 } | 45 } |
42 | 46 |
43 WebPluginProxy::WebPluginProxy( | 47 WebPluginProxy::WebPluginProxy( |
44 PluginChannel* channel, | 48 PluginChannel* channel, |
45 int route_id, | 49 int route_id, |
46 const GURL& page_url, | 50 const GURL& page_url, |
47 gfx::NativeViewId containing_window, | 51 gfx::NativeViewId containing_window, |
48 int host_render_view_routing_id) | 52 int host_render_view_routing_id) |
49 : channel_(channel), | 53 : channel_(channel), |
50 route_id_(route_id), | 54 route_id_(route_id), |
51 cp_browsing_context_(0), | 55 cp_browsing_context_(0), |
52 window_npobject_(NULL), | 56 window_npobject_(NULL), |
53 plugin_element_(NULL), | 57 plugin_element_(NULL), |
54 delegate_(NULL), | 58 delegate_(NULL), |
55 waiting_for_paint_(false), | 59 waiting_for_paint_(false), |
56 containing_window_(containing_window), | 60 containing_window_(containing_window), |
57 page_url_(page_url), | 61 page_url_(page_url), |
58 transparent_(false), | 62 transparent_(false), |
59 host_render_view_routing_id_(host_render_view_routing_id), | 63 host_render_view_routing_id_(host_render_view_routing_id), |
60 ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) { | 64 ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) { |
| 65 #if defined(USE_X11) |
| 66 windowless_shm_pixmap_ = None; |
| 67 use_shm_pixmap_ = false; |
| 68 |
| 69 // If the X server supports SHM pixmaps |
| 70 // and the color depth and masks match, |
| 71 // then consider using SHM pixmaps for windowless plugin painting. |
| 72 Display* display = x11_util::GetXDisplay(); |
| 73 if (x11_util::QuerySharedMemorySupport(display) == |
| 74 x11_util::SHARED_MEMORY_PIXMAP && |
| 75 x11_util::BitsPerPixelForPixmapDepth( |
| 76 display, DefaultDepth(display, 0)) == 32) { |
| 77 Visual* vis = DefaultVisual(display, 0); |
| 78 |
| 79 if (vis->red_mask == 0xff0000 && |
| 80 vis->green_mask == 0xff00 && |
| 81 vis->blue_mask == 0xff) |
| 82 use_shm_pixmap_ = true; |
| 83 } |
| 84 #endif |
61 } | 85 } |
62 | 86 |
63 WebPluginProxy::~WebPluginProxy() { | 87 WebPluginProxy::~WebPluginProxy() { |
64 if (cp_browsing_context_) | 88 if (cp_browsing_context_) |
65 GetContextMap().erase(cp_browsing_context_); | 89 GetContextMap().erase(cp_browsing_context_); |
| 90 |
| 91 #if defined(USE_X11) |
| 92 if (windowless_shm_pixmap_ != None) |
| 93 XFreePixmap(x11_util::GetXDisplay(), windowless_shm_pixmap_); |
| 94 #endif |
66 } | 95 } |
67 | 96 |
68 bool WebPluginProxy::Send(IPC::Message* msg) { | 97 bool WebPluginProxy::Send(IPC::Message* msg) { |
69 return channel_->Send(msg); | 98 return channel_->Send(msg); |
70 } | 99 } |
71 | 100 |
72 void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) { | 101 void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) { |
73 Send(new PluginHostMsg_SetWindow(route_id_, window)); | 102 Send(new PluginHostMsg_SetWindow(route_id_, window)); |
74 } | 103 } |
75 | 104 |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 // This can happen if the renderer has already destroyed the TransportDIB | 589 // This can happen if the renderer has already destroyed the TransportDIB |
561 // by the time we receive the handle, e.g. in case of multiple resizes. | 590 // by the time we receive the handle, e.g. in case of multiple resizes. |
562 windowless_canvas_.reset(); | 591 windowless_canvas_.reset(); |
563 } | 592 } |
564 background_dib_.reset(TransportDIB::Map(background_buffer)); | 593 background_dib_.reset(TransportDIB::Map(background_buffer)); |
565 if (background_dib_.get()) { | 594 if (background_dib_.get()) { |
566 background_canvas_.reset(background_dib_->GetPlatformCanvas(width, height)); | 595 background_canvas_.reset(background_dib_->GetPlatformCanvas(width, height)); |
567 } else { | 596 } else { |
568 background_canvas_.reset(); | 597 background_canvas_.reset(); |
569 } | 598 } |
| 599 |
| 600 // If SHM pixmaps support is available, create a SHM pixmap and |
| 601 // pass it to the delegate for windowless plugin painting. |
| 602 if (delegate_->IsWindowless() && use_shm_pixmap_ && windowless_dib_.get()) { |
| 603 Display* display = x11_util::GetXDisplay(); |
| 604 XID root_window = x11_util::GetX11RootWindow(); |
| 605 XShmSegmentInfo shminfo = {0}; |
| 606 |
| 607 if (windowless_shm_pixmap_ != None) |
| 608 XFreePixmap(display, windowless_shm_pixmap_); |
| 609 |
| 610 shminfo.shmseg = windowless_dib_->MapToX(display); |
| 611 // Create a shared memory pixmap based on the image buffer. |
| 612 windowless_shm_pixmap_ = XShmCreatePixmap(display, root_window, |
| 613 NULL, &shminfo, |
| 614 width, height, |
| 615 DefaultDepth(display, 0)); |
| 616 |
| 617 delegate_->SetWindowlessShmPixmap(windowless_shm_pixmap_); |
| 618 } |
570 } | 619 } |
571 | 620 |
572 #endif | 621 #endif |
573 | 622 |
574 void WebPluginProxy::CancelDocumentLoad() { | 623 void WebPluginProxy::CancelDocumentLoad() { |
575 Send(new PluginHostMsg_CancelDocumentLoad(route_id_)); | 624 Send(new PluginHostMsg_CancelDocumentLoad(route_id_)); |
576 } | 625 } |
577 | 626 |
578 void WebPluginProxy::InitiateHTTPRangeRequest( | 627 void WebPluginProxy::InitiateHTTPRangeRequest( |
579 const char* url, const char* range_info, int range_request_id) { | 628 const char* url, const char* range_info, int range_request_id) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 while (index != resource_clients_.end()) { | 671 while (index != resource_clients_.end()) { |
623 WebPluginResourceClient* client = (*index).second; | 672 WebPluginResourceClient* client = (*index).second; |
624 | 673 |
625 if (client == resource_client) { | 674 if (client == resource_client) { |
626 resource_clients_.erase(index++); | 675 resource_clients_.erase(index++); |
627 } else { | 676 } else { |
628 index++; | 677 index++; |
629 } | 678 } |
630 } | 679 } |
631 } | 680 } |
OLD | NEW |