[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.15.1-1414-gc69ee75

hausmann at webkit.org hausmann at webkit.org
Thu Oct 29 20:39:59 UTC 2009


The following commit has been merged in the webkit-1.1 branch:
commit 47a2cdd8801ecddd2ed31fd84fc24788fb0a8d05
Author: hausmann at webkit.org <hausmann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Oct 6 11:52:42 2009 +0000

    [Qt] Windowless plugins: Add PluginQuirkRequiresDefaultScreenDepth quirk for Flash.
    
    Patch by Girish Ramakrishnan <girish at forwardbias.in> on 2009-10-06
    Reviewed by Simon Hausmann.
    
    Flash does not use the visual provided by us to draw into the drawable.
    It instead uses the system default visual (as returned by XDefaultVisual).
    This means that if the screen default visual is 24-bit, Flash won't be
    able to draw on 32-bit drawable created by us. This is a bug in Flash
    and for the moment, the above quirk is only set for Flash.
    
    Our strategy to create the drawable:
    1. Create a 32-bit drawable if the default screen depth is 32 or the
    quirk is not set (i.e not flash)
    2. If we didn't create a 32-bit drawable (maybe the Display has no such
    visual), we create a drawable with default screen depth.
    
    As a result of the above changes, content propagation behavior changes as:
    1. Content propagation is possible only if the drawable we create and
    Qt's backing store are of the same depth.
    2. If we created a 32-bit drawable, there is no need for content
    propagation (Qt will take care of it).
    
    https://bugs.webkit.org/show_bug.cgi?id=20081
    
    * plugins/PluginPackage.cpp:
    (WebCore::PluginPackage::determineQuirks):
    * plugins/PluginQuirkSet.h:
    (WebCore::):
    * plugins/PluginView.cpp:
    (WebCore::PluginView::PluginView):
    * plugins/PluginView.h:
    * plugins/qt/PluginViewQt.cpp:
    (WebCore::PluginView::updatePluginWidget):
    (WebCore::PluginView::paint):
    (WebCore::getVisualAndColormap):
    (WebCore::PluginView::platformStart):
    (WebCore::PluginView::platformDestroy):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@49169 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index eda200c..fab5e0b 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,43 @@
+2009-10-06  Girish Ramakrishnan  <girish at forwardbias.in>
+
+        Reviewed by Simon Hausmann.
+
+        [Qt] Windowless plugins: Add PluginQuirkRequiresDefaultScreenDepth quirk for Flash.
+
+        Flash does not use the visual provided by us to draw into the drawable.
+        It instead uses the system default visual (as returned by XDefaultVisual).
+        This means that if the screen default visual is 24-bit, Flash won't be
+        able to draw on 32-bit drawable created by us. This is a bug in Flash
+        and for the moment, the above quirk is only set for Flash.
+
+        Our strategy to create the drawable:
+        1. Create a 32-bit drawable if the default screen depth is 32 or the
+        quirk is not set (i.e not flash)
+        2. If we didn't create a 32-bit drawable (maybe the Display has no such
+        visual), we create a drawable with default screen depth.
+
+        As a result of the above changes, content propagation behavior changes as:
+        1. Content propagation is possible only if the drawable we create and
+        Qt's backing store are of the same depth.
+        2. If we created a 32-bit drawable, there is no need for content
+        propagation (Qt will take care of it).
+
+        https://bugs.webkit.org/show_bug.cgi?id=20081
+
+        * plugins/PluginPackage.cpp:
+        (WebCore::PluginPackage::determineQuirks):
+        * plugins/PluginQuirkSet.h:
+        (WebCore::):
+        * plugins/PluginView.cpp:
+        (WebCore::PluginView::PluginView):
+        * plugins/PluginView.h:
+        * plugins/qt/PluginViewQt.cpp:
+        (WebCore::PluginView::updatePluginWidget):
+        (WebCore::PluginView::paint):
+        (WebCore::getVisualAndColormap):
+        (WebCore::PluginView::platformStart):
+        (WebCore::PluginView::platformDestroy):
+
 2009-10-06  Fumitoshi Ukai  <ukai at chromium.org>
 
         Reviewed by Ariya Hidayat.
