| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 targetBoundingBox.y()); | 64 targetBoundingBox.y()); |
| 65 contentTransformation.scaleNonUniform(targetBoundingBox.width(), | 65 contentTransformation.scaleNonUniform(targetBoundingBox.width(), |
| 66 targetBoundingBox.height()); | 66 targetBoundingBox.height()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 if (m_maskContentPicture) | 69 if (m_maskContentPicture) |
| 70 return m_maskContentPicture; | 70 return m_maskContentPicture; |
| 71 | 71 |
| 72 SubtreeContentTransformScope contentTransformScope(contentTransformation); | 72 SubtreeContentTransformScope contentTransformScope(contentTransformation); |
| 73 | 73 |
| 74 // Using strokeBoundingBox instead of paintInvalidationRectInLocalCoordinates | 74 // Using strokeBoundingBox instead of visualRectInLocalCoordinates |
| 75 // to avoid the intersection with local clips/mask, which may yield incorrect | 75 // to avoid the intersection with local clips/mask, which may yield incorrect |
| 76 // results when mixing objectBoundingBox and userSpaceOnUse units. | 76 // results when mixing objectBoundingBox and userSpaceOnUse units. |
| 77 // http://crbug.com/294900 | 77 // http://crbug.com/294900 |
| 78 FloatRect bounds = strokeBoundingBox(); | 78 FloatRect bounds = strokeBoundingBox(); |
| 79 | 79 |
| 80 SkPictureBuilder pictureBuilder(bounds, nullptr, &context); | 80 SkPictureBuilder pictureBuilder(bounds, nullptr, &context); |
| 81 | 81 |
| 82 ColorFilter maskContentFilter = | 82 ColorFilter maskContentFilter = |
| 83 style()->svgStyle().colorInterpolation() == CI_LINEARRGB | 83 style()->svgStyle().colorInterpolation() == CI_LINEARRGB |
| 84 ? ColorFilterSRGBToLinearRGB | 84 ? ColorFilterSRGBToLinearRGB |
| (...skipping 11 matching lines...) Expand all Loading... |
| 96 style->visibility() != EVisibility::Visible) | 96 style->visibility() != EVisibility::Visible) |
| 97 continue; | 97 continue; |
| 98 | 98 |
| 99 SVGPaintContext::paintSubtree(pictureBuilder.context(), layoutObject); | 99 SVGPaintContext::paintSubtree(pictureBuilder.context(), layoutObject); |
| 100 } | 100 } |
| 101 | 101 |
| 102 m_maskContentPicture = pictureBuilder.endRecording(); | 102 m_maskContentPicture = pictureBuilder.endRecording(); |
| 103 return m_maskContentPicture; | 103 return m_maskContentPicture; |
| 104 } | 104 } |
| 105 | 105 |
| 106 void LayoutSVGResourceMasker::calculateMaskContentPaintInvalidationRect() { | 106 void LayoutSVGResourceMasker::calculateMaskContentVisualRect() { |
| 107 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()); | 107 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()); |
| 108 childElement; | 108 childElement; |
| 109 childElement = Traversal<SVGElement>::nextSibling(*childElement)) { | 109 childElement = Traversal<SVGElement>::nextSibling(*childElement)) { |
| 110 LayoutObject* layoutObject = childElement->layoutObject(); | 110 LayoutObject* layoutObject = childElement->layoutObject(); |
| 111 if (!layoutObject) | 111 if (!layoutObject) |
| 112 continue; | 112 continue; |
| 113 const ComputedStyle* style = layoutObject->style(); | 113 const ComputedStyle* style = layoutObject->style(); |
| 114 if (!style || style->display() == EDisplay::None || | 114 if (!style || style->display() == EDisplay::None || |
| 115 style->visibility() != EVisibility::Visible) | 115 style->visibility() != EVisibility::Visible) |
| 116 continue; | 116 continue; |
| 117 m_maskContentBoundaries.unite( | 117 m_maskContentBoundaries.unite( |
| 118 layoutObject->localToSVGParentTransform().mapRect( | 118 layoutObject->localToSVGParentTransform().mapRect( |
| 119 layoutObject->paintInvalidationRectInLocalSVGCoordinates())); | 119 layoutObject->visualRectInLocalSVGCoordinates())); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 FloatRect LayoutSVGResourceMasker::resourceBoundingBox( | 123 FloatRect LayoutSVGResourceMasker::resourceBoundingBox( |
| 124 const LayoutObject* object) { | 124 const LayoutObject* object) { |
| 125 SVGMaskElement* maskElement = toSVGMaskElement(element()); | 125 SVGMaskElement* maskElement = toSVGMaskElement(element()); |
| 126 ASSERT(maskElement); | 126 ASSERT(maskElement); |
| 127 | 127 |
| 128 FloatRect objectBoundingBox = object->objectBoundingBox(); | 128 FloatRect objectBoundingBox = object->objectBoundingBox(); |
| 129 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement>( | 129 FloatRect maskBoundaries = SVGLengthContext::resolveRectangle<SVGMaskElement>( |
| 130 maskElement, maskElement->maskUnits()->currentValue()->enumValue(), | 130 maskElement, maskElement->maskUnits()->currentValue()->enumValue(), |
| 131 objectBoundingBox); | 131 objectBoundingBox); |
| 132 | 132 |
| 133 // Resource was not layouted yet. Give back clipping rect of the mask. | 133 // Resource was not layouted yet. Give back clipping rect of the mask. |
| 134 if (selfNeedsLayout()) | 134 if (selfNeedsLayout()) |
| 135 return maskBoundaries; | 135 return maskBoundaries; |
| 136 | 136 |
| 137 if (m_maskContentBoundaries.isEmpty()) | 137 if (m_maskContentBoundaries.isEmpty()) |
| 138 calculateMaskContentPaintInvalidationRect(); | 138 calculateMaskContentVisualRect(); |
| 139 | 139 |
| 140 FloatRect maskRect = m_maskContentBoundaries; | 140 FloatRect maskRect = m_maskContentBoundaries; |
| 141 if (maskElement->maskContentUnits()->currentValue()->value() == | 141 if (maskElement->maskContentUnits()->currentValue()->value() == |
| 142 SVGUnitTypes::kSvgUnitTypeObjectboundingbox) { | 142 SVGUnitTypes::kSvgUnitTypeObjectboundingbox) { |
| 143 AffineTransform transform; | 143 AffineTransform transform; |
| 144 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 144 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
| 145 transform.scaleNonUniform(objectBoundingBox.width(), | 145 transform.scaleNonUniform(objectBoundingBox.width(), |
| 146 objectBoundingBox.height()); | 146 objectBoundingBox.height()); |
| 147 maskRect = transform.mapRect(maskRect); | 147 maskRect = transform.mapRect(maskRect); |
| 148 } | 148 } |
| 149 | 149 |
| 150 maskRect.intersect(maskBoundaries); | 150 maskRect.intersect(maskBoundaries); |
| 151 return maskRect; | 151 return maskRect; |
| 152 } | 152 } |
| 153 | 153 |
| 154 } // namespace blink | 154 } // namespace blink |
| OLD | NEW |