| 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/PaintInfo.h" | 14 #include "core/paint/PaintInfo.h" |
| 14 #include "core/paint/TransformRecorder.h" | 15 #include "core/paint/TransformRecorder.h" |
| 15 #include "platform/graphics/paint/ClipPathDisplayItem.h" | 16 #include "platform/graphics/paint/ClipPathDisplayItem.h" |
| 16 #include "platform/graphics/paint/CompositingDisplayItem.h" | 17 #include "platform/graphics/paint/CompositingDisplayItem.h" |
| 17 #include "platform/graphics/paint/DisplayItemList.h" | 18 #include "platform/graphics/paint/DisplayItemList.h" |
| 18 #include "platform/graphics/paint/DrawingDisplayItem.h" | 19 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 19 #include "wtf/TemporaryChange.h" | 20 #include "wtf/TemporaryChange.h" |
| 20 | 21 |
| 21 namespace blink { | 22 namespace blink { |
| 22 | 23 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // clipPath can also be clipped by another clipPath. | 76 // clipPath can also be clipped by another clipPath. |
| 76 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&m_clip); | 77 SVGResources* resources = SVGResourcesCache::cachedResourcesForLayoutObj
ect(&m_clip); |
| 77 LayoutSVGResourceClipper* clipPathClipper = resources ? resources->clipp
er() : 0; | 78 LayoutSVGResourceClipper* clipPathClipper = resources ? resources->clipp
er() : 0; |
| 78 ClipperState clipPathClipperState = ClipperNotApplied; | 79 ClipperState clipPathClipperState = ClipperNotApplied; |
| 79 if (clipPathClipper && !SVGClipPainter(*clipPathClipper).applyClippingTo
Context(m_clip, targetBoundingBox, paintInvalidationRect, context, clipPathClipp
erState)) { | 80 if (clipPathClipper && !SVGClipPainter(*clipPathClipper).applyClippingTo
Context(m_clip, targetBoundingBox, paintInvalidationRect, context, clipPathClipp
erState)) { |
| 80 // End the clip mask's compositor. | 81 // End the clip mask's compositor. |
| 81 CompositingRecorder::endCompositing(*context, target); | 82 CompositingRecorder::endCompositing(*context, target); |
| 82 return false; | 83 return false; |
| 83 } | 84 } |
| 84 | 85 |
| 85 drawClipMaskContent(context, target, targetBoundingBox); | 86 drawClipMaskContent(context, target, targetBoundingBox, paintInvalidatio
nRect); |
| 86 | 87 |
| 87 if (clipPathClipper) | 88 if (clipPathClipper) |
| 88 SVGClipPainter(*clipPathClipper).postApplyStatefulResource(m_clip, c
ontext, clipPathClipperState); | 89 SVGClipPainter(*clipPathClipper).postApplyStatefulResource(m_clip, c
ontext, clipPathClipperState); |
| 89 } | 90 } |
| 90 | 91 |
| 91 // Masked content layer start. | 92 // Masked content layer start. |
| 92 CompositingRecorder::beginCompositing(*context, target, SkXfermode::kSrcIn_M
ode, 1, &paintInvalidationRect); | 93 CompositingRecorder::beginCompositing(*context, target, SkXfermode::kSrcIn_M
ode, 1, &paintInvalidationRect); |
| 93 | 94 |
| 94 return true; | 95 return true; |
| 95 } | 96 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 113 CompositingRecorder::endCompositing(*context, target); | 114 CompositingRecorder::endCompositing(*context, target); |
| 114 | 115 |
| 115 // Transfer clip mask -> bg (SrcOver) | 116 // Transfer clip mask -> bg (SrcOver) |
| 116 CompositingRecorder::endCompositing(*context, target); | 117 CompositingRecorder::endCompositing(*context, target); |
| 117 break; | 118 break; |
| 118 default: | 119 default: |
| 119 ASSERT_NOT_REACHED(); | 120 ASSERT_NOT_REACHED(); |
| 120 } | 121 } |
| 121 } | 122 } |
| 122 | 123 |
| 123 void SVGClipPainter::drawClipMaskContent(GraphicsContext* context, const LayoutO
bject& layoutObject, const FloatRect& targetBoundingBox) | 124 void SVGClipPainter::drawClipMaskContent(GraphicsContext* context, const LayoutO
bject& layoutObject, const FloatRect& targetBoundingBox, const FloatRect& target
PaintInvalidationRect) |
| 124 { | 125 { |
| 125 ASSERT(context); | 126 ASSERT(context); |
| 126 | 127 |
| 127 AffineTransform contentTransformation; | 128 AffineTransform contentTransformation; |
| 128 RefPtr<const SkPicture> clipContentPicture = m_clip.createContentPicture(con
tentTransformation, targetBoundingBox, context); | 129 RefPtr<const SkPicture> clipContentPicture = m_clip.createContentPicture(con
tentTransformation, targetBoundingBox, context); |
| 129 | 130 |
| 130 TransformRecorder recorder(*context, layoutObject, contentTransformation); | 131 LayoutObjectDrawingRecorder drawingRecorder(*context, layoutObject, DisplayI
tem::SVGClip, targetPaintInvalidationRect); |
| 131 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 132 if (drawingRecorder.canUseCachedDrawing()) |
| 132 ASSERT(context->displayItemList()); | 133 return; |
| 133 if (context->displayItemList()->displayItemConstructionIsDisabled()) | 134 |
| 134 return; | 135 context->save(); |
| 135 context->displayItemList()->add(DrawingDisplayItem::create(layoutObject,
DisplayItem::SVGClip, clipContentPicture)); | 136 context->concatCTM(contentTransformation); |
| 136 } else { | 137 context->drawPicture(clipContentPicture.get()); |
| 137 DrawingDisplayItem clipPicture(layoutObject, DisplayItem::SVGClip, clipC
ontentPicture); | 138 context->restore(); |
| 138 clipPicture.replay(*context); | |
| 139 } | |
| 140 } | 139 } |
| 141 | 140 |
| 142 } | 141 } |
| OLD | NEW |