OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
5 * Copyright (C) 2009 Google, Inc. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "core/rendering/RenderLayer.h" | 32 #include "core/rendering/RenderLayer.h" |
33 #include "core/rendering/SubtreeLayoutScope.h" | 33 #include "core/rendering/SubtreeLayoutScope.h" |
34 #include "core/rendering/svg/RenderSVGInlineText.h" | 34 #include "core/rendering/svg/RenderSVGInlineText.h" |
35 #include "core/rendering/svg/RenderSVGResourceClipper.h" | 35 #include "core/rendering/svg/RenderSVGResourceClipper.h" |
36 #include "core/rendering/svg/RenderSVGResourceFilter.h" | 36 #include "core/rendering/svg/RenderSVGResourceFilter.h" |
37 #include "core/rendering/svg/RenderSVGResourceMasker.h" | 37 #include "core/rendering/svg/RenderSVGResourceMasker.h" |
38 #include "core/rendering/svg/RenderSVGRoot.h" | 38 #include "core/rendering/svg/RenderSVGRoot.h" |
39 #include "core/rendering/svg/RenderSVGShape.h" | 39 #include "core/rendering/svg/RenderSVGShape.h" |
40 #include "core/rendering/svg/RenderSVGText.h" | 40 #include "core/rendering/svg/RenderSVGText.h" |
41 #include "core/rendering/svg/RenderSVGViewportContainer.h" | 41 #include "core/rendering/svg/RenderSVGViewportContainer.h" |
42 #include "core/rendering/svg/SVGRenderingContext.h" | |
43 #include "core/rendering/svg/SVGResources.h" | 42 #include "core/rendering/svg/SVGResources.h" |
44 #include "core/rendering/svg/SVGResourcesCache.h" | 43 #include "core/rendering/svg/SVGResourcesCache.h" |
45 #include "core/svg/SVGElement.h" | 44 #include "core/svg/SVGElement.h" |
46 #include "platform/geometry/TransformState.h" | 45 #include "platform/geometry/TransformState.h" |
47 | 46 |
48 namespace blink { | 47 namespace blink { |
49 | 48 |
50 LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende
rObject* object, const RenderLayerModelObject* paintInvalidationContainer, const
PaintInvalidationState* paintInvalidationState) | 49 LayoutRect SVGRenderSupport::clippedOverflowRectForPaintInvalidation(const Rende
rObject* object, const RenderLayerModelObject* paintInvalidationContainer, const
PaintInvalidationState* paintInvalidationState) |
51 { | 50 { |
52 // Return early for any cases where we don't actually paint | 51 // Return early for any cases where we don't actually paint |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 return; | 386 return; |
388 | 387 |
389 DashArray dashArray; | 388 DashArray dashArray; |
390 size_t length = dashes->length(); | 389 size_t length = dashes->length(); |
391 for (size_t i = 0; i < length; ++i) | 390 for (size_t i = 0; i < length; ++i) |
392 dashArray.append(dashes->at(i)->value(lengthContext)); | 391 dashArray.append(dashes->at(i)->value(lengthContext)); |
393 | 392 |
394 strokeData->setLineDash(dashArray, svgStyle.strokeDashOffset()->value(length
Context)); | 393 strokeData->setLineDash(dashArray, svgStyle.strokeDashOffset()->value(length
Context)); |
395 } | 394 } |
396 | 395 |
397 static bool shouldTransformOnTextPainting(RenderObject& renderer, AffineTransfor
m& resourceTransform) | 396 bool SVGRenderSupport::updateGraphicsContext(GraphicsContextStateSaver& stateSav
er, RenderStyle* style, RenderObject& renderer, RenderSVGResourceMode resourceMo
de, const AffineTransform* additionalPaintServerTransform) |
398 { | |
399 // This method should only be called for RenderObjects that deal with text r
endering. Cmp. RenderObject.h's is*() methods. | |
400 ASSERT(renderer.isSVGText() || renderer.isSVGTextPath() || renderer.isSVGInl
ine()); | |
401 | |
402 // In text drawing, the scaling part of the graphics context CTM is removed,
compare SVGInlineTextBox::paintTextWithShadows. | |
403 // So, we use that scaling factor here, too, and then push it down to patter
n or gradient space | |
404 // in order to keep the pattern or gradient correctly scaled. | |
405 float scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFac
tor(&renderer); | |
406 if (scalingFactor == 1) | |
407 return false; | |
408 resourceTransform.scale(scalingFactor); | |
409 return true; | |
410 } | |
411 | |
412 static AffineTransform transformOnNonScalingStroke(RenderObject& renderer, const
AffineTransform& resourceTransform) | |
413 { | |
414 ASSERT(renderer.isSVGShape()); | |
415 SVGGraphicsElement* element = toSVGGraphicsElement(renderer.node()); | |
416 AffineTransform transform = element->getScreenCTM(SVGGraphicsElement::Disall
owStyleUpdate); | |
417 transform *= resourceTransform; | |
418 return transform; | |
419 } | |
420 | |
421 static AffineTransform computeResourceSpaceTransform(RenderObject& renderer, con
st SVGRenderStyle& svgStyle, RenderSVGResourceModeFlags resourceModeFlags) | |
422 { | |
423 AffineTransform computedSpaceTransform; | |
424 if (resourceModeFlags & ApplyToTextMode) { | |
425 // Depending on the font scaling factor, we may need to apply an | |
426 // additional transform (scale-factor) to the paintserver, since text | |
427 // painting removes the scale factor from the context. (See | |
428 // SVGInlineTextBoxPainter::paintTextWithShadows.) | |
429 AffineTransform additionalTextTransformation; | |
430 if (shouldTransformOnTextPainting(renderer, additionalTextTransformation
)) | |
431 computedSpaceTransform = additionalTextTransformation; | |
432 } | |
433 if (resourceModeFlags & ApplyToStrokeMode) { | |
434 // Non-scaling stroke needs to reset the transform back to the host tran
sform. | |
435 if (renderer.isSVGShape() && svgStyle.vectorEffect() == VE_NON_SCALING_S
TROKE) | |
436 computedSpaceTransform = transformOnNonScalingStroke(renderer, compu
tedSpaceTransform); | |
437 } | |
438 return computedSpaceTransform; | |
439 } | |
440 | |
441 bool SVGRenderSupport::updateGraphicsContext(GraphicsContextStateSaver& stateSav
er, RenderStyle* style, RenderObject& renderer, unsigned resourceModeFlags) | |
442 { | 397 { |
443 ASSERT(style); | 398 ASSERT(style); |
444 | 399 |
445 RenderSVGResourceMode resourceMode = static_cast<RenderSVGResourceMode>(reso
urceModeFlags & (ApplyToFillMode | ApplyToStrokeMode)); | |
446 ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode)
; | |
447 | |
448 GraphicsContext* context = stateSaver.context(); | 400 GraphicsContext* context = stateSaver.context(); |
449 if (isRenderingClipPathAsMaskImage(renderer)) { | 401 if (isRenderingClipPathAsMaskImage(renderer)) { |
450 if (resourceMode == ApplyToStrokeMode) | 402 if (resourceMode == ApplyToStrokeMode) |
451 return false; | 403 return false; |
452 context->setAlphaAsFloat(1); | 404 context->setAlphaAsFloat(1); |
453 context->setFillColor(SVGRenderStyle::initialFillPaintColor()); | 405 context->setFillColor(SVGRenderStyle::initialFillPaintColor()); |
454 return true; | 406 return true; |
455 } | 407 } |
456 | 408 |
457 SVGPaintServer paintServer = SVGPaintServer::requestForRenderer(renderer, st
yle, resourceMode); | 409 SVGPaintServer paintServer = SVGPaintServer::requestForRenderer(renderer, st
yle, resourceMode); |
458 if (!paintServer.isValid()) | 410 if (!paintServer.isValid()) |
459 return false; | 411 return false; |
460 | 412 |
461 const SVGRenderStyle& svgStyle = style->svgStyle(); | 413 if (additionalPaintServerTransform && paintServer.isTransformDependent()) |
462 | 414 paintServer.prependTransform(*additionalPaintServerTransform); |
463 if (paintServer.isTransformDependent()) | |
464 paintServer.prependTransform(computeResourceSpaceTransform(renderer, svg
Style, resourceModeFlags)); | |
465 | 415 |
466 paintServer.apply(*context, resourceMode, &stateSaver); | 416 paintServer.apply(*context, resourceMode, &stateSaver); |
467 | 417 |
| 418 const SVGRenderStyle& svgStyle = style->svgStyle(); |
| 419 |
468 if (resourceMode == ApplyToFillMode) { | 420 if (resourceMode == ApplyToFillMode) { |
469 context->setAlphaAsFloat(svgStyle.fillOpacity()); | 421 context->setAlphaAsFloat(svgStyle.fillOpacity()); |
470 context->setFillRule(svgStyle.fillRule()); | 422 context->setFillRule(svgStyle.fillRule()); |
471 } else { | 423 } else { |
472 context->setAlphaAsFloat(svgStyle.strokeOpacity()); | 424 context->setAlphaAsFloat(svgStyle.strokeOpacity()); |
473 applyStrokeStyleToContext(context, style, &renderer); | 425 applyStrokeStyleToContext(context, style, &renderer); |
474 } | 426 } |
475 return true; | 427 return true; |
476 } | 428 } |
477 | 429 |
478 bool SVGRenderSupport::isRenderableTextNode(const RenderObject* object) | 430 bool SVGRenderSupport::isRenderableTextNode(const RenderObject* object) |
479 { | 431 { |
480 ASSERT(object->isText()); | 432 ASSERT(object->isText()); |
481 // <br> is marked as text, but is not handled by the SVG rendering code-path
. | 433 // <br> is marked as text, but is not handled by the SVG rendering code-path
. |
482 return object->isSVGInlineText() && !toRenderSVGInlineText(object)->hasEmpty
Text(); | 434 return object->isSVGInlineText() && !toRenderSVGInlineText(object)->hasEmpty
Text(); |
483 } | 435 } |
484 | 436 |
485 } | 437 } |
OLD | NEW |