| 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" | 25 #include "core/paint/SVGPaintServer.h" |
| 27 #include "core/rendering/svg/SVGRenderingContext.h" | 26 #include "core/rendering/svg/SVGRenderingContext.h" |
| 28 #include "core/svg/SVGFitToViewBox.h" | 27 #include "core/svg/SVGFitToViewBox.h" |
| 29 #include "platform/graphics/GraphicsContext.h" | 28 #include "platform/graphics/GraphicsContext.h" |
| 30 | 29 |
| 31 namespace blink { | 30 namespace blink { |
| 32 | 31 |
| 33 const RenderSVGResourceType RenderSVGResourcePattern::s_resourceType = PatternRe
sourceType; | 32 const RenderSVGResourceType RenderSVGResourcePattern::s_resourceType = PatternRe
sourceType; |
| 34 | 33 |
| 35 RenderSVGResourcePattern::RenderSVGResourcePattern(SVGPatternElement* node) | 34 RenderSVGResourcePattern::RenderSVGResourcePattern(SVGPatternElement* node) |
| 36 : RenderSVGResourceContainer(node) | 35 : RenderSVGResourceContainer(node) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 AffineTransform patternTransform = m_attributes.patternTransform(); | 104 AffineTransform patternTransform = m_attributes.patternTransform(); |
| 106 if (!patternTransform.isIdentity()) | 105 if (!patternTransform.isIdentity()) |
| 107 patternData->transform = patternTransform * patternData->transform; | 106 patternData->transform = patternTransform * patternData->transform; |
| 108 | 107 |
| 109 // Various calls above may trigger invalidations in some fringe cases (Image
Buffer allocation | 108 // 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 | 109 // 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. | 110 // 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(); | 111 return m_patternMap.set(object, patternData.release()).storedValue->value.ge
t(); |
| 113 } | 112 } |
| 114 | 113 |
| 115 bool RenderSVGResourcePattern::applyResource(RenderObject* object, RenderStyle*
style, GraphicsContext* context, RenderSVGResourceModeFlags resourceMode) | 114 bool RenderSVGResourcePattern::preparePaintServer(RenderObject* object, RenderSt
yle* style, RenderSVGResourceModeFlags resourceMode, SVGPaintServer& paintServer
) |
| 116 { | 115 { |
| 117 ASSERT(object); | 116 ASSERT(object); |
| 118 ASSERT(style); | 117 ASSERT(style); |
| 119 ASSERT(context); | |
| 120 | 118 |
| 121 clearInvalidationMask(); | 119 clearInvalidationMask(); |
| 122 | 120 |
| 123 SVGPatternElement* patternElement = toSVGPatternElement(element()); | 121 SVGPatternElement* patternElement = toSVGPatternElement(element()); |
| 124 if (!patternElement) | 122 if (!patternElement) |
| 125 return false; | 123 return false; |
| 126 | 124 |
| 127 if (m_shouldCollectPatternAttributes) { | 125 if (m_shouldCollectPatternAttributes) { |
| 128 patternElement->synchronizeAnimatedSVGAttribute(anyQName()); | 126 patternElement->synchronizeAnimatedSVGAttribute(anyQName()); |
| 129 | 127 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 140 | 138 |
| 141 PatternData* patternData = buildPattern(object, patternElement); | 139 PatternData* patternData = buildPattern(object, patternElement); |
| 142 if (!patternData) | 140 if (!patternData) |
| 143 return false; | 141 return false; |
| 144 | 142 |
| 145 const SVGRenderStyle& svgStyle = style->svgStyle(); | 143 const SVGRenderStyle& svgStyle = style->svgStyle(); |
| 146 | 144 |
| 147 AffineTransform computedPatternSpaceTransform = computeResourceSpaceTransfor
m(object, patternData->transform, svgStyle, resourceMode); | 145 AffineTransform computedPatternSpaceTransform = computeResourceSpaceTransfor
m(object, patternData->transform, svgStyle, resourceMode); |
| 148 patternData->pattern->setPatternSpaceTransform(computedPatternSpaceTransform
); | 146 patternData->pattern->setPatternSpaceTransform(computedPatternSpaceTransform
); |
| 149 | 147 |
| 150 // Draw pattern | 148 paintServer.setPattern(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; | 149 return true; |
| 160 } | 150 } |
| 161 | 151 |
| 162 void RenderSVGResourcePattern::postApplyResource(GraphicsContext* context) | |
| 163 { | |
| 164 ASSERT(context); | |
| 165 context->restore(); | |
| 166 } | |
| 167 | |
| 168 static inline FloatRect calculatePatternBoundaries(const PatternAttributes& attr
ibutes, | 152 static inline FloatRect calculatePatternBoundaries(const PatternAttributes& attr
ibutes, |
| 169 const FloatRect& objectBoundi
ngBox, | 153 const FloatRect& objectBoundi
ngBox, |
| 170 const SVGPatternElement* patt
ernElement) | 154 const SVGPatternElement* patt
ernElement) |
| 171 { | 155 { |
| 172 ASSERT(patternElement); | 156 ASSERT(patternElement); |
| 173 return SVGLengthContext::resolveRectangle(patternElement, attributes.pattern
Units(), objectBoundingBox, attributes.x(), attributes.y(), attributes.width(),
attributes.height()); | 157 return SVGLengthContext::resolveRectangle(patternElement, attributes.pattern
Units(), objectBoundingBox, attributes.x(), attributes.y(), attributes.width(),
attributes.height()); |
| 174 } | 158 } |
| 175 | 159 |
| 176 bool RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer, | 160 bool RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer, |
| 177 const PatternAttributes&
attributes, | 161 const PatternAttributes&
attributes, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 continue; | 220 continue; |
| 237 if (element->renderer()->needsLayout()) | 221 if (element->renderer()->needsLayout()) |
| 238 return nullptr; | 222 return nullptr; |
| 239 SVGRenderingContext::renderSubtree(tileImage->context(), element->render
er(), contentTransformation); | 223 SVGRenderingContext::renderSubtree(tileImage->context(), element->render
er(), contentTransformation); |
| 240 } | 224 } |
| 241 | 225 |
| 242 return tileImage.release(); | 226 return tileImage.release(); |
| 243 } | 227 } |
| 244 | 228 |
| 245 } | 229 } |
| OLD | NEW |