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

Unified Diff: webkit/plugins/npapi/webplugin_delegate_impl_mac.mm

Issue 7746009: [Mac] Support windowless Flash plugin rendering directly to the context for single-process apps (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: webkit/plugins/npapi/webplugin_delegate_impl_mac.mm
===================================================================
--- webkit/plugins/npapi/webplugin_delegate_impl_mac.mm (revision 98412)
+++ webkit/plugins/npapi/webplugin_delegate_impl_mac.mm (working copy)
@@ -262,6 +262,7 @@
instance_(instance),
parent_(containing_view),
quirks_(0),
+ use_buffer_context_(true),
buffer_context_(NULL),
layer_(nil),
surface_(NULL),
@@ -692,18 +693,24 @@
const gfx::Rect& damage_rect) {
// If we get a paint event before we are completely set up (e.g., a nested
// call while the plugin is still in NPP_SetWindow), bail.
- if (!have_called_set_window_ || !buffer_context_)
+ if (!have_called_set_window_ || (use_buffer_context_ && !buffer_context_))
return;
- DCHECK(buffer_context_ == context);
+ DCHECK(!use_buffer_context_ || buffer_context_ == context);
static base::StatsRate plugin_paint("Plugin.Paint");
base::StatsScope<base::StatsRate> scope(plugin_paint);
- // Plugin invalidates trigger asynchronous paints with the original
- // invalidation rect; the plugin may be resized before the paint is handled,
- // so we need to ensure that the damage rect is still sane.
- const gfx::Rect paint_rect(damage_rect.Intersect(
- gfx::Rect(0, 0, window_rect_.width(), window_rect_.height())));
+ gfx::Rect paint_rect;
+ if (use_buffer_context_) {
+ // Plugin invalidates trigger asynchronous paints with the original
+ // invalidation rect; the plugin may be resized before the paint is handled,
+ // so we need to ensure that the damage rect is still sane.
+ paint_rect = damage_rect.Intersect(
+ gfx::Rect(0, 0, window_rect_.width(), window_rect_.height()));
+ } else {
+ // Use the actual window region when drawing directly to the window context.
+ paint_rect = damage_rect.Intersect(window_rect_);
+ }
ScopedActiveDelegate active_delegate(this);
@@ -714,6 +721,13 @@
CGContextSaveGState(context);
+ if (!use_buffer_context_) {
+ // Reposition the context origin so that plugins will draw at the correct
+ // location in the window.
+ CGContextClipToRect(context, paint_rect.ToCGRect());
+ CGContextTranslateCTM(context, window_rect_.x(), window_rect_.y());
+ }
+
switch (instance()->event_model()) {
#ifndef NP_NO_CARBON
case NPEventModelCarbon: {
@@ -739,10 +753,15 @@
}
}
- // The backing buffer can change during the call to NPP_HandleEvent, in which
- // case the old context is (or is about to be) invalid.
- if (context == buffer_context_)
+ if (use_buffer_context_) {
+ // The backing buffer can change during the call to NPP_HandleEvent, in
+ // which case the old context is (or is about to be) invalid.
+ if (context == buffer_context_)
+ CGContextRestoreGState(context);
+ } else {
+ // Always restore the context to the saved state.
CGContextRestoreGState(context);
+ }
}
void WebPluginDelegateImpl::WindowlessSetWindow() {
@@ -1115,6 +1134,10 @@
plugin_visible);
}
+void WebPluginDelegateImpl::SetNoBufferContext() {
+ use_buffer_context_ = false;
+}
+
void WebPluginDelegateImpl::FireIdleEvent() {
// Avoid a race condition between IO and UI threads during plugin shutdown
if (!instance())
« no previous file with comments | « webkit/plugins/npapi/webplugin_delegate_impl.h ('k') | webkit/tools/test_shell/mac/test_webview_delegate.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698