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->paintInvalidationRectInLocalCoordinates(); | 69 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); |
70 if (repaintRect.isEmpty() || !element()->hasChildren()) | 70 if (paintInvalidationRect.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, &paintInvalidationRect); |
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->paintInvalidationRectInLocalCoordinates(); | 88 FloatRect paintInvalidationRect = object->paintInvalidationRectInLocalCoordi
nates(); |
89 | 89 |
90 const SVGRenderStyle& svgStyle = style()->svgStyle(); | 90 const SVGRenderStyle& svgStyle = style()->svgStyle(); |
91 ColorFilter maskLayerFilter = svgStyle.maskType() == MT_LUMINANCE | 91 ColorFilter maskLayerFilter = svgStyle.maskType() == MT_LUMINANCE |
92 ? ColorFilterLuminanceToAlpha : ColorFilterNone; | 92 ? ColorFilterLuminanceToAlpha : ColorFilterNone; |
93 ColorFilter maskContentFilter = svgStyle.colorInterpolation() == CI_LINEARRG
B | 93 ColorFilter maskContentFilter = svgStyle.colorInterpolation() == CI_LINEARRG
B |
94 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; | 94 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; |
95 | 95 |
96 // Mask layer start. | 96 // Mask layer start. |
97 context->beginLayer(1, CompositeDestinationIn, &repaintRect, maskLayerFilter
); | 97 context->beginLayer(1, CompositeDestinationIn, &paintInvalidationRect, maskL
ayerFilter); |
98 { | 98 { |
99 // Draw the mask with color conversion (when needed). | 99 // Draw the mask with color conversion (when needed). |
100 GraphicsContextStateSaver maskContentSaver(*context); | 100 GraphicsContextStateSaver maskContentSaver(*context); |
101 context->setColorFilter(maskContentFilter); | 101 context->setColorFilter(maskContentFilter); |
102 | 102 |
103 drawMaskForRenderer(context, object->objectBoundingBox()); | 103 drawMaskForRenderer(context, object->objectBoundingBox()); |
104 } | 104 } |
105 | 105 |
106 // Transfer mask layer -> content layer (DstIn) | 106 // Transfer mask layer -> content layer (DstIn) |
107 context->endLayer(); | 107 context->endLayer(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 RenderStyle* style = renderer->style(); | 143 RenderStyle* style = renderer->style(); |
144 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 144 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) |
145 continue; | 145 continue; |
146 | 146 |
147 SVGRenderingContext::renderSubtree(context, renderer, contentTransform); | 147 SVGRenderingContext::renderSubtree(context, renderer, contentTransform); |
148 } | 148 } |
149 | 149 |
150 return context->endRecording(); | 150 return context->endRecording(); |
151 } | 151 } |
152 | 152 |
153 void RenderSVGResourceMasker::calculateMaskContentRepaintRect() | 153 void RenderSVGResourceMasker::calculateMaskContentPaintInvalidationRect() |
154 { | 154 { |
155 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 155 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
156 RenderObject* renderer = childElement->renderer(); | 156 RenderObject* renderer = childElement->renderer(); |
157 if (!renderer) | 157 if (!renderer) |
158 continue; | 158 continue; |
159 RenderStyle* style = renderer->style(); | 159 RenderStyle* style = renderer->style(); |
160 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 160 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) |
161 continue; | 161 continue; |
162 m_maskContentBoundaries.unite(renderer->localToParentTransform().mapRect
(renderer->paintInvalidationRectInLocalCoordinates())); | 162 m_maskContentBoundaries.unite(renderer->localToParentTransform().mapRect
(renderer->paintInvalidationRectInLocalCoordinates())); |
163 } | 163 } |
164 } | 164 } |
165 | 165 |
166 FloatRect RenderSVGResourceMasker::resourceBoundingBox(const RenderObject* objec
t) | 166 FloatRect RenderSVGResourceMasker::resourceBoundingBox(const RenderObject* objec
t) |
167 { | 167 { |
168 SVGMaskElement* maskElement = toSVGMaskElement(element()); | 168 SVGMaskElement* maskElement = toSVGMaskElement(element()); |
169 ASSERT(maskElement); | 169 ASSERT(maskElement); |
170 | 170 |
171 FloatRect objectBoundingBox = object->objectBoundingBox(); | 171 FloatRect objectBoundingBox = object->objectBoundingBox(); |
172 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement
>(maskElement, maskElement->maskUnits()->currentValue()->enumValue(), objectBoun
dingBox); | 172 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement
>(maskElement, maskElement->maskUnits()->currentValue()->enumValue(), objectBoun
dingBox); |
173 | 173 |
174 // Resource was not layouted yet. Give back clipping rect of the mask. | 174 // Resource was not layouted yet. Give back clipping rect of the mask. |
175 if (selfNeedsLayout()) | 175 if (selfNeedsLayout()) |
176 return maskBoundaries; | 176 return maskBoundaries; |
177 | 177 |
178 if (m_maskContentBoundaries.isEmpty()) | 178 if (m_maskContentBoundaries.isEmpty()) |
179 calculateMaskContentRepaintRect(); | 179 calculateMaskContentPaintInvalidationRect(); |
180 | 180 |
181 FloatRect maskRect = m_maskContentBoundaries; | 181 FloatRect maskRect = m_maskContentBoundaries; |
182 if (maskElement->maskContentUnits()->currentValue()->value() == SVGUnitTypes
::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { | 182 if (maskElement->maskContentUnits()->currentValue()->value() == SVGUnitTypes
::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { |
183 AffineTransform transform; | 183 AffineTransform transform; |
184 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 184 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
185 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); | 185 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); |
186 maskRect = transform.mapRect(maskRect); | 186 maskRect = transform.mapRect(maskRect); |
187 } | 187 } |
188 | 188 |
189 maskRect.intersect(maskBoundaries); | 189 maskRect.intersect(maskBoundaries); |
190 return maskRect; | 190 return maskRect; |
191 } | 191 } |
192 | 192 |
193 } | 193 } |
OLD | NEW |