Changeset 49169 in webkit


Ignore:
Timestamp:
Oct 6, 2009 4:52:42 AM (15 years ago)
Author:
Simon Hausmann
Message:

[Qt] Windowless plugins: Add PluginQuirkRequiresDefaultScreenDepth quirk for Flash.

Patch by Girish Ramakrishnan <Girish Ramakrishnan> 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)

  1. 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.

  1. 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):

Location:
trunk/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r49165 r49169  
     12009-10-06  Girish Ramakrishnan  <girish@forwardbias.in>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Windowless plugins: Add PluginQuirkRequiresDefaultScreenDepth quirk for Flash.
     6
     7        Flash does not use the visual provided by us to draw into the drawable.
     8        It instead uses the system default visual (as returned by XDefaultVisual).
     9        This means that if the screen default visual is 24-bit, Flash won't be
     10        able to draw on 32-bit drawable created by us. This is a bug in Flash
     11        and for the moment, the above quirk is only set for Flash.
     12
     13        Our strategy to create the drawable:
     14        1. Create a 32-bit drawable if the default screen depth is 32 or the
     15        quirk is not set (i.e not flash)
     16        2. If we didn't create a 32-bit drawable (maybe the Display has no such
     17        visual), we create a drawable with default screen depth.
     18
     19        As a result of the above changes, content propagation behavior changes as:
     20        1. Content propagation is possible only if the drawable we create and
     21        Qt's backing store are of the same depth.
     22        2. If we created a 32-bit drawable, there is no need for content
     23        propagation (Qt will take care of it).
     24
     25        https://bugs.webkit.org/show_bug.cgi?id=20081
     26
     27        * plugins/PluginPackage.cpp:
     28        (WebCore::PluginPackage::determineQuirks):
     29        * plugins/PluginQuirkSet.h:
     30        (WebCore::):
     31        * plugins/PluginView.cpp:
     32        (WebCore::PluginView::PluginView):
     33        * plugins/PluginView.h:
     34        * plugins/qt/PluginViewQt.cpp:
     35        (WebCore::PluginView::updatePluginWidget):
     36        (WebCore::PluginView::paint):
     37        (WebCore::getVisualAndColormap):
     38        (WebCore::PluginView::platformStart):
     39        (WebCore::PluginView::platformDestroy):
     40
    1412009-10-06  Fumitoshi Ukai  <ukai@chromium.org>
    242
  • trunk/WebCore/plugins/PluginPackage.cpp

    r46540 r49169  
    184184            m_quirks.add(PluginQuirkRequiresGtkToolKit);
    185185#endif
     186            m_quirks.add(PluginQuirkRequiresDefaultScreenDepth);
    186187        } else {
    187188            // Flash 9 and older requests windowless plugins if we return a mozilla user agent
  • trunk/WebCore/plugins/PluginQuirkSet.h

    r38124 r49169  
    4747        PluginQuirkDontAllowMultipleInstances = 1 << 11,
    4848        PluginQuirkRequiresGtkToolKit = 1 << 12,
     49        PluginQuirkRequiresDefaultScreenDepth = 1 << 13
    4950    };
    5051
  • trunk/WebCore/plugins/PluginView.cpp

    r49159 r49169  
    822822    , m_hasPendingGeometryChange(false)
    823823    , m_drawable(0)
     824    , m_visual(0)
     825    , m_colormap(0)
    824826    , m_pluginDisplay(0)
    825827#endif
  • trunk/WebCore/plugins/PluginView.h

    r49159 r49169  
    328328        bool m_hasPendingGeometryChange;
    329329        Pixmap m_drawable;
     330        Visual* m_visual;
     331        Colormap m_colormap;
    330332        Display* m_pluginDisplay;
    331333
  • trunk/WebCore/plugins/qt/PluginViewQt.cpp

    r49159 r49169  
    6969#include <runtime/JSValue.h>
    7070#include <X11/X.h>
     71#ifndef QT_NO_XRENDER
     72#define Bool int
     73#define Status int
     74#include <X11/extensions/Xrender.h>
     75#endif
    7176
    7277using JSC::ExecState;
     
    106111
    107112    if (!m_isWindowed)
    108         m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(), QX11Info::appDepth());
     113        m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(),
     114                                   ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth);
    109115
    110116    // do not call setNPWindowIfNeeded immediately, will be called on paint()
     
    175181
    176182    QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared);
    177 
    178     if (m_isTransparent) {
    179         // Attempt content propagation by copying over from the backing store
     183    const int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth;
     184    ASSERT(drawableDepth == qtDrawable.depth());
     185
     186    if (m_isTransparent && drawableDepth != 32) {
     187        // Attempt content propagation for drawable with no alpha by copying over from the backing store
    180188        QPoint offset;
    181189        QPaintDevice* backingStoreDevice =  QPainter::redirected(painter->device(), &offset);
     190        offset = -offset; // negating the offset gives us the offset of the view within the backing store pixmap
     191
    182192        const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap;
    183         offset = -offset; // negating the offset gives us the offset of the view within the backing store pixmap
    184 
    185         if (hasValidBackingStore) {
    186             QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice);
     193        QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice);
     194
     195        if (hasValidBackingStore && backingStorePixmap->depth() == drawableDepth) {
    187196            GC gc = XDefaultGC(QX11Info::display(), QX11Info::appScreen());
    188197            XCopyArea(QX11Info::display(), backingStorePixmap->handle(), m_drawable, gc,
    189198                offset.x() + m_windowRect.x() + m_clipRect.x(), offset.y() + m_windowRect.y() + m_clipRect.y(),
    190199                m_clipRect.width(), m_clipRect.height(), m_clipRect.x(), m_clipRect.y());
    191         } else { // no backing store, clean the pixmap
     200        } else { // no backing store, clean the pixmap because the plugin thinks its transparent
    192201            QPainter painter(&qtDrawable);
    193202            painter.fillRect(m_clipRect, Qt::white);
     
    683692}
    684693
     694static void getVisualAndColormap(int depth, Visual **visual, Colormap *colormap)
     695{
     696    *visual = 0;
     697    *colormap = 0;
     698
     699#ifndef QT_NO_XRENDER
     700    static const bool useXRender = qgetenv("QT_X11_NO_XRENDER").isNull(); // Should also check for XRender >= 0.5
     701#else
     702    static const bool useXRender = false;
     703#endif
     704
     705    if (!useXRender && depth == 32)
     706        return;
     707
     708    int nvi;
     709    XVisualInfo templ;
     710    templ.screen  = QX11Info::appScreen();
     711    templ.depth   = depth;
     712    templ.c_class = TrueColor;
     713    XVisualInfo* xvi = XGetVisualInfo(QX11Info::display(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi);
     714
     715    if (!xvi)
     716        return;
     717
     718#ifndef QT_NO_XRENDER
     719    if (depth == 32) {
     720        for (int idx = 0; idx < nvi; ++idx) {
     721            XRenderPictFormat* format = XRenderFindVisualFormat(QX11Info::display(), xvi[idx].visual);
     722            if (format->type == PictTypeDirect && format->direct.alphaMask) {
     723                 *visual = xvi[idx].visual;
     724                 break;
     725            }
     726         }
     727    } else
     728#endif // QT_NO_XRENDER
     729        *visual = xvi[0].visual;
     730
     731    XFree(xvi);
     732
     733    if (*visual)
     734        *colormap = XCreateColormap(QX11Info::display(), QX11Info::appRootWindow(), *visual, AllocNone);
     735}
     736
    685737bool PluginView::platformStart()
    686738{
     
    716768    wsi->type = 0;
    717769
    718     const QX11Info* x11Info = 0;
    719770    if (m_isWindowed) {
    720         x11Info = &platformPluginWidget()->x11Info();
     771        const QX11Info* x11Info = &platformPluginWidget()->x11Info();
     772
     773        wsi->display = x11Info->display();
     774        wsi->visual = (Visual*)x11Info->visual();
     775        wsi->depth = x11Info->depth();
     776        wsi->colormap = x11Info->colormap();
    721777
    722778        m_npWindow.type = NPWindowTypeWindow;
     
    725781        m_npWindow.height = -1;
    726782    } else {
    727         x11Info = &QApplication::desktop()->x11Info();
     783        const QX11Info* x11Info = &QApplication::desktop()->x11Info();
     784
     785        if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) {
     786            getVisualAndColormap(32, &m_visual, &m_colormap);
     787            wsi->depth = 32;
     788        }
     789
     790        if (!m_visual) {
     791            getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap);
     792            wsi->depth = x11Info->depth();
     793        }
     794
     795        wsi->display = x11Info->display();
     796        wsi->visual = m_visual;
     797        wsi->colormap = m_colormap;
    728798
    729799        m_npWindow.type = NPWindowTypeDrawable;
     
    735805    }
    736806
    737     wsi->display = x11Info->display();
    738     wsi->visual = (Visual*)x11Info->visual();
    739     wsi->depth = x11Info->depth();
    740     wsi->colormap = x11Info->colormap();
    741807    m_npWindow.ws_info = wsi;
    742808
     
    756822    if (m_drawable)
    757823        XFreePixmap(QX11Info::display(), m_drawable);
     824
     825    if (m_colormap)
     826        XFreeColormap(QX11Info::display(), m_colormap);
    758827}
    759828
Note: See TracChangeset for help on using the changeset viewer.