| 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/SVGMaskPainter.h" | 5 #include "core/paint/SVGMaskPainter.h" |
| 6 | 6 |
| 7 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 7 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
| 8 #include "core/paint/LayoutObjectDrawingRecorder.h" | 8 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| 9 #include "core/paint/PaintInfo.h" | 9 #include "core/paint/PaintInfo.h" |
| 10 #include "core/paint/TransformRecorder.h" | 10 #include "core/paint/TransformRecorder.h" |
| 11 #include "platform/graphics/paint/CompositingDisplayItem.h" | 11 #include "platform/graphics/paint/CompositingDisplayItem.h" |
| 12 #include "platform/graphics/paint/CompositingRecorder.h" | 12 #include "platform/graphics/paint/CompositingRecorder.h" |
| 13 #include "platform/graphics/paint/DrawingDisplayItem.h" | 13 #include "platform/graphics/paint/DrawingDisplayItem.h" |
| 14 #include "platform/graphics/paint/PaintController.h" | 14 #include "platform/graphics/paint/PaintController.h" |
| 15 | 15 |
| 16 namespace blink { | 16 namespace blink { |
| 17 | 17 |
| 18 bool SVGMaskPainter::prepareEffect(const LayoutObject& object, | 18 bool SVGMaskPainter::prepareEffect(const LayoutObject& object, |
| 19 GraphicsContext& context) { | 19 GraphicsContext& context) { |
| 20 ASSERT(m_mask.style()); | 20 ASSERT(m_mask.style()); |
| 21 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout()); | 21 SECURITY_DCHECK(!m_mask.needsLayout()); |
| 22 | 22 |
| 23 m_mask.clearInvalidationMask(); | 23 m_mask.clearInvalidationMask(); |
| 24 | 24 |
| 25 FloatRect paintInvalidationRect = | 25 FloatRect paintInvalidationRect = |
| 26 object.paintInvalidationRectInLocalSVGCoordinates(); | 26 object.paintInvalidationRectInLocalSVGCoordinates(); |
| 27 if (paintInvalidationRect.isEmpty() || !m_mask.element()->hasChildren()) | 27 if (paintInvalidationRect.isEmpty() || !m_mask.element()->hasChildren()) |
| 28 return false; | 28 return false; |
| 29 | 29 |
| 30 context.getPaintController().createAndAppend<BeginCompositingDisplayItem>( | 30 context.getPaintController().createAndAppend<BeginCompositingDisplayItem>( |
| 31 object, SkXfermode::kSrcOver_Mode, 1, &paintInvalidationRect); | 31 object, SkXfermode::kSrcOver_Mode, 1, &paintInvalidationRect); |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void SVGMaskPainter::finishEffect(const LayoutObject& object, | 35 void SVGMaskPainter::finishEffect(const LayoutObject& object, |
| 36 GraphicsContext& context) { | 36 GraphicsContext& context) { |
| 37 ASSERT(m_mask.style()); | 37 ASSERT(m_mask.style()); |
| 38 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout()); | 38 SECURITY_DCHECK(!m_mask.needsLayout()); |
| 39 | 39 |
| 40 FloatRect paintInvalidationRect = | 40 FloatRect paintInvalidationRect = |
| 41 object.paintInvalidationRectInLocalSVGCoordinates(); | 41 object.paintInvalidationRectInLocalSVGCoordinates(); |
| 42 { | 42 { |
| 43 ColorFilter maskLayerFilter = | 43 ColorFilter maskLayerFilter = |
| 44 m_mask.style()->svgStyle().maskType() == MT_LUMINANCE | 44 m_mask.style()->svgStyle().maskType() == MT_LUMINANCE |
| 45 ? ColorFilterLuminanceToAlpha | 45 ? ColorFilterLuminanceToAlpha |
| 46 : ColorFilterNone; | 46 : ColorFilterNone; |
| 47 CompositingRecorder maskCompositing( | 47 CompositingRecorder maskCompositing( |
| 48 context, object, SkXfermode::kDstIn_Mode, 1, &paintInvalidationRect, | 48 context, object, SkXfermode::kDstIn_Mode, 1, &paintInvalidationRect, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 70 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, | 70 LayoutObjectDrawingRecorder drawingRecorder(context, layoutObject, |
| 71 DisplayItem::kSVGMask, | 71 DisplayItem::kSVGMask, |
| 72 targetPaintInvalidationRect); | 72 targetPaintInvalidationRect); |
| 73 context.save(); | 73 context.save(); |
| 74 context.concatCTM(contentTransformation); | 74 context.concatCTM(contentTransformation); |
| 75 context.drawPicture(maskContentPicture.get()); | 75 context.drawPicture(maskContentPicture.get()); |
| 76 context.restore(); | 76 context.restore(); |
| 77 } | 77 } |
| 78 | 78 |
| 79 } // namespace blink | 79 } // namespace blink |
| OLD | NEW |