Changeset 74220 in webkit


Ignore:
Timestamp:
Dec 16, 2010 5:44:53 PM (13 years ago)
Author:
ariya@webkit.org
Message:

2010-12-16 Ariya Hidayat <ariya@sencha.com>

Reviewed by Andreas Kling.

[Qt] GraphicsContext should respect QWebView render hints
https://bugs.webkit.org/show_bug.cgi?id=51208

GraphicsContext does not override SmoothPixmapTransform (see also
r62762). To keep the same behavior, canvas default image interpolation
quality is set to medium and QWebView's render hints by default also
include SmoothPixmapTransform.

  • html/HTMLCanvasElement.h:
  • platform/graphics/qt/GraphicsContextQt.cpp: (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):

2010-12-16 Ariya Hidayat <ariya@sencha.com>

Reviewed by Andreas Kling.

[Qt] GraphicsContext should respect QWebView render hints
https://bugs.webkit.org/show_bug.cgi?id=51208

Add some checks to ensure that GraphicsContext (via QWebFrame)
does not clobber the render hints.

  • Api/qwebview.cpp: (QWebViewPrivate::QWebViewPrivate):
  • tests/qwebframe/tst_qwebframe.cpp:
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r74218 r74220  
     12010-12-16  Ariya Hidayat  <ariya@sencha.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] GraphicsContext should respect QWebView render hints
     6        https://bugs.webkit.org/show_bug.cgi?id=51208
     7
     8        GraphicsContext does not override SmoothPixmapTransform (see also
     9        r62762). To keep the same behavior, canvas default image interpolation
     10        quality is set to medium and QWebView's render hints by default also
     11        include SmoothPixmapTransform.
     12
     13        * html/HTMLCanvasElement.h:
     14        * platform/graphics/qt/GraphicsContextQt.cpp:
     15        (WebCore::GraphicsContextPlatformPrivate::GraphicsContextPlatformPrivate):
     16
    1172010-12-16  Daniel Bates  <dbates@rim.com>
    218
  • trunk/WebCore/html/HTMLCanvasElement.h

    r73927 r74220  
    3333#include "IntSize.h"
    3434
    35 #if PLATFORM(CHROMIUM)
     35#if PLATFORM(CHROMIUM) || PLATFORM(QT)
    3636#define DefaultInterpolationQuality InterpolationMedium
    3737#elif PLATFORM(CG)
  • trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp

    r74187 r74220  
    238238    antiAliasingForRectsAndLines = painter->testRenderHint(QPainter::Antialiasing);
    239239
    240     painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true);
     240    painter->setRenderHint(QPainter::Antialiasing, true);
    241241}
    242242
  • trunk/WebKit/qt/Api/qwebview.cpp

    r73867 r74220  
    4040        : view(view)
    4141        , page(0)
    42         , renderHints(QPainter::TextAntialiasing)
     42        , renderHints(QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform)
    4343    {
    4444        Q_ASSERT(view);
     
    714714    These hints are used to initialize QPainter before painting the Web page.
    715715
    716     QPainter::TextAntialiasing is enabled by default.
     716    QPainter::TextAntialiasing and QPainter::SmoothPixmapTransform are enabled by default.
    717717
    718718    \note This property is not available on Symbian. However, the getter and
  • trunk/WebKit/qt/ChangeLog

    r74173 r74220  
     12010-12-16  Ariya Hidayat  <ariya@sencha.com>
     2
     3        Reviewed by Andreas Kling.
     4
     5        [Qt] GraphicsContext should respect QWebView render hints
     6        https://bugs.webkit.org/show_bug.cgi?id=51208
     7
     8        Add some checks to ensure that GraphicsContext (via QWebFrame)
     9        does not clobber the render hints.
     10
     11        * Api/qwebview.cpp:
     12        (QWebViewPrivate::QWebViewPrivate):
     13        * tests/qwebframe/tst_qwebframe.cpp:
     14
    1152010-12-15  Laszlo Gombos  <laszlo.1.gombos@nokia.com>
    216
  • trunk/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp

    r73865 r74220  
    3030#include <QApplication>
    3131#include <QComboBox>
     32#include <QPaintEngine>
    3233#include <QPicture>
    3334#include <QRegExp>
     
    617618    void hasSetFocus();
    618619    void render();
     620    void renderHints();
    619621    void scrollPosition();
    620622    void scrollToAnchor();
     
    28582860}
    28592861
     2862
     2863class DummyPaintEngine: public QPaintEngine {
     2864public:
     2865
     2866    DummyPaintEngine()
     2867        : QPaintEngine(QPaintEngine::AllFeatures)
     2868        , renderHints(0)
     2869    {
     2870    }
     2871
     2872    bool begin(QPaintDevice*)
     2873    {
     2874        setActive(true);
     2875        return true;
     2876    }
     2877
     2878    bool end()
     2879    {
     2880        setActive(false);
     2881        return false;
     2882    }
     2883
     2884    void updateState(const QPaintEngineState& state)
     2885    {
     2886        renderHints = state.renderHints();
     2887    }
     2888
     2889    void drawPath(const QPainterPath&) { }
     2890    void drawPixmap(const QRectF&, const QPixmap&, const QRectF&) { }
     2891
     2892    QPaintEngine::Type type() const
     2893    {
     2894        return static_cast<QPaintEngine::Type>(QPaintEngine::User + 2);
     2895    }
     2896
     2897    QPainter::RenderHints renderHints;
     2898};
     2899
     2900class DummyPaintDevice: public QPaintDevice {
     2901public:
     2902    DummyPaintDevice()
     2903        : QPaintDevice()
     2904        , m_engine(new DummyPaintEngine)
     2905    {
     2906    }
     2907
     2908    ~DummyPaintDevice()
     2909    {
     2910        delete m_engine;
     2911    }
     2912
     2913    QPaintEngine* paintEngine() const
     2914    {
     2915        return m_engine;
     2916    }
     2917
     2918    QPainter::RenderHints renderHints() const
     2919    {
     2920        return m_engine->renderHints;
     2921    }
     2922
     2923protected:
     2924    int metric(PaintDeviceMetric metric) const;
     2925
     2926private:
     2927    DummyPaintEngine* m_engine;
     2928    friend class DummyPaintEngine;
     2929};
     2930
     2931
     2932int DummyPaintDevice::metric(PaintDeviceMetric metric) const
     2933{
     2934    switch (metric) {
     2935    case PdmWidth:
     2936        return 400;
     2937        break;
     2938
     2939    case PdmHeight:
     2940        return 200;
     2941        break;
     2942
     2943    case PdmNumColors:
     2944        return INT_MAX;
     2945        break;
     2946
     2947    case PdmDepth:
     2948        return 32;
     2949        break;
     2950
     2951    default:
     2952        break;
     2953    }
     2954    return 0;
     2955}
     2956
     2957void tst_QWebFrame::renderHints()
     2958{
     2959    QString html("<html><body><p>Hello, world!</p></body></html>");
     2960
     2961    QWebPage page;
     2962    page.mainFrame()->setHtml(html);
     2963    page.setViewportSize(page.mainFrame()->contentsSize());
     2964
     2965    // We will call frame->render and trap the paint engine state changes
     2966    // to ensure that GraphicsContext does not clobber the render hints.
     2967    DummyPaintDevice buffer;
     2968    QPainter painter(&buffer);
     2969
     2970    painter.setRenderHint(QPainter::TextAntialiasing, false);
     2971    page.mainFrame()->render(&painter);
     2972    QVERIFY(!(buffer.renderHints() & QPainter::TextAntialiasing));
     2973    QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform));
     2974    QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing));
     2975
     2976    painter.setRenderHint(QPainter::TextAntialiasing, true);
     2977    page.mainFrame()->render(&painter);
     2978    QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing);
     2979    QVERIFY(!(buffer.renderHints() & QPainter::SmoothPixmapTransform));
     2980    QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing));
     2981
     2982    painter.setRenderHint(QPainter::SmoothPixmapTransform, true);
     2983    page.mainFrame()->render(&painter);
     2984    QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing);
     2985    QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform);
     2986    QVERIFY(!(buffer.renderHints() & QPainter::HighQualityAntialiasing));
     2987
     2988    painter.setRenderHint(QPainter::HighQualityAntialiasing, true);
     2989    page.mainFrame()->render(&painter);
     2990    QVERIFY(buffer.renderHints() & QPainter::TextAntialiasing);
     2991    QVERIFY(buffer.renderHints() & QPainter::SmoothPixmapTransform);
     2992    QVERIFY(buffer.renderHints() & QPainter::HighQualityAntialiasing);
     2993}
     2994
    28602995void tst_QWebFrame::scrollPosition()
    28612996{
Note: See TracChangeset for help on using the changeset viewer.