Changeset 86269 in webkit


Ignore:
Timestamp:
May 11, 2011 2:17:50 PM (13 years ago)
Author:
noam.rosenthal@nokia.com
Message:

2011-05-11 Noam Rosenthal <noam.rosenthal@nokia.com>

Reviewed by Kenneth Rohde Christiansen.

[Texmap][Qt] Upstream texture-mapper changes from Qt's WebKit2 branch
https://bugs.webkit.org/show_bug.cgi?id=60439

Patch 5/12: Implement the new TextureMapper functions for the Qt backend.
This allow non-rectangular clipping, some stub functions, and getting a unique
id for an image.

No new tests. Tests in LayoutTests/compositing cover this.

  • platform/graphics/qt/TextureMapperQt.cpp: (WebCore::TextureMapperQt::beginClip): (WebCore::TextureMapperQt::endClip): (WebCore::TextureMapperQt::viewportSize): (WebCore::TextureMapperQt::setGraphicsContext): (WebCore::TextureMapperQt::graphicsContext): (WebCore::TextureMapperQt::drawTexture): (WebCore::TextureMapperQt::beginPainting): (WebCore::TextureMapperQt::endPainting): (WebCore::RGBA32PremultimpliedBufferQt::beginPaint): (WebCore::uidForImage):
  • platform/graphics/qt/TextureMapperQt.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r86266 r86269  
    33        Reviewed by Kenneth Rohde Christiansen.
    44
    5 
    65        [Texmap][Qt] Upstream texture-mapper changes from Qt's WebKit2 branch
     6        https://bugs.webkit.org/show_bug.cgi?id=60439
     7
     8        Patch 5/12: Implement the new TextureMapper functions for the Qt backend.
     9        This allow non-rectangular clipping, some stub functions, and getting a unique
     10        id for an image.
     11
     12        No new tests. Tests in LayoutTests/compositing cover this.
     13
     14        * platform/graphics/qt/TextureMapperQt.cpp:
     15        (WebCore::TextureMapperQt::beginClip):
     16        (WebCore::TextureMapperQt::endClip):
     17        (WebCore::TextureMapperQt::viewportSize):
     18        (WebCore::TextureMapperQt::setGraphicsContext):
     19        (WebCore::TextureMapperQt::graphicsContext):
     20        (WebCore::TextureMapperQt::drawTexture):
     21        (WebCore::TextureMapperQt::beginPainting):
     22        (WebCore::TextureMapperQt::endPainting):
     23        (WebCore::RGBA32PremultimpliedBufferQt::beginPaint):
     24        (WebCore::uidForImage):
     25        * platform/graphics/qt/TextureMapperQt.h:
     26
     272011-05-11  Noam Rosenthal  <noam.rosenthal@nokia.com>
     28
     29        Reviewed by Kenneth Rohde Christiansen.
     30
     31        [Texmap] Upstream texture-mapper changes from Qt's WebKit2 branch
    732        https://bugs.webkit.org/show_bug.cgi?id=60439
    833
  • trunk/Source/WebCore/platform/graphics/qt/TextureMapperQt.cpp

    r71538 r86269  
    9999}
    100100
    101 void TextureMapperQt::setClip(const IntRect& rect)
    102 {
    103      QPainter* painter = m_currentSurface ? &m_currentSurface->m_painter : m_painter;
     101void TextureMapperQt::beginClip(const TransformationMatrix& matrix, const FloatRect& rect)
     102{
     103     QPainter* painter = currentPainter();
     104     painter->save();
     105     QTransform prevTransform = painter->transform();
     106     painter->setTransform(matrix, false);
    104107     painter->setClipRect(rect);
    105 }
     108     painter->setTransform(prevTransform, false);
     109}
     110
     111void TextureMapperQt::endClip()
     112{
     113    currentPainter()->restore();
     114}
     115
     116IntSize TextureMapperQt::viewportSize() const
     117{
     118    return IntSize(m_painter->device()->width(), m_painter->device()->height());
     119}
     120
    106121
    107122TextureMapperQt::TextureMapperQt()
     
    112127void TextureMapperQt::setGraphicsContext(GraphicsContext* context)
    113128{
     129    m_context = context;
    114130    m_painter = context->platformContext();
    115131    initialize(m_painter);
     132}
     133
     134GraphicsContext* TextureMapperQt::graphicsContext()
     135{
     136    return m_context;
    116137}
    117138
     
    133154
    134155
    135 void TextureMapperQt::drawTexture(const BitmapTexture& texture, const IntRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* maskTexture)
     156void TextureMapperQt::drawTexture(const BitmapTexture& texture, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* maskTexture)
    136157{
    137158    const BitmapTextureQt& textureQt = static_cast<const BitmapTextureQt&>(texture);
     
    158179    painter->setOpacity(opacity);
    159180    painter->setTransform(matrix, true);
    160     painter->drawPixmap(targetRect, pixmap, textureQt.sourceRect());
     181    painter->drawPixmap(targetRect, pixmap, FloatRect(textureQt.sourceRect()));
    161182    painter->setTransform(prevTransform);
    162183    painter->setOpacity(prevOpacity);
     
    181202{
    182203
     204}
     205
     206void TextureMapperQt::beginPainting()
     207{
     208    m_painter->save();
     209}
     210
     211void TextureMapperQt::endPainting()
     212{
     213    m_painter->restore();
    183214}
    184215
     
    189220    {
    190221        // m_image is only using during paint, it's safe to override it.
    191         m_image = QImage(rect.size().width(), rect.size().height(), QImage::Format_ARGB32_Premultiplied);
     222        m_image = QImage(rect.size().width(), rect.size().height(), opaque ? QImage::Format_RGB32 : QImage::Format_ARGB32_Premultiplied);
    192223        if (!opaque)
    193224            m_image.fill(0);
     
    211242}
    212243
     244uint64_t uidForImage(Image* image)
     245{
     246    return image->nativeImageForCurrentFrame()->serialNumber();
     247}
    213248#endif
    214249};
  • trunk/Source/WebCore/platform/graphics/qt/TextureMapperQt.h

    r71538 r86269  
    4343    virtual bool isPacked() const { return m_isPacked; }
    4444
     45    QPainter* painter() { return &m_painter; }
     46
    4547private:
    4648    QPainter m_painter;
     
    5456    TextureMapperQt();
    5557
    56     virtual void drawTexture(const BitmapTexture& texture, const IntRect& targetRect, const TransformationMatrix& matrix, float opacity, const BitmapTexture* maskTexture);
     58    virtual void drawTexture(const BitmapTexture&, const FloatRect& targetRect, const TransformationMatrix&, float opacity, const BitmapTexture* maskTexture);
    5759    virtual void bindSurface(BitmapTexture* surface);
    58     virtual void setClip(const IntRect&);
     60    virtual void beginClip(const TransformationMatrix&, const FloatRect&);
     61    virtual void endClip();
    5962    virtual void setGraphicsContext(GraphicsContext*);
     63    virtual GraphicsContext* graphicsContext();
    6064    virtual bool allowSurfaceForRoot() const { return false; }
    6165    virtual PassRefPtr<BitmapTexture> createTexture();
     66    virtual IntSize viewportSize() const;
     67    virtual void beginPainting();
     68    virtual void endPainting();
    6269
    6370    static void initialize(QPainter* painter)
     
    6774
    6875    static PassOwnPtr<TextureMapper> create() { return new TextureMapperQt; }
     76private:
     77    inline QPainter* currentPainter() { return m_currentSurface ? m_currentSurface->painter() : m_painter; }
    6978
    70 private:
    7179    QPainter* m_painter;
     80    GraphicsContext* m_context;
    7281    RefPtr<BitmapTextureQt> m_currentSurface;
    7382};
Note: See TracChangeset for help on using the changeset viewer.