| 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/SVGMaskPainter.h" | 6 #include "core/paint/SVGMaskPainter.h" |
| 7 | 7 |
| 8 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 8 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
| 9 #include "core/paint/CompositingRecorder.h" | 9 #include "core/paint/CompositingRecorder.h" |
| 10 #include "core/paint/LayoutObjectDrawingRecorder.h" | 10 #include "core/paint/LayoutObjectDrawingRecorder.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 ASSERT(context); | 21 ASSERT(context); |
| 22 ASSERT(m_mask.style()); | 22 ASSERT(m_mask.style()); |
| 23 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout()); | 23 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout()); |
| 24 | 24 |
| 25 m_mask.clearInvalidationMask(); | 25 m_mask.clearInvalidationMask(); |
| 26 | 26 |
| 27 FloatRect paintInvalidationRect = object.paintInvalidationRectInLocalCoordin
ates(); | 27 FloatRect paintInvalidationRect = object.paintInvalidationRectInLocalCoordin
ates(); |
| 28 if (paintInvalidationRect.isEmpty() || !m_mask.element()->hasChildren()) | 28 if (paintInvalidationRect.isEmpty() || !m_mask.element()->hasChildren()) |
| 29 return false; | 29 return false; |
| 30 | 30 |
| 31 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 31 //if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 32 ASSERT(context->displayItemList()); | 32 // ASSERT(context->displayItemList()); |
| 33 if (context->displayItemList()->displayItemConstructionIsDisabled()) | 33 // if (context->displayItemList()->displayItemConstructionIsDisabled()) |
| 34 return true; | 34 // return true; |
| 35 context->displayItemList()->add(BeginCompositingDisplayItem::create(obje
ct, SkXfermode::kSrcOver_Mode, 1, &paintInvalidationRect)); | 35 // context->displayItemList()->add(BeginCompositingDisplayItem::create(ob
ject, SkXfermode::kSrcOver_Mode, 1, &paintInvalidationRect)); |
| 36 } else { | 36 //} else { |
| 37 BeginCompositingDisplayItem beginCompositingContent(object, SkXfermode::
kSrcOver_Mode, 1, &paintInvalidationRect); | 37 // BeginCompositingDisplayItem beginCompositingContent(object, SkXfermode
::kSrcOver_Mode, 1, &paintInvalidationRect); |
| 38 beginCompositingContent.replay(*context); | 38 // beginCompositingContent.replay(*context); |
| 39 } | 39 //} |
| 40 | 40 |
| 41 return true; | 41 return true; |
| 42 } | 42 } |
| 43 | 43 |
| 44 void SVGMaskPainter::finishEffect(const LayoutObject& object, GraphicsContext* c
ontext) | 44 void SVGMaskPainter::finishEffect(const LayoutObject& object, GraphicsContext* c
ontext) |
| 45 { | 45 { |
| 46 ASSERT(context); | 46 ASSERT(context); |
| 47 ASSERT(m_mask.style()); | 47 ASSERT(m_mask.style()); |
| 48 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout()); | 48 ASSERT_WITH_SECURITY_IMPLICATION(!m_mask.needsLayout()); |
| 49 | 49 |
| 50 FloatRect paintInvalidationRect = object.paintInvalidationRectInLocalCoordin
ates(); | 50 FloatRect paintInvalidationRect = object.paintInvalidationRectInLocalCoordin
ates(); |
| 51 { | 51 { |
| 52 ColorFilter maskLayerFilter = m_mask.style()->svgStyle().maskType() == M
T_LUMINANCE | 52 ColorFilter maskLayerFilter = m_mask.style()->svgStyle().maskType() == M
T_LUMINANCE |
| 53 ? ColorFilterLuminanceToAlpha : ColorFilterNone; | 53 ? ColorFilterLuminanceToAlpha : ColorFilterNone; |
| 54 CompositingRecorder maskCompositing(*context, object, SkXfermode::kDstIn
_Mode, 1, &paintInvalidationRect, maskLayerFilter); | 54 CompositingRecorder maskCompositing(*context, object, SkXfermode::kDstIn
_Mode, 1, &paintInvalidationRect, maskLayerFilter); |
| 55 drawMaskForLayoutObject(context, object, object.objectBoundingBox(), pai
ntInvalidationRect); | 55 drawMaskForLayoutObject(context, object, object.objectBoundingBox(), pai
ntInvalidationRect); |
| 56 } | 56 } |
| 57 | 57 |
| 58 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 58 //if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 59 ASSERT(context->displayItemList()); | 59 // ASSERT(context->displayItemList()); |
| 60 if (!context->displayItemList()->displayItemConstructionIsDisabled()) { | 60 // if (!context->displayItemList()->displayItemConstructionIsDisabled())
{ |
| 61 if (context->displayItemList()->lastDisplayItemIsNoopBegin()) | 61 // if (context->displayItemList()->lastDisplayItemIsNoopBegin()) |
| 62 context->displayItemList()->removeLastDisplayItem(); | 62 // context->displayItemList()->removeLastDisplayItem(); |
| 63 else | 63 // else |
| 64 context->displayItemList()->add(EndCompositingDisplayItem::creat
e(object)); | 64 // context->displayItemList()->add(EndCompositingDisplayItem::cre
ate(object)); |
| 65 } | 65 // } |
| 66 } else { | 66 //} else { |
| 67 EndCompositingDisplayItem endCompositingContent(object); | 67 // EndCompositingDisplayItem endCompositingContent(object); |
| 68 endCompositingContent.replay(*context); | 68 // endCompositingContent.replay(*context); |
| 69 } | 69 //} |
| 70 } | 70 } |
| 71 | 71 |
| 72 void SVGMaskPainter::drawMaskForLayoutObject(GraphicsContext* context, const Lay
outObject& layoutObject, const FloatRect& targetBoundingBox, const FloatRect& ta
rgetPaintInvalidationRect) | 72 void SVGMaskPainter::drawMaskForLayoutObject(GraphicsContext* context, const Lay
outObject& layoutObject, const FloatRect& targetBoundingBox, const FloatRect& ta
rgetPaintInvalidationRect) |
| 73 { | 73 { |
| 74 ASSERT(context); | 74 ASSERT(context); |
| 75 | 75 |
| 76 AffineTransform contentTransformation; | 76 AffineTransform contentTransformation; |
| 77 RefPtr<const SkPicture> maskContentPicture = m_mask.createContentPicture(con
tentTransformation, targetBoundingBox, context); | 77 RefPtr<const SkPicture> maskContentPicture = m_mask.createContentPicture(con
tentTransformation, targetBoundingBox, context); |
| 78 | 78 |
| 79 LayoutObjectDrawingRecorder drawingRecorder(*context, layoutObject, DisplayI
tem::SVGMask, targetPaintInvalidationRect); | 79 LayoutObjectDrawingRecorder drawingRecorder(*context, layoutObject, DisplayI
tem::SVGMask, targetPaintInvalidationRect); |
| 80 if (drawingRecorder.canUseCachedDrawing()) | 80 if (drawingRecorder.canUseCachedDrawing()) |
| 81 return; | 81 return; |
| 82 | 82 |
| 83 context->save(); | 83 context->save(); |
| 84 context->concatCTM(contentTransformation); | 84 context->concatCTM(contentTransformation); |
| 85 context->drawPicture(maskContentPicture.get()); | 85 context->drawPicture(maskContentPicture.get()); |
| 86 context->restore(); | 86 context->restore(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 } | 89 } |
| OLD | NEW |