Changeset 36795 in webkit


Ignore:
Timestamp:
Sep 22, 2008 11:05:59 PM (16 years ago)
Author:
eric@webkit.org
Message:

2008-09-22 Dirk Schulze <vbs85@gmx.de>

Reviewed by eseidel. Landed by eseidel.

Moved makeMapBetweenRects from SVG/CG to AffineTransform
Make SVGResourceClipper::applyClip more cross-platform

  • platform/graphics/AffineTransform.cpp:
  • platform/graphics/AffineTransform.h:
  • svg/graphics/cg/CgSupport.cpp:
  • svg/graphics/cg/CgSupport.h:
  • svg/graphics/cg/SVGPaintServerGradientCg.cpp: (WebCore::SVGPaintServerGradient::handleBoundingBoxModeAndGradientTransformation):
  • svg/graphics/cg/SVGResourceClipperCg.cpp: (WebCore::SVGResourceClipper::applyClip):
Location:
trunk/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r36791 r36795  
     12008-09-22  Dirk Schulze  <vbs85@gmx.de>
     2
     3        Reviewed by eseidel.  Landed by eseidel.
     4
     5        Moved makeMapBetweenRects from SVG/CG to AffineTransform
     6        Make SVGResourceClipper::applyClip more cross-platform
     7
     8        * platform/graphics/AffineTransform.cpp:
     9        * platform/graphics/AffineTransform.h:
     10        * svg/graphics/cg/CgSupport.cpp:
     11        * svg/graphics/cg/CgSupport.h:
     12        * svg/graphics/cg/SVGPaintServerGradientCg.cpp:
     13        (WebCore::SVGPaintServerGradient::handleBoundingBoxModeAndGradientTransformation):
     14        * svg/graphics/cg/SVGResourceClipperCg.cpp:
     15        (WebCore::SVGResourceClipper::applyClip):
     16
    1172008-09-22  Alp Toker  <alp@nuanti.com>
    218
  • trunk/WebCore/platform/graphics/AffineTransform.cpp

    r36275 r36795  
    136136}
    137137
     138AffineTransform& AffineTransform::makeMapBetweenRects(const FloatRect& source, const FloatRect& dest);
     139{
     140    AffineTransform transform;
     141    transform.translate(dest.x() - source.x(), dest.y() - source.y());
     142    transform.scale(dest.width() / source.width(), dest.height() / source.height());
     143    return transform;
     144}
     145
    138146IntPoint AffineTransform::mapPoint(const IntPoint& point) const
    139147{
  • trunk/WebCore/platform/graphics/AffineTransform.h

    r36274 r36795  
    124124};
    125125
     126AffineTransform& makeMapBetweenRects(const FloatRect& source, const FloatRect& dest);
     127
    126128} // namespace WebCore
    127129
  • trunk/WebCore/svg/graphics/cg/CgSupport.cpp

    r36734 r36795  
    4141
    4242namespace WebCore {
    43 
    44 CGAffineTransform CGAffineTransformMakeMapBetweenRects(CGRect source, CGRect dest)
    45 {
    46     CGAffineTransform transform = CGAffineTransformMakeTranslation(dest.origin.x - source.origin.x, dest.origin.y - source.origin.y);
    47     transform = CGAffineTransformScale(transform, dest.size.width/source.size.width, dest.size.height/source.size.height);
    48     return transform;
    49 }
    5043
    5144CGContextRef scratchContext()
  • trunk/WebCore/svg/graphics/cg/CgSupport.h

    r36734 r36795  
    4242class GraphicsContext;
    4343
    44 CGAffineTransform CGAffineTransformMakeMapBetweenRects(CGRect source, CGRect dest);
    45 
    4644CGContextRef scratchContext();
    4745FloatRect strokeBoundingBox(const Path& path, RenderStyle*, const RenderObject*);
  • trunk/WebCore/svg/graphics/cg/SVGPaintServerGradientCg.cpp

    r31830 r36795  
    2525#include "SVGPaintServerGradient.h"
    2626
    27 #include "CgSupport.h"
    2827#include "FloatConversion.h"
    2928#include "GraphicsContext.h"
     
    255254void SVGPaintServerGradient::handleBoundingBoxModeAndGradientTransformation(GraphicsContext* context, const FloatRect& targetRect) const
    256255{
    257     CGContextRef contextRef = context->platformContext();
    258 
    259256    if (boundingBoxMode()) {
    260257        // Choose default gradient bounding box
    261         CGRect gradientBBox = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
     258        FloatRect gradientBBox(0.0f, 0.0f, 1.0f, 1.0f);
    262259
    263260        // Generate a transform to map between both bounding boxes
    264         CGAffineTransform gradientIntoObjectBBox = CGAffineTransformMakeMapBetweenRects(gradientBBox, CGRect(targetRect));
    265         CGContextConcatCTM(contextRef, gradientIntoObjectBBox);
     261        context->concatCTM(makeMapBetweenRects(gradientBBox, targetRect));
    266262    }
    267263
    268264    // Apply the gradient's own transform
    269     CGAffineTransform transform = gradientTransform();
    270     CGContextConcatCTM(contextRef, transform);
     265    context->concatCTM(gradientTransform());
    271266}
    272267
  • trunk/WebCore/svg/graphics/cg/SVGResourceClipperCg.cpp

    r29663 r36795  
    3131#include "SVGResourceClipper.h"
    3232
     33#include "AffineTransform.h"
    3334#include "GraphicsContext.h"
    34 #include "CgSupport.h"
    3535
    3636namespace WebCore {
     
    3838void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const
    3939{
    40     CGContextRef cgContext = context->platformContext();
    4140    if (m_clipData.clipData().size() < 1)
    4241        return;
     
    4746    context->beginPath();
    4847
    49     CGAffineTransform bboxTransform = CGAffineTransformMakeMapBetweenRects(CGRectMake(0,0,1,1), CGRect(boundingBox));
     48    AffineTransform bboxTransform = makeMapBetweenRects(FloatRect(0.0f, 0.0f, 1.0f, 1.0f), boundingBox);
    5049
    5150    for (unsigned x = 0; x < m_clipData.clipData().size(); x++) {
     
    5453            heterogenousClipRules = true;
    5554       
    56         CGPathRef clipPath = data.path.platformPath();
     55        Path clipPath = data.path;
    5756
    58         if (data.bboxUnits) {
    59             CGMutablePathRef transformedPath = CGPathCreateMutable();
    60             CGPathAddPath(transformedPath, &bboxTransform, clipPath);
    61             CGContextAddPath(cgContext, transformedPath);
    62             CGPathRelease(transformedPath);
    63         } else
    64             CGContextAddPath(cgContext, clipPath);
     57        if (data.bboxUnits)
     58            clipPath.transform(bboxTransform);
     59
     60        context->addPath(clipPath);
    6561    }
    6662
     63    CGContextRef cgContext = context->platformContext();
    6764    if (m_clipData.clipData().size()) {
    6865        // FIXME!
Note: See TracChangeset for help on using the changeset viewer.