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/SVGResources.h" | 9 #include "core/layout/svg/SVGResources.h" |
10 #include "core/layout/svg/SVGResourcesCache.h" | 10 #include "core/layout/svg/SVGResourcesCache.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // userSpaceOnUse units (the zoom is accounted for objectBoundingBox-resolve
d lengths). | 49 // userSpaceOnUse units (the zoom is accounted for objectBoundingBox-resolve
d lengths). |
50 if (!target.isSVG() && m_clip.clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE
_USERSPACEONUSE) { | 50 if (!target.isSVG() && m_clip.clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE
_USERSPACEONUSE) { |
51 ASSERT(m_clip.style()); | 51 ASSERT(m_clip.style()); |
52 animatedLocalTransform.scale(m_clip.style()->effectiveZoom()); | 52 animatedLocalTransform.scale(m_clip.style()->effectiveZoom()); |
53 } | 53 } |
54 | 54 |
55 // First, try to apply the clip as a clipPath. | 55 // First, try to apply the clip as a clipPath. |
56 Path clipPath; | 56 Path clipPath; |
57 if (m_clip.asPath(animatedLocalTransform, targetBoundingBox, clipPath)) { | 57 if (m_clip.asPath(animatedLocalTransform, targetBoundingBox, clipPath)) { |
58 clipperState = ClipperAppliedPath; | 58 clipperState = ClipperAppliedPath; |
59 context.paintController().createAndAppend<BeginClipPathDisplayItem>(targ
et, clipPath); | 59 context.getPaintController().createAndAppend<BeginClipPathDisplayItem>(t
arget, clipPath); |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 // Fall back to masking. | 63 // Fall back to masking. |
64 clipperState = ClipperAppliedMask; | 64 clipperState = ClipperAppliedMask; |
65 | 65 |
66 // Begin compositing the clip mask. | 66 // Begin compositing the clip mask. |
67 CompositingRecorder::beginCompositing(context, target, SkXfermode::kSrcOver_
Mode, 1, &paintInvalidationRect); | 67 CompositingRecorder::beginCompositing(context, target, SkXfermode::kSrcOver_
Mode, 1, &paintInvalidationRect); |
68 { | 68 { |
69 TransformRecorder recorder(context, target, animatedLocalTransform); | 69 TransformRecorder recorder(context, target, animatedLocalTransform); |
(...skipping 18 matching lines...) Expand all Loading... |
88 CompositingRecorder::beginCompositing(context, target, SkXfermode::kSrcIn_Mo
de, 1, &paintInvalidationRect); | 88 CompositingRecorder::beginCompositing(context, target, SkXfermode::kSrcIn_Mo
de, 1, &paintInvalidationRect); |
89 | 89 |
90 return true; | 90 return true; |
91 } | 91 } |
92 | 92 |
93 void SVGClipPainter::finishEffect(const LayoutObject& target, GraphicsContext& c
ontext, ClipperState& clipperState) | 93 void SVGClipPainter::finishEffect(const LayoutObject& target, GraphicsContext& c
ontext, ClipperState& clipperState) |
94 { | 94 { |
95 switch (clipperState) { | 95 switch (clipperState) { |
96 case ClipperAppliedPath: | 96 case ClipperAppliedPath: |
97 // Path-only clipping, no layers to restore but we need to emit an end t
o the clip path display item. | 97 // Path-only clipping, no layers to restore but we need to emit an end t
o the clip path display item. |
98 context.paintController().endItem<EndClipPathDisplayItem>(target); | 98 context.getPaintController().endItem<EndClipPathDisplayItem>(target); |
99 break; | 99 break; |
100 case ClipperAppliedMask: | 100 case ClipperAppliedMask: |
101 // Transfer content -> clip mask (SrcIn) | 101 // Transfer content -> clip mask (SrcIn) |
102 CompositingRecorder::endCompositing(context, target); | 102 CompositingRecorder::endCompositing(context, target); |
103 | 103 |
104 // Transfer clip mask -> bg (SrcOver) | 104 // Transfer clip mask -> bg (SrcOver) |
105 CompositingRecorder::endCompositing(context, target); | 105 CompositingRecorder::endCompositing(context, target); |
106 break; | 106 break; |
107 default: | 107 default: |
108 ASSERT_NOT_REACHED(); | 108 ASSERT_NOT_REACHED(); |
109 } | 109 } |
110 } | 110 } |
111 | 111 |
112 void SVGClipPainter::drawClipMaskContent(GraphicsContext& context, const LayoutO
bject& layoutObject, const FloatRect& targetBoundingBox, const FloatRect& target
PaintInvalidationRect) | 112 void SVGClipPainter::drawClipMaskContent(GraphicsContext& context, const LayoutO
bject& layoutObject, const FloatRect& targetBoundingBox, const FloatRect& target
PaintInvalidationRect) |
113 { | 113 { |
114 AffineTransform contentTransformation; | 114 AffineTransform contentTransformation; |
115 RefPtr<const SkPicture> clipContentPicture = m_clip.createContentPicture(con
tentTransformation, targetBoundingBox, context); | 115 RefPtr<const SkPicture> clipContentPicture = m_clip.createContentPicture(con
tentTransformation, targetBoundingBox, context); |
116 | 116 |
117 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutO
bject, DisplayItem::SVGClip)) | 117 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutO
bject, DisplayItem::SVGClip)) |
118 return; | 118 return; |
119 | 119 |
120 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, DisplayIt
em::SVGClip, targetPaintInvalidationRect); | 120 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, DisplayIt
em::SVGClip, targetPaintInvalidationRect); |
121 context.save(); | 121 context.save(); |
122 context.concatCTM(contentTransformation); | 122 context.concatCTM(contentTransformation); |
123 context.drawPicture(clipContentPicture.get()); | 123 context.drawPicture(clipContentPicture.get()); |
124 context.restore(); | 124 context.restore(); |
125 } | 125 } |
126 | 126 |
127 } // namespace blink | 127 } // namespace blink |
OLD | NEW |