Changeset 36737 in webkit
- Timestamp:
- Sep 21, 2008 3:37:37 AM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r36734 r36737 1 2008-09-21 Dirk Schulze <vbs85@gmx.de> 2 3 Reviewed by eseidel. Landed by eseidel. 4 5 All platforms use the DashArray in the GraphicsContext. 6 7 * svg/graphics/SVGPaintServer.h: 8 * svg/graphics/cairo/SVGPaintServerGradientCairo.cpp: 9 (WebCore::SVGPaintServerGradient::setup): 10 * svg/graphics/cairo/SVGPaintServerPatternCairo.cpp: 11 (WebCore::SVGPaintServerPattern::setup): 12 * svg/graphics/cairo/SVGPaintServerSolidCairo.cpp: 13 (WebCore::SVGPaintServerSolid::setup): 14 * svg/graphics/qt/SVGPaintServerGradientQt.cpp: 15 (WebCore::SVGPaintServerGradient::setup): 16 * svg/graphics/qt/SVGPaintServerQt.cpp: 17 * svg/graphics/qt/SVGPaintServerSolidQt.cpp: 18 (WebCore::SVGPaintServerSolid::setup): 19 1 20 2008-09-21 Dirk Schulze <vbs85@gmx.de> 2 21 -
trunk/WebCore/svg/graphics/SVGPaintServer.h
r36734 r36737 34 34 #if PLATFORM(CG) 35 35 #include <ApplicationServices/ApplicationServices.h> 36 #endif37 38 #if PLATFORM(QT)39 #include <qglobal.h>40 QT_BEGIN_NAMESPACE41 class QPen;42 QT_END_NAMESPACE43 36 #endif 44 37 … … 92 85 #endif 93 86 94 #if PLATFORM(QT)95 void setPenProperties(const RenderObject*, const RenderStyle*, QPen&) const;96 #endif97 87 protected: 98 88 SVGPaintServer(); -
trunk/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp
r35391 r36737 31 31 #include "RenderStyle.h" 32 32 #include "SVGGradientElement.h" 33 #include <wtf/OwnArrayPtr.h>34 33 35 34 namespace WebCore { 36 37 // TODO: Share this code with all SVGPaintServers38 static void applyStrokeStyleToContext(GraphicsContext* context, const SVGRenderStyle* style, const RenderObject* object)39 {40 cairo_t* cr = context->platformContext();41 42 context->setStrokeThickness(SVGRenderStyle::cssPrimitiveToLength(object, style->strokeWidth(), 1.0));43 context->setLineCap(style->capStyle());44 context->setLineJoin(style->joinStyle());45 if (style->joinStyle() == MiterJoin)46 context->setMiterLimit(style->strokeMiterLimit());47 48 const DashArray& dashes = dashArrayFromRenderingStyle(object->style());49 OwnArrayPtr<double> dsh(new double[dashes.size()]);50 for (size_t i = 0 ; i < dashes.size() ; i++)51 dsh[i] = dashes[i];52 double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->strokeDashOffset(), 0.0);53 cairo_set_dash(cr, dsh.get(), dashes.size(), dashOffset);54 }55 35 56 36 bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const … … 64 44 cairo_matrix_init_identity (&matrix); 65 45 const cairo_matrix_t gradient_matrix = gradientTransform(); 66 const SVGRenderStyle* style = object->style()->svgStyle(); 46 47 const SVGRenderStyle* svgStyle = object->style()->svgStyle(); 48 RenderStyle* style = object->style(); 67 49 68 50 if (this->type() == LinearGradientPaintServer) { … … 162 144 } 163 145 164 if ((type & ApplyToFillTargetType) && s tyle->hasFill())165 c airo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);146 if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) 147 context->setFillRule(svgStyle->fillRule()); 166 148 167 if ((type & ApplyToStrokeTargetType) && s tyle->hasStroke())149 if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) 168 150 applyStrokeStyleToContext(context, style, object); 169 151 -
trunk/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
r35731 r36737 34 34 namespace WebCore { 35 35 36 // TODO: Share this code with all SVGPaintServers37 static void applyStrokeStyleToContext(GraphicsContext* context, const SVGRenderStyle* style, const RenderObject* object)38 {39 cairo_t* cr = context->platformContext();40 41 context->setStrokeThickness(SVGRenderStyle::cssPrimitiveToLength(object, style->strokeWidth(), 1.0));42 context->setLineCap(style->capStyle());43 context->setLineJoin(style->joinStyle());44 if (style->joinStyle() == MiterJoin)45 context->setMiterLimit(style->strokeMiterLimit());46 47 const DashArray& dashes = dashArrayFromRenderingStyle(object->style());48 OwnArrayPtr<double> dsh(new double[dashes.size()]);49 for (size_t i = 0; i < dashes.size() ; i++)50 dsh[i] = dashes[i];51 double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->strokeDashOffset(), 0.0);52 cairo_set_dash(cr, dsh.get(), dashes.size(), dashOffset);53 }54 55 36 bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const 56 37 { 57 38 FloatRect targetRect = object->relativeBBox(false); 58 39 59 const SVGRenderStyle* style = object->style()->svgStyle(); 40 const SVGRenderStyle* svgStyle = object->style()->svgStyle(); 41 RenderStyle* style = object->style(); 60 42 61 float strokeWidth = SVGRenderStyle::cssPrimitiveToLength(object, s tyle->strokeWidth(), 1.0);43 float strokeWidth = SVGRenderStyle::cssPrimitiveToLength(object, svgStyle->strokeWidth(), 1.0f); 62 44 63 45 if (targetRect.width() == 0) … … 84 66 cairo_pattern_set_matrix(pattern, &matrix); 85 67 86 if ((type & ApplyToFillTargetType) && s tyle->hasFill())87 c airo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);68 if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) 69 context->setFillRule(svgStyle->fillRule()); 88 70 89 if ((type & ApplyToStrokeTargetType) && s tyle->hasStroke())71 if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) 90 72 applyStrokeStyleToContext(context, style, object); 91 73 -
trunk/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp
r29663 r36737 32 32 { 33 33 // TODO: share this code with other PaintServers 34 cairo_t* cr = context->platformContext(); 34 35 35 c airo_t* cr = context->platformContext();36 const SVGRenderStyle* style = object->style()->svgStyle();36 const SVGRenderStyle* svgStyle = object->style()->svgStyle(); 37 RenderStyle* style = object->style(); 37 38 38 39 float red, green, blue, alpha; 39 40 color().getRGBA(red, green, blue, alpha); 40 41 41 if ((type & ApplyToFillTargetType) && style->hasFill()) { 42 alpha = style->fillOpacity(); 43 44 cairo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); 42 if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) { 43 alpha = svgStyle->fillOpacity(); 44 context->setFillRule(svgStyle->fillRule()); 45 45 } 46 46 47 if ((type & ApplyToStrokeTargetType) && style->hasStroke()) { 48 alpha = style->strokeOpacity(); 49 50 cairo_set_line_width(cr, SVGRenderStyle::cssPrimitiveToLength(object, style->strokeWidth(), 1.0)); 51 context->setLineCap(style->capStyle()); 52 context->setLineJoin(style->joinStyle()); 53 if (style->joinStyle() == MiterJoin) 54 context->setMiterLimit(style->strokeMiterLimit()); 55 56 const DashArray& dashes = dashArrayFromRenderingStyle(object->style()); 57 double* dsh = new double[dashes.size()]; 58 for (unsigned i = 0 ; i < dashes.size() ; i++) 59 dsh[i] = dashes[i]; 60 double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->strokeDashOffset(), 0.0); 61 cairo_set_dash(cr, dsh, dashes.size(), dashOffset); 62 delete[] dsh; 47 if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) { 48 alpha = svgStyle->strokeOpacity(); 49 applyStrokeStyleToContext(context, style, object); 63 50 } 64 51 -
trunk/WebCore/svg/graphics/qt/SVGPaintServerGradientQt.cpp
r29663 r36737 63 63 Q_ASSERT(path); 64 64 65 RenderStyle* renderStyle = object->style(); 65 const SVGRenderStyle* svgStyle = object->style()->svgStyle(); 66 RenderStyle* style = object->style(); 66 67 67 68 QGradient gradient = setupGradient(context, object); … … 78 79 double opacity = 1.0; 79 80 80 if ((type & ApplyToFillTargetType) && renderStyle->svgStyle()->hasFill()) {81 if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) { 81 82 fillColorArray(gradient, gradientStops(), opacity); 82 83 … … 85 86 86 87 painter->setBrush(brush); 87 context->setFillRule( renderStyle->svgStyle()->fillRule());88 context->setFillRule(svgStyle->fillRule()); 88 89 } 89 90 90 if ((type & ApplyToStrokeTargetType) && renderStyle->svgStyle()->hasStroke()) {91 if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) { 91 92 fillColorArray(gradient, gradientStops(), opacity); 92 93 … … 94 95 QBrush brush(gradient); 95 96 brush.setMatrix(gradientTransform()); 97 pen.setBrush(brush); 98 painter->setPen(pen); 96 99 97 setPenProperties(object, renderStyle, pen); 98 pen.setBrush(brush); 99 100 painter->setPen(pen); 100 applyStrokeStyleToContext(context, style, object); 101 101 } 102 102 -
trunk/WebCore/svg/graphics/qt/SVGPaintServerQt.cpp
r35992 r36737 34 34 35 35 namespace WebCore { 36 37 void SVGPaintServer::setPenProperties(const RenderObject* object, const RenderStyle* style, QPen& pen) const38 {39 pen.setWidthF(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0));40 41 if (style->svgStyle()->capStyle() == ButtCap)42 pen.setCapStyle(Qt::FlatCap);43 else if (style->svgStyle()->capStyle() == RoundCap)44 pen.setCapStyle(Qt::RoundCap);45 46 if (style->svgStyle()->joinStyle() == MiterJoin) {47 pen.setJoinStyle(Qt::MiterJoin);48 pen.setMiterLimit((qreal) style->svgStyle()->strokeMiterLimit());49 } else if(style->svgStyle()->joinStyle() == RoundJoin)50 pen.setJoinStyle(Qt::RoundJoin);51 52 const DashArray& dashes = WebCore::dashArrayFromRenderingStyle(style);53 double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeDashOffset(), 0.0);54 55 unsigned int dashLength = !dashes.isEmpty() ? dashes.size() : 0;56 if(dashLength) {57 QVector<qreal> pattern;58 unsigned int count = (dashLength % 2) == 0 ? dashLength : dashLength * 2;59 60 for(unsigned int i = 0; i < count; i++)61 pattern.append(dashes[i % dashLength] / (float)pen.widthF());62 63 pen.setDashPattern(pattern);64 65 Q_UNUSED(dashOffset);66 // TODO: dash-offset, does/will qt4 API allow it? (Rob)67 }68 }69 36 70 37 void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -
trunk/WebCore/svg/graphics/qt/SVGPaintServerSolidQt.cpp
r35992 r36737 38 38 Q_ASSERT(painter); 39 39 40 RenderStyle* renderStyle = object ? object->style() : 0; 40 const SVGRenderStyle* svgStyle = object->style()->svgStyle(); 41 RenderStyle* style = object ? object->style() : 0; 41 42 // TODO? painter->setOpacity(renderStyle->opacity()); 42 43 43 44 QColor c = color(); 44 45 45 if ((type & ApplyToFillTargetType) && (! renderStyle || renderStyle->svgStyle()->hasFill())) {46 if ( renderStyle)47 c.setAlphaF( renderStyle->svgStyle()->fillOpacity());46 if ((type & ApplyToFillTargetType) && (!style || svgStyle->hasFill())) { 47 if (style) 48 c.setAlphaF(svgStyle->fillOpacity()); 48 49 49 50 QBrush brush(c); 50 51 painter->setBrush(brush); 51 52 52 if ( renderStyle)53 context->setFillRule( renderStyle->svgStyle()->fillRule());53 if (style) 54 context->setFillRule(svgStyle->fillRule()); 54 55 55 56 /* if(isPaintingText()) ... */ 56 57 } 57 58 58 if ((type & ApplyToStrokeTargetType) && (! renderStyle || renderStyle->svgStyle()->hasStroke())) {59 if ( renderStyle)60 c.setAlphaF( renderStyle->svgStyle()->strokeOpacity());59 if ((type & ApplyToStrokeTargetType) && (!style || svgStyle->hasStroke())) { 60 if (style) 61 c.setAlphaF(svgStyle->strokeOpacity()); 61 62 62 63 QPen pen(c); 63 if (renderStyle)64 setPenProperties(object, renderStyle, pen);65 64 painter->setPen(pen); 65 if (style) 66 applyStrokeStyleToContext(context, style, object); 66 67 67 68 /* if(isPaintingText()) ... */
Note: See TracChangeset
for help on using the changeset viewer.