| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/paint/SVGClipPainter.h" | 5 #include "core/paint/SVGClipPainter.h" |
| 6 | 6 |
| 7 #include "core/dom/ElementTraversal.h" | 7 #include "core/dom/ElementTraversal.h" |
| 8 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 8 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
| 9 #include "core/layout/svg/SVGLayoutSupport.h" | 9 #include "core/layout/svg/SVGLayoutSupport.h" |
| 10 #include "core/layout/svg/SVGResources.h" | 10 #include "core/layout/svg/SVGResources.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 m_clip.clearInvalidationMask(); | 49 m_clip.clearInvalidationMask(); |
| 50 | 50 |
| 51 if (paintInvalidationRect.isEmpty() || m_clip.hasCycle()) | 51 if (paintInvalidationRect.isEmpty() || m_clip.hasCycle()) |
| 52 return false; | 52 return false; |
| 53 | 53 |
| 54 SVGClipExpansionCycleHelper inClipExpansionChange(m_clip); | 54 SVGClipExpansionCycleHelper inClipExpansionChange(m_clip); |
| 55 | 55 |
| 56 AffineTransform animatedLocalTransform = | 56 AffineTransform animatedLocalTransform = |
| 57 toSVGClipPathElement(m_clip.element())->calculateAnimatedLocalTransform(); | 57 toSVGClipPathElement(m_clip.element())->calculateAnimatedLocalTransform(); |
| 58 // When drawing a clip for non-SVG elements, the CTM does not include the zoom
factor. | 58 // When drawing a clip for non-SVG elements, the CTM does not include the zoom |
| 59 // In this case, we need to apply the zoom scale explicitly - but only for cli
ps with | 59 // factor. In this case, we need to apply the zoom scale explicitly - but |
| 60 // userSpaceOnUse units (the zoom is accounted for objectBoundingBox-resolved
lengths). | 60 // only for clips with userSpaceOnUse units (the zoom is accounted for |
| 61 // objectBoundingBox-resolved lengths). |
| 61 if (!target.isSVG() && | 62 if (!target.isSVG() && |
| 62 m_clip.clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) { | 63 m_clip.clipPathUnits() == SVGUnitTypes::kSvgUnitTypeUserspaceonuse) { |
| 63 DCHECK(m_clip.style()); | 64 DCHECK(m_clip.style()); |
| 64 animatedLocalTransform.scale(m_clip.style()->effectiveZoom()); | 65 animatedLocalTransform.scale(m_clip.style()->effectiveZoom()); |
| 65 } | 66 } |
| 66 | 67 |
| 67 // First, try to apply the clip as a clipPath. | 68 // First, try to apply the clip as a clipPath. |
| 68 Path clipPath; | 69 Path clipPath; |
| 69 if (m_clip.asPath(animatedLocalTransform, targetBoundingBox, clipPath)) { | 70 if (m_clip.asPath(animatedLocalTransform, targetBoundingBox, clipPath)) { |
| 70 AffineTransform positionTransform; | 71 AffineTransform positionTransform; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 98 context, target, SkXfermode::kSrcIn_Mode, 1, &paintInvalidationRect); | 99 context, target, SkXfermode::kSrcIn_Mode, 1, &paintInvalidationRect); |
| 99 | 100 |
| 100 return true; | 101 return true; |
| 101 } | 102 } |
| 102 | 103 |
| 103 void SVGClipPainter::finishEffect(const LayoutObject& target, | 104 void SVGClipPainter::finishEffect(const LayoutObject& target, |
| 104 GraphicsContext& context, | 105 GraphicsContext& context, |
| 105 ClipperState& clipperState) { | 106 ClipperState& clipperState) { |
| 106 switch (clipperState) { | 107 switch (clipperState) { |
| 107 case ClipperState::AppliedPath: | 108 case ClipperState::AppliedPath: |
| 108 // Path-only clipping, no layers to restore but we need to emit an end to
the clip path display item. | 109 // Path-only clipping, no layers to restore but we need to emit an end to |
| 110 // the clip path display item. |
| 109 context.getPaintController().endItem<EndClipPathDisplayItem>(target); | 111 context.getPaintController().endItem<EndClipPathDisplayItem>(target); |
| 110 break; | 112 break; |
| 111 case ClipperState::AppliedMask: | 113 case ClipperState::AppliedMask: |
| 112 // Transfer content -> clip mask (SrcIn) | 114 // Transfer content -> clip mask (SrcIn) |
| 113 CompositingRecorder::endCompositing(context, target); | 115 CompositingRecorder::endCompositing(context, target); |
| 114 | 116 |
| 115 // Transfer clip mask -> bg (SrcOver) | 117 // Transfer clip mask -> bg (SrcOver) |
| 116 CompositingRecorder::endCompositing(context, target); | 118 CompositingRecorder::endCompositing(context, target); |
| 117 break; | 119 break; |
| 118 default: | 120 default: |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 165 |
| 164 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, | 166 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, |
| 165 DisplayItem::kSVGClip, | 167 DisplayItem::kSVGClip, |
| 166 targetPaintInvalidationRect); | 168 targetPaintInvalidationRect); |
| 167 sk_sp<SkPicture> maskPicture = maskPictureBuilder.endRecording(); | 169 sk_sp<SkPicture> maskPicture = maskPictureBuilder.endRecording(); |
| 168 context.drawPicture(maskPicture.get()); | 170 context.drawPicture(maskPicture.get()); |
| 169 return true; | 171 return true; |
| 170 } | 172 } |
| 171 | 173 |
| 172 } // namespace blink | 174 } // namespace blink |
| OLD | NEW |