Changeset 65612 in webkit


Ignore:
Timestamp:
Aug 18, 2010 9:52:32 AM (14 years ago)
Author:
Girish Ramakrishnan
Message:

[Qt] Implement Maemo5 local rendering NPAPI extension. See
https://wiki.mozilla.org/Plugins:NokiaMaemoImageSurface for details.

With the local rendering extension, Flash will paint into a 16-bit surface.
For wmode=transparent, Flash expects the surface to contain the contents
beneath it. As it is tricky to implement the content propagation across all
graphics systems, transparent Flash is not supported. We just fill the surface
with white and wmode=transparent behaves the same as wmode=opaque with a white
background.

Reviewed by Kenneth Rohde Christiansen.

https://bugs.webkit.org/show_bug.cgi?id=44043

  • WebCore.pro:
  • plugins/PluginView.cpp:

(WebCore::PluginView::setValue):
(WebCore::PluginView::PluginView):

  • plugins/PluginView.h:
  • plugins/qt/PluginViewQt.cpp:

(WebCore::PluginView::updatePluginWidget):
(WebCore::PluginView::paintUsingImageSurfaceExtension):
(WebCore::PluginView::paint):
(WebCore::PluginView::platformGetValueStatic):

Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65611 r65612  
     12010-08-18  Girish Ramakrishnan  <girish@forwardbias.in>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Implement Maemo5 local rendering NPAPI extension. See
     6        https://wiki.mozilla.org/Plugins:NokiaMaemoImageSurface for details.
     7
     8        With the local rendering extension, Flash will paint into a 16-bit surface.
     9        For wmode=transparent, Flash expects the surface to contain the contents
     10        beneath it. As it is tricky to implement the content propagation across all
     11        graphics systems, transparent Flash is not supported. We just fill the surface
     12        with white and wmode=transparent behaves the same as wmode=opaque with a white
     13        background.
     14
     15        https://bugs.webkit.org/show_bug.cgi?id=44043
     16
     17        * WebCore.pro:
     18        * plugins/PluginView.cpp:
     19        (WebCore::PluginView::setValue):
     20        (WebCore::PluginView::PluginView):
     21        * plugins/PluginView.h:
     22        * plugins/qt/PluginViewQt.cpp:
     23        (WebCore::PluginView::updatePluginWidget):
     24        (WebCore::PluginView::paintUsingImageSurfaceExtension):
     25        (WebCore::PluginView::paint):
     26        (WebCore::PluginView::platformGetValueStatic):
     27
    1282010-08-18  Sheriff Bot  <webkit.review.bot@gmail.com>
    229
  • trunk/WebCore/WebCore.pro

    r65611 r65612  
    23632363                    LIBS += -lXrender
    23642364                }
     2365                maemo5 {
     2366                    DEFINES += MOZ_PLATFORM_MAEMO=5
     2367                }
    23652368                SOURCES += \
    23662369                    plugins/qt/PluginContainerQt.cpp \
  • trunk/WebCore/plugins/PluginView.cpp

    r62846 r65612  
    22 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
    33 * Copyright (C) 2008 Collabora Ltd. All rights reserved.
     4 * Copyright (C) 2010 Girish Ramakrishnan <girish@forwardbias.in>
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    674675#endif // defined(XP_MACOSX)
    675676
     677#if PLATFORM(QT) && defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     678    case NPPVpluginWindowlessLocalBool:
     679        m_renderToImage = true;
     680        return NPERR_NO_ERROR;
     681#endif
     682
    676683    default:
    677684        notImplemented();
     
    850857    , m_pluginDisplay(0)
    851858#endif
     859#if PLATFORM(QT) && defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     860    , m_renderToImage(false)
     861#endif
    852862    , m_loadManually(loadManually)
    853863    , m_manualStream(0)
  • trunk/WebCore/plugins/PluginView.h

    r59904 r65612  
    5555#endif
    5656#endif
     57#if PLATFORM(QT) && defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     58#include <QImage>
     59class QPainter;
     60#endif
    5761
    5862#if USE(JSC)
     
    375379#endif
    376380
     381#if PLATFORM(QT) && defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     382        QImage m_image;
     383        bool m_renderToImage;
     384        void paintUsingImageSurfaceExtension(QPainter* painter, const IntRect& exposedRect);
     385#endif
     386
    377387        IntRect m_clipRect; // The clip rect to apply to a windowed plug-in
    378388        IntRect m_windowRect; // Our window rect.
  • trunk/WebCore/plugins/qt/PluginViewQt.cpp

    r65586 r65612  
    112112
    113113    if (!m_isWindowed && m_windowRect.size() != oldWindowRect.size()) {
    114         if (m_drawable)
    115             XFreePixmap(QX11Info::display(), m_drawable);
    116 
    117         m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(),
    118                                    ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth);
    119         QApplication::syncX(); // make sure that the server knows about the Drawable
     114#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     115        // On Maemo5, Flash always renders to 16-bit buffer
     116        if (m_renderToImage)
     117            m_image = QImage(m_windowRect.width(), m_windowRect.height(), QImage::Format_RGB16);
     118        else
     119#endif
     120        {
     121            if (m_drawable)
     122                XFreePixmap(QX11Info::display(), m_drawable);
     123
     124            m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(),
     125                                       ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth);
     126            QApplication::syncX(); // make sure that the server knows about the Drawable
     127        }
    120128    }
    121129
     
    161169}
    162170
     171#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     172void PluginView::paintUsingImageSurfaceExtension(QPainter* painter, const IntRect& exposedRect)
     173{
     174    if (m_isTransparent) {
     175        // On Maemo5, Flash expects the buffer to contain the contents that are below it.
     176        // We don't support transparency, so clean the image before giving to Flash.
     177        QPainter imagePainter(&m_image);
     178        imagePainter.fillRect(exposedRect, Qt::white);
     179    }
     180
     181    NPImageExpose imageExpose;
     182    imageExpose.data = reinterpret_cast<char*>(m_image.bits());
     183    imageExpose.stride = m_image.bytesPerLine();
     184    imageExpose.depth = m_image.depth();
     185    imageExpose.x = exposedRect.x();
     186    imageExpose.y = exposedRect.y();
     187    imageExpose.width = exposedRect.width();
     188    imageExpose.height = exposedRect.height();
     189    imageExpose.dataSize.width = m_image.width();
     190    imageExpose.dataSize.height = m_image.height();
     191    imageExpose.translateX = 0;
     192    imageExpose.translateY = 0;
     193    imageExpose.scaleX = 1;
     194    imageExpose.scaleY = 1;
     195
     196    XEvent xevent;
     197    memset(&xevent, 0, sizeof(XEvent));
     198    XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose;
     199    exposeEvent.type = GraphicsExpose;
     200    exposeEvent.display = 0;
     201    exposeEvent.drawable = reinterpret_cast<XID>(&imageExpose);
     202    exposeEvent.x = exposedRect.x();
     203    exposeEvent.y = exposedRect.y();
     204    exposeEvent.width = exposedRect.width();
     205    exposeEvent.height = exposedRect.height();
     206
     207    dispatchNPEvent(xevent);
     208
     209    painter->drawImage(QPoint(frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y()), m_image, exposedRect);
     210}
     211#endif
     212
    163213void PluginView::paint(GraphicsContext* context, const IntRect& rect)
    164214{
     
    173223    setNPWindowIfNeeded();
    174224
    175     if (m_isWindowed || !m_drawable)
    176         return;
    177 
    178     const bool syncX = m_pluginDisplay && m_pluginDisplay != QX11Info::display();
     225    if (m_isWindowed)
     226        return;
     227
     228    if (!m_drawable
     229#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     230        && m_image.isNull()
     231#endif
     232       )
     233        return;
    179234
    180235    QPainter* painter = context->platformContext();
     
    183238    exposedRect.move(-frameRect().x(), -frameRect().y());
    184239
     240#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     241    if (!m_image.isNull()) {
     242        paintUsingImageSurfaceExtension(painter, exposedRect);
     243        return;
     244    }
     245#endif
     246
    185247    QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared);
    186248    const int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth;
    187249    ASSERT(drawableDepth == qtDrawable.depth());
     250    const bool syncX = m_pluginDisplay && m_pluginDisplay != QX11Info::display();
    188251
    189252    // When printing, Qt uses a QPicture to capture the output in preview mode. The
     
    588651        return true;
    589652
     653#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO == 5)
     654    case NPNVSupportsWindowlessLocal:
     655        *static_cast<NPBool*>(value) = true;
     656        *result = NPERR_NO_ERROR;
     657        return true;
     658#endif
     659
    590660    default:
    591661        return false;
Note: See TracChangeset for help on using the changeset viewer.