Changeset 35390 in webkit
- Timestamp:
- Jul 26, 2008 10:38:28 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r35383 r35390 1 2008-07-26 Dirk Schulze <vbs85@gmx.de> 2 3 Reviewed by Nikolas Zimmermann. 4 5 Added pattern-support for SVG in Cairo. 6 7 * svg/graphics/cairo/SVGPaintServerPatternCairo.cpp: 8 (WebCore::applyStrokeStyleToContext): 9 (WebCore::SVGPaintServerPattern::setup): 10 1 11 2008-07-26 Keishi Hattori <casey.hattori@gmail.com> 2 12 -
trunk/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp
r29663 r35390 1 1 /* 2 2 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 3 * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de> 3 4 * 4 5 * This library is free software; you can redistribute it and/or … … 21 22 22 23 #if ENABLE(SVG) 23 #include "NotImplemented.h"24 24 #include "SVGPaintServerPattern.h" 25 26 #include "GraphicsContext.h" 27 #include "ImageBuffer.h" 28 #include "RenderObject.h" 29 #include "SVGPatternElement.h" 30 #include <wtf/OwnArrayPtr.h> 25 31 26 32 namespace WebCore { 27 33 34 // TODO: Share this code with all SVGPaintServers 35 static void applyStrokeStyleToContext(GraphicsContext* context, const SVGRenderStyle* style, const RenderObject* object) 36 { 37 cairo_t* cr = context->platformContext(); 38 39 context->setStrokeThickness(SVGRenderStyle::cssPrimitiveToLength(object, style->strokeWidth(), 1.0)); 40 context->setLineCap(style->capStyle()); 41 context->setLineJoin(style->joinStyle()); 42 if (style->joinStyle() == MiterJoin) 43 context->setMiterLimit(style->strokeMiterLimit()); 44 45 const DashArray& dashes = dashArrayFromRenderingStyle(object->style()); 46 OwnArrayPtr<double> dsh(new double[dashes.size()]); 47 for (size_t i = 0; i < dashes.size() ; i++) 48 dsh[i] = dashes[i]; 49 double dashOffset = SVGRenderStyle::cssPrimitiveToLength(object, style->strokeDashOffset(), 0.0); 50 cairo_set_dash(cr, dsh.get(), dashes.size(), dashOffset); 51 } 52 28 53 bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const 29 54 { 30 notImplemented(); 55 FloatRect targetRect = object->relativeBBox(false); 56 57 const SVGRenderStyle* style = object->style()->svgStyle(); 58 59 float strokeWidth = SVGRenderStyle::cssPrimitiveToLength(object, style->strokeWidth(), 1.0); 60 61 if (targetRect.width() == 0) 62 targetRect = FloatRect(targetRect.x(), targetRect.y(), strokeWidth, targetRect.height()); 63 if (targetRect.height() == 0) 64 targetRect = FloatRect(targetRect.x(), targetRect.y(), targetRect.width(), strokeWidth); 65 66 m_ownerElement->buildPattern(targetRect); 67 68 cairo_surface_t* image = tile()->surface(); 69 if (!image) 70 return false; 71 72 cairo_t* cr = context->platformContext(); 73 74 cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image); 75 cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); 76 77 cairo_pattern_set_filter(pattern, CAIRO_FILTER_BEST); 78 cairo_matrix_t pattern_matrix = patternTransform(); 79 cairo_matrix_t matrix = {1, 0, 0, 1, patternBoundaries().x(), patternBoundaries().y()}; 80 cairo_matrix_multiply(&matrix, &matrix, &pattern_matrix); 81 cairo_matrix_invert(&matrix); 82 cairo_pattern_set_matrix(pattern, &matrix); 83 84 if ((type & ApplyToFillTargetType) && style->hasFill()) 85 cairo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); 86 87 if ((type & ApplyToStrokeTargetType) && style->hasStroke()) 88 applyStrokeStyleToContext(context, style, object); 89 90 cairo_set_source(cr, pattern); 91 cairo_pattern_destroy(pattern); 92 31 93 return true; 32 94 }
Note: See TracChangeset
for help on using the changeset viewer.