Title: [98897] trunk/Source/WebKit2
Revision
98897
Author
ander...@apple.com
Date
2011-10-31 16:07:12 -0700 (Mon, 31 Oct 2011)

Log Message

Factor code to resize the plug-in backing store out into a separate function
https://bugs.webkit.org/show_bug.cgi?id=71250

Reviewed by Adam Roben.

Add a PluginProxy::contentsScaleFactor helper function to get rid of a bunch of PLATFORM(MAC) #ifdefs,
and move the code to update the backing store out into a separate function.

* WebProcess/Plugins/PluginProxy.cpp:
(WebKit::PluginProxy::initialize):
(WebKit::PluginProxy::paint):
(WebKit::PluginProxy::geometryDidChange):
(WebKit::PluginProxy::contentsScaleFactor):
(WebKit::PluginProxy::updateBackingStore):
(WebKit::PluginProxy::update):
* WebProcess/Plugins/PluginProxy.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (98896 => 98897)


--- trunk/Source/WebKit2/ChangeLog	2011-10-31 23:02:48 UTC (rev 98896)
+++ trunk/Source/WebKit2/ChangeLog	2011-10-31 23:07:12 UTC (rev 98897)
@@ -1,3 +1,22 @@
+2011-10-31  Anders Carlsson  <ander...@apple.com>
+
+        Factor code to resize the plug-in backing store out into a separate function
+        https://bugs.webkit.org/show_bug.cgi?id=71250
+
+        Reviewed by Adam Roben.
+
+        Add a PluginProxy::contentsScaleFactor helper function to get rid of a bunch of PLATFORM(MAC) #ifdefs,
+        and move the code to update the backing store out into a separate function.
+
+        * WebProcess/Plugins/PluginProxy.cpp:
+        (WebKit::PluginProxy::initialize):
+        (WebKit::PluginProxy::paint):
+        (WebKit::PluginProxy::geometryDidChange):
+        (WebKit::PluginProxy::contentsScaleFactor):
+        (WebKit::PluginProxy::updateBackingStore):
+        (WebKit::PluginProxy::update):
+        * WebProcess/Plugins/PluginProxy.h:
+
 2011-10-31  Jeff Miller  <je...@apple.com>
 
         Add more APIs to WKUserContentURLPattern.h

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp (98896 => 98897)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2011-10-31 23:02:48 UTC (rev 98896)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.cpp	2011-10-31 23:07:12 UTC (rev 98897)
@@ -102,7 +102,7 @@
     creationParameters.isAcceleratedCompositingEnabled = controller()->isAcceleratedCompositingEnabled();
 #endif
 #if PLATFORM(MAC)
-    creationParameters.contentsScaleFactor = controller()->contentsScaleFactor();
+    creationParameters.contentsScaleFactor = contentsScaleFactor();
 #endif
 
     bool result = false;
@@ -135,21 +135,15 @@
     if (!needsBackingStore() || !m_backingStore)
         return;
 
-#if PLATFORM(MAC)
-    float contentsScaleFactor = controller()->contentsScaleFactor();
-#else
-    float contentsScaleFactor = 1;
-#endif
-
     if (!m_pluginBackingStoreContainsValidData) {
         m_connection->connection()->sendSync(Messages::PluginControllerProxy::PaintEntirePlugin(), Messages::PluginControllerProxy::PaintEntirePlugin::Reply(), m_pluginInstanceID);
     
         // Blit the plug-in backing store into our own backing store.
         OwnPtr<WebCore::GraphicsContext> graphicsContext = m_backingStore->createGraphicsContext();
-        graphicsContext->applyDeviceScaleFactor(contentsScaleFactor);
+        graphicsContext->applyDeviceScaleFactor(contentsScaleFactor());
         graphicsContext->setCompositeOperation(CompositeCopy);
 
-        m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor, IntPoint(), IntRect(0, 0, m_frameRectInWindowCoordinates.width(), m_frameRectInWindowCoordinates.height()));
+        m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor(), IntPoint(), IntRect(0, 0, m_frameRectInWindowCoordinates.width(), m_frameRectInWindowCoordinates.height()));
 
         m_pluginBackingStoreContainsValidData = true;
     }
@@ -157,7 +151,7 @@
     IntRect dirtyRectInPluginCoordinates = dirtyRect;
     dirtyRectInPluginCoordinates.move(-m_frameRectInWindowCoordinates.x(), -m_frameRectInWindowCoordinates.y());
 
-    m_backingStore->paint(*graphicsContext, contentsScaleFactor, dirtyRect.location(), dirtyRectInPluginCoordinates);
+    m_backingStore->paint(*graphicsContext, contentsScaleFactor(), dirtyRect.location(), dirtyRectInPluginCoordinates);
 
     if (m_waitingForPaintInResponseToUpdate) {
         m_waitingForPaintInResponseToUpdate = false;
@@ -186,38 +180,17 @@
 {
     ASSERT(m_isStarted);
 
-#if PLATFORM(MAC)
-    float contentsScaleFactor = controller()->contentsScaleFactor();
-#else
-    float contentsScaleFactor = 1;
-#endif
-
     if (m_frameRectInWindowCoordinates.isEmpty() || !needsBackingStore()) {
         ShareableBitmap::Handle pluginBackingStoreHandle;
-        m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(m_frameRectInWindowCoordinates, m_clipRectInWindowCoordinates, contentsScaleFactor, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+        m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(m_frameRectInWindowCoordinates, m_clipRectInWindowCoordinates, contentsScaleFactor(), pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
         return;
     }
 
-    bool didUpdateBackingStore = false;
-    IntSize backingStoreSize = m_frameRectInWindowCoordinates.size();
-    backingStoreSize.scale(contentsScaleFactor);
-
-    if (!m_backingStore) {
-        m_backingStore = ShareableBitmap::create(backingStoreSize, ShareableBitmap::SupportsAlpha);
-        didUpdateBackingStore = true;
-    } else if (backingStoreSize != m_backingStore->size()) {
-        // The backing store already exists, just resize it.
-        if (!m_backingStore->resize(backingStoreSize))
-            return;
-
-        didUpdateBackingStore = true;
-    }
-
     ShareableBitmap::Handle pluginBackingStoreHandle;
 
-    if (didUpdateBackingStore) {
+    if (updateBackingStore()) {
         // Create a new plug-in backing store.
-        m_pluginBackingStore = ShareableBitmap::createShareable(backingStoreSize, ShareableBitmap::SupportsAlpha);
+        m_pluginBackingStore = ShareableBitmap::createShareable(m_backingStore->size(), ShareableBitmap::SupportsAlpha);
         if (!m_pluginBackingStore)
             return;
 
@@ -230,7 +203,7 @@
         m_pluginBackingStoreContainsValidData = false;
     }
 
-    m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(m_frameRectInWindowCoordinates, m_frameRectInWindowCoordinates, contentsScaleFactor, pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
+    m_connection->connection()->send(Messages::PluginControllerProxy::GeometryDidChange(m_frameRectInWindowCoordinates, m_frameRectInWindowCoordinates, contentsScaleFactor(), pluginBackingStoreHandle), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
 }
 
 void PluginProxy::deprecatedGeometryDidChange(const IntRect& frameRectInWindowCoordinates, const IntRect& clipRectInWindowCoordinates)
@@ -471,6 +444,33 @@
     returnValue = controller()->getAuthenticationInfo(protectionSpace, username, password);
 }
 
+float PluginProxy::contentsScaleFactor()
+{
+#if PLATFORM(MAC)
+    return controller()->contentsScaleFactor();
+#else
+    return 1;
+#endif
+}
+
+bool PluginProxy::updateBackingStore()
+{
+    IntSize backingStoreSize = m_frameRectInWindowCoordinates.size();
+    backingStoreSize.scale(contentsScaleFactor());
+    
+    if (!m_backingStore) {
+        m_backingStore = ShareableBitmap::create(backingStoreSize, ShareableBitmap::SupportsAlpha);
+        return true;
+    }
+
+    if (backingStoreSize != m_backingStore->size()) {
+        // The backing store already exists, just resize it.
+        return m_backingStore->resize(backingStoreSize);
+    }
+
+    return false;
+}
+
 uint64_t PluginProxy::windowNPObjectID()
 {
     NPObject* windowScriptNPObject = controller()->windowScriptNPObject();
@@ -543,17 +543,11 @@
     paintedRectPluginCoordinates.move(-m_frameRectInWindowCoordinates.x(), -m_frameRectInWindowCoordinates.y());
 
     if (m_backingStore) {
-#if PLATFORM(MAC)
-        float contentsScaleFactor = controller()->contentsScaleFactor();
-#else
-        float contentsScaleFactor = 1;
-#endif
-
         // Blit the plug-in backing store into our own backing store.
         OwnPtr<GraphicsContext> graphicsContext = m_backingStore->createGraphicsContext();
-        graphicsContext->applyDeviceScaleFactor(contentsScaleFactor);
+        graphicsContext->applyDeviceScaleFactor(contentsScaleFactor());
         graphicsContext->setCompositeOperation(CompositeCopy);
-        m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor, paintedRectPluginCoordinates.location(), 
+        m_pluginBackingStore->paint(*graphicsContext, contentsScaleFactor(), paintedRectPluginCoordinates.location(), 
                                     paintedRectPluginCoordinates);
     }
 

Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (98896 => 98897)


--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2011-10-31 23:02:48 UTC (rev 98896)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h	2011-10-31 23:07:12 UTC (rev 98897)
@@ -110,7 +110,9 @@
     virtual WebCore::Scrollbar* horizontalScrollbar();
     virtual WebCore::Scrollbar* verticalScrollbar();
 
+    float contentsScaleFactor();
     bool needsBackingStore() const;
+    bool updateBackingStore();
     uint64_t windowNPObjectID();
 
     void geometryDidChange();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to