Changeset 53318 in webkit


Ignore:
Timestamp:
Jan 14, 2010 9:10:59 PM (14 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/6020083> -webkit-gradient slows down scrolling when page has horizontal scrollbar
https://bugs.webkit.org/show_bug.cgi?id=19650

Reviewed by Simon Fraser.

  • platform/graphics/GeneratedImage.cpp:

(WebCore::GeneratedImage::drawPattern): Added call to adjustParametersForTiledDrawing(),
letting the generator substitute the parameters with visually-equivalent values that
are more efficient.

  • platform/graphics/Generator.h:

(WebCore::Generator::adjustParametersForTiledDrawing): Added a base class implementation
that does nothing.

  • platform/graphics/Gradient.cpp:

(WebCore::Gradient::adjustParametersForTiledDrawing): Added. If the gradient is a horizontal
or vertical linear gradient, changes to use a 1-pixel tall (or wide) tile.

  • platform/graphics/Gradient.h:
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53315 r53318  
     12010-01-14  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Simon Fraser.
     4
     5        <rdar://problem/6020083> -webkit-gradient slows down scrolling when page has horizontal scrollbar
     6        https://bugs.webkit.org/show_bug.cgi?id=19650
     7
     8        * platform/graphics/GeneratedImage.cpp:
     9        (WebCore::GeneratedImage::drawPattern): Added call to adjustParametersForTiledDrawing(),
     10        letting the generator substitute the parameters with visually-equivalent values that
     11        are more efficient.
     12        * platform/graphics/Generator.h:
     13        (WebCore::Generator::adjustParametersForTiledDrawing): Added a base class implementation
     14        that does nothing.
     15        * platform/graphics/Gradient.cpp:
     16        (WebCore::Gradient::adjustParametersForTiledDrawing): Added. If the gradient is a horizontal
     17        or vertical linear gradient, changes to use a 1-pixel tall (or wide) tile.
     18        * platform/graphics/Gradient.h:
     19
    1202010-01-14  Norbert Leser  <norbert.leser@nokia.com>
    221
  • trunk/WebCore/platform/graphics/GeneratedImage.cpp

    r52229 r53318  
    11/*
    2  * Copyright (C) 2008 Apple Computer, Inc. All rights reserved.
     2 * Copyright (C) 2008, 2009, 2010 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    1111 *    documentation and/or other materials provided with the distribution.
    1212 *
    13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
    14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
    17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
    21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     23 * THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
     
    5151                                 const FloatPoint& phase, ColorSpace styleColorSpace, CompositeOperator compositeOp, const FloatRect& destRect)
    5252{
     53    // Allow the generator to provide visually-equivalent tiling parameters for better performance.
     54    IntSize adjustedSize = m_size;
     55    FloatRect adjustedSrcRect = srcRect;
     56    m_generator->adjustParametersForTiledDrawing(adjustedSize, adjustedSrcRect);
     57
    5358    // Create a BitmapImage and call drawPattern on it.
    54     OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(m_size);
     59    OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(adjustedSize);
    5560    ASSERT(imageBuffer.get());
    56    
     61
    5762    // Fill with the gradient.
    5863    GraphicsContext* graphicsContext = imageBuffer->context();
    59     graphicsContext->fillRect(FloatRect(FloatPoint(), m_size), *m_generator.get());
    60    
     64    graphicsContext->fillRect(FloatRect(FloatPoint(), adjustedSize), *m_generator.get());
     65
    6166    // Grab the final image from the image buffer.
    6267    Image* bitmap = imageBuffer->image();
    63    
     68
    6469    // Now just call drawTiled on that image.
    65     bitmap->drawPattern(context, srcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
     70    bitmap->drawPattern(context, adjustedSrcRect, patternTransform, phase, styleColorSpace, compositeOp, destRect);
    6671}
    6772
  • trunk/WebCore/platform/graphics/Generator.h

    r35966 r53318  
    3939   
    4040    virtual void fill(GraphicsContext*, const FloatRect&) = 0;
     41    virtual void adjustParametersForTiledDrawing(IntSize& /* size */, FloatRect& /* srcRect */) { }
    4142};
    4243
  • trunk/WebCore/platform/graphics/Gradient.cpp

    r46017 r53318  
    11/*
    2  * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2006, 2007, 2008, 2010 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
    44 *
     
    2929
    3030#include "Color.h"
     31#include "FloatRect.h"
     32#include <wtf/UnusedParam.h>
    3133
    3234namespace WebCore {
     
    6163{
    6264    platformDestroy();
     65}
     66
     67void Gradient::adjustParametersForTiledDrawing(IntSize& size, FloatRect& srcRect)
     68{
     69    if (m_radial)
     70        return;
     71
     72    if (srcRect.isEmpty())
     73        return;
     74
     75    if (m_p0.x() == m_p1.x()) {
     76        size.setWidth(1);
     77        srcRect.setWidth(1);
     78        srcRect.setX(0);
     79        return;
     80    }
     81    if (m_p0.y() != m_p1.y())
     82        return;
     83
     84    size.setHeight(1);
     85    srcRect.setHeight(1);
     86    srcRect.setY(0);
    6387}
    6488
  • trunk/WebCore/platform/graphics/Gradient.h

    r52791 r53318  
    106106
    107107        virtual void fill(GraphicsContext*, const FloatRect&);
     108        virtual void adjustParametersForTiledDrawing(IntSize& size, FloatRect& srcRect);
     109
    108110        void setPlatformGradientSpaceTransform(const TransformationMatrix& gradientSpaceTransformation);
    109111
Note: See TracChangeset for help on using the changeset viewer.