Changeset 191117 in webkit


Ignore:
Timestamp:
Oct 15, 2015, 10:20:10 AM (10 years ago)
Author:
Simon Fraser
Message:

Move ImageBuffer:clip() into GraphicsContextCG
https://bugs.webkit.org/show_bug.cgi?id=150140

Reviewed by Zalan Bujtas.

Move the guts of CG's ImageBuffer:clip() into GraphicsContextCG.

  • platform/graphics/GraphicsContext.h:
  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::clipToNativeImage):

  • platform/graphics/cg/ImageBufferCG.cpp:

(WebCore::ImageBuffer::clip):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r191114 r191117  
     12015-10-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Move ImageBuffer:clip() into GraphicsContextCG
     4        https://bugs.webkit.org/show_bug.cgi?id=150140
     5
     6        Reviewed by Zalan Bujtas.
     7
     8        Move the guts of CG's ImageBuffer:clip() into GraphicsContextCG.
     9
     10        * platform/graphics/GraphicsContext.h:
     11        * platform/graphics/cg/GraphicsContextCG.cpp:
     12        (WebCore::GraphicsContext::clipToNativeImage):
     13        * platform/graphics/cg/ImageBufferCG.cpp:
     14        (WebCore::ImageBuffer::clip):
     15
    1162015-10-14  Brady Eidson  <beidson@apple.com>
    217
  • trunk/Source/WebCore/platform/graphics/GraphicsContext.h

    r191049 r191117  
    263263        WEBCORE_EXPORT void drawNativeImage(PassNativeImagePtr, const FloatSize& selfSize, ColorSpace styleColorSpace, const FloatRect& destRect, const FloatRect& srcRect, CompositeOperator = CompositeSourceOver, BlendMode = BlendModeNormal, ImageOrientation = DefaultImageOrientation);
    264264
     265        void clipToNativeImage(PassNativeImagePtr, const FloatRect& destRect, const FloatSize& bufferSize);
     266
    265267        // Allow font smoothing (LCD antialiasing). Not part of the graphics state.
    266268        void setAllowsFontSmoothing(bool);
  • trunk/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r191000 r191117  
    346346}
    347347
     348void GraphicsContext::clipToNativeImage(PassNativeImagePtr image, const FloatRect& destRect, const FloatSize& bufferSize)
     349{
     350    CGContextRef context = platformContext();
     351    // FIXME: This image needs to be grayscale to be used as an alpha mask here.
     352    CGContextTranslateCTM(context, destRect.x(), destRect.y() + bufferSize.height());
     353    CGContextScaleCTM(context, 1, -1);
     354    CGContextClipToRect(context, FloatRect(FloatPoint(0, bufferSize.height() - destRect.height()), destRect.size()));
     355    CGContextClipToMask(context, FloatRect(FloatPoint(), bufferSize), image);
     356    CGContextScaleCTM(context, 1, -1);
     357    CGContextTranslateCTM(context, -destRect.x(), -destRect.y() - destRect.height());
     358}
     359
    348360// Draws a filled rectangle with a stroked border.
    349361void GraphicsContext::drawRect(const FloatRect& rect, float borderThickness)
  • trunk/Source/WebCore/platform/graphics/cg/ImageBufferCG.cpp

    r190910 r191117  
    267267{
    268268    FloatSize backingStoreSizeInUserSpace = scaleSizeToUserSpace(rect.size(), m_data.backingStoreSize, internalSize());
    269 
    270     CGContextRef platformContextToClip = contextToClip.platformContext();
    271     // FIXME: This image needs to be grayscale to be used as an alpha mask here.
    272269    RetainPtr<CGImageRef> image = copyNativeImage(DontCopyBackingStore);
    273     CGContextTranslateCTM(platformContextToClip, rect.x(), rect.y() + backingStoreSizeInUserSpace.height());
    274     CGContextScaleCTM(platformContextToClip, 1, -1);
    275     CGContextClipToRect(platformContextToClip, FloatRect(FloatPoint(0, backingStoreSizeInUserSpace.height() - rect.height()), rect.size()));
    276     CGContextClipToMask(platformContextToClip, FloatRect(FloatPoint(), backingStoreSizeInUserSpace), image.get());
    277     CGContextScaleCTM(platformContextToClip, 1, -1);
    278     CGContextTranslateCTM(platformContextToClip, -rect.x(), -rect.y() - rect.height());
     270    contextToClip.clipToNativeImage(image.get(), rect, backingStoreSizeInUserSpace);
    279271}
    280272
Note: See TracChangeset for help on using the changeset viewer.