Changeset 89221 in webkit


Ignore:
Timestamp:
Jun 19, 2011 1:48:17 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-06-19 Una Sabovic <una.sabovic@palm.com>

Reviewed by Darin Adler.

Optimization: avoid call to clearRect() when bgColor is valid when painting the root background in RenderBoxModelObject::paintFillLayerExtended
https://bugs.webkit.org/show_bug.cgi?id=62908

When root layers base color is fully transparent backgroundRect was cleared before bgColor is applied.
Instead of clearing the rect we apply CompositeCopy operation when painting the background color.

No new tests. This is an optimization, it doesn't change any existing functionality.

  • platform/graphics/GraphicsContext.cpp: (WebCore::GraphicsContext::fillRect):
  • platform/graphics/GraphicsContext.h:
  • rendering/RenderBoxModelObject.cpp: (WebCore::RenderBoxModelObject::paintFillLayerExtended):
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89220 r89221  
     12011-06-19  Una Sabovic  <una.sabovic@palm.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        Optimization: avoid call to clearRect() when bgColor is valid when painting the root background in RenderBoxModelObject::paintFillLayerExtended
     6        https://bugs.webkit.org/show_bug.cgi?id=62908
     7
     8        When root layers base color is fully transparent backgroundRect was cleared before bgColor is applied.
     9        Instead of clearing the rect we apply CompositeCopy operation when painting the background color.
     10
     11        No new tests. This is an optimization, it doesn't change any existing functionality.
     12
     13        * platform/graphics/GraphicsContext.cpp:
     14        (WebCore::GraphicsContext::fillRect):
     15        * platform/graphics/GraphicsContext.h:
     16        * rendering/RenderBoxModelObject.cpp:
     17        (WebCore::RenderBoxModelObject::paintFillLayerExtended):
     18
    1192011-06-19  Dirk Schulze  <krit@webkit.org>
    220
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp

    r85853 r89221  
    614614}
    615615
     616void GraphicsContext::fillRect(const FloatRect& rect, const Color& color, ColorSpace styleColorSpace, CompositeOperator op)
     617{
     618    if (paintingDisabled())
     619        return;
     620
     621    CompositeOperator previousOperator = compositeOperation();
     622    setCompositeOperation(op);
     623    fillRect(rect, color, styleColorSpace);
     624    setCompositeOperation(previousOperator);
     625}
     626
    616627void GraphicsContext::fillRoundedRect(const RoundedIntRect& rect, const Color& color, ColorSpace colorSpace)
    617628{
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r87745 r89221  
    294294        void fillRect(const FloatRect&, const Color&, ColorSpace);
    295295        void fillRect(const FloatRect&, Generator&);
     296        void fillRect(const FloatRect&, const Color&, ColorSpace, CompositeOperator);
    296297        void fillRoundedRect(const IntRect&, const IntSize& topLeft, const IntSize& topRight, const IntSize& bottomLeft, const IntSize& bottomRight, const Color&, ColorSpace);
    297298        void fillRoundedRect(const RoundedIntRect&, const Color&, ColorSpace);
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r89057 r89221  
    743743        // If we have an alpha and we are painting the root element, go ahead and blend with the base background color.
    744744        Color baseColor;
     745        bool shouldClearBackground = false;
    745746        if (isOpaqueRoot) {
    746747            baseColor = view()->frameView()->baseBackgroundColor();
    747748            if (!baseColor.alpha())
    748                 context->clearRect(backgroundRect);
    749         }
    750 
    751         if (baseColor.alpha() > 0) {
     749                shouldClearBackground = true;
     750        }
     751
     752        if (baseColor.alpha()) {
    752753            if (bgColor.alpha())
    753754                baseColor = baseColor.blend(bgColor);
    754755
    755             CompositeOperator previousOperator = context->compositeOperation();
    756             context->setCompositeOperation(CompositeCopy);
    757             context->fillRect(backgroundRect, baseColor, style()->colorSpace());
    758             context->setCompositeOperation(previousOperator);
    759         } else if (bgColor.alpha() > 0)
    760             context->fillRect(backgroundRect, bgColor, style()->colorSpace());
     756            context->fillRect(backgroundRect, baseColor, style()->colorSpace(), CompositeCopy);
     757        } else if (bgColor.alpha()) {
     758            CompositeOperator operation = shouldClearBackground ? CompositeCopy : context->compositeOperation();
     759            context->fillRect(backgroundRect, bgColor, style()->colorSpace(), operation);
     760        } else if (shouldClearBackground)
     761            context->clearRect(backgroundRect);
    761762    }
    762763
Note: See TracChangeset for help on using the changeset viewer.