| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 m_maskContentBoundaries = FloatRect(); | 45 m_maskContentBoundaries = FloatRect(); |
| 46 markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInval
idation : ParentOnlyInvalidation); | 46 markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInval
idation : ParentOnlyInvalidation); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void LayoutSVGResourceMasker::removeClientFromCache(LayoutObject* client, bool m
arkForInvalidation) | 49 void LayoutSVGResourceMasker::removeClientFromCache(LayoutObject* client, bool m
arkForInvalidation) |
| 50 { | 50 { |
| 51 ASSERT(client); | 51 ASSERT(client); |
| 52 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati
on : ParentOnlyInvalidation); | 52 markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidati
on : ParentOnlyInvalidation); |
| 53 } | 53 } |
| 54 | 54 |
| 55 PassRefPtr<const SkPicture> LayoutSVGResourceMasker::createContentPicture() | 55 PassRefPtr<const SkPicture> LayoutSVGResourceMasker::createContentPicture(Affine
Transform& contentTransformation, const FloatRect& targetBoundingBox) |
| 56 { | 56 { |
| 57 SVGUnitTypes::SVGUnitType contentUnits = toSVGMaskElement(element())->maskCo
ntentUnits()->currentValue()->enumValue(); |
| 58 if (contentUnits == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { |
| 59 contentTransformation.translate(targetBoundingBox.x(), targetBoundingBox
.y()); |
| 60 contentTransformation.scaleNonUniform(targetBoundingBox.width(), targetB
oundingBox.height()); |
| 61 } |
| 62 |
| 63 if (m_maskContentPicture) |
| 64 return m_maskContentPicture; |
| 65 |
| 66 SubtreeContentTransformScope contentTransformScope(contentTransformation); |
| 67 |
| 57 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection | 68 // Using strokeBoundingBox (instead of paintInvalidationRectInLocalCoordinat
es) to avoid the intersection |
| 58 // 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 |
| 59 // userSpaceOnUse units (http://crbug.com/294900). | 70 // userSpaceOnUse units (http://crbug.com/294900). |
| 60 FloatRect bounds = strokeBoundingBox(); | 71 FloatRect bounds = strokeBoundingBox(); |
| 61 | 72 |
| 62 OwnPtr<DisplayItemList> displayItemList; | 73 OwnPtr<DisplayItemList> displayItemList; |
| 63 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) | 74 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) |
| 64 displayItemList = DisplayItemList::create(); | 75 displayItemList = DisplayItemList::create(); |
| 65 GraphicsContext context(nullptr, displayItemList.get()); | 76 GraphicsContext context(nullptr, displayItemList.get()); |
| 66 context.beginRecording(bounds); | 77 context.beginRecording(bounds); |
| 67 | 78 |
| 68 ColorFilter maskContentFilter = style()->svgStyle().colorInterpolation() ==
CI_LINEARRGB | 79 ColorFilter maskContentFilter = style()->svgStyle().colorInterpolation() ==
CI_LINEARRGB |
| 69 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; | 80 ? ColorFilterSRGBToLinearRGB : ColorFilterNone; |
| 70 context.setColorFilter(maskContentFilter); | 81 context.setColorFilter(maskContentFilter); |
| 71 | 82 |
| 72 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 83 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
| 73 LayoutObject* renderer = childElement->renderer(); | 84 LayoutObject* renderer = childElement->renderer(); |
| 74 if (!renderer) | 85 if (!renderer) |
| 75 continue; | 86 continue; |
| 76 const LayoutStyle* style = renderer->style(); | 87 const LayoutStyle* style = renderer->style(); |
| 77 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) | 88 if (!style || style->display() == NONE || style->visibility() != VISIBLE
) |
| 78 continue; | 89 continue; |
| 79 | 90 |
| 80 SVGPaintContext::paintSubtree(&context, renderer); | 91 SVGPaintContext::paintSubtree(&context, renderer); |
| 81 } | 92 } |
| 82 | 93 |
| 83 if (displayItemList) | 94 if (displayItemList) |
| 84 displayItemList->replay(&context); | 95 displayItemList->replay(&context); |
| 85 return context.endRecording(); | 96 m_maskContentPicture = context.endRecording(); |
| 86 } | |
| 87 | |
| 88 PassRefPtr<const SkPicture> LayoutSVGResourceMasker::getContentPicture(AffineTra
nsform& contentTransformation, const FloatRect& targetBoundingBox) | |
| 89 { | |
| 90 SVGUnitTypes::SVGUnitType contentUnits = toSVGMaskElement(element())->maskCo
ntentUnits()->currentValue()->enumValue(); | |
| 91 if (contentUnits == SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { | |
| 92 contentTransformation.translate(targetBoundingBox.x(), targetBoundingBox
.y()); | |
| 93 contentTransformation.scaleNonUniform(targetBoundingBox.width(), targetB
oundingBox.height()); | |
| 94 } | |
| 95 | |
| 96 if (!m_maskContentPicture) { | |
| 97 SubtreeContentTransformScope contentTransformScope(contentTransformation
); | |
| 98 m_maskContentPicture = createContentPicture(); | |
| 99 } | |
| 100 | |
| 101 return m_maskContentPicture; | 97 return m_maskContentPicture; |
| 102 } | 98 } |
| 103 | 99 |
| 104 void LayoutSVGResourceMasker::calculateMaskContentPaintInvalidationRect() | 100 void LayoutSVGResourceMasker::calculateMaskContentPaintInvalidationRect() |
| 105 { | 101 { |
| 106 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { | 102 for (SVGElement* childElement = Traversal<SVGElement>::firstChild(*element()
); childElement; childElement = Traversal<SVGElement>::nextSibling(*childElement
)) { |
| 107 LayoutObject* renderer = childElement->renderer(); | 103 LayoutObject* renderer = childElement->renderer(); |
| 108 if (!renderer) | 104 if (!renderer) |
| 109 continue; | 105 continue; |
| 110 const LayoutStyle* style = renderer->style(); | 106 const LayoutStyle* style = renderer->style(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 135 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); | 131 transform.translate(objectBoundingBox.x(), objectBoundingBox.y()); |
| 136 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); | 132 transform.scaleNonUniform(objectBoundingBox.width(), objectBoundingBox.h
eight()); |
| 137 maskRect = transform.mapRect(maskRect); | 133 maskRect = transform.mapRect(maskRect); |
| 138 } | 134 } |
| 139 | 135 |
| 140 maskRect.intersect(maskBoundaries); | 136 maskRect.intersect(maskBoundaries); |
| 141 return maskRect; | 137 return maskRect; |
| 142 } | 138 } |
| 143 | 139 |
| 144 } | 140 } |
| OLD | NEW |