| Index: Source/core/paint/SVGFilterPainter.cpp
|
| diff --git a/Source/core/layout/svg/LayoutSVGResourceFilter.cpp b/Source/core/paint/SVGFilterPainter.cpp
|
| similarity index 55%
|
| copy from Source/core/layout/svg/LayoutSVGResourceFilter.cpp
|
| copy to Source/core/paint/SVGFilterPainter.cpp
|
| index 3b4ca9ebd680df5f57dbb50c558763d423b6a411..fa5a889001a9f8c031da843a7e52ad13cf194534 100644
|
| --- a/Source/core/layout/svg/LayoutSVGResourceFilter.cpp
|
| +++ b/Source/core/paint/SVGFilterPainter.cpp
|
| @@ -1,109 +1,24 @@
|
| -/*
|
| - * Copyright (C) 2004, 2005, 2006, 2007 Nikolas Zimmermann <zimmermann@kde.org>
|
| - * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
|
| - * Copyright (C) 2005 Eric Seidel <eric@webkit.org>
|
| - * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
|
| - * Copyright (C) Research In Motion Limited 2010. All rights reserved.
|
| - *
|
| - * This library is free software; you can redistribute it and/or
|
| - * modify it under the terms of the GNU Library General Public
|
| - * License as published by the Free Software Foundation; either
|
| - * version 2 of the License, or (at your option) any later version.
|
| - *
|
| - * This library is distributed in the hope that it will be useful,
|
| - * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| - * Library General Public License for more details.
|
| - *
|
| - * You should have received a copy of the GNU Library General Public License
|
| - * along with this library; see the file COPYING.LIB. If not, write to
|
| - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
| - * Boston, MA 02110-1301, USA.
|
| - */
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
|
|
| #include "config.h"
|
| +#include "core/paint/SVGFilterPainter.h"
|
| +
|
| +#include "core/layout/PaintInfo.h"
|
| #include "core/layout/svg/LayoutSVGResourceFilter.h"
|
|
|
| -#include "core/dom/ElementTraversal.h"
|
| -#include "core/svg/SVGFilterPrimitiveStandardAttributes.h"
|
| -#include "platform/graphics/GraphicsContext.h"
|
| +#include "core/paint/CompositingRecorder.h"
|
| +#include "core/paint/TransformRecorder.h"
|
| #include "platform/graphics/filters/SkiaImageFilterBuilder.h"
|
| #include "platform/graphics/filters/SourceAlpha.h"
|
| #include "platform/graphics/filters/SourceGraphic.h"
|
| -#include "third_party/skia/include/core/SkPicture.h"
|
| +#include "platform/graphics/paint/CompositingDisplayItem.h"
|
| +#include "platform/graphics/paint/DisplayItemList.h"
|
| +#include "platform/graphics/paint/DrawingDisplayItem.h"
|
|
|
| namespace blink {
|
|
|
| -DEFINE_TRACE(FilterData)
|
| -{
|
| -#if ENABLE(OILPAN)
|
| - visitor->trace(filter);
|
| - visitor->trace(builder);
|
| -#endif
|
| -}
|
| -
|
| -LayoutSVGResourceFilter::LayoutSVGResourceFilter(SVGFilterElement* node)
|
| - : LayoutSVGResourceContainer(node)
|
| -{
|
| -}
|
| -
|
| -LayoutSVGResourceFilter::~LayoutSVGResourceFilter()
|
| -{
|
| -}
|
| -
|
| -void LayoutSVGResourceFilter::destroy()
|
| -{
|
| - m_filter.clear();
|
| - LayoutSVGResourceContainer::destroy();
|
| -}
|
| -
|
| -bool LayoutSVGResourceFilter::isChildAllowed(LayoutObject* child, const LayoutStyle&) const
|
| -{
|
| - return child->isSVGResourceFilterPrimitive();
|
| -}
|
| -
|
| -void LayoutSVGResourceFilter::removeAllClientsFromCache(bool markForInvalidation)
|
| -{
|
| - m_filter.clear();
|
| - markAllClientsForInvalidation(markForInvalidation ? LayoutAndBoundariesInvalidation : ParentOnlyInvalidation);
|
| -}
|
| -
|
| -void LayoutSVGResourceFilter::removeClientFromCache(LayoutObject* client, bool markForInvalidation)
|
| -{
|
| - ASSERT(client);
|
| -
|
| - m_filter.remove(client);
|
| -
|
| - markClientForInvalidation(client, markForInvalidation ? BoundariesInvalidation : ParentOnlyInvalidation);
|
| -}
|
| -
|
| -PassRefPtrWillBeRawPtr<SVGFilterBuilder> LayoutSVGResourceFilter::buildPrimitives(SVGFilter* filter)
|
| -{
|
| - SVGFilterElement* filterElement = toSVGFilterElement(element());
|
| - FloatRect targetBoundingBox = filter->targetBoundingBox();
|
| -
|
| - // Add effects to the builder
|
| - RefPtrWillBeRawPtr<SVGFilterBuilder> builder = SVGFilterBuilder::create(SourceGraphic::create(filter), SourceAlpha::create(filter));
|
| - for (SVGElement* element = Traversal<SVGElement>::firstChild(*filterElement); element; element = Traversal<SVGElement>::nextSibling(*element)) {
|
| - if (!element->isFilterEffect() || !element->layoutObject())
|
| - continue;
|
| -
|
| - SVGFilterPrimitiveStandardAttributes* effectElement = static_cast<SVGFilterPrimitiveStandardAttributes*>(element);
|
| - RefPtrWillBeRawPtr<FilterEffect> effect = effectElement->build(builder.get(), filter);
|
| - if (!effect) {
|
| - builder->clearEffects();
|
| - return nullptr;
|
| - }
|
| - builder->appendEffectToEffectReferences(effect, effectElement->layoutObject());
|
| - effectElement->setStandardAttributes(effect.get());
|
| - effect->setEffectBoundaries(SVGLengthContext::resolveRectangle<SVGFilterPrimitiveStandardAttributes>(effectElement, filterElement->primitiveUnits()->currentValue()->enumValue(), targetBoundingBox));
|
| - effect->setOperatingColorSpace(
|
| - effectElement->layoutObject()->style()->svgStyle().colorInterpolationFilters() == CI_LINEARRGB ? ColorSpaceLinearRGB : ColorSpaceDeviceRGB);
|
| - builder->add(AtomicString(effectElement->result()->currentValue()->value()), effect);
|
| - }
|
| - return builder.release();
|
| -}
|
| -
|
| static GraphicsContext* beginRecordingContent(GraphicsContext* context, FilterData* filterData)
|
| {
|
| ASSERT(filterData->m_state == FilterData::Initial);
|
| @@ -205,26 +120,27 @@ static void paintFilteredContent(GraphicsContext* context, FilterData* filterDat
|
| filterData->m_state = FilterData::ReadyToPaint;
|
| }
|
|
|
| -GraphicsContext* LayoutSVGResourceFilter::prepareEffect(LayoutObject* object, GraphicsContext* context)
|
| +GraphicsContext* SVGFilterPainter::prepareEffect(LayoutObject* object, GraphicsContext* context)
|
| {
|
| ASSERT(object);
|
| ASSERT(context);
|
|
|
| - clearInvalidationMask();
|
| + m_filter.clearInvalidationMask();
|
|
|
| - if (FilterData* filterData = m_filter.get(object)) {
|
| + if (FilterData* filterData = m_filter.getFilterDataForLayoutObject(object)) {
|
| // If the filterData already exists we do not need to record the content
|
| // to be filtered. This can occur if the content was previously recorded
|
| // or we are in a cycle.
|
| if (filterData->m_state == FilterData::PaintingFilter)
|
| filterData->m_state = FilterData::PaintingFilterCycleDetected;
|
| +
|
| return nullptr;
|
| }
|
|
|
| OwnPtrWillBeRawPtr<FilterData> filterData = FilterData::create();
|
| FloatRect targetBoundingBox = object->objectBoundingBox();
|
|
|
| - SVGFilterElement* filterElement = toSVGFilterElement(element());
|
| + SVGFilterElement* filterElement = toSVGFilterElement(m_filter.element());
|
| filterData->boundaries = SVGLengthContext::resolveRectangle<SVGFilterElement>(filterElement, filterElement->filterUnits()->currentValue()->enumValue(), targetBoundingBox);
|
| if (filterData->boundaries.isEmpty())
|
| return nullptr;
|
| @@ -236,7 +152,7 @@ GraphicsContext* LayoutSVGResourceFilter::prepareEffect(LayoutObject* object, Gr
|
| filterData->filter = SVGFilter::create(enclosingIntRect(drawingRegion), targetBoundingBox, filterData->boundaries, primitiveBoundingBoxMode);
|
|
|
| // Create all relevant filter primitives.
|
| - filterData->builder = buildPrimitives(filterData->filter.get());
|
| + filterData->builder = m_filter.buildPrimitives(filterData->filter.get());
|
| if (!filterData->builder)
|
| return nullptr;
|
|
|
| @@ -247,16 +163,16 @@ GraphicsContext* LayoutSVGResourceFilter::prepareEffect(LayoutObject* object, Gr
|
| lastEffect->determineFilterPrimitiveSubregion(ClipToFilterRegion);
|
|
|
| FilterData* data = filterData.get();
|
| - m_filter.set(object, filterData.release());
|
| + m_filter.setFilterDataForLayoutObject(object, filterData.release());
|
| return beginRecordingContent(context, data);
|
| }
|
|
|
| -void LayoutSVGResourceFilter::finishEffect(LayoutObject* object, GraphicsContext* context)
|
| +void SVGFilterPainter::finishEffect(LayoutObject* object, GraphicsContext* context)
|
| {
|
| ASSERT(object);
|
| ASSERT(context);
|
|
|
| - FilterData* filterData = m_filter.get(object);
|
| + FilterData* filterData = m_filter.getFilterDataForLayoutObject(object);
|
| if (!filterData)
|
| return;
|
|
|
| @@ -274,42 +190,7 @@ void LayoutSVGResourceFilter::finishEffect(LayoutObject* object, GraphicsContext
|
| endRecordingContent(context, filterData);
|
|
|
| if (filterData->m_state == FilterData::ReadyToPaint)
|
| - paintFilteredContent(context, filterData, toSVGFilterElement(element()));
|
| -}
|
| -
|
| -FloatRect LayoutSVGResourceFilter::resourceBoundingBox(const LayoutObject* object)
|
| -{
|
| - if (SVGFilterElement* element = toSVGFilterElement(this->element()))
|
| - return SVGLengthContext::resolveRectangle<SVGFilterElement>(element, element->filterUnits()->currentValue()->enumValue(), object->objectBoundingBox());
|
| -
|
| - return FloatRect();
|
| -}
|
| -
|
| -void LayoutSVGResourceFilter::primitiveAttributeChanged(LayoutObject* object, const QualifiedName& attribute)
|
| -{
|
| - FilterMap::iterator it = m_filter.begin();
|
| - FilterMap::iterator end = m_filter.end();
|
| - SVGFilterPrimitiveStandardAttributes* primitve = static_cast<SVGFilterPrimitiveStandardAttributes*>(object->node());
|
| -
|
| - for (; it != end; ++it) {
|
| - FilterData* filterData = it->value.get();
|
| - if (filterData->m_state != FilterData::ReadyToPaint)
|
| - continue;
|
| -
|
| - SVGFilterBuilder* builder = filterData->builder.get();
|
| - FilterEffect* effect = builder->effectByRenderer(object);
|
| - if (!effect)
|
| - continue;
|
| - // Since all effects shares the same attribute value, all
|
| - // or none of them will be changed.
|
| - if (!primitve->setFilterEffectAttribute(effect, attribute))
|
| - return;
|
| - builder->clearResultsRecursive(effect);
|
| -
|
| - // Issue paint invalidations for the image on the screen.
|
| - markClientForInvalidation(it->key, PaintInvalidation);
|
| - }
|
| - markAllClientLayersForInvalidation();
|
| + paintFilteredContent(context, filterData, toSVGFilterElement(m_filter.element()));
|
| }
|
|
|
| }
|
|
|