diff options
Diffstat (limited to 'WebCore/svg/graphics/cairo')
8 files changed, 0 insertions, 581 deletions
diff --git a/WebCore/svg/graphics/cairo/RenderPathCairo.cpp b/WebCore/svg/graphics/cairo/RenderPathCairo.cpp deleted file mode 100644 index 72379b5..0000000 --- a/WebCore/svg/graphics/cairo/RenderPathCairo.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" -#include "RenderPath.h" - -#include "CairoPath.h" -#include "SVGPaintServer.h" - -namespace WebCore { - -bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const -{ - if (requiresStroke && !SVGPaintServer::strokePaintServer(style(), this)) - return false; - - cairo_t* cr = path().platformPath()->m_cr; - - // TODO: set stroke properties - return cairo_in_stroke(cr, point.x(), point.y()); -} - -FloatRect RenderPath::strokeBBox() const -{ - // TODO: this implementation is naive - - cairo_t* cr = path().platformPath()->m_cr; - - double x0, x1, y0, y1; - cairo_stroke_extents(cr, &x0, &y0, &x1, &y1); - FloatRect bbox = FloatRect(x0, y0, x1 - x0, y1 - y0); - - return bbox; -} - -} diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp deleted file mode 100644 index 37cab6f..0000000 --- a/WebCore/svg/graphics/cairo/SVGPaintServerCairo.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServer.h" - -#include "GraphicsContext.h" -#include "SVGPaintServer.h" -#include "RenderPath.h" - -#include <cairo.h> - -namespace WebCore { - -void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -{ - if (!setup(context, path, type)) - return; - - renderPath(context, path, type); - teardown(context, path, type); -} - -void SVGPaintServer::teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const -{ - // no-op -} - -void SVGPaintServer::renderPath(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const -{ - cairo_t* cr = context->platformContext(); - const SVGRenderStyle* style = path->style()->svgStyle(); - - cairo_set_fill_rule(cr, style->fillRule() == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); - - if ((type & ApplyToFillTargetType) && style->hasFill()) - cairo_fill_preserve(cr); - - if ((type & ApplyToStrokeTargetType) && style->hasStroke()) - cairo_stroke_preserve(cr); - - cairo_new_path(cr); -} - -} // namespace WebCore - -#endif diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp deleted file mode 100644 index e237962..0000000 --- a/WebCore/svg/graphics/cairo/SVGPaintServerGradientCairo.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServerGradient.h" -#include "SVGPaintServerLinearGradient.h" -#include "SVGPaintServerRadialGradient.h" - -#include "GraphicsContext.h" -#include "RenderObject.h" -#include "RenderPath.h" -#include "RenderStyle.h" -#include "SVGGradientElement.h" - -namespace WebCore { - -bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const -{ - m_ownerElement->buildGradient(); - - cairo_t* cr = context->platformContext(); - cairo_pattern_t* pattern; - - cairo_matrix_t matrix; - cairo_matrix_init_identity (&matrix); - const cairo_matrix_t gradient_matrix = gradientTransform(); - - const SVGRenderStyle* svgStyle = object->style()->svgStyle(); - RenderStyle* style = object->style(); - - if (this->type() == LinearGradientPaintServer) { - const SVGPaintServerLinearGradient* linear = static_cast<const SVGPaintServerLinearGradient*>(this); - - if (boundingBoxMode()) { - FloatRect bbox = object->relativeBBox(false); - if (bbox.width() == 0 || bbox.height() == 0) { - applyStrokeStyleToContext(context, style, object); - cairo_set_source_rgb(cr, 0, 0, 0); - return true; - } - cairo_matrix_translate(&matrix, bbox.x(), bbox.y()); - cairo_matrix_scale(&matrix, bbox.width(), bbox.height()); - } - - double x0 = linear->gradientStart().x(); - double y0 = linear->gradientStart().y(); - double x1 = linear->gradientEnd().x(); - double y1 = linear->gradientEnd().y(); - - pattern = cairo_pattern_create_linear(x0, y0, x1, y1); - - } else if (this->type() == RadialGradientPaintServer) { - const SVGPaintServerRadialGradient* radial = static_cast<const SVGPaintServerRadialGradient*>(this); - - if (boundingBoxMode()) { - FloatRect bbox = object->relativeBBox(false); - if (bbox.width() == 0 || bbox.height() == 0) { - applyStrokeStyleToContext(context, style, object); - cairo_set_source_rgb(cr, 0, 0, 0); - return true; - } - cairo_matrix_translate(&matrix, bbox.x(), bbox.y()); - cairo_matrix_scale(&matrix, bbox.width(), bbox.height()); - } - - double cx = radial->gradientCenter().x(); - double cy = radial->gradientCenter().y(); - double radius = radial->gradientRadius(); - double fx = radial->gradientFocal().x(); - double fy = radial->gradientFocal().y(); - - fx -= cx; - fy -= cy; - - double fradius = 0.0; - - if (sqrt(fx * fx + fy * fy) >= radius) { - double angle = atan2(fy, fx); - if ((fx + cx) < cx) - fx = cos(angle) * radius + 0.002; - else - fx = cos(angle) * radius - 0.002; - if ((fy + cy) < cy) - fy = sin(angle) * radius + 0.002; - else - fy = sin(angle) * radius - 0.002; - } - - pattern = cairo_pattern_create_radial(fx + cx, fy + cy, fradius, cx, cy, radius); - - } else { - return false; - } - - cairo_pattern_set_filter(pattern, CAIRO_FILTER_BILINEAR); - - switch (spreadMethod()) { - case SpreadMethodPad: - cairo_pattern_set_extend(pattern, CAIRO_EXTEND_PAD); - break; - case SpreadMethodReflect: - cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT); - break; - case SpreadMethodRepeat: - cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); - break; - default: - cairo_pattern_set_extend(pattern, CAIRO_EXTEND_NONE); - break; - } - - cairo_matrix_multiply(&matrix, &matrix, &gradient_matrix); - cairo_matrix_invert(&matrix); - cairo_pattern_set_matrix(pattern, &matrix); - - const Vector<SVGGradientStop>& stops = gradientStops(); - - for (unsigned i = 0; i < stops.size(); ++i) { - float offset = stops[i].first; - Color color = stops[i].second; - if (i > 0 && offset < stops[i - 1].first) - offset = stops[i - 1].first; - - cairo_pattern_add_color_stop_rgba(pattern, offset, color.red() / 255.0, color.green() / 255.0, color.blue() / 255.0, color.alpha() / 255.0); - } - - if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) - context->setFillRule(svgStyle->fillRule()); - - if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) - applyStrokeStyleToContext(context, style, object); - - cairo_set_source(cr, pattern); - cairo_pattern_destroy(pattern); - - return true; -} - -} // namespace WebCore - -#endif diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp deleted file mode 100644 index 86530bc..0000000 --- a/WebCore/svg/graphics/cairo/SVGPaintServerPatternCairo.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServerPattern.h" - -#include "GraphicsContext.h" -#include "Image.h" -#include "ImageBuffer.h" -#include "RenderObject.h" -#include "SVGPatternElement.h" - -#include <wtf/OwnArrayPtr.h> - -namespace WebCore { - -bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const -{ - FloatRect targetRect = object->relativeBBox(false); - - const SVGRenderStyle* svgStyle = object->style()->svgStyle(); - RenderStyle* style = object->style(); - - float strokeWidth = SVGRenderStyle::cssPrimitiveToLength(object, svgStyle->strokeWidth(), 1.0f); - - if (targetRect.width() == 0) - targetRect = FloatRect(targetRect.x(), targetRect.y(), strokeWidth, targetRect.height()); - if (targetRect.height() == 0) - targetRect = FloatRect(targetRect.x(), targetRect.y(), targetRect.width(), strokeWidth); - - m_ownerElement->buildPattern(targetRect); - - cairo_surface_t* image = tile()->image()->nativeImageForCurrentFrame(); - if (!image) - return false; - - cairo_t* cr = context->platformContext(); - - cairo_pattern_t* pattern = cairo_pattern_create_for_surface(image); - cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT); - - cairo_pattern_set_filter(pattern, CAIRO_FILTER_BEST); - cairo_matrix_t pattern_matrix = patternTransform(); - cairo_matrix_t matrix = {1, 0, 0, 1, patternBoundaries().x(), patternBoundaries().y()}; - cairo_matrix_multiply(&matrix, &matrix, &pattern_matrix); - cairo_matrix_invert(&matrix); - cairo_pattern_set_matrix(pattern, &matrix); - - if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) - context->setFillRule(svgStyle->fillRule()); - - if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) - applyStrokeStyleToContext(context, style, object); - - cairo_set_source(cr, pattern); - cairo_pattern_destroy(pattern); - - return true; -} - -} // namespace WebCore - -#endif diff --git a/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp b/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp deleted file mode 100644 index 49e6f55..0000000 --- a/WebCore/svg/graphics/cairo/SVGPaintServerSolidCairo.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGPaintServerSolid.h" - -#include "GraphicsContext.h" -#include "SVGPaintServer.h" -#include "RenderPath.h" - -namespace WebCore { - -bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const -{ - // TODO: share this code with other PaintServers - cairo_t* cr = context->platformContext(); - - const SVGRenderStyle* svgStyle = object->style()->svgStyle(); - RenderStyle* style = object->style(); - - float red, green, blue, alpha; - color().getRGBA(red, green, blue, alpha); - - if ((type & ApplyToFillTargetType) && svgStyle->hasFill()) { - alpha = svgStyle->fillOpacity(); - context->setFillRule(svgStyle->fillRule()); - } - - if ((type & ApplyToStrokeTargetType) && svgStyle->hasStroke()) { - alpha = svgStyle->strokeOpacity(); - applyStrokeStyleToContext(context, style, object); - } - - cairo_set_source_rgba(cr, red, green, blue, alpha); - - return true; -} - -} // namespace WebCore - -#endif diff --git a/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp deleted file mode 100644 index 6aec0ae..0000000 --- a/WebCore/svg/graphics/cairo/SVGResourceClipperCairo.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * Copyright (C) 2008 Dirk Schulze <vbs85@gmx.de> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGResourceClipper.h" -#include "AffineTransform.h" -#include "CairoPath.h" -#include "GraphicsContext.h" - -#include <cairo.h> - -namespace WebCore { - -void SVGResourceClipper::applyClip(GraphicsContext* context, const FloatRect& boundingBox) const -{ - cairo_t* cr = context->platformContext(); - if (m_clipData.clipData().size() < 1) - return; - - cairo_reset_clip(cr); - context->beginPath(); - - for (unsigned int x = 0; x < m_clipData.clipData().size(); x++) { - ClipData data = m_clipData.clipData()[x]; - - Path path = data.path; - if (path.isEmpty()) - continue; - path.closeSubpath(); - - if (data.bboxUnits) { - // Make use of the clipping units - AffineTransform transform; - transform.translate(boundingBox.x(), boundingBox.y()); - transform.scale(boundingBox.width(), boundingBox.height()); - path.transform(transform); - } - cairo_path_t* clipPath = cairo_copy_path(path.platformPath()->m_cr); - cairo_append_path(cr, clipPath); - - cairo_set_fill_rule(cr, data.windRule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING); - } - - cairo_clip(cr); -} - -} // namespace WebCore - -#endif diff --git a/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp deleted file mode 100644 index a27038a..0000000 --- a/WebCore/svg/graphics/cairo/SVGResourceFilterCairo.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2008 Collabora Ltd. All rights reserved. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#if ENABLE(SVG) && ENABLE(SVG_FILTERS) - -#include "NotImplemented.h" -#include "SVGResourceFilter.h" - -namespace WebCore { - -SVGResourceFilterPlatformData* SVGResourceFilter::createPlatformData() -{ - notImplemented(); - return 0; -} - -void SVGResourceFilter::prepareFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -void SVGResourceFilter::applyFilter(GraphicsContext*&, const FloatRect&) -{ - notImplemented(); -} - -} // namespace WebCore - -#endif - diff --git a/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp b/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp deleted file mode 100644 index 1f690b5..0000000 --- a/WebCore/svg/graphics/cairo/SVGResourceMaskerCairo.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (C) 2007 Alp Toker <alp@atoker.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include "config.h" - -#if ENABLE(SVG) -#include "SVGResourceMasker.h" -#include "Image.h" -#include "ImageBuffer.h" -#include "GraphicsContext.h" - -#include <cairo.h> - -namespace WebCore { - -void SVGResourceMasker::applyMask(GraphicsContext* context, const FloatRect& boundingBox) -{ - if (!m_mask) - return; - - cairo_t* cr = context->platformContext(); - cairo_surface_t* surface = m_mask->image()->nativeImageForCurrentFrame(); - if (!surface) - return; - cairo_pattern_t* mask = cairo_pattern_create_for_surface(surface); - cairo_mask(cr, mask); - cairo_pattern_destroy(mask); -} - -} // namespace WebCore - -#endif |