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" |
| 11 #include "platform/graphics/CompositorFactory.h" |
| 12 #include "platform/graphics/CompositorFilterOperations.h" |
11 #include "platform/graphics/GraphicsContext.h" | 13 #include "platform/graphics/GraphicsContext.h" |
12 #include "platform/graphics/GraphicsLayer.h" | 14 #include "platform/graphics/GraphicsLayer.h" |
13 #include "platform/graphics/filters/FilterEffect.h" | 15 #include "platform/graphics/filters/FilterEffect.h" |
14 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 16 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
15 #include "platform/graphics/paint/FilterDisplayItem.h" | 17 #include "platform/graphics/paint/FilterDisplayItem.h" |
16 #include "platform/graphics/paint/PaintController.h" | 18 #include "platform/graphics/paint/PaintController.h" |
17 #include "public/platform/Platform.h" | 19 #include "public/platform/Platform.h" |
18 #include "public/platform/WebCompositorSupport.h" | 20 #include "public/platform/WebCompositorSupport.h" |
19 #include "public/platform/WebFilterOperations.h" | |
20 | 21 |
21 namespace blink { | 22 namespace blink { |
22 | 23 |
23 FilterPainter::FilterPainter(PaintLayer& layer, GraphicsContext& context, const
LayoutPoint& offsetFromRoot, const ClipRect& clipRect, PaintLayerPaintingInfo& p
aintingInfo, PaintLayerFlags paintFlags, | 24 FilterPainter::FilterPainter(PaintLayer& layer, GraphicsContext& context, const
LayoutPoint& offsetFromRoot, const ClipRect& clipRect, PaintLayerPaintingInfo& p
aintingInfo, PaintLayerFlags paintFlags, |
24 LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed) | 25 LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed) |
25 : m_filterInProgress(false) | 26 : m_filterInProgress(false) |
26 , m_context(context) | 27 , m_context(context) |
27 , m_layoutObject(layer.layoutObject()) | 28 , m_layoutObject(layer.layoutObject()) |
28 { | 29 { |
29 if (!layer.paintsWithFilters()) | 30 if (!layer.paintsWithFilters()) |
(...skipping 24 matching lines...) Expand all Loading... |
54 // done it above, and doing it later will defeat the outsets. | 55 // done it above, and doing it later will defeat the outsets. |
55 paintingInfo.clipToDirtyRect = false; | 56 paintingInfo.clipToDirtyRect = false; |
56 | 57 |
57 if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius())
{ | 58 if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius())
{ |
58 m_clipRecorder = adoptPtr(new LayerClipRecorder(context, *layer.layoutOb
ject(), DisplayItem::ClipLayerFilter, clipRect, &paintingInfo, LayoutPoint(), pa
intFlags)); | 59 m_clipRecorder = adoptPtr(new LayerClipRecorder(context, *layer.layoutOb
ject(), DisplayItem::ClipLayerFilter, clipRect, &paintingInfo, LayoutPoint(), pa
intFlags)); |
59 } | 60 } |
60 | 61 |
61 ASSERT(m_layoutObject); | 62 ASSERT(m_layoutObject); |
62 if (!context.paintController().displayItemConstructionIsDisabled()) { | 63 if (!context.paintController().displayItemConstructionIsDisabled()) { |
63 FilterOperations filterOperations(layer.computeFilterOperations(m_layout
Object->styleRef())); | 64 FilterOperations filterOperations(layer.computeFilterOperations(m_layout
Object->styleRef())); |
64 OwnPtr<WebFilterOperations> webFilterOperations = adoptPtr(Platform::cur
rent()->compositorSupport()->createFilterOperations()); | 65 OwnPtr<CompositorFilterOperations> compositorFilterOperations = adoptPtr
(CompositorFactory::current().createFilterOperations()); |
65 builder.buildFilterOperations(filterOperations, webFilterOperations.get(
)); | 66 builder.buildFilterOperations(filterOperations, compositorFilterOperatio
ns.get()); |
66 // FIXME: It's possible to have empty WebFilterOperations here even | 67 // FIXME: It's possible to have empty CompositorFilterOperations here ev
en |
67 // though the SkImageFilter produced above is non-null, since the | 68 // though the SkImageFilter produced above is non-null, since the |
68 // layer's FilterEffectBuilder can have a stale representation of | 69 // layer's FilterEffectBuilder can have a stale representation of |
69 // the layer's filter. See crbug.com/502026. | 70 // the layer's filter. See crbug.com/502026. |
70 if (webFilterOperations->isEmpty()) | 71 if (compositorFilterOperations->isEmpty()) |
71 return; | 72 return; |
72 LayoutRect visualBounds(rootRelativeBounds); | 73 LayoutRect visualBounds(rootRelativeBounds); |
73 if (layer.enclosingPaginationLayer()) { | 74 if (layer.enclosingPaginationLayer()) { |
74 // Filters are set up before pagination, so we need to make the boun
ding box visual on our own. | 75 // Filters are set up before pagination, so we need to make the boun
ding box visual on our own. |
75 visualBounds.moveBy(-offsetFromRoot); | 76 visualBounds.moveBy(-offsetFromRoot); |
76 layer.convertFromFlowThreadToVisualBoundingBoxInAncestor(paintingInf
o.rootLayer, visualBounds); | 77 layer.convertFromFlowThreadToVisualBoundingBoxInAncestor(paintingInf
o.rootLayer, visualBounds); |
77 } | 78 } |
78 context.paintController().createAndAppend<BeginFilterDisplayItem>(*m_lay
outObject, imageFilter, FloatRect(visualBounds), webFilterOperations.release()); | 79 context.paintController().createAndAppend<BeginFilterDisplayItem>(*m_lay
outObject, imageFilter, FloatRect(visualBounds), compositorFilterOperations.rele
ase()); |
79 } | 80 } |
80 | 81 |
81 m_filterInProgress = true; | 82 m_filterInProgress = true; |
82 } | 83 } |
83 | 84 |
84 FilterPainter::~FilterPainter() | 85 FilterPainter::~FilterPainter() |
85 { | 86 { |
86 if (!m_filterInProgress) | 87 if (!m_filterInProgress) |
87 return; | 88 return; |
88 | 89 |
89 m_context.paintController().endItem<EndFilterDisplayItem>(*m_layoutObject); | 90 m_context.paintController().endItem<EndFilterDisplayItem>(*m_layoutObject); |
90 } | 91 } |
91 | 92 |
92 } // namespace blink | 93 } // namespace blink |
OLD | NEW |