diff --git a/WebCore/plugins/PluginPackage.cpp b/WebCore/plugins/PluginPackage.cpp
index 612a9d7..00b5fb8 100644
--- a/WebCore/plugins/PluginPackage.cpp
+++ b/WebCore/plugins/PluginPackage.cpp
@@ -183,6 +183,7 @@ void PluginPackage::determineQuirks(const String& mimeType)
 #if PLATFORM(QT)
             m_quirks.add(PluginQuirkRequiresGtkToolKit);
 #endif
+            m_quirks.add(PluginQuirkRequiresDefaultScreenDepth);
         } else {
             // Flash 9 and older requests windowless plugins if we return a mozilla user agent
             m_quirks.add(PluginQuirkWantsMozillaUserAgent);
diff --git a/WebCore/plugins/PluginQuirkSet.h b/WebCore/plugins/PluginQuirkSet.h
index b652c6e..de29baf 100644
--- a/WebCore/plugins/PluginQuirkSet.h
+++ b/WebCore/plugins/PluginQuirkSet.h
@@ -46,6 +46,7 @@ namespace WebCore {
         PluginQuirkDontSetNullWindowHandleOnDestroy = 1 << 10,
         PluginQuirkDontAllowMultipleInstances = 1 << 11,
         PluginQuirkRequiresGtkToolKit = 1 << 12,
+        PluginQuirkRequiresDefaultScreenDepth = 1 << 13
     };
 
     class PluginQuirkSet {
diff --git a/WebCore/plugins/PluginView.cpp b/WebCore/plugins/PluginView.cpp
index 5770886..14f7053 100644
--- a/WebCore/plugins/PluginView.cpp
+++ b/WebCore/plugins/PluginView.cpp
@@ -821,6 +821,8 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p
 #if defined(Q_WS_X11)
     , m_hasPendingGeometryChange(false)
     , m_drawable(0)
+    , m_visual(0)
+    , m_colormap(0)
     , m_pluginDisplay(0)
 #endif
     , m_loadManually(loadManually)
diff --git a/WebCore/plugins/PluginView.h b/WebCore/plugins/PluginView.h
index e7b2293..6ae1b14 100644
--- a/WebCore/plugins/PluginView.h
+++ b/WebCore/plugins/PluginView.h
@@ -327,6 +327,8 @@ private:
 #if defined(Q_WS_X11)
         bool m_hasPendingGeometryChange;
         Pixmap m_drawable;
+        Visual* m_visual;
+        Colormap m_colormap;
         Display* m_pluginDisplay;
 
         void initXEvent(XEvent* event);
diff --git a/WebCore/plugins/qt/PluginViewQt.cpp b/WebCore/plugins/qt/PluginViewQt.cpp
index c5b2b26..cdd7616 100644
--- a/WebCore/plugins/qt/PluginViewQt.cpp
+++ b/WebCore/plugins/qt/PluginViewQt.cpp
@@ -68,6 +68,11 @@
 #include <runtime/JSLock.h>
 #include <runtime/JSValue.h>
 #include <X11/X.h>
+#ifndef QT_NO_XRENDER
+#define Bool int
+#define Status int
+#include <X11/extensions/Xrender.h>
+#endif
 
 using JSC::ExecState;
 using JSC::Interpreter;
@@ -105,7 +110,8 @@ void PluginView::updatePluginWidget()
         XFreePixmap(QX11Info::display(), m_drawable);
 
     if (!m_isWindowed)
-        m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(), QX11Info::appDepth());
+        m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(), 
+                                   ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth);
 
     // do not call setNPWindowIfNeeded immediately, will be called on paint()
     m_hasPendingGeometryChange = true;
@@ -174,21 +180,24 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
         return;
 
     QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared);
+    const int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth;
+    ASSERT(drawableDepth == qtDrawable.depth());
 
-    if (m_isTransparent) {
-        // Attempt content propagation by copying over from the backing store
+    if (m_isTransparent && drawableDepth != 32) {
+        // Attempt content propagation for drawable with no alpha by copying over from the backing store
         QPoint offset;
         QPaintDevice* backingStoreDevice =  QPainter::redirected(painter->device(), &offset);
-        const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap;
         offset = -offset; // negating the offset gives us the offset of the view within the backing store pixmap
 
-        if (hasValidBackingStore) {
-            QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice);
+        const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap;
+        QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice);
+
+        if (hasValidBackingStore && backingStorePixmap->depth() == drawableDepth) {
             GC gc = XDefaultGC(QX11Info::display(), QX11Info::appScreen());
             XCopyArea(QX11Info::display(), backingStorePixmap->handle(), m_drawable, gc,
                 offset.x() + m_windowRect.x() + m_clipRect.x(), offset.y() + m_windowRect.y() + m_clipRect.y(),
                 m_clipRect.width(), m_clipRect.height(), m_clipRect.x(), m_clipRect.y());
-        } else { // no backing store, clean the pixmap
+        } else { // no backing store, clean the pixmap because the plugin thinks its transparent
             QPainter painter(&qtDrawable);
             painter.fillRect(m_clipRect, Qt::white);
         }
@@ -682,6 +691,49 @@ static Display *getPluginDisplay()
     return (Display*)gdk_x11_display_get_xdisplay(gdk_display_get_default());
 }
 
