| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 return true; | 114 return true; |
| 115 } | 115 } |
| 116 | 116 |
| 117 bool RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, C
olorSpace colorSpace, const SVGMaskElement* maskElement, RenderObject* object) | 117 bool RenderSVGResourceMasker::drawContentIntoMaskImage(MaskerData* maskerData, C
olorSpace colorSpace, const SVGMaskElement* maskElement, RenderObject* object) |
| 118 { | 118 { |
| 119 GraphicsContext* maskImageContext = maskerData->maskImage->context(); | 119 GraphicsContext* maskImageContext = maskerData->maskImage->context(); |
| 120 ASSERT(maskImageContext); | 120 ASSERT(maskImageContext); |
| 121 | 121 |
| 122 // Eventually adjust the mask image context according to the target objectBo
undingBox. | 122 // Eventually adjust the mask image context according to the target objectBo
undingBox. |
| 123 AffineTransform maskContentTransformation; | 123 AffineTransform maskContentTransformation; |
| 124 if (maskElement->maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOU
NDINGBOX) { | 124 if (maskElement->maskContentUnitsCurrentValue() == SVGUnitTypes::SVG_UNIT_TY
PE_OBJECTBOUNDINGBOX) { |
| 125 FloatRect objectBoundingBox = object->objectBoundingBox(); | 125 FloatRect objectBoundingBox = object->objectBoundingBox(); |
| 126 maskContentTransformation.translate(objectBoundingBox.x(), objectBoundin
gBox.y()); | 126 maskContentTransformation.translate(objectBoundingBox.x(), objectBoundin
gBox.y()); |
| 127 maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), obj
ectBoundingBox.height()); | 127 maskContentTransformation.scaleNonUniform(objectBoundingBox.width(), obj
ectBoundingBox.height()); |
| 128 maskImageContext->concatCTM(maskContentTransformation); | 128 maskImageContext->concatCTM(maskContentTransformation); |
| 129 } | 129 } |
| 130 | 130 |
| 131 // Draw the content into the ImageBuffer. | 131 // Draw the content into the ImageBuffer. |
| 132 for (Node* node = maskElement->firstChild(); node; node = node->nextSibling(
)) { | 132 for (Node* node = maskElement->firstChild(); node; node = node->nextSibling(
)) { |
| 133 RenderObject* renderer = node->renderer(); | 133 RenderObject* renderer = node->renderer(); |
| 134 if (!node->isSVGElement() || !toSVGElement(node)->isSVGStyledElement() |
| !renderer) | 134 if (!node->isSVGElement() || !toSVGElement(node)->isSVGStyledElement() |
| !renderer) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 164 m_maskContentBoundaries.unite(renderer->localToParentTransform().mapRect
(renderer->repaintRectInLocalCoordinates())); | 164 m_maskContentBoundaries.unite(renderer->localToParentTransform().mapRect
(renderer->repaintRectInLocalCoordinates())); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 FloatRect RenderSVGResourceMasker::resourceBoundingBox(RenderObject* object) | 168 FloatRect RenderSVGResourceMasker::resourceBoundingBox(RenderObject* object) |
| 169 { | 169 { |
| 170 SVGMaskElement* maskElement = static_cast<SVGMaskElement*>(node()); | 170 SVGMaskElement* maskElement = static_cast<SVGMaskElement*>(node()); |
| 171 ASSERT(maskElement); | 171 ASSERT(maskElement); |
| 172 | 172 |
| 173 FloatRect objectBoundingBox = object->objectBoundingBox(); | 173 FloatRect objectBoundingBox = object->objectBoundingBox(); |
| 174 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement
>(maskElement, maskElement->maskUnits(), objectBoundingBox); | 174 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement
>(maskElement, maskElement->maskUnitsCurrentValue(), objectBoundingBox); |
| 175 | 175 |
| 176 // Resource was not layouted yet. Give back clipping rect of the mask. | 176 // Resource was not layouted yet. Give back clipping rect of the mask. |
| 177 if (selfNeedsLayout()) | 177 if (selfNeedsLayout()) |
| 178 return maskBoundaries; | 178 return maskBoundaries; |
| 179 | 179 |
| 180 if (m_maskContentBoundaries.isEmpty()) | 180 if (m_maskContentBoundaries.isEmpty()) |
| 181 calculateMaskContentRepaintRect(); | 181 calculateMaskContentRepaintRect(); |
| 182 | 182 |
| 183 FloatRect maskRect = m_maskContentBoundaries; | 183 FloatRect maskRect = m_maskContentBoundaries; |
| 184 if (maskElement->maskContentUnits() == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOU
NDINGBOX) { | 184 if (maskElement->maskContentUnitsCurrentValue() == SVGUnitTypes::SVG_UNIT_TY
PE_OBJECTBOUNDINGBOX) { |
| 185 AffineTransform transform; | 185 AffineTransform transform; |
| 186 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 186 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
| 187 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); | 187 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); |
| 188 maskRect = transform.mapRect(maskRect); | 188 maskRect = transform.mapRect(maskRect); |
| 189 } | 189 } |
| 190 | 190 |
| 191 maskRect.intersect(maskBoundaries); | 191 maskRect.intersect(maskBoundaries); |
| 192 return maskRect; | 192 return maskRect; |
| 193 } | 193 } |
| 194 | 194 |
| 195 } | 195 } |
| OLD | NEW |