OLD | NEW |
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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 GraphicsContext*& context, unsigned short resourceMode) | 59 GraphicsContext*& context, unsigned short resourceMode) |
60 { | 60 { |
61 ASSERT(object); | 61 ASSERT(object); |
62 ASSERT(context); | 62 ASSERT(context); |
63 ASSERT(style()); | 63 ASSERT(style()); |
64 ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode); | 64 ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode); |
65 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); | 65 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); |
66 | 66 |
67 clearInvalidationMask(); | 67 clearInvalidationMask(); |
68 | 68 |
69 FloatRect repaintRect = object->repaintRectInLocalCoordinates(); | 69 FloatRect repaintRect = object->paintInvalidationRectInLocalCoordinates(); |
70 if (repaintRect.isEmpty() || !element()->hasChildren()) | 70 if (repaintRect.isEmpty() || !element()->hasChildren()) |
71 return false; | 71 return false; |
72 | 72 |
73 // Content layer start. | 73 // Content layer start. |
74 context->beginTransparencyLayer(1, &repaintRect); | 74 context->beginTransparencyLayer(1, &repaintRect); |
75 | 75 |
76 return true; | 76 return true; |
77 } | 77 } |
78 | 78 |
79 void RenderSVGResourceMasker::postApplyResource(RenderObject* object, GraphicsCo
ntext*& context, | 79 void RenderSVGResourceMasker::postApplyResource(RenderObject* object, GraphicsCo
ntext*& context, |
80 unsigned short resourceMode, const Path*, const RenderSVGShape*) | 80 unsigned short resourceMode, const Path*, const RenderSVGShape*) |
81 { | 81 { |
82 ASSERT(object); | 82 ASSERT(object); |
83 ASSERT(context); | 83 ASSERT(context); |
84 ASSERT(style()); | 84 ASSERT(style()); |
85 ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode); | 85 ASSERT_UNUSED(resourceMode, resourceMode == ApplyToDefaultMode); |
86 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); | 86 ASSERT_WITH_SECURITY_IMPLICATION(!needsLayout()); |
87 | 87 |
88 FloatRect repaintRect = object->repaintRectInLocalCoordinates(); | 88 FloatRect repaintRect = object->paintInvalidationRectInLocalCoordinates(); |
89 | 89 |
90 const SVGRenderStyle* svgStyle = style()->svgStyle(); | 90 const SVGRenderStyle* svgStyle = style()->svgStyle(); |
91 ASSERT(svgStyle); | 91 ASSERT(svgStyle); |
92 ColorFilter maskLayerFilter = svgStyle->maskType() == MT_LUMINANCE | 92 ColorFilter maskLayerFilter = svgStyle->maskType() == MT_LUMINANCE |
93 ? ColorFilterLuminanceToAlpha : ColorFilterNone; | 93 ? ColorFilterLuminanceToAlpha : ColorFilterNone; |
94 ColorFilter maskContentFilter = svgStyle->colorInterpolation() == CI_LINEARR
GB | 94 ColorFilter maskContentFilter = svgStyle->colorInterpolation() == CI_LINEARR
GB |
95 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; | 95 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; |
96 | 96 |
97 // Mask layer start. | 97 // Mask layer start. |
98 context->beginLayer(1, CompositeDestinationIn, &repaintRect, maskLayerFilter
); | 98 context->beginLayer(1, CompositeDestinationIn, &repaintRect, maskLayerFilter
); |
(...skipping 27 matching lines...) Expand all Loading... |
126 m_maskContentDisplayList = asDisplayList(context, contentTransformation)
; | 126 m_maskContentDisplayList = asDisplayList(context, contentTransformation)
; |
127 ASSERT(m_maskContentDisplayList); | 127 ASSERT(m_maskContentDisplayList); |
128 context->drawDisplayList(m_maskContentDisplayList.get()); | 128 context->drawDisplayList(m_maskContentDisplayList.get()); |
129 } | 129 } |
130 | 130 |
131 PassRefPtr<DisplayList> RenderSVGResourceMasker::asDisplayList(GraphicsContext*
context, | 131 PassRefPtr<DisplayList> RenderSVGResourceMasker::asDisplayList(GraphicsContext*
context, |
132 const AffineTransform& contentTransform) | 132 const AffineTransform& contentTransform) |
133 { | 133 { |
134 ASSERT(context); | 134 ASSERT(context); |
135 | 135 |
136 // Using strokeBoundingBox (instead of repaintRectInLocalCoordinates) to avo
id the intersection | 136 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection |
137 // with local clips/mask, which may yield incorrect results when mixing obje
ctBoundingBox and | 137 // with local clips/mask, which may yield incorrect results when mixing obje
ctBoundingBox and |
138 // userSpaceOnUse units (http://crbug.com/294900). | 138 // userSpaceOnUse units (http://crbug.com/294900). |
139 context->beginRecording(strokeBoundingBox()); | 139 context->beginRecording(strokeBoundingBox()); |
140 for (Element* childElement = ElementTraversal::firstWithin(*element()); chil
dElement; childElement = ElementTraversal::nextSibling(*childElement)) { | 140 for (Element* childElement = ElementTraversal::firstWithin(*element()); chil
dElement; childElement = ElementTraversal::nextSibling(*childElement)) { |
141 RenderObject* renderer = childElement->renderer(); | 141 RenderObject* renderer = childElement->renderer(); |
142 if (!childElement->isSVGElement() || !renderer) | 142 if (!childElement->isSVGElement() || !renderer) |
143 continue; | 143 continue; |
144 RenderStyle* style = renderer->style(); | 144 RenderStyle* style = renderer->style(); |
145 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 145 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) |
146 continue; | 146 continue; |
147 | 147 |
148 SVGRenderingContext::renderSubtree(context, renderer, contentTransform); | 148 SVGRenderingContext::renderSubtree(context, renderer, contentTransform); |
149 } | 149 } |
150 | 150 |
151 return context->endRecording(); | 151 return context->endRecording(); |
152 } | 152 } |
153 | 153 |
154 void RenderSVGResourceMasker::calculateMaskContentRepaintRect() | 154 void RenderSVGResourceMasker::calculateMaskContentRepaintRect() |
155 { | 155 { |
156 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 156 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
157 RenderObject* renderer = childElement->renderer(); | 157 RenderObject* renderer = childElement->renderer(); |
158 if (!renderer) | 158 if (!renderer) |
159 continue; | 159 continue; |
160 RenderStyle* style = renderer->style(); | 160 RenderStyle* style = renderer->style(); |
161 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 161 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) |
162 continue; | 162 continue; |
163 m_maskContentBoundaries.unite(renderer->localToParentTransform().mapRect
(renderer->repaintRectInLocalCoordinates())); | 163 m_maskContentBoundaries.unite(renderer->localToParentTransform().mapRect
(renderer->paintInvalidationRectInLocalCoordinates())); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 FloatRect RenderSVGResourceMasker::resourceBoundingBox(const RenderObject* objec
t) | 167 FloatRect RenderSVGResourceMasker::resourceBoundingBox(const RenderObject* objec
t) |
168 { | 168 { |
169 SVGMaskElement* maskElement = toSVGMaskElement(element()); | 169 SVGMaskElement* maskElement = toSVGMaskElement(element()); |
170 ASSERT(maskElement); | 170 ASSERT(maskElement); |
171 | 171 |
172 FloatRect objectBoundingBox = object->objectBoundingBox(); | 172 FloatRect objectBoundingBox = object->objectBoundingBox(); |
173 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement
>(maskElement, maskElement->maskUnits()->currentValue()->enumValue(), objectBoun
dingBox); | 173 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement
>(maskElement, maskElement->maskUnits()->currentValue()->enumValue(), objectBoun
dingBox); |
(...skipping 11 matching lines...) Expand all Loading... |
185 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 185 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
186 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); | 186 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); |
187 maskRect = transform.mapRect(maskRect); | 187 maskRect = transform.mapRect(maskRect); |
188 } | 188 } |
189 | 189 |
190 maskRect.intersect(maskBoundaries); | 190 maskRect.intersect(maskBoundaries); |
191 return maskRect; | 191 return maskRect; |
192 } | 192 } |
193 | 193 |
194 } | 194 } |
OLD | NEW |