Changeset 47360 in webkit


Ignore:
Timestamp:
Aug 17, 2009 7:19:13 AM (15 years ago)
Author:
treat@webkit.org
Message:

Style fixes based on cpp_style.py and WebKit Style guide for
GraphicsContextCG.cpp

Patch by Mike Fenton <mike.fenton@torchmobile.com> on 2009-08-13
Reviewed by Adam Treat.

https://bugs.webkit.org/show_bug.cgi?id=28268

  • platform/graphics/cg/GraphicsContextCG.cpp:

(WebCore::GraphicsContext::drawLine):
(WebCore::GraphicsContext::drawEllipse):
(WebCore::GraphicsContext::strokeArc):
(WebCore::GraphicsContext::drawConvexPolygon):
(WebCore::GraphicsContext::applyStrokePattern):
(WebCore::GraphicsContext::drawPath):
(WebCore::GraphicsContext::clipOut):
(WebCore::GraphicsContext::clipOutEllipseInRect):
(WebCore::GraphicsContext::addInnerRoundedRectClip):
(WebCore::GraphicsContext::clipToImageBuffer):
(WebCore::GraphicsContext::setPlatformShadow):
(WebCore::GraphicsContext::setLineCap):
(WebCore::GraphicsContext::setLineJoin):
(WebCore::GraphicsContext::roundToDevicePixels):
(WebCore::GraphicsContext::drawLineForText):
(WebCore::GraphicsContext::setURLForRect):
(WebCore::GraphicsContext::setImageInterpolationQuality):
(WebCore::GraphicsContext::imageInterpolationQuality):
(WebCore::GraphicsContext::setPlatformTextDrawingMode):
(WebCore::GraphicsContext::setCompositeOperation):

Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r47359 r47360  
     12009-08-13  Mike Fenton  <mike.fenton@torchmobile.com>
     2
     3        Reviewed by Adam Treat.
     4
     5        Style fixes based on cpp_style.py and WebKit Style guide for
     6        GraphicsContextCG.cpp
     7
     8        https://bugs.webkit.org/show_bug.cgi?id=28268
     9
     10        * platform/graphics/cg/GraphicsContextCG.cpp:
     11        (WebCore::GraphicsContext::drawLine):
     12        (WebCore::GraphicsContext::drawEllipse):
     13        (WebCore::GraphicsContext::strokeArc):
     14        (WebCore::GraphicsContext::drawConvexPolygon):
     15        (WebCore::GraphicsContext::applyStrokePattern):
     16        (WebCore::GraphicsContext::drawPath):
     17        (WebCore::GraphicsContext::clipOut):
     18        (WebCore::GraphicsContext::clipOutEllipseInRect):
     19        (WebCore::GraphicsContext::addInnerRoundedRectClip):
     20        (WebCore::GraphicsContext::clipToImageBuffer):
     21        (WebCore::GraphicsContext::setPlatformShadow):
     22        (WebCore::GraphicsContext::setLineCap):
     23        (WebCore::GraphicsContext::setLineJoin):
     24        (WebCore::GraphicsContext::roundToDevicePixels):
     25        (WebCore::GraphicsContext::drawLineForText):
     26        (WebCore::GraphicsContext::setURLForRect):
     27        (WebCore::GraphicsContext::setImageInterpolationQuality):
     28        (WebCore::GraphicsContext::imageInterpolationQuality):
     29        (WebCore::GraphicsContext::setPlatformTextDrawingMode):
     30        (WebCore::GraphicsContext::setCompositeOperation):
     31
    1322009-08-13  Mike Fenton  <mike.fenton@torchmobile.com>
    233
  • trunk/WebCore/platform/graphics/cg/GraphicsContextCG.cpp

    r44170 r47360  
    2929#include "GraphicsContext.h"
    3030
    31 #include "TransformationMatrix.h"
    3231#include "FloatConversion.h"
     32#include "GraphicsContextPlatformPrivateCG.h"
    3333#include "GraphicsContextPrivate.h"
    34 #include "GraphicsContextPlatformPrivateCG.h"
    3534#include "ImageBuffer.h"
    3635#include "KURL.h"
    3736#include "Path.h"
    3837#include "Pattern.h"
     38#include "TransformationMatrix.h"
     39
    3940#include <CoreGraphics/CGBitmapContext.h>
    4041#include <CoreGraphics/CGPDFContext.h>
     
    179180    int patWidth = 0;
    180181    switch (strokeStyle()) {
    181         case NoStroke:
    182         case SolidStroke:
    183             break;
    184         case DottedStroke:
    185             patWidth = (int)width;
    186             break;
    187         case DashedStroke:
    188             patWidth = 3 * (int)width;
    189             break;
    190     }
    191 
    192     CGContextRef context = platformContext();
    193    
     182    case NoStroke:
     183    case SolidStroke:
     184        break;
     185    case DottedStroke:
     186        patWidth = (int)width;
     187        break;
     188    case DashedStroke:
     189        patWidth = 3 * (int)width;
     190        break;
     191    }
     192
     193    CGContextRef context = platformContext();
     194
    194195    if (shouldAntialias())
    195196        CGContextSetShouldAntialias(context, false);
     
    222223            patternOffset = 1.0f;
    223224        else {
    224             bool evenNumberOfSegments = numSegments % 2 == 0;
     225            bool evenNumberOfSegments = !(numSegments % 2);
    225226            if (remainder)
    226227                evenNumberOfSegments = !evenNumberOfSegments;
     
    236237            }
    237238        }
    238        
     239
    239240        const CGFloat dottedLine[2] = { patWidth, patWidth };
    240241        CGContextSetLineDash(context, patternOffset, dottedLine, 2);
     
    249250    if (patWidth)
    250251        CGContextRestoreGState(context);
    251        
     252
    252253    if (shouldAntialias())
    253254        CGContextSetShouldAntialias(context, true);
     
    264265    if (paintingDisabled())
    265266        return;
    266        
     267
    267268    CGContextRef context = platformContext();
    268269    CGContextBeginPath(context);
     
    276277
    277278void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
    278 { 
     279{
    279280    if (paintingDisabled() || strokeStyle() == NoStroke || strokeThickness() <= 0.0f)
    280281        return;
    281    
     282
    282283    CGContextRef context = platformContext();
    283284    CGContextSaveGState(context);
    284285    CGContextBeginPath(context);
    285286    CGContextSetShouldAntialias(context, false);
    286    
     287
    287288    int x = rect.x();
    288289    int y = rect.y();
     
    291292    float scaleFactor = h / w;
    292293    float reverseScaleFactor = w / h;
    293    
     294
    294295    if (w != h)
    295296        scale(FloatSize(1, scaleFactor));
    296    
     297
    297298    float hRadius = w / 2;
    298299    float vRadius = h / 2;
     
    305306    if (w != h)
    306307        scale(FloatSize(1, reverseScaleFactor));
    307    
    308    
     308
    309309    float width = strokeThickness();
    310310    int patWidth = 0;
    311    
     311
    312312    switch (strokeStyle()) {
    313         case DottedStroke:
    314             patWidth = (int)(width / 2);
    315             break;
    316         case DashedStroke:
    317             patWidth = 3 * (int)(width / 2);
    318             break;
    319         default:
    320             break;
    321     }
    322    
     313    case DottedStroke:
     314        patWidth = (int)(width / 2);
     315        break;
     316    case DashedStroke:
     317        patWidth = 3 * (int)(width / 2);
     318        break;
     319    default:
     320        break;
     321    }
     322
    323323    if (patWidth) {
    324324        // Example: 80 pixels with a width of 30 pixels.
     
    330330        else // We are elliptical and will have to estimate the distance
    331331            distance = static_cast<int>((piFloat * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0f)) / 2.0f);
    332        
     332
    333333        int remainder = distance % patWidth;
    334334        int coverage = distance - remainder;
     
    340340            patternOffset = 1.0f;
    341341        else {
    342             bool evenNumberOfSegments = numSegments % 2 == 0;
     342            bool evenNumberOfSegments = !(numSegments % 2);
    343343            if (remainder)
    344344                evenNumberOfSegments = !evenNumberOfSegments;
     
    354354            }
    355355        }
    356    
     356
    357357        const CGFloat dottedLine[2] = { patWidth, patWidth };
    358358        CGContextSetLineDash(context, patternOffset, dottedLine, 2);
     
    360360
    361361    CGContextStrokePath(context);
    362    
     362
    363363    CGContextRestoreGState(context);
    364364}
     
    376376    if (antialiased != shouldAntialias())
    377377        CGContextSetShouldAntialias(context, antialiased);
    378    
     378
    379379    CGContextBeginPath(context);
    380380    CGContextMoveToPoint(context, points[0].x(), points[0].y());
     
    384384
    385385    drawPath();
    386    
     386
    387387    if (antialiased != shouldAntialias())
    388388        CGContextSetShouldAntialias(context, shouldAntialias());
     
    392392{
    393393    CGContextRef cgContext = platformContext();
    394    
     394
    395395    CGPatternRef platformPattern = m_common->state.strokePattern.get()->createPlatformPattern(getCTM());
    396396    if (!platformPattern)
     
    464464        return;
    465465    }
    466    
     466
    467467    if (state.fillColorSpace == PatternColorSpace)
    468468        applyFillPattern();
     
    600600    if (paintingDisabled())
    601601        return;
    602        
     602
    603603    CGRect rects[2] = { CGContextGetClipBoundingBox(platformContext()), rect };
    604604    CGContextBeginPath(platformContext());
     
    611611    if (paintingDisabled())
    612612        return;
    613        
     613
    614614    CGContextBeginPath(platformContext());
    615615    CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));
     
    640640    clip(rect);
    641641    CGContextRef context = platformContext();
    642    
     642
    643643    // Add outer ellipse
    644644    CGContextAddEllipseInRect(context, CGRectMake(rect.x(), rect.y(), rect.width(), rect.height()));
     
    646646    CGContextAddEllipseInRect(context, CGRectMake(rect.x() + thickness, rect.y() + thickness,
    647647        rect.width() - (thickness * 2), rect.height() - (thickness * 2)));
    648    
     648
    649649    CGContextEOClip(context);
    650650}
     
    654654    if (paintingDisabled())
    655655        return;
    656    
     656
    657657    CGContextTranslateCTM(platformContext(), rect.x(), rect.y() + rect.height());
    658658    CGContextScaleCTM(platformContext(), 1, -1);
     
    735735        CGContextSetShadowWithColor(context,
    736736                                    CGSizeMake(width, height),
    737                                     blurRadius, 
     737                                    blurRadius,
    738738                                    colorCG);
    739739        CGColorRelease(colorCG);
     
    800800        return;
    801801    switch (cap) {
    802         case ButtCap:
    803             CGContextSetLineCap(platformContext(), kCGLineCapButt);
    804             break;
    805         case RoundCap:
    806             CGContextSetLineCap(platformContext(), kCGLineCapRound);
    807             break;
    808         case SquareCap:
    809             CGContextSetLineCap(platformContext(), kCGLineCapSquare);
    810             break;
     802    case ButtCap:
     803        CGContextSetLineCap(platformContext(), kCGLineCapButt);
     804        break;
     805    case RoundCap:
     806        CGContextSetLineCap(platformContext(), kCGLineCapRound);
     807        break;
     808    case SquareCap:
     809        CGContextSetLineCap(platformContext(), kCGLineCapSquare);
     810        break;
    811811    }
    812812}
     
    822822        return;
    823823    switch (join) {
    824         case MiterJoin:
    825             CGContextSetLineJoin(platformContext(), kCGLineJoinMiter);
    826             break;
    827         case RoundJoin:
    828             CGContextSetLineJoin(platformContext(), kCGLineJoinRound);
    829             break;
    830         case BevelJoin:
    831             CGContextSetLineJoin(platformContext(), kCGLineJoinBevel);
    832             break;
     824    case MiterJoin:
     825        CGContextSetLineJoin(platformContext(), kCGLineJoinMiter);
     826        break;
     827    case RoundJoin:
     828        CGContextSetLineJoin(platformContext(), kCGLineJoinRound);
     829        break;
     830    case BevelJoin:
     831        CGContextSetLineJoin(platformContext(), kCGLineJoinBevel);
     832        break;
    833833    }
    834834}
     
    859859    if (paintingDisabled())
    860860        return;
    861        
     861
    862862    CGContextBeginPath(platformContext());
    863863    CGContextAddRect(platformContext(), CGContextGetClipBoundingBox(platformContext()));
     
    910910FloatRect GraphicsContext::roundToDevicePixels(const FloatRect& rect)
    911911{
    912     // It is not enough just to round to pixels in device space. The rotation part of the 
     912    // It is not enough just to round to pixels in device space. The rotation part of the
    913913    // affine transform matrix to device space can mess with this conversion if we have a
    914     // rotating image like the hands of the world clock widget. We just need the scale, so 
     914    // rotating image like the hands of the world clock widget. We just need the scale, so
    915915    // we get the affine transform matrix and extract the scale.
    916916
     
    935935    deviceLowerRight.x = roundf(deviceLowerRight.x);
    936936    deviceLowerRight.y = roundf(deviceLowerRight.y);
    937    
     937
    938938    // Don't let the height or width round to 0 unless either was originally 0
    939     if (deviceOrigin.y == deviceLowerRight.y && rect.height() != 0)
     939    if (deviceOrigin.y == deviceLowerRight.y && rect.height())
    940940        deviceLowerRight.y += 1;
    941     if (deviceOrigin.x == deviceLowerRight.x && rect.width() != 0)
     941    if (deviceOrigin.x == deviceLowerRight.x && rect.width())
    942942        deviceLowerRight.x += 1;
    943943
     
    985985        }
    986986    }
    987    
     987
    988988    if (fillColor() != strokeColor())
    989989        setCGFillColor(platformContext(), strokeColor());
     
    991991    if (fillColor() != strokeColor())
    992992        setCGFillColor(platformContext(), fillColor());
    993        
     993
    994994    if (restoreAntialiasMode)
    995995        CGContextSetShouldAntialias(platformContext(), true);
     
    10001000    if (paintingDisabled())
    10011001        return;
    1002        
     1002
    10031003    CFURLRef urlRef = link.createCFURL();
    10041004    if (urlRef) {
    10051005        CGContextRef context = platformContext();
    1006        
     1006
    10071007        // Get the bounding box to handle clipping.
    10081008        CGRect box = CGContextGetClipBoundingBox(context);
     
    10231023    if (paintingDisabled())
    10241024        return;
    1025    
     1025
    10261026    CGInterpolationQuality quality = kCGInterpolationDefault;
    10271027    switch (mode) {
    1028         case InterpolationDefault:
    1029             quality = kCGInterpolationDefault;
    1030             break;
    1031         case InterpolationNone:
    1032             quality = kCGInterpolationNone;
    1033             break;
    1034         case InterpolationLow:
    1035             quality = kCGInterpolationLow;
    1036             break;
    1037 
    1038         // Fall through to InterpolationHigh if kCGInterpolationMedium is not available
    1039         case InterpolationMedium:
     1028    case InterpolationDefault:
     1029        quality = kCGInterpolationDefault;
     1030        break;
     1031    case InterpolationNone:
     1032        quality = kCGInterpolationNone;
     1033        break;
     1034    case InterpolationLow:
     1035        quality = kCGInterpolationLow;
     1036        break;
     1037
     1038    // Fall through to InterpolationHigh if kCGInterpolationMedium is not available
     1039    case InterpolationMedium:
    10401040#if HAVE(CG_INTERPOLATION_MEDIUM)
    1041             quality = kCGInterpolationMedium;
    1042             break;
     1041        quality = kCGInterpolationMedium;
     1042        break;
    10431043#endif
    1044         case InterpolationHigh:
    1045             quality = kCGInterpolationHigh;
    1046             break;
     1044    case InterpolationHigh:
     1045        quality = kCGInterpolationHigh;
     1046        break;
    10471047    }
    10481048    CGContextSetInterpolationQuality(platformContext(), quality);
     
    10561056    CGInterpolationQuality quality = CGContextGetInterpolationQuality(platformContext());
    10571057    switch (quality) {
    1058         case kCGInterpolationDefault:
    1059             return InterpolationDefault;
    1060         case kCGInterpolationNone:
    1061             return InterpolationNone;
    1062         case kCGInterpolationLow:
    1063             return InterpolationLow;
     1058    case kCGInterpolationDefault:
     1059        return InterpolationDefault;
     1060    case kCGInterpolationNone:
     1061        return InterpolationNone;
     1062    case kCGInterpolationLow:
     1063        return InterpolationLow;
    10641064#if HAVE(CG_INTERPOLATION_MEDIUM)
    1065         case kCGInterpolationMedium:
    1066             return InterpolationMedium;
     1065    case kCGInterpolationMedium:
     1066        return InterpolationMedium;
    10671067#endif
    1068         case kCGInterpolationHigh:
    1069             return InterpolationHigh;
     1068    case kCGInterpolationHigh:
     1069        return InterpolationHigh;
    10701070    }
    10711071    return InterpolationDefault;
     
    10801080    CGContextRef context = platformContext();
    10811081    switch (mode) {
    1082         case cTextInvisible: // Invisible
    1083             CGContextSetTextDrawingMode(context, kCGTextInvisible);
    1084             break;
    1085         case cTextFill: // Fill
    1086             CGContextSetTextDrawingMode(context, kCGTextFill);
    1087             break;
    1088         case cTextStroke: // Stroke
    1089             CGContextSetTextDrawingMode(context, kCGTextStroke);
    1090             break;
    1091         case 3: // Fill | Stroke
    1092             CGContextSetTextDrawingMode(context, kCGTextFillStroke);
    1093             break;
    1094         case cTextClip: // Clip
    1095             CGContextSetTextDrawingMode(context, kCGTextClip);
    1096             break;
    1097         case 5: // Fill | Clip
    1098             CGContextSetTextDrawingMode(context, kCGTextFillClip);
    1099             break;
    1100         case 6: // Stroke | Clip
    1101             CGContextSetTextDrawingMode(context, kCGTextStrokeClip);
    1102             break;
    1103         case 7: // Fill | Stroke | Clip
    1104             CGContextSetTextDrawingMode(context, kCGTextFillStrokeClip);
    1105             break;
    1106         default:
    1107             break;
     1082    case cTextInvisible: // Invisible
     1083        CGContextSetTextDrawingMode(context, kCGTextInvisible);
     1084        break;
     1085    case cTextFill: // Fill
     1086        CGContextSetTextDrawingMode(context, kCGTextFill);
     1087        break;
     1088    case cTextStroke: // Stroke
     1089        CGContextSetTextDrawingMode(context, kCGTextStroke);
     1090        break;
     1091    case 3: // Fill | Stroke
     1092        CGContextSetTextDrawingMode(context, kCGTextFillStroke);
     1093        break;
     1094    case cTextClip: // Clip
     1095        CGContextSetTextDrawingMode(context, kCGTextClip);
     1096        break;
     1097    case 5: // Fill | Clip
     1098        CGContextSetTextDrawingMode(context, kCGTextFillClip);
     1099        break;
     1100    case 6: // Stroke | Clip
     1101        CGContextSetTextDrawingMode(context, kCGTextStrokeClip);
     1102        break;
     1103    case 7: // Fill | Stroke | Clip
     1104        CGContextSetTextDrawingMode(context, kCGTextFillStrokeClip);
     1105        break;
     1106    default:
     1107        break;
    11081108    }
    11091109}
     
    11391139#ifndef BUILDING_ON_TIGER // Tiger's setCompositeOperation() is defined in GraphicsContextMac.mm.
    11401140void GraphicsContext::setCompositeOperation(CompositeOperator mode)
    1141 {   
    1142     if (paintingDisabled())
    1143         return;
    1144 
    1145     CGBlendMode target = kCGBlendModeNormal;   
     1141{
     1142    if (paintingDisabled())
     1143        return;
     1144
     1145    CGBlendMode target = kCGBlendModeNormal;
    11461146    switch (mode) {
    1147         case CompositeClear:
    1148             target = kCGBlendModeClear;
    1149             break;
    1150         case CompositeCopy:
    1151             target = kCGBlendModeCopy;
    1152             break;
    1153         case CompositeSourceOver:
    1154             //kCGBlendModeNormal
    1155             break;
    1156         case CompositeSourceIn:
    1157             target = kCGBlendModeSourceIn;
    1158             break;
    1159         case CompositeSourceOut:
    1160             target = kCGBlendModeSourceOut;
    1161             break;
    1162         case CompositeSourceAtop:
    1163             target = kCGBlendModeSourceAtop;
    1164             break;
    1165         case CompositeDestinationOver:
    1166             target = kCGBlendModeDestinationOver;
    1167             break;
    1168         case CompositeDestinationIn:
    1169             target = kCGBlendModeDestinationIn;
    1170             break;
    1171         case CompositeDestinationOut:
    1172             target = kCGBlendModeDestinationOut;
    1173             break;
    1174         case CompositeDestinationAtop:
    1175             target = kCGBlendModeDestinationAtop;
    1176             break;
    1177         case CompositeXOR:
    1178             target = kCGBlendModeXOR;
    1179             break;
    1180         case CompositePlusDarker:
    1181             target = kCGBlendModePlusDarker;
    1182             break;
    1183         case CompositeHighlight:
    1184             // currently unsupported
    1185             break;
    1186         case CompositePlusLighter:
    1187             target = kCGBlendModePlusLighter;
    1188             break;
     1147    case CompositeClear:
     1148        target = kCGBlendModeClear;
     1149        break;
     1150    case CompositeCopy:
     1151        target = kCGBlendModeCopy;
     1152        break;
     1153    case CompositeSourceOver:
     1154        //kCGBlendModeNormal
     1155        break;
     1156    case CompositeSourceIn:
     1157        target = kCGBlendModeSourceIn;
     1158        break;
     1159    case CompositeSourceOut:
     1160        target = kCGBlendModeSourceOut;
     1161        break;
     1162    case CompositeSourceAtop:
     1163        target = kCGBlendModeSourceAtop;
     1164        break;
     1165    case CompositeDestinationOver:
     1166        target = kCGBlendModeDestinationOver;
     1167        break;
     1168    case CompositeDestinationIn:
     1169        target = kCGBlendModeDestinationIn;
     1170        break;
     1171    case CompositeDestinationOut:
     1172        target = kCGBlendModeDestinationOut;
     1173        break;
     1174    case CompositeDestinationAtop:
     1175        target = kCGBlendModeDestinationAtop;
     1176        break;
     1177    case CompositeXOR:
     1178        target = kCGBlendModeXOR;
     1179        break;
     1180    case CompositePlusDarker:
     1181        target = kCGBlendModePlusDarker;
     1182        break;
     1183    case CompositeHighlight:
     1184        // currently unsupported
     1185        break;
     1186    case CompositePlusLighter:
     1187        target = kCGBlendModePlusLighter;
     1188        break;
    11891189    }
    11901190    CGContextSetBlendMode(platformContext(), target);
Note: See TracChangeset for help on using the changeset viewer.