Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(755)

Side by Side Diff: Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp

Issue 9235065: Merge 105978 - crash in WebCore::RenderSVGContainer::paint (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/963/
Patch Set: Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return false; 110 return false;
111 111
112 GraphicsContext* maskImageContext = maskerData->maskImage->context(); 112 GraphicsContext* maskImageContext = maskerData->maskImage->context();
113 ASSERT(maskImageContext); 113 ASSERT(maskImageContext);
114 114
115 // The save/restore pair is needed for clipToImageBuffer - it doesn't wo rk without it on non-Cg platforms. 115 // The save/restore pair is needed for clipToImageBuffer - it doesn't wo rk without it on non-Cg platforms.
116 maskImageContext->save(); 116 maskImageContext->save();
117 maskImageContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbso luteTargetRect.y()); 117 maskImageContext->translate(-clampedAbsoluteTargetRect.x(), -clampedAbso luteTargetRect.y());
118 maskImageContext->concatCTM(absoluteTransform); 118 maskImageContext->concatCTM(absoluteTransform);
119 119
120 drawContentIntoMaskImage(maskerData, colorSpace, maskElement, object); 120 if (!drawContentIntoMaskImage(maskerData, colorSpace, maskElement, objec t)) {
121 maskImageContext->restore();
122 maskerData->maskImage.clear();
123 }
121 } 124 }
122 125
123 if (!maskerData->maskImage) 126 if (!maskerData->maskImage)
124 return false; 127 return false;
125 128
126 SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAb soluteTargetRect, maskerData->maskImage); 129 SVGImageBufferTools::clipToImageBuffer(context, absoluteTransform, clampedAb soluteTargetRect, maskerData->maskImage);
127 return true; 130 return true;
128 } 131 }
129 132
130 void RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, C olorSpace colorSpace, const SVGMaskElement* maskElement, RenderObject* object) 133 bool RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, C olorSpace colorSpace, const SVGMaskElement* maskElement, RenderObject* object)
131 { 134 {
132 GraphicsContext* maskImageContext = maskerData->maskImage->context(); 135 GraphicsContext* maskImageContext = maskerData->maskImage->context();
133 ASSERT(maskImageContext); 136 ASSERT(maskImageContext);
134 137
135 // Eventually adjust the mask image context according to the target objectBo undingBox. 138 // Eventually adjust the mask image context according to the target objectBo undingBox.
136 AffineTransform maskContentTransformation; 139 AffineTransform maskContentTransformation;
137 if (maskElement->maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOU NDINGBOX) { 140 if (maskElement->maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOU NDINGBOX) {
138 FloatRect objectBoundingBox = object->objectBoundingBox(); 141 FloatRect objectBoundingBox = object->objectBoundingBox();
139 maskContentTransformation.translate(objectBoundingBox.x(), objectBoundin gBox.y()); 142 maskContentTransformation.translate(objectBoundingBox.x(), objectBoundin gBox.y());
140 maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), obj ectBoundingBox.height()); 143 maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), obj ectBoundingBox.height());
141 maskImageContext->concatCTM(maskContentTransformation); 144 maskImageContext->concatCTM(maskContentTransformation);
142 } 145 }
143 146
144 // Draw the content into the ImageBuffer. 147 // Draw the content into the ImageBuffer.
145 for (Node* node = maskElement->firstChild(); node; node = node->nextSibling( )) { 148 for (Node* node = maskElement->firstChild(); node; node = node->nextSibling( )) {
146 RenderObject* renderer = node->renderer(); 149 RenderObject* renderer = node->renderer();
147 if (!node->isSVGElement() || !static_cast<SVGElement*>(node)->isStyled() || !renderer) 150 if (!node->isSVGElement() || !static_cast<SVGElement*>(node)->isStyled() || !renderer)
148 continue; 151 continue;
152 if (renderer->needsLayout())
153 return false;
149 RenderStyle* style = renderer->style(); 154 RenderStyle* style = renderer->style();
150 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) 155 if (!style || style->display() == NONE || style->visibility() != VISIBLE )
151 continue; 156 continue;
152 SVGImageBufferTools::renderSubtreeToImageBuffer(maskerData->maskImage.ge t(), renderer, maskContentTransformation); 157 SVGImageBufferTools::renderSubtreeToImageBuffer(maskerData->maskImage.ge t(), renderer, maskContentTransformation);
153 } 158 }
154 159
155 maskImageContext->restore(); 160 maskImageContext->restore();
156 161
157 #if !USE(CG) 162 #if !USE(CG)
158 maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, colorSpace); 163 maskerData->maskImage->transformColorSpace(ColorSpaceDeviceRGB, colorSpace);
159 #else 164 #else
160 UNUSED_PARAM(colorSpace); 165 UNUSED_PARAM(colorSpace);
161 #endif 166 #endif
162 167
163 // Create the luminance mask. 168 // Create the luminance mask.
164 maskerData->maskImage->convertToLuminanceMask(); 169 maskerData->maskImage->convertToLuminanceMask();
170 return true;
165 } 171 }
166 172
167 void RenderSVGResourceMasker::calculateMaskContentRepaintRect() 173 void RenderSVGResourceMasker::calculateMaskContentRepaintRect()
168 { 174 {
169 for (Node* childNode = node()->firstChild(); childNode; childNode = childNod e->nextSibling()) { 175 for (Node* childNode = node()->firstChild(); childNode; childNode = childNod e->nextSibling()) {
170 RenderObject* renderer = childNode->renderer(); 176 RenderObject* renderer = childNode->renderer();
171 if (!childNode->isSVGElement() || !static_cast<SVGElement*>(childNode)-> isStyled() || !renderer) 177 if (!childNode->isSVGElement() || !static_cast<SVGElement*>(childNode)-> isStyled() || !renderer)
172 continue; 178 continue;
173 RenderStyle* style = renderer->style(); 179 RenderStyle* style = renderer->style();
174 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) 180 if (!style || style->display() == NONE || style->visibility() != VISIBLE )
(...skipping 25 matching lines...) Expand all
200 maskRect = transform.mapRect(maskRect); 206 maskRect = transform.mapRect(maskRect);
201 } 207 }
202 208
203 maskRect.intersect(maskBoundaries); 209 maskRect.intersect(maskBoundaries);
204 return maskRect; 210 return maskRect;
205 } 211 }
206 212
207 } 213 }
208 214
209 #endif // ENABLE(SVG) 215 #endif // ENABLE(SVG)
OLDNEW
« no previous file with comments | « Source/WebCore/rendering/svg/RenderSVGResourceMasker.h ('k') | Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698