+static void getVisualAndColormap(int depth, Visual **visual, Colormap *colormap)
+{
+    *visual = 0;
+    *colormap = 0;
+
+#ifndef QT_NO_XRENDER
+    static const bool useXRender = qgetenv("QT_X11_NO_XRENDER").isNull(); // Should also check for XRender >= 0.5
+#else
+    static const bool useXRender = false;
+#endif
+
+    if (!useXRender && depth == 32)
+        return;
+
+    int nvi;
+    XVisualInfo templ;
+    templ.screen  = QX11Info::appScreen();
+    templ.depth   = depth;
+    templ.c_class = TrueColor;
+    XVisualInfo* xvi = XGetVisualInfo(QX11Info::display(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi);
+
+    if (!xvi)
+        return;
+
+#ifndef QT_NO_XRENDER
+    if (depth == 32) {
+        for (int idx = 0; idx < nvi; ++idx) {
+            XRenderPictFormat* format = XRenderFindVisualFormat(QX11Info::display(), xvi[idx].visual);
+            if (format->type == PictTypeDirect && format->direct.alphaMask) {
+                 *visual = xvi[idx].visual;
+                 break;
+            }
+         }
+    } else
+#endif // QT_NO_XRENDER
+        *visual = xvi[0].visual;
+
+    XFree(xvi);
+
+    if (*visual)
+        *colormap = XCreateColormap(QX11Info::display(), QX11Info::appRootWindow(), *visual, AllocNone);
+}
+
 bool PluginView::platformStart()
 {
     ASSERT(m_isStarted);
@@ -715,16 +767,34 @@ bool PluginView::platformStart()
     NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct();
     wsi->type = 0;
 
-    const QX11Info* x11Info = 0;
     if (m_isWindowed) {
-        x11Info = &platformPluginWidget()->x11Info();
+        const QX11Info* x11Info = &platformPluginWidget()->x11Info();
+
+        wsi->display = x11Info->display();
+        wsi->visual = (Visual*)x11Info->visual();
+        wsi->depth = x11Info->depth();
+        wsi->colormap = x11Info->colormap();
 
         m_npWindow.type = NPWindowTypeWindow;
         m_npWindow.window = (void*)platformPluginWidget()->winId();
         m_npWindow.width = -1;
         m_npWindow.height = -1;
     } else {
-        x11Info = &QApplication::desktop()->x11Info();
+        const QX11Info* x11Info = &QApplication::desktop()->x11Info();
+
+        if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) {
+            getVisualAndColormap(32, &m_visual, &m_colormap);
+            wsi->depth = 32;
+        }
+
+        if (!m_visual) {
+            getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap);
+            wsi->depth = x11Info->depth();
+        }
+
+        wsi->display = x11Info->display();
+        wsi->visual = m_visual;
+        wsi->colormap = m_colormap;
 
         m_npWindow.type = NPWindowTypeDrawable;
         m_npWindow.window = 0; // Not used?
@@ -734,10 +804,6 @@ bool PluginView::platformStart()
         m_npWindow.height = -1;
     }
 
-    wsi->display = x11Info->display();
-    wsi->visual = (Visual*)x11Info->visual();
-    wsi->depth = x11Info->depth();
-    wsi->colormap = x11Info->colormap();
     m_npWindow.ws_info = wsi;
 
     if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) {
@@ -755,6 +821,9 @@ void PluginView::platformDestroy()
 
     if (m_drawable)
         XFreePixmap(QX11Info::display(), m_drawable);
+
+    if (m_colormap)
+        XFreeColormap(QX11Info::display(), m_colormap);
 }
 
 void PluginView::halt()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list