| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "config.h" | 20 #include "config.h" |
| 21 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 21 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
| 22 | 22 |
| 23 #include "core/dom/ElementTraversal.h" | 23 #include "core/dom/ElementTraversal.h" |
| 24 #include "core/layout/svg/SVGLayoutSupport.h" | 24 #include "core/layout/svg/SVGLayoutSupport.h" |
| 25 #include "core/paint/SVGPaintContext.h" | 25 #include "core/paint/SVGPaintContext.h" |
| 26 #include "core/svg/SVGElement.h" | 26 #include "core/svg/SVGElement.h" |
| 27 #include "platform/graphics/paint/DisplayItemList.h" | 27 #include "platform/graphics/paint/SkPictureBuilder.h" |
| 28 #include "platform/transforms/AffineTransform.h" | 28 #include "platform/transforms/AffineTransform.h" |
| 29 #include "third_party/skia/include/core/SkPicture.h" | 29 #include "third_party/skia/include/core/SkPicture.h" |
| 30 | 30 |
| 31 namespace blink { | 31 namespace blink { |
| 32 | 32 |
| 33 LayoutSVGResourceMasker::LayoutSVGResourceMasker(SVGMaskElement* node) | 33 LayoutSVGResourceMasker::LayoutSVGResourceMasker(SVGMaskElement* node) |
| 34 : LayoutSVGResourceContainer(node) | 34 : LayoutSVGResourceContainer(node) |
| 35 { | 35 { |
| 36 } | 36 } |
| 37 | 37 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 63 if (m_maskContentPicture) | 63 if (m_maskContentPicture) |
| 64 return m_maskContentPicture; | 64 return m_maskContentPicture; |
| 65 | 65 |
| 66 SubtreeContentTransformScope contentTransformScope(contentTransformation); | 66 SubtreeContentTransformScope contentTransformScope(contentTransformation); |
| 67 | 67 |
| 68 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection | 68 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection |
| 69 // with local clips/mask, which may yield incorrect results when mixing obje
ctBoundingBox and | 69 // with local clips/mask, which may yield incorrect results when mixing obje
ctBoundingBox and |
| 70 // userSpaceOnUse units (http://crbug.com/294900). | 70 // userSpaceOnUse units (http://crbug.com/294900). |
| 71 FloatRect bounds = strokeBoundingBox(); | 71 FloatRect bounds = strokeBoundingBox(); |
| 72 | 72 |
| 73 OwnPtr<DisplayItemList> displayItemList; | 73 SkPictureBuilder pictureBuilder(bounds); |
| 74 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | |
| 75 displayItemList = DisplayItemList::create(); | |
| 76 GraphicsContext context(displayItemList.get()); | |
| 77 context.beginRecording(bounds); | |
| 78 | 74 |
| 79 ColorFilter maskContentFilter = style()->svgStyle().colorInterpolation() ==
CI_LINEARRGB | 75 ColorFilter maskContentFilter = style()->svgStyle().colorInterpolation() ==
CI_LINEARRGB |
| 80 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; | 76 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; |
| 81 context.setColorFilter(maskContentFilter); | 77 pictureBuilder.context().setColorFilter(maskContentFilter); |
| 82 | 78 |
| 83 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 79 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
| 84 LayoutObject* layoutObject = childElement->layoutObject(); | 80 LayoutObject* layoutObject = childElement->layoutObject(); |
| 85 if (!layoutObject) | 81 if (!layoutObject) |
| 86 continue; | 82 continue; |
| 87 const ComputedStyle* style = layoutObject->style(); | 83 const ComputedStyle* style = layoutObject->style(); |
| 88 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 84 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) |
| 89 continue; | 85 continue; |
| 90 | 86 |
| 91 SVGPaintContext::paintSubtree(&context, layoutObject); | 87 SVGPaintContext::paintSubtree(&pictureBuilder.context(), layoutObject); |
| 92 } | 88 } |
| 93 | 89 |
| 94 if (displayItemList) | 90 m_maskContentPicture = pictureBuilder.endRecording(); |
| 95 displayItemList->commitNewDisplayItemsAndReplay(context); | |
| 96 m_maskContentPicture = context.endRecording(); | |
| 97 return m_maskContentPicture; | 91 return m_maskContentPicture; |
| 98 } | 92 } |
| 99 | 93 |
| 100 void LayoutSVGResourceMasker::calculateMaskContentPaintInvalidationRect() | 94 void LayoutSVGResourceMasker::calculateMaskContentPaintInvalidationRect() |
| 101 { | 95 { |
| 102 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 96 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
| 103 LayoutObject* layoutObject = childElement->layoutObject(); | 97 LayoutObject* layoutObject = childElement->layoutObject(); |
| 104 if (!layoutObject) | 98 if (!layoutObject) |
| 105 continue; | 99 continue; |
| 106 const ComputedStyle* style = layoutObject->style(); | 100 const ComputedStyle* style = layoutObject->style(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 131 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 125 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
| 132 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); | 126 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); |
| 133 maskRect = transform.mapRect(maskRect); | 127 maskRect = transform.mapRect(maskRect); |
| 134 } | 128 } |
| 135 | 129 |
| 136 maskRect.intersect(maskBoundaries); | 130 maskRect.intersect(maskBoundaries); |
| 137 return maskRect; | 131 return maskRect; |
| 138 } | 132 } |
| 139 | 133 |
| 140 } | 134 } |
| OLD | NEW |