[webkit-help] [SOLVED] Finding "visible" region of element, or preventing overlap in layout

Konstantin Tokarev annulen at yandex.ru
Wed Feb 22 01:18:46 PST 2012


I've solved my problem by clearing contents of rectangle of video element while keeping the region available for further drawing.

I'm using QtWebKit port and my code is like this:

void MediaPlayerPrivateXXX::paint(GraphicsContext *context, const IntRect &rect)
{
    if (context->paintingDisabled())
        return;

    if (!m_isVisible)
        return;

    QPainter* painter = context->platformContext();
    QRect qrect = QRect(rect);
    if (paused()) {
        // draw captured image of paused frame
    } else {
        painter->save();
        painter->setBrush(QBrush(Qt::transparent));
    // The next line is the key
        painter->setCompositionMode(QPainter::CompositionMode_Clear);
        painter->drawRect(qrect);
        painter->restore();
    }
}

It works equally with or without enabled accelerated compositing.

-- 
Regards,
Konstantin


More information about the webkit-help mailing list