Changeset 69187 in webkit


Ignore:
Timestamp:
Oct 6, 2010 5:47:28 AM (13 years ago)
Author:
krit@webkit.org
Message:

2010-10-06 Dirk Schulze <krit@webkit.org>

Unreviewed fix of Cairo ports.

SVGs with filters look grainy when scaled
https://bugs.webkit.org/show_bug.cgi?id=5526

Fixed issues on Cairos shadow implementation after the changes to FilterEffects.
Cairo calculates the inflation of the effect rect itself. Respect this for FEGaussianBlur.
This is just a temporary solution, since Cairo and Qt will use ContextShadow soon.

  • platform/graphics/GraphicsContext.h:
  • platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::drawBorderlessRectShadow): (WebCore::GraphicsContext::applyPlatformShadow): (WebCore::GraphicsContext::createShadowMask): (WebCore::GraphicsContext::drawTiledShadow): (WebCore::GraphicsContext::fillRoundedRect):
  • platform/graphics/filters/ImageBufferFilter.cpp: (WebCore::ImageBufferFilter::ImageBufferFilter): (WebCore::ImageBufferFilter::create):
  • platform/graphics/filters/ImageBufferFilter.h: (WebCore::ImageBufferFilter::filterRegion): (WebCore::ImageBufferFilter::sourceImageRect):
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69186 r69187  
     12010-10-06  Dirk Schulze  <krit@webkit.org>
     2
     3        Unreviewed fix of Cairo ports.
     4
     5        SVGs with filters look grainy when scaled
     6        https://bugs.webkit.org/show_bug.cgi?id=5526
     7
     8        Fixed issues on Cairos shadow implementation after the changes to FilterEffects.
     9        Cairo calculates the inflation of the effect rect itself. Respect this for FEGaussianBlur.
     10        This is just a temporary solution, since Cairo and Qt will use ContextShadow soon.
     11
     12        * platform/graphics/GraphicsContext.h:
     13        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     14        (WebCore::drawBorderlessRectShadow):
     15        (WebCore::GraphicsContext::applyPlatformShadow):
     16        (WebCore::GraphicsContext::createShadowMask):
     17        (WebCore::GraphicsContext::drawTiledShadow):
     18        (WebCore::GraphicsContext::fillRoundedRect):
     19        * platform/graphics/filters/ImageBufferFilter.cpp:
     20        (WebCore::ImageBufferFilter::ImageBufferFilter):
     21        (WebCore::ImageBufferFilter::create):
     22        * platform/graphics/filters/ImageBufferFilter.h:
     23        (WebCore::ImageBufferFilter::filterRegion):
     24        (WebCore::ImageBufferFilter::sourceImageRect):
     25
    1262010-10-06  Nikolas Zimmermann  <nzimmermann@rim.com>
    227
  • trunk/WebCore/platform/graphics/GraphicsContext.h

    r68221 r69187  
    299299#if PLATFORM(CAIRO)
    300300        float getAlpha();
    301         void applyPlatformShadow(PassOwnPtr<ImageBuffer> buffer, const Color& shadowColor, const FloatRect& shadowRect, float radius);
    302         PlatformRefPtr<cairo_surface_t> createShadowMask(PassOwnPtr<ImageBuffer>, const FloatRect&, float radius);
     301        void applyPlatformShadow(PassOwnPtr<ImageBuffer> buffer, const Color& shadowColor, FloatRect& shadowRect, float radius);
     302        PlatformRefPtr<cairo_surface_t> createShadowMask(PassOwnPtr<ImageBuffer>, FloatRect&, float radius);
    303303
    304304        static void calculateShadowBufferDimensions(IntSize& shadowBufferSize, FloatRect& shadowRect, float& radius, const FloatRect& sourceRect, const FloatSize& shadowOffset, float shadowBlur);
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r69181 r69187  
    611611        return;
    612612
    613     AffineTransform transform = context->getCTM();
    614     // drawTiledShadow still does not work with rotations.
    615     if ((transform.isIdentityOrTranslationOrFlipped())) {
    616         cairo_t* cr = context->platformContext();
    617         cairo_save(cr);
    618         appendWebCorePathToCairoContext(cr, Path::createRectangle(rect));
    619         FloatSize corner;
    620         IntRect shadowRect(rect);
    621         context->drawTiledShadow(shadowRect, corner, corner, corner, corner, DeviceColorSpace);
    622         cairo_restore(cr);
    623 
    624         return;
    625     }
    626 
    627613    IntSize shadowBufferSize;
    628614    FloatRect shadowRect;
     
    921907}
    922908
    923 void GraphicsContext::applyPlatformShadow(PassOwnPtr<ImageBuffer> buffer, const Color& shadowColor, const FloatRect& shadowRect, float radius)
     909void GraphicsContext::applyPlatformShadow(PassOwnPtr<ImageBuffer> buffer, const Color& shadowColor, FloatRect& shadowRect, float radius)
    924910{
    925911#if ENABLE(FILTERS)
     
    930916}
    931917
    932 PlatformRefPtr<cairo_surface_t> GraphicsContext::createShadowMask(PassOwnPtr<ImageBuffer> buffer, const FloatRect& shadowRect, float radius)
     918PlatformRefPtr<cairo_surface_t> GraphicsContext::createShadowMask(PassOwnPtr<ImageBuffer> buffer, FloatRect& shadowRect, float radius)
    933919{
    934920#if ENABLE(FILTERS)
     
    942928
    943929    // create filter
    944     RefPtr<Filter> filter = ImageBufferFilter::create();
     930    IntRect filterRegion = IntRect(IntPoint(), roundedIntSize(shadowRect.size()));
     931    RefPtr<Filter> filter = ImageBufferFilter::create(filterRegion);
    945932    filter->setSourceImage(buffer);
    946933    RefPtr<FilterEffect> source = SourceGraphic::create();
    947     source->setAbsolutePaintRect(IntRect(IntPoint(), roundedIntSize(shadowRect.size())));
    948934    source->setIsAlphaImage(true);
    949935    RefPtr<FilterEffect> blur = FEGaussianBlur::create(stdDeviation, stdDeviation);
     936    blur->setMaxEffectRect(filterRegion);
    950937    FilterEffectVector& inputEffects = blur->inputEffects();
    951938    inputEffects.append(source.get());
    952     blur->setAbsolutePaintRect(IntRect(IntPoint(), roundedIntSize(shadowRect.size())));
    953939    blur->apply(filter.get());
     940
     941    // Calculate shadow region for context
     942    shadowRect.move(blur->absolutePaintRect().location().x(), blur->absolutePaintRect().location().y());
     943    shadowRect.setSize(blur->absolutePaintRect().size());
    954944    return blur->resultImage()->m_data.m_surface;
    955945#endif
     
    12811271        return;
    12821272
    1283     IntRect smallRect = IntRect(blurRadius, blurRadius, smallBufferSize.width() - radiusTwice, smallBufferSize.height() - radiusTwice);
     1273    FloatRect smallRect = FloatRect(blurRadius, blurRadius, smallBufferSize.width() - radiusTwice, smallBufferSize.height() - radiusTwice);
    12841274
    12851275    // Draw shadow into a new ImageBuffer.
     
    13861376    appendWebCorePathToCairoContext(cr, Path::createRoundedRectangle(r, topLeft, topRight, bottomLeft, bottomRight));
    13871377    setColor(cr, color);
    1388     AffineTransform transform = this->getCTM();
    1389     // drawTiledShadow still does not work with rotations.
    1390     if (transform.isIdentityOrTranslationOrFlipped())
    1391         drawTiledShadow(r, topLeft, topRight, bottomLeft, bottomRight, colorSpace);
    1392     else
    1393         drawPathShadow(this, m_common, true, false);
     1378    drawPathShadow(this, m_common, true, false);
    13941379    cairo_fill(cr);
    13951380    cairo_restore(cr);
  • trunk/WebCore/platform/graphics/filters/ImageBufferFilter.cpp

    r67929 r69187  
    2828namespace WebCore {
    2929
    30 ImageBufferFilter::ImageBufferFilter()
     30ImageBufferFilter::ImageBufferFilter(const FloatRect& sourceImageRect)
    3131    : Filter()
     32    , m_sourceImageRect(sourceImageRect)
    3233{
    33     setFilterResolution(FloatSize(1.f, 1.f));
     34    setFilterResolution(FloatSize(1, 1));
    3435}
    3536
    36 PassRefPtr<ImageBufferFilter> ImageBufferFilter::create()
     37PassRefPtr<ImageBufferFilter> ImageBufferFilter::create(const FloatRect& sourceImageRect)
    3738{
    38     return adoptRef(new ImageBufferFilter());
     39    return adoptRef(new ImageBufferFilter(sourceImageRect));
    3940}
    4041
  • trunk/WebCore/platform/graphics/filters/ImageBufferFilter.h

    r67929 r69187  
    3636class ImageBufferFilter : public Filter {
    3737public:
    38     static PassRefPtr<ImageBufferFilter> create();
     38    static PassRefPtr<ImageBufferFilter> create(const FloatRect&);
    3939
    40     virtual FloatRect filterRegion() const { return FloatRect(); }
    41     virtual FloatRect sourceImageRect() const { return FloatRect(); }
     40    virtual FloatRect filterRegion() const { return m_sourceImageRect; }
     41    virtual FloatRect sourceImageRect() const { return m_sourceImageRect; }
    4242
    4343    // SVG specific
     
    4848
    4949private:
    50     ImageBufferFilter();
     50    ImageBufferFilter(const FloatRect&);
     51
     52    FloatRect m_sourceImageRect;
    5153};
    5254
Note: See TracChangeset for help on using the changeset viewer.