| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 */ | 19 */ |
| 20 | 20 |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 | |
| 23 #include "core/rendering/svg/RenderSVGResourcePattern.h" | 22 #include "core/rendering/svg/RenderSVGResourcePattern.h" |
| 24 | 23 |
| 25 #include "core/dom/ElementTraversal.h" | 24 #include "core/dom/ElementTraversal.h" |
| 26 #include "core/rendering/svg/SVGRenderSupport.h" | |
| 27 #include "core/rendering/svg/SVGRenderingContext.h" | 25 #include "core/rendering/svg/SVGRenderingContext.h" |
| 28 #include "core/svg/SVGFitToViewBox.h" | 26 #include "core/svg/SVGFitToViewBox.h" |
| 29 #include "platform/graphics/GraphicsContext.h" | 27 #include "platform/graphics/GraphicsContext.h" |
| 30 | 28 |
| 31 namespace blink { | 29 namespace blink { |
| 32 | 30 |
| 33 const RenderSVGResourceType RenderSVGResourcePattern::s_resourceType = PatternRe
sourceType; | 31 const RenderSVGResourceType RenderSVGResourcePattern::s_resourceType = PatternRe
sourceType; |
| 34 | 32 |
| 35 RenderSVGResourcePattern::RenderSVGResourcePattern(SVGPatternElement* node) | 33 RenderSVGResourcePattern::RenderSVGResourcePattern(SVGPatternElement* node) |
| 36 : RenderSVGResourceContainer(node) | 34 : RenderSVGResourceContainer(node) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 AffineTransform patternTransform = m_attributes.patternTransform(); | 103 AffineTransform patternTransform = m_attributes.patternTransform(); |
| 106 if (!patternTransform.isIdentity()) | 104 if (!patternTransform.isIdentity()) |
| 107 patternData->transform = patternTransform * patternData->transform; | 105 patternData->transform = patternTransform * patternData->transform; |
| 108 | 106 |
| 109 // Various calls above may trigger invalidations in some fringe cases (Image
Buffer allocation | 107 // Various calls above may trigger invalidations in some fringe cases (Image
Buffer allocation |
| 110 // failures in the SVG image cache for example). To avoid having our Pattern
Data deleted by | 108 // failures in the SVG image cache for example). To avoid having our Pattern
Data deleted by |
| 111 // removeAllClientsFromCache(), we only make it visible in the cache at the
very end. | 109 // removeAllClientsFromCache(), we only make it visible in the cache at the
very end. |
| 112 return m_patternMap.set(object, patternData.release()).storedValue->value.ge
t(); | 110 return m_patternMap.set(object, patternData.release()).storedValue->value.ge
t(); |
| 113 } | 111 } |
| 114 | 112 |
| 115 bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle*
style, GraphicsContext* context, RenderSVGResourceModeFlags resourceMode) | 113 SVGPaintServer RenderSVGResourcePattern::preparePaintServer(RenderObject* object
, RenderStyle* style, RenderSVGResourceModeFlags resourceMode) |
| 116 { | 114 { |
| 117 ASSERT(object); | 115 ASSERT(object); |
| 118 ASSERT(style); | 116 ASSERT(style); |
| 119 ASSERT(context); | |
| 120 | 117 |
| 121 clearInvalidationMask(); | 118 clearInvalidationMask(); |
| 122 | 119 |
| 123 SVGPatternElement* patternElement = toSVGPatternElement(element()); | 120 SVGPatternElement* patternElement = toSVGPatternElement(element()); |
| 124 if (!patternElement) | 121 if (!patternElement) |
| 125 return false; | 122 return SVGPaintServer::invalid(); |
| 126 | 123 |
| 127 if (m_shouldCollectPatternAttributes) { | 124 if (m_shouldCollectPatternAttributes) { |
| 128 patternElement->synchronizeAnimatedSVGAttribute(anyQName()); | 125 patternElement->synchronizeAnimatedSVGAttribute(anyQName()); |
| 129 | 126 |
| 130 m_attributes = PatternAttributes(); | 127 m_attributes = PatternAttributes(); |
| 131 patternElement->collectPatternAttributes(m_attributes); | 128 patternElement->collectPatternAttributes(m_attributes); |
| 132 m_shouldCollectPatternAttributes = false; | 129 m_shouldCollectPatternAttributes = false; |
| 133 } | 130 } |
| 134 | 131 |
| 135 // Spec: When the geometry of the applicable element has no width or height
and objectBoundingBox is specified, | 132 // Spec: When the geometry of the applicable element has no width or height
and objectBoundingBox is specified, |
| 136 // then the given effect (e.g. a gradient or a filter) will be ignored. | 133 // then the given effect (e.g. a gradient or a filter) will be ignored. |
| 137 FloatRect objectBoundingBox = object->objectBoundingBox(); | 134 FloatRect objectBoundingBox = object->objectBoundingBox(); |
| 138 if (m_attributes.patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDIN
GBOX && objectBoundingBox.isEmpty()) | 135 if (m_attributes.patternUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDIN
GBOX && objectBoundingBox.isEmpty()) |
| 139 return false; | 136 return SVGPaintServer::invalid(); |
| 140 | 137 |
| 141 PatternData* patternData = buildPattern(object, patternElement); | 138 PatternData* patternData = buildPattern(object, patternElement); |
| 142 if (!patternData) | 139 if (!patternData) |
| 143 return false; | 140 return SVGPaintServer::invalid(); |
| 144 | 141 |
| 145 const SVGRenderStyle& svgStyle = style->svgStyle(); | 142 const SVGRenderStyle& svgStyle = style->svgStyle(); |
| 146 | 143 |
| 147 AffineTransform computedPatternSpaceTransform = computeResourceSpaceTransfor
m(object, patternData->transform, svgStyle, resourceMode); | 144 AffineTransform computedPatternSpaceTransform = computeResourceSpaceTransfor
m(object, patternData->transform, svgStyle, resourceMode); |
| 148 patternData->pattern->setPatternSpaceTransform(computedPatternSpaceTransform
); | 145 patternData->pattern->setPatternSpaceTransform(computedPatternSpaceTransform
); |
| 149 | 146 |
| 150 // Draw pattern | 147 return SVGPaintServer(patternData->pattern); |
| 151 context->save(); | |
| 152 | |
| 153 if (resourceMode & ApplyToFillMode) | |
| 154 context->setFillPattern(patternData->pattern); | |
| 155 else if (resourceMode & ApplyToStrokeMode) | |
| 156 context->setStrokePattern(patternData->pattern); | |
| 157 | |
| 158 updateGraphicsContext(context, style, *object, resourceMode); | |
| 159 return true; | |
| 160 } | |
| 161 | |
| 162 void RenderSVGResourcePattern::postApplyResource(GraphicsContext* context) | |
| 163 { | |
| 164 ASSERT(context); | |
| 165 context->restore(); | |
| 166 } | 148 } |
| 167 | 149 |
| 168 static inline FloatRect calculatePatternBoundaries(const PatternAttributes& attr
ibutes, | 150 static inline FloatRect calculatePatternBoundaries(const PatternAttributes& attr
ibutes, |
| 169 const FloatRect& objectBoundi
ngBox, | 151 const FloatRect& objectBoundi
ngBox, |
| 170 const SVGPatternElement* patt
ernElement) | 152 const SVGPatternElement* patt
ernElement) |
| 171 { | 153 { |
| 172 ASSERT(patternElement); | 154 ASSERT(patternElement); |
| 173 return SVGLengthContext::resolveRectangle(patternElement, attributes.pattern
Units(), objectBoundingBox, attributes.x(), attributes.y(), attributes.width(),
attributes.height()); | 155 return SVGLengthContext::resolveRectangle(patternElement, attributes.pattern
Units(), objectBoundingBox, attributes.x(), attributes.y(), attributes.width(),
attributes.height()); |
| 174 } | 156 } |
| 175 | 157 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 continue; | 218 continue; |
| 237 if (element->renderer()->needsLayout()) | 219 if (element->renderer()->needsLayout()) |
| 238 return nullptr; | 220 return nullptr; |
| 239 SVGRenderingContext::renderSubtree(tileImage->context(), element->render
er(), contentTransformation); | 221 SVGRenderingContext::renderSubtree(tileImage->context(), element->render
er(), contentTransformation); |
| 240 } | 222 } |
| 241 | 223 |
| 242 return tileImage.release(); | 224 return tileImage.release(); |
| 243 } | 225 } |
| 244 | 226 |
| 245 } | 227 } |
| OLD | NEW |