Chromium Code Reviews| 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/DisplayItemList.h" |
| 28 #include "platform/graphics/paint/SkPictureBuilder.h" | |
| 28 #include "platform/transforms/AffineTransform.h" | 29 #include "platform/transforms/AffineTransform.h" |
| 29 #include "third_party/skia/include/core/SkPicture.h" | 30 #include "third_party/skia/include/core/SkPicture.h" |
| 30 | 31 |
| 31 namespace blink { | 32 namespace blink { |
| 32 | 33 |
| 33 LayoutSVGResourceMasker::LayoutSVGResourceMasker(SVGMaskElement* node) | 34 LayoutSVGResourceMasker::LayoutSVGResourceMasker(SVGMaskElement* node) |
| 34 : LayoutSVGResourceContainer(node) | 35 : LayoutSVGResourceContainer(node) |
| 35 { | 36 { |
| 36 } | 37 } |
| 37 | 38 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 63 if (m_maskContentPicture) | 64 if (m_maskContentPicture) |
| 64 return m_maskContentPicture; | 65 return m_maskContentPicture; |
| 65 | 66 |
| 66 SubtreeContentTransformScope contentTransformScope(contentTransformation); | 67 SubtreeContentTransformScope contentTransformScope(contentTransformation); |
| 67 | 68 |
| 68 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat es) to avoid the intersection | 69 // 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 | 70 // with local clips/mask, which may yield incorrect results when mixing obje ctBoundingBox and |
| 70 // userSpaceOnUse units (http://crbug.com/294900). | 71 // userSpaceOnUse units (http://crbug.com/294900). |
| 71 FloatRect bounds = strokeBoundingBox(); | 72 FloatRect bounds = strokeBoundingBox(); |
| 72 | 73 |
| 73 OwnPtr<DisplayItemList> displayItemList; | 74 SkPictureBuilder pictureBuilder(bounds); |
| 74 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | |
| 75 displayItemList = DisplayItemList::create(); | |
| 76 GraphicsContext context(displayItemList.get()); | |
| 77 context.beginRecording(bounds); | |
| 78 | 75 |
| 79 ColorFilter maskContentFilter = style()->svgStyle().colorInterpolation() == CI_LINEARRGB | 76 ColorFilter maskContentFilter = style()->svgStyle().colorInterpolation() == CI_LINEARRGB |
| 80 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; | 77 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; |
| 81 context.setColorFilter(maskContentFilter); | 78 pictureBuilder.context().setColorFilter(maskContentFilter); |
| 82 | 79 |
| 83 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { | 80 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { |
| 84 LayoutObject* layoutObject = childElement->layoutObject(); | 81 LayoutObject* layoutObject = childElement->layoutObject(); |
| 85 if (!layoutObject) | 82 if (!layoutObject) |
| 86 continue; | 83 continue; |
| 87 const ComputedStyle* style = layoutObject->style(); | 84 const ComputedStyle* style = layoutObject->style(); |
| 88 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) | 85 if (!style || style->display() == NONE || style->visibility() != VISIBLE ) |
| 89 continue; | 86 continue; |
| 90 | 87 |
| 91 SVGPaintContext::paintSubtree(&context, layoutObject); | 88 SVGPaintContext::paintSubtree(&pictureBuilder.context(), layoutObject); |
| 92 } | 89 } |
| 93 | 90 |
| 94 if (displayItemList) | 91 m_maskContentPicture = pictureBuilder.context().endRecording(); |
|
pdr.
2015/04/17 04:30:34
This should be pictureBuilder.endRecording().
| |
| 95 displayItemList->commitNewDisplayItemsAndReplay(context); | |
| 96 m_maskContentPicture = context.endRecording(); | |
| 97 return m_maskContentPicture; | 92 return m_maskContentPicture; |
| 98 } | 93 } |
| 99 | 94 |
| 100 void LayoutSVGResourceMasker::calculateMaskContentPaintInvalidationRect() | 95 void LayoutSVGResourceMasker::calculateMaskContentPaintInvalidationRect() |
| 101 { | 96 { |
| 102 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { | 97 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element() ); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement )) { |
| 103 LayoutObject* layoutObject = childElement->layoutObject(); | 98 LayoutObject* layoutObject = childElement->layoutObject(); |
| 104 if (!layoutObject) | 99 if (!layoutObject) |
| 105 continue; | 100 continue; |
| 106 const ComputedStyle* style = layoutObject->style(); | 101 const ComputedStyle* style = layoutObject->style(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 131 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 126 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
| 132 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); | 127 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h eight()); |
| 133 maskRect = transform.mapRect(maskRect); | 128 maskRect = transform.mapRect(maskRect); |
| 134 } | 129 } |
| 135 | 130 |
| 136 maskRect.intersect(maskBoundaries); | 131 maskRect.intersect(maskBoundaries); |
| 137 return maskRect; | 132 return maskRect; |
| 138 } | 133 } |
| 139 | 134 |
| 140 } | 135 } |
| OLD | NEW |