Commit 43d7a64d authored by Ben Boeckel's avatar Ben Boeckel

vtkCompositePolyDataMapper2: cache opacity check

There is a report[1] that this method takes excessive time in newer
versions. Cache the opacity check based on the input's modified time.

Change-Id: Ia2e737dc4aca2b1d0d1dc9ed33440b0e817c3c31
parent 2cfdb418
......@@ -45,6 +45,7 @@ vtkCompositePolyDataMapper2::vtkCompositePolyDataMapper2()
this->SetSelectionPainter(selectionPainter);
selectionPainter->FastDelete();
this->SelectionCompositePainter = selectionPainter;
this->LastOpaqueCheckTime = 0;
}
//----------------------------------------------------------------------------
......@@ -106,6 +107,12 @@ bool vtkCompositePolyDataMapper2::GetIsOpaque()
{
vtkCompositeDataSet *input = vtkCompositeDataSet::SafeDownCast(
this->GetInputDataObject(0, 0));
unsigned long int lastMTime = std::max(input->GetMTime(), this->GetMTime());
if (lastMTime <= this->LastOpaqueCheckTime)
{
return this->LastOpaqueCheckValue;
}
this->LastOpaqueCheckTime = lastMTime;
if (this->ScalarVisibility &&
this->ColorMode == VTK_COLOR_MODE_DEFAULT && input)
{
......@@ -131,6 +138,7 @@ bool vtkCompositePolyDataMapper2::GetIsOpaque()
{
// If the opacity is 255, despite the fact that the user specified
// RGBA, we know that the Alpha is 100% opaque. So treat as opaque.
this->LastOpaqueCheckValue = false;
return false;
}
}
......@@ -140,10 +148,12 @@ bool vtkCompositePolyDataMapper2::GetIsOpaque()
else if(this->CompositeAttributes &&
this->CompositeAttributes->HasBlockOpacities())
{
this->LastOpaqueCheckValue = false;
return false;
}
return this->Superclass::GetIsOpaque();
this->LastOpaqueCheckValue = this->Superclass::GetIsOpaque();
return this->LastOpaqueCheckValue;
}
//----------------------------------------------------------------------------
......
......@@ -111,6 +111,10 @@ protected:
vtkPainter* SelectionCompositePainter;
private:
unsigned long int LastOpaqueCheckTime;
bool LastOpaqueCheckValue;
private:
vtkCompositePolyDataMapper2(const vtkCompositePolyDataMapper2&); // Not implemented.
void operator=(const vtkCompositePolyDataMapper2&); // Not implemented.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment