| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/SVGClipPainter.h" | 6 #include "core/paint/SVGClipPainter.h" |
| 7 | 7 |
| 8 #include "core/dom/ElementTraversal.h" | 8 #include "core/dom/ElementTraversal.h" |
| 9 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 9 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
| 10 #include "core/layout/svg/SVGResources.h" | 10 #include "core/layout/svg/SVGResources.h" |
| 11 #include "core/layout/svg/SVGResourcesCache.h" | 11 #include "core/layout/svg/SVGResourcesCache.h" |
| 12 #include "core/paint/CompositingRecorder.h" | 12 #include "core/paint/CompositingRecorder.h" |
| 13 #include "core/paint/LayoutObjectDrawingRecorder.h" | 13 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 14 #include "core/paint/PaintInfo.h" | 14 #include "core/paint/PaintInfo.h" |
| 15 #include "core/paint/TransformRecorder.h" | 15 #include "core/paint/TransformRecorder.h" |
| 16 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 16 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
| 17 #include "platform/graphics/paint/CompositingDisplayItem.h" | 17 #include "platform/graphics/paint/CompositingDisplayItem.h" |
| 18 #include "platform/graphics/paint/DisplayItemList.h" | |
| 19 #include "platform/graphics/paint/DrawingDisplayItem.h" | 18 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 19 #include "platform/graphics/paint/PaintController.h" |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 class SVGClipExpansionCycleHelper { | 25 class SVGClipExpansionCycleHelper { |
| 26 public: | 26 public: |
| 27 SVGClipExpansionCycleHelper(LayoutSVGResourceClipper& clip) : m_clip(clip) {
clip.beginClipExpansion(); } | 27 SVGClipExpansionCycleHelper(LayoutSVGResourceClipper& clip) : m_clip(clip) {
clip.beginClipExpansion(); } |
| 28 ~SVGClipExpansionCycleHelper() { m_clip.endClipExpansion(); } | 28 ~SVGClipExpansionCycleHelper() { m_clip.endClipExpansion(); } |
| 29 private: | 29 private: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 52 // userSpaceOnUse units (the zoom is accounted for objectBoundingBox-resolve
d lengths). | 52 // userSpaceOnUse units (the zoom is accounted for objectBoundingBox-resolve
d lengths). |
| 53 if (!target.isSVG() && m_clip.clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE
_USERSPACEONUSE) { | 53 if (!target.isSVG() && m_clip.clipPathUnits() == SVGUnitTypes::SVG_UNIT_TYPE
_USERSPACEONUSE) { |
| 54 ASSERT(m_clip.style()); | 54 ASSERT(m_clip.style()); |
| 55 animatedLocalTransform.scale(m_clip.style()->effectiveZoom()); | 55 animatedLocalTransform.scale(m_clip.style()->effectiveZoom()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 // First, try to apply the clip as a clipPath. | 58 // First, try to apply the clip as a clipPath. |
| 59 Path clipPath; | 59 Path clipPath; |
| 60 if (m_clip.asPath(animatedLocalTransform, targetBoundingBox, clipPath)) { | 60 if (m_clip.asPath(animatedLocalTransform, targetBoundingBox, clipPath)) { |
| 61 clipperState = ClipperAppliedPath; | 61 clipperState = ClipperAppliedPath; |
| 62 ASSERT(context->displayItemList()); | 62 ASSERT(context->paintController()); |
| 63 context->displayItemList()->createAndAppend<BeginClipPathDisplayItem>(ta
rget, clipPath); | 63 context->paintController()->createAndAppend<BeginClipPathDisplayItem>(ta
rget, clipPath); |
| 64 return true; | 64 return true; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Fall back to masking. | 67 // Fall back to masking. |
| 68 clipperState = ClipperAppliedMask; | 68 clipperState = ClipperAppliedMask; |
| 69 | 69 |
| 70 // Begin compositing the clip mask. | 70 // Begin compositing the clip mask. |
| 71 CompositingRecorder::beginCompositing(*context, target, SkXfermode::kSrcOver
_Mode, 1, &paintInvalidationRect); | 71 CompositingRecorder::beginCompositing(*context, target, SkXfermode::kSrcOver
_Mode, 1, &paintInvalidationRect); |
| 72 { | 72 { |
| 73 TransformRecorder recorder(*context, target, animatedLocalTransform); | 73 TransformRecorder recorder(*context, target, animatedLocalTransform); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 92 CompositingRecorder::beginCompositing(*context, target, SkXfermode::kSrcIn_M
ode, 1, &paintInvalidationRect); | 92 CompositingRecorder::beginCompositing(*context, target, SkXfermode::kSrcIn_M
ode, 1, &paintInvalidationRect); |
| 93 | 93 |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void SVGClipPainter::finishEffect(const LayoutObject& target, GraphicsContext* c
ontext, ClipperState& clipperState) | 97 void SVGClipPainter::finishEffect(const LayoutObject& target, GraphicsContext* c
ontext, ClipperState& clipperState) |
| 98 { | 98 { |
| 99 switch (clipperState) { | 99 switch (clipperState) { |
| 100 case ClipperAppliedPath: | 100 case ClipperAppliedPath: |
| 101 // Path-only clipping, no layers to restore but we need to emit an end t
o the clip path display item. | 101 // Path-only clipping, no layers to restore but we need to emit an end t
o the clip path display item. |
| 102 ASSERT(context->displayItemList()); | 102 ASSERT(context->paintController()); |
| 103 context->displayItemList()->endItem<EndClipPathDisplayItem>(target); | 103 context->paintController()->endItem<EndClipPathDisplayItem>(target); |
| 104 break; | 104 break; |
| 105 case ClipperAppliedMask: | 105 case ClipperAppliedMask: |
| 106 // Transfer content -> clip mask (SrcIn) | 106 // Transfer content -> clip mask (SrcIn) |
| 107 CompositingRecorder::endCompositing(*context, target); | 107 CompositingRecorder::endCompositing(*context, target); |
| 108 | 108 |
| 109 // Transfer clip mask -> bg (SrcOver) | 109 // Transfer clip mask -> bg (SrcOver) |
| 110 CompositingRecorder::endCompositing(*context, target); | 110 CompositingRecorder::endCompositing(*context, target); |
| 111 break; | 111 break; |
| 112 default: | 112 default: |
| 113 ASSERT_NOT_REACHED(); | 113 ASSERT_NOT_REACHED(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 125 return; | 125 return; |
| 126 | 126 |
| 127 LayoutObjectDrawingRecorder drawingRecorder(*context, layoutObject, DisplayI
tem::SVGClip, targetPaintInvalidationRect, LayoutPoint()); | 127 LayoutObjectDrawingRecorder drawingRecorder(*context, layoutObject, DisplayI
tem::SVGClip, targetPaintInvalidationRect, LayoutPoint()); |
| 128 context->save(); | 128 context->save(); |
| 129 context->concatCTM(contentTransformation); | 129 context->concatCTM(contentTransformation); |
| 130 context->drawPicture(clipContentPicture.get()); | 130 context->drawPicture(clipContentPicture.get()); |
| 131 context->restore(); | 131 context->restore(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 } | 134 } |
| OLD | NEW |