From 7893b08d5b18e2fc3355d56df48bed7330b6ba70 Mon Sep 17 00:00:00 2001 From: Tom Klein Date: Wed, 7 Oct 2015 08:25:00 +0200 Subject: [PATCH] Bug 1203376 - Honor filter region settings for lighting filters. r=mstange --HG-- extra : rebase_source : adecead97d734b9bb9b5b104b88edf81c82a13a4 --- gfx/2d/FilterNodeD2D1.cpp | 23 +++++++++++++- gfx/2d/FilterNodeSoftware.cpp | 4 +-- gfx/src/FilterSupport.cpp | 8 +++-- gfx/src/FilterSupport.h | 3 +- .../svg/filters/feDiffuseLighting-1-ref.svg | 11 ++++++- .../filters/filter-lighting-region-ref.svg | 11 +++++++ .../svg/filters/filter-lighting-region.svg | 30 +++++++++++++++++++ layout/reftests/svg/filters/reftest.list | 4 ++- 8 files changed, 85 insertions(+), 9 deletions(-) create mode 100644 layout/reftests/svg/filters/filter-lighting-region-ref.svg create mode 100644 layout/reftests/svg/filters/filter-lighting-region.svg diff --git a/gfx/2d/FilterNodeD2D1.cpp b/gfx/2d/FilterNodeD2D1.cpp index 364460a06fe0..b144c3c7e467 100644 --- a/gfx/2d/FilterNodeD2D1.cpp +++ b/gfx/2d/FilterNodeD2D1.cpp @@ -536,6 +536,27 @@ IsTransferFilterType(FilterType aType) } } +static bool +HasUnboundedOutputRegion(FilterType aType) +{ + if (IsTransferFilterType(aType)) { + return true; + } + + switch (aType) { + case FilterType::COLOR_MATRIX: + case FilterType::POINT_DIFFUSE: + case FilterType::SPOT_DIFFUSE: + case FilterType::DISTANT_DIFFUSE: + case FilterType::POINT_SPECULAR: + case FilterType::SPOT_SPECULAR: + case FilterType::DISTANT_SPECULAR: + return true; + default: + return false; + } +} + /* static */ already_AddRefed FilterNodeD2D1::Create(ID2D1DeviceContext *aDC, FilterType aType) @@ -556,7 +577,7 @@ FilterNodeD2D1::Create(ID2D1DeviceContext *aDC, FilterType aType) RefPtr filter = new FilterNodeD2D1(effect, aType); - if (IsTransferFilterType(aType) || aType == FilterType::COLOR_MATRIX) { + if (HasUnboundedOutputRegion(aType)) { // These filters can produce non-transparent output from transparent // input pixels, and we want them to have an unbounded output region. filter = new FilterNodeExtendInputAdapterD2D1(aDC, filter, aType); diff --git a/gfx/2d/FilterNodeSoftware.cpp b/gfx/2d/FilterNodeSoftware.cpp index ff988054a3ed..2e16c5dc7822 100644 --- a/gfx/2d/FilterNodeSoftware.cpp +++ b/gfx/2d/FilterNodeSoftware.cpp @@ -3340,7 +3340,7 @@ template IntRect FilterNodeLightingSoftware::GetOutputRectInRect(const IntRect& aRect) { - return GetInputRectInRect(IN_LIGHTING_IN, aRect); + return aRect; } Point3D @@ -3482,7 +3482,7 @@ FilterNodeLightingSoftware::DoRender(const IntRect& aRe RefPtr input = GetInputDataSourceSurface(IN_LIGHTING_IN, srcRect, CAN_HANDLE_A8, - EDGE_MODE_DUPLICATE); + EDGE_MODE_NONE); if (!input) { return nullptr; diff --git a/gfx/src/FilterSupport.cpp b/gfx/src/FilterSupport.cpp index 8ff67f95720e..3040b0e02638 100644 --- a/gfx/src/FilterSupport.cpp +++ b/gfx/src/FilterSupport.cpp @@ -1232,9 +1232,6 @@ FilterNodeGraphFromDescription(DrawTarget* aDT, { const nsTArray& primitives = aFilter.mPrimitives; - Rect resultNeededRect(aResultNeededRect); - resultNeededRect.RoundOut(); - RefPtr sourceFilters[4]; nsTArray > primitiveFilters; @@ -1407,6 +1404,9 @@ ResultChangeRegionForPrimitive(const FilterPrimitiveDescription& aDescription, case PrimitiveType::ConvolveMatrix: { + if (atts.GetUint(eConvolveMatrixEdgeMode) != EDGE_MODE_NONE) { + return aDescription.PrimitiveSubregion(); + } Size kernelUnitLength = atts.GetSize(eConvolveMatrixKernelUnitLength); IntSize kernelSize = atts.GetIntSize(eConvolveMatrixKernelSize); IntPoint target = atts.GetIntPoint(eConvolveMatrixTarget); @@ -1603,6 +1603,8 @@ FilterSupport::PostFilterExtentsForPrimitive(const FilterPrimitiveDescription& a case PrimitiveType::Turbulence: case PrimitiveType::Image: + case PrimitiveType::DiffuseLighting: + case PrimitiveType::SpecularLighting: { return aDescription.PrimitiveSubregion(); } diff --git a/gfx/src/FilterSupport.h b/gfx/src/FilterSupport.h index f601e3987993..96a43d7cbba3 100644 --- a/gfx/src/FilterSupport.h +++ b/gfx/src/FilterSupport.h @@ -437,7 +437,8 @@ public: /** * Computes the region that changes in the filter output due to a change in - * input. + * input. This is primarily needed when an individual piece of content inside + * a filtered container element changes. */ static nsIntRegion ComputeResultChangeRegion(const FilterDescription& aFilter, diff --git a/layout/reftests/svg/filters/feDiffuseLighting-1-ref.svg b/layout/reftests/svg/filters/feDiffuseLighting-1-ref.svg index 9a03386007c5..efdf45390360 100644 --- a/layout/reftests/svg/filters/feDiffuseLighting-1-ref.svg +++ b/layout/reftests/svg/filters/feDiffuseLighting-1-ref.svg @@ -3,5 +3,14 @@ http://creativecommons.org/publicdomain/zero/1.0/ --> - + diff --git a/layout/reftests/svg/filters/filter-lighting-region-ref.svg b/layout/reftests/svg/filters/filter-lighting-region-ref.svg new file mode 100644 index 000000000000..d7337102b7b7 --- /dev/null +++ b/layout/reftests/svg/filters/filter-lighting-region-ref.svg @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/layout/reftests/svg/filters/filter-lighting-region.svg b/layout/reftests/svg/filters/filter-lighting-region.svg new file mode 100644 index 000000000000..883b6d805dda --- /dev/null +++ b/layout/reftests/svg/filters/filter-lighting-region.svg @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/layout/reftests/svg/filters/reftest.list b/layout/reftests/svg/filters/reftest.list index 3a623f22c7c5..053ae15e2a99 100644 --- a/layout/reftests/svg/filters/reftest.list +++ b/layout/reftests/svg/filters/reftest.list @@ -109,10 +109,12 @@ fuzzy(2,500) == feDisplacementMap-colour-01.svg feDisplacementMap-colour-01-ref. == feTile-large-02.svg feTile-large-02-ref.svg == feTile-outside-01.svg feTile-outside-01-ref.svg -fuzzy(1,119) == feDiffuseLighting-1.svg feDiffuseLighting-1-ref.svg +fuzzy(1,217) == feDiffuseLighting-1.svg feDiffuseLighting-1-ref.svg fuzzy(2,2659) skip-if(d2d) == feSpecularLighting-1.svg feSpecularLighting-1-ref.svg +== filter-lighting-region.svg filter-lighting-region-ref.svg + == fePointLight-zoomed-page.svg fePointLight-zoomed-page-ref.svg == feTurbulence-offset.svg feTurbulence-offset-ref.svg