| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 CompositingRecorder::endCompositing(context, target); | 99 CompositingRecorder::endCompositing(context, target); |
| 100 break; | 100 break; |
| 101 default: | 101 default: |
| 102 ASSERT_NOT_REACHED(); | 102 ASSERT_NOT_REACHED(); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 bool SVGClipPainter::drawClipAsMask(GraphicsContext& context, const LayoutObject
& layoutObject, const FloatRect& targetBoundingBox, | 106 bool SVGClipPainter::drawClipAsMask(GraphicsContext& context, const LayoutObject
& layoutObject, const FloatRect& targetBoundingBox, |
| 107 const FloatRect& targetPaintInvalidationRect, const AffineTransform& localTr
ansform, const FloatPoint& layerPositionOffset) | 107 const FloatRect& targetPaintInvalidationRect, const AffineTransform& localTr
ansform, const FloatPoint& layerPositionOffset) |
| 108 { | 108 { |
| 109 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutO
bject, DisplayItem::SVGClip)) | 109 if (LayoutObjectDrawingRecorder::useCachedDrawingIfPossible(context, layoutO
bject, DisplayItem::kSVGClip)) |
| 110 return true; | 110 return true; |
| 111 | 111 |
| 112 SkPictureBuilder maskPictureBuilder(targetPaintInvalidationRect, nullptr, &c
ontext); | 112 SkPictureBuilder maskPictureBuilder(targetPaintInvalidationRect, nullptr, &c
ontext); |
| 113 GraphicsContext& maskContext = maskPictureBuilder.context(); | 113 GraphicsContext& maskContext = maskPictureBuilder.context(); |
| 114 { | 114 { |
| 115 TransformRecorder recorder(maskContext, layoutObject, localTransform); | 115 TransformRecorder recorder(maskContext, layoutObject, localTransform); |
| 116 | 116 |
| 117 // Create a clipPathClipper if this clipPath is clipped by another clipP
ath. | 117 // Create a clipPathClipper if this clipPath is clipped by another clipP
ath. |
| 118 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&m_clip); | 118 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&m_clip); |
| 119 LayoutSVGResourceClipper* clipPathClipper = resources ? resources->clipp
er() : nullptr; | 119 LayoutSVGResourceClipper* clipPathClipper = resources ? resources->clipp
er() : nullptr; |
| 120 ClipperState clipPathClipperState = ClipperNotApplied; | 120 ClipperState clipPathClipperState = ClipperNotApplied; |
| 121 if (clipPathClipper && !SVGClipPainter(*clipPathClipper).prepareEffect(m
_clip, targetBoundingBox, targetPaintInvalidationRect, layerPositionOffset, mask
Context, clipPathClipperState)) | 121 if (clipPathClipper && !SVGClipPainter(*clipPathClipper).prepareEffect(m
_clip, targetBoundingBox, targetPaintInvalidationRect, layerPositionOffset, mask
Context, clipPathClipperState)) |
| 122 return false; | 122 return false; |
| 123 | 123 |
| 124 { | 124 { |
| 125 AffineTransform contentTransform; | 125 AffineTransform contentTransform; |
| 126 if (m_clip.clipPathUnits() == SVGUnitTypes::kSvgUnitTypeObjectboundi
ngbox) { | 126 if (m_clip.clipPathUnits() == SVGUnitTypes::kSvgUnitTypeObjectboundi
ngbox) { |
| 127 contentTransform.translate(targetBoundingBox.x(), targetBounding
Box.y()); | 127 contentTransform.translate(targetBoundingBox.x(), targetBounding
Box.y()); |
| 128 contentTransform.scaleNonUniform(targetBoundingBox.width(), targ
etBoundingBox.height()); | 128 contentTransform.scaleNonUniform(targetBoundingBox.width(), targ
etBoundingBox.height()); |
| 129 } | 129 } |
| 130 SubtreeContentTransformScope contentTransformScope(contentTransform)
; | 130 SubtreeContentTransformScope contentTransformScope(contentTransform)
; |
| 131 | 131 |
| 132 TransformRecorder contentTransformRecorder(maskContext, layoutObject
, contentTransform); | 132 TransformRecorder contentTransformRecorder(maskContext, layoutObject
, contentTransform); |
| 133 RefPtr<const SkPicture> clipContentPicture = m_clip.createContentPic
ture(); | 133 RefPtr<const SkPicture> clipContentPicture = m_clip.createContentPic
ture(); |
| 134 maskContext.getPaintController().createAndAppend<DrawingDisplayItem>
(layoutObject, DisplayItem::SVGClip, clipContentPicture.get()); | 134 maskContext.getPaintController().createAndAppend<DrawingDisplayItem>
(layoutObject, DisplayItem::kSVGClip, clipContentPicture.get()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 if (clipPathClipper) | 137 if (clipPathClipper) |
| 138 SVGClipPainter(*clipPathClipper).finishEffect(m_clip, maskContext, c
lipPathClipperState); | 138 SVGClipPainter(*clipPathClipper).finishEffect(m_clip, maskContext, c
lipPathClipperState); |
| 139 } | 139 } |
| 140 | 140 |
| 141 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, DisplayIt
em::SVGClip, targetPaintInvalidationRect); | 141 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, DisplayIt
em::kSVGClip, targetPaintInvalidationRect); |
| 142 RefPtr<SkPicture> maskPicture = maskPictureBuilder.endRecording(); | 142 RefPtr<SkPicture> maskPicture = maskPictureBuilder.endRecording(); |
| 143 context.drawPicture(maskPicture.get()); | 143 context.drawPicture(maskPicture.get()); |
| 144 return true; | 144 return true; |
| 145 } | 145 } |
| 146 | 146 |
| 147 } // namespace blink | 147 } // namespace blink |
| OLD | NEW |