| 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 "config.h" | 5 #include "config.h" |
| 6 #include "core/paint/FilterPainter.h" | 6 #include "core/paint/FilterPainter.h" |
| 7 | 7 |
| 8 #include "core/layout/FilterEffectRenderer.h" | 8 #include "core/layout/FilterEffectRenderer.h" |
| 9 #include "core/layout/Layer.h" | 9 #include "core/layout/Layer.h" |
| 10 #include "core/layout/LayoutView.h" | 10 #include "core/layout/LayoutView.h" |
| 11 #include "core/paint/LayerClipRecorder.h" | 11 #include "core/paint/LayerClipRecorder.h" |
| 12 #include "core/paint/LayerPainter.h" | 12 #include "core/paint/LayerPainter.h" |
| 13 #include "platform/RuntimeEnabledFeatures.h" | 13 #include "platform/RuntimeEnabledFeatures.h" |
| 14 #include "platform/graphics/GraphicsContext.h" | 14 #include "platform/graphics/GraphicsContext.h" |
| 15 #include "platform/graphics/GraphicsLayer.h" | 15 #include "platform/graphics/GraphicsLayer.h" |
| 16 #include "platform/graphics/filters/FilterEffect.h" | 16 #include "platform/graphics/filters/FilterEffect.h" |
| 17 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" | 17 #include "platform/graphics/filters/SkiaImageFilterBuilder.h" |
| 18 #include "platform/graphics/paint/DisplayItemList.h" | 18 #include "platform/graphics/paint/DisplayItemList.h" |
| 19 #include "platform/graphics/paint/FilterDisplayItem.h" | 19 #include "platform/graphics/paint/FilterDisplayItem.h" |
| 20 #include "public/platform/Platform.h" | 20 #include "public/platform/Platform.h" |
| 21 #include "public/platform/WebCompositorSupport.h" | 21 #include "public/platform/WebCompositorSupport.h" |
| 22 #include "public/platform/WebFilterOperations.h" | 22 #include "public/platform/WebFilterOperations.h" |
| 23 | 23 |
| 24 namespace blink { | 24 namespace blink { |
| 25 | 25 |
| 26 FilterPainter::FilterPainter(Layer& renderLayer, GraphicsContext* context, const
LayoutPoint& offsetFromRoot, const ClipRect& clipRect, LayerPaintingInfo& paint
ingInfo, PaintLayerFlags paintFlags, | 26 FilterPainter::FilterPainter(Layer& renderLayer, GraphicsContext* context, const
LayoutPoint& offsetFromRoot, const ClipRect& clipRect, LayerPaintingInfo& paint
ingInfo, PaintLayerFlags paintFlags, |
| 27 LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed) | 27 LayoutRect& rootRelativeBounds, bool& rootRelativeBoundsComputed) |
| 28 : m_filterInProgress(false) | 28 : m_filterInProgress(false) |
| 29 , m_context(context) | 29 , m_context(context) |
| 30 , m_renderer(renderLayer.renderer()) | 30 , m_renderer(renderLayer.layoutObject()) |
| 31 { | 31 { |
| 32 if (!renderLayer.filterRenderer() || !renderLayer.paintsWithFilters()) | 32 if (!renderLayer.filterRenderer() || !renderLayer.paintsWithFilters()) |
| 33 return; | 33 return; |
| 34 | 34 |
| 35 ASSERT(renderLayer.filterInfo()); | 35 ASSERT(renderLayer.filterInfo()); |
| 36 | 36 |
| 37 SkiaImageFilterBuilder builder(context); | 37 SkiaImageFilterBuilder builder(context); |
| 38 RefPtrWillBeRawPtr<FilterEffect> lastEffect = renderLayer.filterRenderer()->
lastEffect(); | 38 RefPtrWillBeRawPtr<FilterEffect> lastEffect = renderLayer.filterRenderer()->
lastEffect(); |
| 39 lastEffect->determineFilterPrimitiveSubregion(MapRectForward); | 39 lastEffect->determineFilterPrimitiveSubregion(MapRectForward); |
| 40 RefPtr<SkImageFilter> imageFilter = builder.build(lastEffect.get(), ColorSpa
ceDeviceRGB); | 40 RefPtr<SkImageFilter> imageFilter = builder.build(lastEffect.get(), ColorSpa
ceDeviceRGB); |
| 41 if (!imageFilter) | 41 if (!imageFilter) |
| 42 return; | 42 return; |
| 43 | 43 |
| 44 if (!rootRelativeBoundsComputed) { | 44 if (!rootRelativeBoundsComputed) { |
| 45 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludingReflectionA
ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); | 45 rootRelativeBounds = renderLayer.physicalBoundingBoxIncludingReflectionA
ndStackingChildren(paintingInfo.rootLayer, offsetFromRoot); |
| 46 rootRelativeBoundsComputed = true; | 46 rootRelativeBoundsComputed = true; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // We'll handle clipping to the dirty rect before filter rasterization. | 49 // We'll handle clipping to the dirty rect before filter rasterization. |
| 50 // Filter processing will automatically expand the clip rect and the offscre
en to accommodate any filter outsets. | 50 // Filter processing will automatically expand the clip rect and the offscre
en to accommodate any filter outsets. |
| 51 // FIXME: It is incorrect to just clip to the damageRect here once multiple
fragments are involved. | 51 // FIXME: It is incorrect to just clip to the damageRect here once multiple
fragments are involved. |
| 52 | 52 |
| 53 // Subsequent code should not clip to the dirty rect, since we've already | 53 // Subsequent code should not clip to the dirty rect, since we've already |
| 54 // done it above, and doing it later will defeat the outsets. | 54 // done it above, and doing it later will defeat the outsets. |
| 55 paintingInfo.clipToDirtyRect = false; | 55 paintingInfo.clipToDirtyRect = false; |
| 56 | 56 |
| 57 if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius())
{ | 57 if (clipRect.rect() != paintingInfo.paintDirtyRect || clipRect.hasRadius())
{ |
| 58 m_clipRecorder = adoptPtr(new LayerClipRecorder(renderLayer.renderer(),
context, DisplayItem::ClipLayerFilter, clipRect, &paintingInfo, LayoutPoint(), p
aintFlags)); | 58 m_clipRecorder = adoptPtr(new LayerClipRecorder(renderLayer.layoutObject
(), context, DisplayItem::ClipLayerFilter, clipRect, &paintingInfo, LayoutPoint(
), paintFlags)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 ASSERT(m_renderer); | 61 ASSERT(m_renderer); |
| 62 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 62 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 63 FilterOperations filterOperations(renderLayer.computeFilterOperations(m_
renderer->styleRef())); | 63 FilterOperations filterOperations(renderLayer.computeFilterOperations(m_
renderer->styleRef())); |
| 64 OwnPtr<WebFilterOperations> webFilterOperations = adoptPtr(Platform::cur
rent()->compositorSupport()->createFilterOperations()); | 64 OwnPtr<WebFilterOperations> webFilterOperations = adoptPtr(Platform::cur
rent()->compositorSupport()->createFilterOperations()); |
| 65 builder.buildFilterOperations(filterOperations, webFilterOperations.get(
)); | 65 builder.buildFilterOperations(filterOperations, webFilterOperations.get(
)); |
| 66 OwnPtr<BeginFilterDisplayItem> filterDisplayItem = BeginFilterDisplayIte
m::create(m_renderer->displayItemClient(), imageFilter, rootRelativeBounds, webF
ilterOperations.release()); | 66 OwnPtr<BeginFilterDisplayItem> filterDisplayItem = BeginFilterDisplayIte
m::create(m_renderer->displayItemClient(), imageFilter, rootRelativeBounds, webF
ilterOperations.release()); |
| 67 | 67 |
| 68 ASSERT(context->displayItemList()); | 68 ASSERT(context->displayItemList()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 84 OwnPtr<EndFilterDisplayItem> endFilterDisplayItem = EndFilterDisplayItem::cr
eate(m_renderer->displayItemClient()); | 84 OwnPtr<EndFilterDisplayItem> endFilterDisplayItem = EndFilterDisplayItem::cr
eate(m_renderer->displayItemClient()); |
| 85 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { | 85 if (RuntimeEnabledFeatures::slimmingPaintEnabled()) { |
| 86 ASSERT(m_context->displayItemList()); | 86 ASSERT(m_context->displayItemList()); |
| 87 m_context->displayItemList()->add(endFilterDisplayItem.release()); | 87 m_context->displayItemList()->add(endFilterDisplayItem.release()); |
| 88 } else { | 88 } else { |
| 89 endFilterDisplayItem->replay(m_context); | 89 endFilterDisplayItem->replay(m_context); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |