Changeset 47359 in webkit
- Timestamp:
- Aug 17, 2009 7:01:23 AM (15 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r47357 r47359 1 2009-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 GraphicsContext.cpp/h, GraphicsContextCairo.cpp and GraphicsContextQt.cpp. 7 8 https://bugs.webkit.org/show_bug.cgi?id=28268 9 10 * platform/graphics/GraphicsContext.cpp: 11 (WebCore::GraphicsContext::save): 12 (WebCore::GraphicsContext::restore): 13 (GraphicsContext::drawText): 14 (GraphicsContext::initFocusRing): 15 (GraphicsContext::focusRingBoundingRect): 16 (GraphicsContext::drawImage): 17 * platform/graphics/GraphicsContext.h: 18 * platform/graphics/cairo/GraphicsContextCairo.cpp: 19 (WebCore::GraphicsContext::drawLine): 20 (WebCore::GraphicsContext::strokeArc): 21 (WebCore::GraphicsContext::setLineCap): 22 (WebCore::GraphicsContext::setLineJoin): 23 (WebCore::toCairoOperator): 24 * platform/graphics/qt/GraphicsContextQt.cpp: 25 1 26 2009-08-17 Darin Adler <darin@apple.com> 2 27 -
trunk/WebCore/platform/graphics/GraphicsContext.cpp
r47146 r47359 28 28 29 29 #include "BidiResolver.h" 30 #include "Font.h" 30 31 #include "Generator.h" 31 32 #include "GraphicsContextPrivate.h" 32 #include "Font.h"33 33 34 34 using namespace std; … … 90 90 91 91 m_common->stack.append(m_common->state); 92 92 93 93 savePlatformState(); 94 94 } … … 105 105 m_common->state = m_common->stack.last(); 106 106 m_common->stack.removeLast(); 107 107 108 108 restorePlatformState(); 109 109 } … … 306 306 307 307 void GraphicsContext::drawImage(Image* image, const IntPoint& p, CompositeOperator op) 308 { 308 { 309 309 drawImage(image, p, IntRect(0, 0, -1, -1), op); 310 310 } … … 330 330 if (paintingDisabled()) 331 331 return; 332 332 333 333 font.drawText(this, run, point, from, to); 334 334 } … … 384 384 return; 385 385 clearFocusRing(); 386 386 387 387 m_common->m_focusRingWidth = width; 388 388 m_common->m_focusRingOffset = offset; … … 397 397 { 398 398 IntRect result = IntRect(0, 0, 0, 0); 399 399 400 400 const Vector<IntRect>& rects = focusRingRects(); 401 401 unsigned rectCount = rects.size(); 402 402 for (unsigned i = 0; i < rectCount; i++) 403 403 result.unite(rects[i]); 404 404 405 405 return result; 406 406 } … … 437 437 float tw = dest.width(); 438 438 float th = dest.height(); 439 439 440 440 if (tsw == -1) 441 441 tsw = image->width(); -
trunk/WebCore/platform/graphics/GraphicsContext.h
r47146 r47359 50 50 class wxWindowDC; 51 51 52 // wxGraphicsContext allows us to support Path, etc. 53 // but on some platforms, e.g. Linux, it requires fairly 52 // wxGraphicsContext allows us to support Path, etc. 53 // but on some platforms, e.g. Linux, it requires fairly 54 54 // new software. 55 55 #if USE(WXGC) … … 123 123 const int cTextStroke = 2; 124 124 const int cTextClip = 4; 125 125 126 126 enum StrokeStyle { 127 127 NoStroke, … … 131 131 }; 132 132 133 // FIXME: This is a place-holder until we decide to add134 // real color space support to WebCore. At that time, ColorSpace will be a135 // class and instances will be held off of Colors. There will be136 // special singleton Gradient and Pattern color spaces to mark when137 // a fill or stroke is using a gradient or pattern instead of a solid color.138 // https://bugs.webkit.org/show_bug.cgi?id=20558133 // FIXME: This is a place-holder until we decide to add 134 // real color space support to WebCore. At that time, ColorSpace will be a 135 // class and instances will be held off of Colors. There will be 136 // special singleton Gradient and Pattern color spaces to mark when 137 // a fill or stroke is using a gradient or pattern instead of a solid color. 138 // https://bugs.webkit.org/show_bug.cgi?id=20558 139 139 enum ColorSpace { 140 140 SolidColorSpace, … … 155 155 GraphicsContext(PlatformGraphicsContext*); 156 156 ~GraphicsContext(); 157 157 158 158 #if !PLATFORM(WINCE) || PLATFORM(QT) 159 159 PlatformGraphicsContext* platformContext() const; 160 160 #endif 161 161 162 162 float strokeThickness() const; 163 163 void setStrokeThickness(float); … … 235 235 void drawTiledImage(Image*, const IntRect& destRect, const IntPoint& srcPoint, const IntSize& tileSize, 236 236 CompositeOperator = CompositeSourceOver); 237 void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect, 237 void drawTiledImage(Image*, const IntRect& destRect, const IntRect& srcRect, 238 238 Image::TileRule hRule = Image::StretchTile, Image::TileRule vRule = Image::StretchTile, 239 239 CompositeOperator = CompositeSourceOver); … … 259 259 260 260 FloatRect roundToDevicePixels(const FloatRect&); 261 261 262 262 void drawLineForText(const IntPoint&, int width, bool printing); 263 263 void drawLineForMisspellingOrBadGrammar(const IntPoint&, int width, bool grammar); 264 264 265 265 bool paintingDisabled() const; 266 266 void setPaintingDisabled(bool); 267 267 268 268 bool updatingControlTints() const; 269 269 void setUpdatingControlTints(bool); … … 304 304 void translate(float x, float y); 305 305 IntPoint origin(); 306 306 307 307 void setURLForRect(const KURL&, const IntRect&); 308 308 -
trunk/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
r45285 r47359 32 32 #if PLATFORM(CAIRO) 33 33 34 #include "TransformationMatrix.h"35 34 #include "CairoPath.h" 36 35 #include "FloatRect.h" … … 42 41 #include "Pattern.h" 43 42 #include "SimpleFontData.h" 43 #include "TransformationMatrix.h" 44 44 45 45 #include <cairo.h> … … 54 54 #include <cairo-win32.h> 55 55 #endif 56 #include "GraphicsContextPlatformPrivateCairo.h" 56 57 #include "GraphicsContextPrivate.h" 57 #include "GraphicsContextPlatformPrivateCairo.h"58 58 59 59 #ifndef M_PI … … 240 240 patternOffset = 1.0; 241 241 else { 242 bool evenNumberOfSegments = numSegments%2 == 0;242 bool evenNumberOfSegments = !(numSegments % 2); 243 243 if (remainder) 244 244 evenNumberOfSegments = !evenNumberOfSegments; … … 246 246 if (remainder) { 247 247 patternOffset += patWidth - remainder; 248 patternOffset += remainder/2; 249 } 250 else 251 patternOffset = patWidth/2; 252 } 253 else if (!evenNumberOfSegments) { 248 patternOffset += remainder / 2; 249 } else 250 patternOffset = patWidth / 2; 251 } else if (!evenNumberOfSegments) { 254 252 if (remainder) 255 patternOffset = (patWidth - remainder) /2;253 patternOffset = (patWidth - remainder) / 2; 256 254 } 257 255 } … … 319 317 if (w != h) 320 318 cairo_scale(cr, 1., scaleFactor); 321 319 322 320 cairo_arc_negative(cr, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, -fa * M_PI/180, -falen * M_PI/180); 323 321 … … 327 325 float width = strokeThickness(); 328 326 int patWidth = 0; 329 327 330 328 switch (strokeStyle()) { 331 332 333 334 335 336 337 338 329 case DottedStroke: 330 patWidth = static_cast<int>(width / 2); 331 break; 332 case DashedStroke: 333 patWidth = 3 * static_cast<int>(width / 2); 334 break; 335 default: 336 break; 339 337 } 340 338 … … 350 348 else // We are elliptical and will have to estimate the distance 351 349 distance = static_cast<int>((M_PI * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0)) / 2.0); 352 350 353 351 int remainder = distance % patWidth; 354 352 int coverage = distance - remainder; … … 360 358 patternOffset = 1.0; 361 359 else { 362 bool evenNumberOfSegments = numSegments % 2 == 0;360 bool evenNumberOfSegments = !(numSegments % 2); 363 361 if (remainder) 364 362 evenNumberOfSegments = !evenNumberOfSegments; … … 829 827 cairo_line_cap_t cairoCap = CAIRO_LINE_CAP_BUTT; 830 828 switch (lineCap) { 831 832 833 834 835 836 837 838 839 829 case ButtCap: 830 // no-op 831 break; 832 case RoundCap: 833 cairoCap = CAIRO_LINE_CAP_ROUND; 834 break; 835 case SquareCap: 836 cairoCap = CAIRO_LINE_CAP_SQUARE; 837 break; 840 838 } 841 839 cairo_set_line_cap(m_data->cr, cairoCap); … … 854 852 cairo_line_join_t cairoJoin = CAIRO_LINE_JOIN_MITER; 855 853 switch (lineJoin) { 856 857 858 859 860 861 862 863 864 854 case MiterJoin: 855 // no-op 856 break; 857 case RoundJoin: 858 cairoJoin = CAIRO_LINE_JOIN_ROUND; 859 break; 860 case BevelJoin: 861 cairoJoin = CAIRO_LINE_JOIN_BEVEL; 862 break; 865 863 } 866 864 cairo_set_line_join(m_data->cr, cairoJoin); … … 888 886 { 889 887 switch (op) { 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 888 case CompositeClear: 889 return CAIRO_OPERATOR_CLEAR; 890 case CompositeCopy: 891 return CAIRO_OPERATOR_SOURCE; 892 case CompositeSourceOver: 893 return CAIRO_OPERATOR_OVER; 894 case CompositeSourceIn: 895 return CAIRO_OPERATOR_IN; 896 case CompositeSourceOut: 897 return CAIRO_OPERATOR_OUT; 898 case CompositeSourceAtop: 899 return CAIRO_OPERATOR_ATOP; 900 case CompositeDestinationOver: 901 return CAIRO_OPERATOR_DEST_OVER; 902 case CompositeDestinationIn: 903 return CAIRO_OPERATOR_DEST_IN; 904 case CompositeDestinationOut: 905 return CAIRO_OPERATOR_DEST_OUT; 906 case CompositeDestinationAtop: 907 return CAIRO_OPERATOR_DEST_ATOP; 908 case CompositeXOR: 909 return CAIRO_OPERATOR_XOR; 910 case CompositePlusDarker: 911 return CAIRO_OPERATOR_SATURATE; 912 case CompositeHighlight: 913 // There is no Cairo equivalent for CompositeHighlight. 914 return CAIRO_OPERATOR_OVER; 915 case CompositePlusLighter: 916 return CAIRO_OPERATOR_ADD; 917 default: 918 return CAIRO_OPERATOR_SOURCE; 921 919 } 922 920 } -
trunk/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
r47190 r47359 35 35 36 36 #include "config.h" 37 #include "GraphicsContext.h" 37 38 38 39 #ifdef Q_WS_WIN … … 43 44 #include "FloatConversion.h" 44 45 #include "Font.h" 45 #include "GraphicsContext.h"46 46 #include "GraphicsContextPrivate.h" 47 47 #include "ImageBuffer.h" … … 1220 1220 1221 1221 #ifdef Q_WS_WIN 1222 #include <windows.h>1223 1222 1224 1223 HDC GraphicsContext::getWindowsContext(const IntRect& dstRect, bool supportAlphaBlend, bool mayCreateBitmap)
Note: See TracChangeset
for help on using the changeset viewer.