diff options
author | andersca@apple.com <andersca@apple.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2010-10-19 22:48:18 +0000 |
---|---|---|
committer | andersca@apple.com <andersca@apple.com@bbb929c8-8fbe-4397-9dbb-9b2b20218538> | 2010-10-19 22:48:18 +0000 |
commit | ecfc9026736c5f15572df701600515bbcd2f2ba5 (patch) | |
tree | a12634784eafb9d71717d0afaeb7a5e5fbbd8e5d | |
parent | e5123b4357da59e57fa0dcfdf73017216e226c07 (diff) | |
download | chromium_src-ecfc9026736c5f15572df701600515bbcd2f2ba5.zip chromium_src-ecfc9026736c5f15572df701600515bbcd2f2ba5.tar.gz chromium_src-ecfc9026736c5f15572df701600515bbcd2f2ba5.tar.bz2 |
Coalesce plug-in drawing
https://bugs.webkit.org/show_bug.cgi?id=47939
Reviewed by Sam Weinig.
Coalesce plug-in drawing in the same manner as we do it in the chunked update drawing area.
* PluginProcess/PluginControllerProxy.cpp:
(WebKit::PluginControllerProxy::PluginControllerProxy):
Initialize m_waitingForDidUpdate to false.
(WebKit::PluginControllerProxy::startPaintTimer):
Move code from invalidate out to here. Don't start the paint timer if m_waitingForDidUpdate is true.
(WebKit::PluginControllerProxy::invalidate):
Call startPaintTimer.
(WebKit::PluginControllerProxy::didUpdate):
Set m_waitingForDidUpdate to false and start the paint timer.
* PluginProcess/PluginControllerProxy.messages.in:
Add DidUpdate message.
* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::PluginProxy):
Initialize m_waitingForPaintInResponseToUpdate to false.
(WebKit::PluginProxy::paint):
If m_waitingForPaintInResponseToUpdate is true, send a DidUpdate message.
(WebKit::PluginProxy::update):
Set m_waitingForPaintInResponseToUpdate to true.
git-svn-id: svn://svn.chromium.org/blink/trunk@70098 bbb929c8-8fbe-4397-9dbb-9b2b20218538
6 files changed, 84 insertions, 13 deletions
diff --git a/third_party/WebKit/WebKit2/ChangeLog b/third_party/WebKit/WebKit2/ChangeLog index 170c5d4..8051f89 100644 --- a/third_party/WebKit/WebKit2/ChangeLog +++ b/third_party/WebKit/WebKit2/ChangeLog @@ -1,3 +1,38 @@ +2010-10-19 Anders Carlsson <andersca@apple.com> + + Reviewed by Sam Weinig. + + Coalesce plug-in drawing + https://bugs.webkit.org/show_bug.cgi?id=47939 + + Coalesce plug-in drawing in the same manner as we do it in the chunked update drawing area. + + * PluginProcess/PluginControllerProxy.cpp: + (WebKit::PluginControllerProxy::PluginControllerProxy): + Initialize m_waitingForDidUpdate to false. + + (WebKit::PluginControllerProxy::startPaintTimer): + Move code from invalidate out to here. Don't start the paint timer if m_waitingForDidUpdate is true. + + (WebKit::PluginControllerProxy::invalidate): + Call startPaintTimer. + + (WebKit::PluginControllerProxy::didUpdate): + Set m_waitingForDidUpdate to false and start the paint timer. + + * PluginProcess/PluginControllerProxy.messages.in: + Add DidUpdate message. + + * WebProcess/Plugins/PluginProxy.cpp: + (WebKit::PluginProxy::PluginProxy): + Initialize m_waitingForPaintInResponseToUpdate to false. + + (WebKit::PluginProxy::paint): + If m_waitingForPaintInResponseToUpdate is true, send a DidUpdate message. + + (WebKit::PluginProxy::update): + Set m_waitingForPaintInResponseToUpdate to true. + 2010-10-19 Sam Weinig <sam@webkit.org> Reviewed by Anders Carlsson. diff --git a/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.cpp b/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.cpp index 30eb60e..07381e9 100644 --- a/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.cpp +++ b/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.cpp @@ -53,6 +53,7 @@ PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, u , m_userAgent(userAgent) , m_isPrivateBrowsingEnabled(isPrivateBrowsingEnabled) , m_paintTimer(RunLoop::main(), this, &PluginControllerProxy::paint) + , m_waitingForDidUpdate(false) { } @@ -102,29 +103,39 @@ void PluginControllerProxy::paint() m_connection->connection()->send(Messages::PluginProxy::Update(dirtyRect), m_pluginInstanceID); } -void PluginControllerProxy::invalidate(const IntRect& rect) +void PluginControllerProxy::startPaintTimer() { - // Convert the dirty rect to window coordinates. - IntRect dirtyRect = rect; - dirtyRect.move(m_frameRect.x(), m_frameRect.y()); - - // Make sure that the dirty rect is not greater than the plug-in itself. - dirtyRect.intersect(m_frameRect); - - m_dirtyRect.unite(dirtyRect); - // Check if we should start the timer. if (m_dirtyRect.isEmpty()) return; - + // FIXME: Check clip rect. if (m_paintTimer.isActive()) return; + if (m_waitingForDidUpdate) + return; + // Start the timer. m_paintTimer.startOneShot(0); + + m_waitingForDidUpdate = true; +} + +void PluginControllerProxy::invalidate(const IntRect& rect) +{ + // Convert the dirty rect to window coordinates. + IntRect dirtyRect = rect; + dirtyRect.move(m_frameRect.x(), m_frameRect.y()); + + // Make sure that the dirty rect is not greater than the plug-in itself. + dirtyRect.intersect(m_frameRect); + + m_dirtyRect.unite(dirtyRect); + + startPaintTimer(); } String PluginControllerProxy::userAgent() @@ -285,6 +296,12 @@ void PluginControllerProxy::setFocus(bool hasFocus) m_plugin->setFocus(hasFocus); } +void PluginControllerProxy::didUpdate() +{ + m_waitingForDidUpdate = false; + startPaintTimer(); +} + #if PLATFORM(MAC) void PluginControllerProxy::windowFocusChanged(bool hasFocus) { diff --git a/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.h b/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.h index b6f59ea..e23090e 100644 --- a/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.h +++ b/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.h @@ -62,6 +62,7 @@ public: private: PluginControllerProxy(WebProcessConnection* connection, uint64_t pluginInstanceID, const String& userAgent, bool isPrivateBrowsingEnabled); + void startPaintTimer(); void paint(); // PluginController @@ -94,6 +95,7 @@ private: void handleMouseLeaveEvent(const WebMouseEvent&, bool& handled); void handleKeyboardEvent(const WebKeyboardEvent&, bool& handled); void setFocus(bool); + void didUpdate(); #if PLATFORM(MAC) void windowFocusChanged(bool); void windowFrameChanged(const WebCore::IntRect&); @@ -119,6 +121,10 @@ private: // The paint timer, used for coalescing painting. RunLoop::Timer<PluginControllerProxy> m_paintTimer; + // Whether we're waiting for the plug-in proxy in the web process to draw the contents of its + // backing store into the web process backing store. + bool m_waitingForDidUpdate; + // The backing store that this plug-in draws into. RefPtr<BackingStore> m_backingStore; }; diff --git a/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.messages.in b/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.messages.in index be840be..baab004 100644 --- a/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.messages.in +++ b/third_party/WebKit/WebKit2/PluginProcess/PluginControllerProxy.messages.in @@ -59,6 +59,9 @@ messages -> PluginControllerProxy { # Sent when the plug-in focus changes. SetFocus(bool isFocused) + # Sent when the update requested by Update has been painted. + DidUpdate() + #if PLATFORM(MAC) # Sent when the containing NSWindow's focus changes WindowFocusChanged(bool hasFocus) diff --git a/third_party/WebKit/WebKit2/WebProcess/Plugins/PluginProxy.cpp b/third_party/WebKit/WebKit2/WebProcess/Plugins/PluginProxy.cpp index 4747869..dc15157 100644 --- a/third_party/WebKit/WebKit2/WebProcess/Plugins/PluginProxy.cpp +++ b/third_party/WebKit/WebKit2/WebProcess/Plugins/PluginProxy.cpp @@ -58,7 +58,7 @@ PluginProxy::PluginProxy(PassRefPtr<PluginProcessConnection> connection) , m_pluginInstanceID(generatePluginInstanceID()) , m_pluginController(0) , m_isStarted(false) - + , m_waitingForPaintInResponseToUpdate(false) { } @@ -122,6 +122,12 @@ void PluginProxy::paint(GraphicsContext* graphicsContext, const IntRect& dirtyRe m_backingStore->paint(graphicsContext, dirtyRectInPluginCoordinates); graphicsContext->restore(); + + if (m_waitingForPaintInResponseToUpdate) { + m_waitingForPaintInResponseToUpdate = false; + m_connection->connection()->send(Messages::PluginControllerProxy::DidUpdate(), m_pluginInstanceID); + return; + } } #if PLATFORM(MAC) @@ -349,7 +355,8 @@ void PluginProxy::update(const IntRect& paintedRect) m_pluginBackingStore->paint(graphicsContext.get(), paintedRectPluginCoordinates); } - // Ask the controller to invalidate the rect for us. + // Ask the controller to invalidate the rect for us. + m_waitingForPaintInResponseToUpdate = true; m_pluginController->invalidate(paintedRectPluginCoordinates); } diff --git a/third_party/WebKit/WebKit2/WebProcess/Plugins/PluginProxy.h b/third_party/WebKit/WebKit2/WebProcess/Plugins/PluginProxy.h index 4bea06d..ef1db8e 100644 --- a/third_party/WebKit/WebKit2/WebProcess/Plugins/PluginProxy.h +++ b/third_party/WebKit/WebKit2/WebProcess/Plugins/PluginProxy.h @@ -114,6 +114,9 @@ private: RefPtr<BackingStore> m_pluginBackingStore; bool m_isStarted; + + // Whether we're called invalidate in response to an update call, and are now waiting for a paint call. + bool m_waitingForPaintInResponseToUpdate; }; } // namespace WebKit |