OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> | 5 * Copyright (C) 2011 Dirk Schulze <krit@webkit.org> |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 238 |
239 AffineTransform contentTransformation; | 239 AffineTransform contentTransformation; |
240 SVGUnitTypes::SVGUnitType contentUnits = toSVGClipPathElement(element())->cl
ipPathUnits()->currentValue()->enumValue(); | 240 SVGUnitTypes::SVGUnitType contentUnits = toSVGClipPathElement(element())->cl
ipPathUnits()->currentValue()->enumValue(); |
241 if (contentUnits == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { | 241 if (contentUnits == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { |
242 contentTransformation.translate(targetBoundingBox.x(), targetBoundingBox
.y()); | 242 contentTransformation.translate(targetBoundingBox.x(), targetBoundingBox
.y()); |
243 contentTransformation.scaleNonUniform(targetBoundingBox.width(), targetB
oundingBox.height()); | 243 contentTransformation.scaleNonUniform(targetBoundingBox.width(), targetB
oundingBox.height()); |
244 context->concatCTM(contentTransformation); | 244 context->concatCTM(contentTransformation); |
245 } | 245 } |
246 | 246 |
247 if (!m_clipContentDisplayList) | 247 if (!m_clipContentDisplayList) |
248 m_clipContentDisplayList = asDisplayList(context, contentTransformation)
; | 248 createDisplayList(context, contentTransformation); |
249 | 249 |
250 ASSERT(m_clipContentDisplayList); | 250 ASSERT(m_clipContentDisplayList); |
251 context->drawDisplayList(m_clipContentDisplayList.get()); | 251 context->drawDisplayList(m_clipContentDisplayList.get()); |
252 } | 252 } |
253 | 253 |
254 PassRefPtr<DisplayList> RenderSVGResourceClipper::asDisplayList(GraphicsContext*
context, | 254 void RenderSVGResourceClipper::createDisplayList(GraphicsContext* context, |
255 const AffineTransform& contentTransformation) | 255 const AffineTransform& contentTransformation) |
256 { | 256 { |
257 ASSERT(context); | 257 ASSERT(context); |
258 ASSERT(frame()); | 258 ASSERT(frame()); |
259 | 259 |
260 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection | 260 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection |
261 // with local clips/mask, which may yield incorrect results when mixing obje
ctBoundingBox and | 261 // with local clips/mask, which may yield incorrect results when mixing obje
ctBoundingBox and |
262 // userSpaceOnUse units (http://crbug.com/294900). | 262 // userSpaceOnUse units (http://crbug.com/294900). |
263 context->beginRecording(strokeBoundingBox()); | 263 FloatRect bounds = strokeBoundingBox(); |
| 264 context->beginRecording(bounds); |
264 | 265 |
265 // Switch to a paint behavior where all children of this <clipPath> will be
rendered using special constraints: | 266 // Switch to a paint behavior where all children of this <clipPath> will be
rendered using special constraints: |
266 // - fill-opacity/stroke-opacity/opacity set to 1 | 267 // - fill-opacity/stroke-opacity/opacity set to 1 |
267 // - masker/filter not applied when rendering the children | 268 // - masker/filter not applied when rendering the children |
268 // - fill is set to the initial fill paint server (solid, black) | 269 // - fill is set to the initial fill paint server (solid, black) |
269 // - stroke is set to the initial stroke paint server (none) | 270 // - stroke is set to the initial stroke paint server (none) |
270 PaintBehavior oldBehavior = frame()->view()->paintBehavior(); | 271 PaintBehavior oldBehavior = frame()->view()->paintBehavior(); |
271 frame()->view()->setPaintBehavior(oldBehavior | PaintBehaviorRenderingSVGMas
k); | 272 frame()->view()->setPaintBehavior(oldBehavior | PaintBehaviorRenderingSVGMas
k); |
272 | 273 |
273 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 274 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
(...skipping 23 matching lines...) Expand all Loading... |
297 context->setFillRule(newClipRule); | 298 context->setFillRule(newClipRule); |
298 | 299 |
299 if (isUseElement) | 300 if (isUseElement) |
300 renderer = childElement->renderer(); | 301 renderer = childElement->renderer(); |
301 | 302 |
302 SVGRenderingContext::renderSubtree(context, renderer, contentTransformat
ion); | 303 SVGRenderingContext::renderSubtree(context, renderer, contentTransformat
ion); |
303 } | 304 } |
304 | 305 |
305 frame()->view()->setPaintBehavior(oldBehavior); | 306 frame()->view()->setPaintBehavior(oldBehavior); |
306 | 307 |
307 return context->endRecording(); | 308 m_clipContentDisplayList = context->endRecording(); |
308 } | 309 } |
309 | 310 |
310 void RenderSVGResourceClipper::calculateClipContentPaintInvalidationRect() | 311 void RenderSVGResourceClipper::calculateClipContentPaintInvalidationRect() |
311 { | 312 { |
312 // This is a rough heuristic to appraise the clip size and doesn't consider
clip on clip. | 313 // This is a rough heuristic to appraise the clip size and doesn't consider
clip on clip. |
313 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 314 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
314 RenderObject* renderer = childElement->renderer(); | 315 RenderObject* renderer = childElement->renderer(); |
315 if (!renderer) | 316 if (!renderer) |
316 continue; | 317 continue; |
317 if (!renderer->isSVGShape() && !renderer->isSVGText() && !isSVGUseElemen
t(*childElement)) | 318 if (!renderer->isSVGShape() && !renderer->isSVGText() && !isSVGUseElemen
t(*childElement)) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 AffineTransform transform; | 374 AffineTransform transform; |
374 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 375 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
375 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); | 376 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); |
376 return transform.mapRect(m_clipBoundaries); | 377 return transform.mapRect(m_clipBoundaries); |
377 } | 378 } |
378 | 379 |
379 return m_clipBoundaries; | 380 return m_clipBoundaries; |
380 } | 381 } |
381 | 382 |
382 } | 383 } |
OLD | NEW |