summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/plugin_messages.h7
-rw-r--r--chrome/plugin/webplugin_delegate_stub.cc3
-rw-r--r--chrome/plugin/webplugin_proxy.cc7
-rw-r--r--chrome/plugin/webplugin_proxy.h4
-rw-r--r--chrome/renderer/webplugin_delegate_proxy.cc28
5 files changed, 37 insertions, 12 deletions
diff --git a/chrome/common/plugin_messages.h b/chrome/common/plugin_messages.h
index bfee6c3..82116d8 100644
--- a/chrome/common/plugin_messages.h
+++ b/chrome/common/plugin_messages.h
@@ -98,6 +98,7 @@ struct PluginMsg_UpdateGeometry_Param {
gfx::Rect clip_rect;
TransportDIB::Handle windowless_buffer;
TransportDIB::Handle background_buffer;
+ bool transparent;
#if defined(OS_MACOSX)
// This field contains a key that the plug-in process is expected to return
@@ -386,6 +387,7 @@ struct ParamTraits<PluginMsg_UpdateGeometry_Param> {
WriteParam(m, p.clip_rect);
WriteParam(m, p.windowless_buffer);
WriteParam(m, p.background_buffer);
+ WriteParam(m, p.transparent);
#if defined(OS_MACOSX)
WriteParam(m, p.ack_key);
#endif
@@ -395,7 +397,8 @@ struct ParamTraits<PluginMsg_UpdateGeometry_Param> {
ReadParam(m, iter, &r->window_rect) &&
ReadParam(m, iter, &r->clip_rect) &&
ReadParam(m, iter, &r->windowless_buffer) &&
- ReadParam(m, iter, &r->background_buffer)
+ ReadParam(m, iter, &r->background_buffer) &&
+ ReadParam(m, iter, &r->transparent)
#if defined(OS_MACOSX)
&&
ReadParam(m, iter, &r->ack_key)
@@ -411,6 +414,8 @@ struct ParamTraits<PluginMsg_UpdateGeometry_Param> {
LogParam(p.windowless_buffer, l);
l->append(L", ");
LogParam(p.background_buffer, l);
+ l->append(L", ");
+ LogParam(p.transparent, l);
#if defined(OS_MACOSX)
l->append(L", ");
LogParam(p.ack_key, l);
diff --git a/chrome/plugin/webplugin_delegate_stub.cc b/chrome/plugin/webplugin_delegate_stub.cc
index dd3f6a0..104c8b9 100644
--- a/chrome/plugin/webplugin_delegate_stub.cc
+++ b/chrome/plugin/webplugin_delegate_stub.cc
@@ -313,7 +313,8 @@ void WebPluginDelegateStub::OnUpdateGeometry(
const PluginMsg_UpdateGeometry_Param& param) {
webplugin_->UpdateGeometry(
param.window_rect, param.clip_rect,
- param.windowless_buffer, param.background_buffer
+ param.windowless_buffer, param.background_buffer,
+ param.transparent
#if defined(OS_MACOSX)
,
param.ack_key
diff --git a/chrome/plugin/webplugin_proxy.cc b/chrome/plugin/webplugin_proxy.cc
index ac04589..2dfc7a2 100644
--- a/chrome/plugin/webplugin_proxy.cc
+++ b/chrome/plugin/webplugin_proxy.cc
@@ -55,6 +55,7 @@ WebPluginProxy::WebPluginProxy(
waiting_for_paint_(false),
containing_window_(containing_window),
page_url_(page_url),
+ transparent_(false),
host_render_view_routing_id_(host_render_view_routing_id),
ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) {
}
@@ -375,7 +376,7 @@ void WebPluginProxy::Paint(const gfx::Rect& rect) {
scoped_cftyperef<CGImageRef> sub_image(
CGImageCreateWithImageInRect(image, source_rect));
CGContextDrawImage(windowless_context_, rect.ToCGRect(), sub_image);
- } else {
+ } else if (transparent_) {
CGContextClearRect(windowless_context_, rect.ToCGRect());
}
CGContextClipToRect(windowless_context_, rect.ToCGRect());
@@ -427,7 +428,8 @@ void WebPluginProxy::UpdateGeometry(
const gfx::Rect& window_rect,
const gfx::Rect& clip_rect,
const TransportDIB::Handle& windowless_buffer,
- const TransportDIB::Handle& background_buffer
+ const TransportDIB::Handle& background_buffer,
+ bool transparent
#if defined(OS_MACOSX)
,
int ack_key
@@ -435,6 +437,7 @@ void WebPluginProxy::UpdateGeometry(
) {
gfx::Rect old = delegate_->GetRect();
gfx::Rect old_clip_rect = delegate_->GetClipRect();
+ transparent_ = transparent;
// Update the buffers before doing anything that could call into plugin code,
// so that we don't process buffer changes out of order if plugins make
diff --git a/chrome/plugin/webplugin_proxy.h b/chrome/plugin/webplugin_proxy.h
index 11cb552..f03de96 100644
--- a/chrome/plugin/webplugin_proxy.h
+++ b/chrome/plugin/webplugin_proxy.h
@@ -117,7 +117,8 @@ class WebPluginProxy : public webkit_glue::WebPlugin {
void UpdateGeometry(const gfx::Rect& window_rect,
const gfx::Rect& clip_rect,
const TransportDIB::Handle& windowless_buffer,
- const TransportDIB::Handle& background_buffer
+ const TransportDIB::Handle& background_buffer,
+ bool transparent
#if defined(OS_MACOSX)
,
int ack_key
@@ -170,6 +171,7 @@ class WebPluginProxy : public webkit_glue::WebPlugin {
// Variables used for desynchronized windowless plugin painting. See note in
// webplugin_delegate_proxy.h for how this works.
+ bool transparent_;
#if defined(OS_MACOSX)
scoped_ptr<TransportDIB> windowless_dib_;
scoped_ptr<TransportDIB> background_dib_;
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc
index e11c848..5049bf4 100644
--- a/chrome/renderer/webplugin_delegate_proxy.cc
+++ b/chrome/renderer/webplugin_delegate_proxy.cc
@@ -533,6 +533,7 @@ void WebPluginDelegateProxy::UpdateGeometry(const gfx::Rect& window_rect,
param.clip_rect = clip_rect;
param.windowless_buffer = TransportDIB::DefaultHandleValue();
param.background_buffer = TransportDIB::DefaultHandleValue();
+ param.transparent = transparent_;
#if defined(OS_POSIX)
// If we're using POSIX mmap'd TransportDIBs, sending the handle across
@@ -1241,15 +1242,28 @@ void WebPluginDelegateProxy::CopyFromTransportToBacking(const gfx::Rect& rect) {
}
// Copy the damaged rect from the transport bitmap to the backing store.
- gfx::Rect dest_rect = rect;
#if defined(OS_MACOSX)
- FlipRectVerticallyWithHeight(&dest_rect, plugin_rect_.height());
- gfx::NativeDrawingContext backing_context =
- backing_store_canvas_.get()->getTopPlatformDevice().GetBitmapContext();
- CGContextClearRect(backing_context, dest_rect.ToCGRect());
-#endif
- BlitCanvasToCanvas(backing_store_canvas_.get(), dest_rect,
+ // Blitting the bits directly is much faster than going through CG, and since
+ // since the goal is just to move the raw pixels between two bitmaps with the
+ // same pixel format (no compositing, color correction, etc.), it's safe.
+ const size_t stride =
+ skia::PlatformCanvas::StrideForWidth(plugin_rect_.width());
+ const size_t chunk_size = 4 * rect.width();
+ char* source_data = static_cast<char*>(transport_store_->memory()) +
+ rect.y() * stride + 4 * rect.x();
+ // The two bitmaps are flipped relative to each other.
+ int dest_starting_row = plugin_rect_.height() - rect.y() - 1;
+ char* target_data = static_cast<char*>(backing_store_->memory()) +
+ dest_starting_row * stride + 4 * rect.x();
+ for (int row = 0; row < rect.height(); ++row) {
+ memcpy(target_data, source_data, chunk_size);
+ source_data += stride;
+ target_data -= stride;
+ }
+#else
+ BlitCanvasToCanvas(backing_store_canvas_.get(), rect,
transport_store_canvas_.get(), rect.origin());
+#endif
backing_store_painted_ = backing_store_painted_.Union(rect);
}