1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCompositeRenderManager.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkCompositeRenderManager.h"
#include "vtkCompressCompositer.h"
#include "vtkFloatArray.h"
#include "vtkMultiProcessController.h"
#include "vtkObjectFactory.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include "vtkTimerLog.h"
#include "vtkUnsignedCharArray.h"
vtkStandardNewMacro(vtkCompositeRenderManager);
vtkCxxSetObjectMacro(vtkCompositeRenderManager, Compositer, vtkCompositer);
//----------------------------------------------------------------------------
vtkCompositeRenderManager::vtkCompositeRenderManager()
{
this->Compositer = vtkCompressCompositer::New();
this->Compositer->Register(this);
this->Compositer->Delete();
this->DepthData = vtkFloatArray::New();
this->TmpPixelData = vtkUnsignedCharArray::New();
this->TmpDepthData = vtkFloatArray::New();
this->DepthData->SetNumberOfComponents(1);
this->TmpPixelData->SetNumberOfComponents(4);
this->TmpDepthData->SetNumberOfComponents(1);
}
//----------------------------------------------------------------------------
vtkCompositeRenderManager::~vtkCompositeRenderManager()
{
this->SetCompositer(nullptr);
this->DepthData->Delete();
this->TmpPixelData->Delete();
this->TmpDepthData->Delete();
}
//----------------------------------------------------------------------------
void vtkCompositeRenderManager::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "Compositer: " << endl;
this->Compositer->PrintSelf(os, indent.GetNextIndent());
}
//----------------------------------------------------------------------------
void vtkCompositeRenderManager::PreRenderProcessing()
{
vtkTimerLog::MarkStartEvent("Compositing");
// Turn swap buffers off before the render so the end render method has a
// chance to add to the back buffer.
if (this->UseBackBuffer)
{
this->RenderWindow->SwapBuffersOff();
}
this->SavedMultiSamplesSetting = this->RenderWindow->GetMultiSamples();
this->RenderWindow->SetMultiSamples(0);
}
//----------------------------------------------------------------------------
void vtkCompositeRenderManager::PostRenderProcessing()
{
this->RenderWindow->SetMultiSamples(this->SavedMultiSamplesSetting);
if (!this->UseCompositing || this->CheckForAbortComposite())
{
vtkTimerLog::MarkEndEvent("Compositing");
return;
}
if (this->Controller->GetNumberOfProcesses() > 1)
{
// Read in data.
this->ReadReducedImage();
this->Timer->StartTimer();
this->RenderWindow->GetZbufferData(
0, 0, this->ReducedImageSize[0] - 1, this->ReducedImageSize[1] - 1, this->DepthData);
// Set up temporary buffers.
this->TmpPixelData->SetNumberOfComponents(this->ReducedImage->GetNumberOfComponents());
this->TmpPixelData->SetNumberOfTuples(this->ReducedImage->GetNumberOfTuples());
this->TmpDepthData->SetNumberOfComponents(this->DepthData->GetNumberOfComponents());
this->TmpDepthData->SetNumberOfTuples(this->DepthData->GetNumberOfTuples());
// Do composite
this->Compositer->SetController(this->Controller);
this->Compositer->CompositeBuffer(
this->ReducedImage, this->DepthData, this->TmpPixelData, this->TmpDepthData);
this->Timer->StopTimer();
this->ImageProcessingTime = this->Timer->GetElapsedTime();
}
this->WriteFullImage();
// Swap buffers here
if (this->UseBackBuffer)
{
this->RenderWindow->SwapBuffersOn();
}
this->RenderWindow->Frame();
vtkTimerLog::MarkEndEvent("Compositing");
}
|