Changeset 65530 in webkit


Ignore:
Timestamp:
Aug 17, 2010 12:05:02 PM (14 years ago)
Author:
Martin Robinson
Message:

2010-08-17 Martin Robinson <mrobinson@igalia.com>

Reviewed by David Hyatt.

[Cairo] Remove unnecessary full-surface copies from ImageCairo and GraphicsContextCairo
https://bugs.webkit.org/show_bug.cgi?id=44076

No new tests as functionality has not changed.

  • GNUmakefile.am: Added GRefPtrCairo to the sources list.
  • platform/graphics/cairo/GRefPtrCairo.cpp: Added. (WTF::refGPtr): Added specializations for cairo_t and cairo_surface_t. (WTF::derefGPtr):
  • platform/graphics/cairo/GRefPtrCairo.h: Added.
  • platform/graphics/cairo/GraphicsContextCairo.cpp: (WebCore::GraphicsContext::createPlatformShadow): Access the image surface directly from the ImageBuffer instead of wrapping it in an Image.
  • platform/graphics/cairo/ImageCairo.cpp: (WebCore::Image::drawPattern): Create the temporary surface using cairo primitives instead of through the platform-independent WebCore code.
Location:
trunk/WebCore
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r65529 r65530  
     12010-08-17  Martin Robinson  <mrobinson@igalia.com>
     2
     3        Reviewed by David Hyatt.
     4
     5        [Cairo] Remove unnecessary full-surface copies from ImageCairo and GraphicsContextCairo
     6        https://bugs.webkit.org/show_bug.cgi?id=44076
     7
     8        No new tests as functionality has not changed.
     9
     10        * GNUmakefile.am: Added GRefPtrCairo to the sources list.
     11        * platform/graphics/cairo/GRefPtrCairo.cpp: Added.
     12        (WTF::refGPtr): Added specializations for cairo_t and cairo_surface_t.
     13        (WTF::derefGPtr):
     14        * platform/graphics/cairo/GRefPtrCairo.h: Added.
     15        * platform/graphics/cairo/GraphicsContextCairo.cpp:
     16        (WebCore::GraphicsContext::createPlatformShadow): Access the image surface directly
     17        from the ImageBuffer instead of wrapping it in an Image.
     18        * platform/graphics/cairo/ImageCairo.cpp:
     19        (WebCore::Image::drawPattern): Create the temporary surface using cairo primitives
     20        instead of through the platform-independent WebCore code.
     21
    1222010-08-17  Martin Robinson  <mrobinson@igalia.com>
    223
  • trunk/WebCore/GNUmakefile.am

    r65529 r65530  
    24452445        WebCore/platform/graphics/cairo/GOwnPtrCairo.cpp \
    24462446        WebCore/platform/graphics/cairo/GOwnPtrCairo.h \
     2447        WebCore/platform/graphics/cairo/GRefPtrCairo.cpp \
     2448        WebCore/platform/graphics/cairo/GRefPtrCairo.h \
    24472449        WebCore/platform/graphics/cairo/GradientCairo.cpp \
    24482450        WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp \
  • trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp

    r65451 r65530  
    929929    if (!kernelSize) {
    930930        setColor(cr, shadowColor);
    931         RefPtr<Image> copiedImage = buffer->copyImage(); // FIXME: Copying the image is wasteful.
    932         cairo_mask_surface(cr, copiedImage->nativeImageForCurrentFrame(), shadowRect.x(), shadowRect.y());
     931        cairo_mask_surface(cr, buffer->m_data.m_surface, shadowRect.x(), shadowRect.y());
    933932        return;
    934933    }
     
    950949    // Masking makes it possible to just blur the alpha channel.
    951950    setColor(cr, shadowColor);
    952     RefPtr<Image> copiedImage = blur->resultImage()->copyImage(); // FIXME: Copying the image is wasteful.
    953     cairo_mask_surface(cr, copiedImage->nativeImageForCurrentFrame(), shadowRect.x(), shadowRect.y());
     951    cairo_mask_surface(cr, blur->resultImage()->m_data.m_surface, shadowRect.x(), shadowRect.y());
    954952#endif
    955953}
  • trunk/WebCore/platform/graphics/cairo/ImageCairo.cpp

    r65454 r65530  
    3434#include "Color.h"
    3535#include "FloatRect.h"
     36#include "GRefPtrCairo.h"
    3637#include "GraphicsContext.h"
    3738#include "ImageBuffer.h"
     
    185186    context->save();
    186187
    187     IntRect imageSize = enclosingIntRect(tileRect);
    188     OwnPtr<ImageBuffer> imageSurface = ImageBuffer::create(imageSize.size());
    189 
    190     if (!imageSurface)
    191         return;
    192 
     188    GRefPtr<cairo_surface_t> clippedImageSurface = 0;
    193189    if (tileRect.size() != size()) {
    194         cairo_t* clippedImageContext = imageSurface->context()->platformContext();
    195         cairo_set_source_surface(clippedImageContext, image, -tileRect.x(), -tileRect.y());
    196         cairo_paint(clippedImageContext);
    197         RefPtr<Image> copiedImage = imageSurface->copyImage(); // FIXME: Copying here is wasteful.
    198         image = copiedImage->nativeImageForCurrentFrame();
     190        IntRect imageSize = enclosingIntRect(tileRect);
     191        clippedImageSurface = adoptGRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, imageSize.width(), imageSize.height()));
     192        GRefPtr<cairo_t> clippedImageContext(cairo_create(clippedImageSurface.get()));
     193        cairo_set_source_surface(clippedImageContext.get(), image, -tileRect.x(), -tileRect.y());
     194        cairo_paint(clippedImageContext.get());
     195        image = clippedImageSurface.get();
    199196    }
    200197
Note: See TracChangeset for help on using the changeset viewer.