| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/FilterPainter.h" | 5 #include "core/paint/FilterPainter.h" |
| 6 | 6 |
| 7 #include "core/paint/FilterEffectBuilder.h" | 7 #include "core/paint/FilterEffectBuilder.h" |
| 8 #include "core/paint/LayerClipRecorder.h" | 8 #include "core/paint/LayerClipRecorder.h" |
| 9 #include "core/paint/PaintLayer.h" | 9 #include "core/paint/PaintLayer.h" |
| 10 #include "platform/RuntimeEnabledFeatures.h" | 10 #include "platform/RuntimeEnabledFeatures.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // We'll handle clipping to the dirty rect before filter rasterization. | 44 // We'll handle clipping to the dirty rect before filter rasterization. |
| 45 // Filter processing will automatically expand the clip rect and the offscreen | 45 // Filter processing will automatically expand the clip rect and the offscreen |
| 46 // to accommodate any filter outsets. | 46 // to accommodate any filter outsets. |
| 47 // FIXME: It is incorrect to just clip to the damageRect here once multiple | 47 // FIXME: It is incorrect to just clip to the damageRect here once multiple |
| 48 // fragments are involved. | 48 // fragments are involved. |
| 49 | 49 |
| 50 // Subsequent code should not clip to the dirty rect, since we've already | 50 // Subsequent code should not clip to the dirty rect, since we've already |
| 51 // done it above, and doing it later will defeat the outsets. | 51 // done it above, and doing it later will defeat the outsets. |
| 52 paintingInfo.clipToDirtyRect = false; | 52 paintingInfo.clipToDirtyRect = false; |
| 53 | 53 |
| 54 DCHECK(m_layoutObject); | |
| 55 | |
| 56 if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) { | 54 if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius()) { |
| 57 m_clipRecorder = WTF::wrapUnique(new LayerClipRecorder( | 55 m_clipRecorder = WTF::wrapUnique(new LayerClipRecorder( |
| 58 context, *layer.layoutObject(), DisplayItem::kClipLayerFilter, clipRect, | 56 context, layer.layoutObject(), DisplayItem::kClipLayerFilter, clipRect, |
| 59 paintingInfo.rootLayer, LayoutPoint(), paintFlags)); | 57 paintingInfo.rootLayer, LayoutPoint(), paintFlags)); |
| 60 } | 58 } |
| 61 | 59 |
| 62 if (!context.getPaintController().displayItemConstructionIsDisabled()) { | 60 if (!context.getPaintController().displayItemConstructionIsDisabled()) { |
| 63 CompositorFilterOperations compositorFilterOperations = | 61 CompositorFilterOperations compositorFilterOperations = |
| 64 layer.createCompositorFilterOperationsForFilter( | 62 layer.createCompositorFilterOperationsForFilter( |
| 65 m_layoutObject->styleRef()); | 63 m_layoutObject.styleRef()); |
| 66 // FIXME: It's possible to have empty CompositorFilterOperations here even | 64 // FIXME: It's possible to have empty CompositorFilterOperations here even |
| 67 // though the SkImageFilter produced above is non-null, since the | 65 // though the SkImageFilter produced above is non-null, since the |
| 68 // layer's FilterEffectBuilder can have a stale representation of | 66 // layer's FilterEffectBuilder can have a stale representation of |
| 69 // the layer's filter. See crbug.com/502026. | 67 // the layer's filter. See crbug.com/502026. |
| 70 if (compositorFilterOperations.isEmpty()) | 68 if (compositorFilterOperations.isEmpty()) |
| 71 return; | 69 return; |
| 72 LayoutRect visualBounds( | 70 LayoutRect visualBounds( |
| 73 layer.physicalBoundingBoxIncludingStackingChildren(offsetFromRoot)); | 71 layer.physicalBoundingBoxIncludingStackingChildren(offsetFromRoot)); |
| 74 if (layer.enclosingPaginationLayer()) { | 72 if (layer.enclosingPaginationLayer()) { |
| 75 // Filters are set up before pagination, so we need to make the bounding | 73 // Filters are set up before pagination, so we need to make the bounding |
| 76 // box visual on our own. | 74 // box visual on our own. |
| 77 visualBounds.moveBy(-offsetFromRoot); | 75 visualBounds.moveBy(-offsetFromRoot); |
| 78 layer.convertFromFlowThreadToVisualBoundingBoxInAncestor( | 76 layer.convertFromFlowThreadToVisualBoundingBoxInAncestor( |
| 79 paintingInfo.rootLayer, visualBounds); | 77 paintingInfo.rootLayer, visualBounds); |
| 80 } | 78 } |
| 81 FloatPoint origin(offsetFromRoot); | 79 FloatPoint origin(offsetFromRoot); |
| 82 context.getPaintController().createAndAppend<BeginFilterDisplayItem>( | 80 context.getPaintController().createAndAppend<BeginFilterDisplayItem>( |
| 83 *m_layoutObject, std::move(imageFilter), FloatRect(visualBounds), | 81 m_layoutObject, std::move(imageFilter), FloatRect(visualBounds), origin, |
| 84 origin, std::move(compositorFilterOperations)); | 82 std::move(compositorFilterOperations)); |
| 85 } | 83 } |
| 86 | 84 |
| 87 m_filterInProgress = true; | 85 m_filterInProgress = true; |
| 88 } | 86 } |
| 89 | 87 |
| 90 FilterPainter::~FilterPainter() { | 88 FilterPainter::~FilterPainter() { |
| 91 if (!m_filterInProgress) | 89 if (!m_filterInProgress) |
| 92 return; | 90 return; |
| 93 | 91 |
| 94 m_context.getPaintController().endItem<EndFilterDisplayItem>(*m_layoutObject); | 92 m_context.getPaintController().endItem<EndFilterDisplayItem>(m_layoutObject); |
| 95 } | 93 } |
| 96 | 94 |
| 97 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |