From 33956e6925a09a8582827b3d69c321c747d18e25 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Thu, 25 Sep 2014 15:19:28 -0400 Subject: [PATCH] Bug 983241 - Allow filterNodeSoftware->SetInput(*, nullptr) in order to drop reference to input surface / filter. r=Bas --- gfx/2d/FilterNodeSoftware.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gfx/2d/FilterNodeSoftware.cpp b/gfx/2d/FilterNodeSoftware.cpp index e4d4ddffbd92..c8bd40add58d 100644 --- a/gfx/2d/FilterNodeSoftware.cpp +++ b/gfx/2d/FilterNodeSoftware.cpp @@ -932,7 +932,7 @@ FilterNodeSoftware::~FilterNodeSoftware() void FilterNodeSoftware::SetInput(uint32_t aIndex, FilterNode *aFilter) { - if (aFilter->GetBackendType() != FILTER_BACKEND_SOFTWARE) { + if (aFilter && aFilter->GetBackendType() != FILTER_BACKEND_SOFTWARE) { MOZ_ASSERT(false, "can only take software filters as inputs"); return; } @@ -955,10 +955,8 @@ FilterNodeSoftware::SetInput(uint32_t aInputEnumIndex, MOZ_CRASH(); return; } - if ((uint32_t)inputIndex >= mInputSurfaces.size()) { + if ((uint32_t)inputIndex >= NumberOfSetInputs()) { mInputSurfaces.resize(inputIndex + 1); - } - if ((uint32_t)inputIndex >= mInputFilters.size()) { mInputFilters.resize(inputIndex + 1); } mInputSurfaces[inputIndex] = aSurface; @@ -969,6 +967,10 @@ FilterNodeSoftware::SetInput(uint32_t aInputEnumIndex, aFilter->AddInvalidationListener(this); } mInputFilters[inputIndex] = aFilter; + if (!aSurface && !aFilter && (size_t)inputIndex == NumberOfSetInputs()) { + mInputSurfaces.resize(inputIndex); + mInputFilters.resize(inputIndex); + } Invalidate(); }