Commit 3a1cd1f1 authored by David C. Lonie's avatar David C. Lonie

Remove Rendering/FreeType/vtkFreeTypeUtilities.

This is part of removing ftgl for android compilation. Also took out
the text rendering benchmark, as it's rather pointless without this
class.
parent 26480bda
......@@ -2,7 +2,6 @@ include(vtkObjectFactory)
set(Module_SRCS
vtkFreeTypeStringToImage.cxx
vtkFreeTypeUtilities.cxx
vtkFreeTypeTools.cxx
vtkMathTextFreeTypeTextRenderer.cxx
vtkMathTextUtilities.cxx
......@@ -28,7 +27,6 @@ set(Module_SRCS
set_source_files_properties(
vtkFreeTypeTools
vtkFreeTypeUtilities
fonts/face_arial_bold
fonts/face_arial_bold_italic
fonts/face_arial
......
/*=========================================================================
Program: Visualization Toolkit
Module: BenchmarkFreeTypeRendering.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 "vtkFreeTypeTools.h"
#include "vtkFreeTypeUtilities.h"
#include "vtkTextRenderer.h"
#include "vtkImageData.h"
#include "vtkNew.h"
#include "vtkStdString.h"
#include "vtkTextProperty.h"
#include <ctime>
#include <cstdio>
#include <algorithm>
//----------------------------------------------------------------------------
int BenchmarkFreeTypeRendering(int , char *[])
{
clock_t startT;
clock_t endT;
double elapsedSecs;
double minSecs;
double maxSecs;
double aveSecs;
vtkFreeTypeTools *ftTools = vtkFreeTypeTools::GetInstance();
vtkFreeTypeUtilities *ftUtils = vtkFreeTypeUtilities::GetInstance();
vtkNew<vtkTextProperty> tprop;
vtkNew<vtkTextRenderer> textRenderer;
vtkStdString str;
for (int i = 0; i < 500; ++i)
{
str += "I'm a test string!\n";
}
elapsedSecs = 0;
minSecs = VTK_DOUBLE_MAX;
maxSecs = 0;
aveSecs = 0;
for (int i = 0; i < 100; ++i)
{
// Set the font to something different to throw off the FT caches.
tprop->SetFontFamily(i % VTK_UNKNOWN_FONT);
tprop->SetFontSize(i % 50 + 10);
tprop->SetBold(i % 2);
tprop->SetItalic((i % 51) % 2);
tprop->SetOrientation(static_cast<double>(i) * (360.0 / 100.0));
// Reset the image data
vtkNew<vtkImageData> image;
// Clock the time needed to render the string.
startT = clock();
ftTools->RenderString(tprop.GetPointer(), str, 72, image.GetPointer());
endT = clock();
double iterSecs = static_cast<double>(endT - startT) /
static_cast<double>(CLOCKS_PER_SEC);
elapsedSecs += iterSecs;
minSecs = std::min(minSecs, iterSecs);
maxSecs = std::max(maxSecs, iterSecs);
}
aveSecs = elapsedSecs / 100.0;
printf("FTTools Total: %9.5f Min: %9.5f Max: %9.5f Ave: %9.5f\n",
elapsedSecs, minSecs, maxSecs, aveSecs);
elapsedSecs = 0;
minSecs = VTK_DOUBLE_MAX;
maxSecs = 0;
aveSecs = 0;
for (int i = 0; i < 100; ++i)
{
// Set the font to something different to throw off the FT face cache.
tprop->SetFontFamily(i % VTK_UNKNOWN_FONT);
tprop->SetFontSize(i % 50 + 10);
tprop->SetBold(i % 2);
tprop->SetItalic((i % 51) % 2);
tprop->SetOrientation(static_cast<double>(i) * (360.0 / 100.0));
// Reset the image data
vtkNew<vtkImageData> image;
// Clock the time needed to render the string.
startT = clock();
textRenderer->RenderString(tprop.GetPointer(), str, image.GetPointer(),
NULL, 72);
endT = clock();
double iterSecs = static_cast<double>(endT - startT) /
static_cast<double>(CLOCKS_PER_SEC);
elapsedSecs += iterSecs;
minSecs = std::min(minSecs, iterSecs);
maxSecs = std::max(maxSecs, iterSecs);
}
aveSecs = elapsedSecs / 100.0;
printf("TextRen Total: %9.5f Min: %9.5f Max: %9.5f Ave: %9.5f\n",
elapsedSecs, minSecs, maxSecs, aveSecs);
elapsedSecs = 0;
minSecs = VTK_DOUBLE_MAX;
maxSecs = 0;
aveSecs = 0;
for (int i = 0; i < 100; ++i)
{
// Set the font to something different to throw off the FT face cache.
tprop->SetFontFamily(i % VTK_UNKNOWN_FONT);
tprop->SetFontSize(i % 50 + 10);
tprop->SetBold(i % 2);
tprop->SetItalic((i % 51) % 2);
tprop->SetOrientation(static_cast<double>(i) * (360.0 / 100.0));
// Reset the image data
vtkNew<vtkImageData> image;
// Clock the time needed to render the string.
startT = clock();
ftUtils->RenderString(tprop.GetPointer(), str, image.GetPointer());
endT = clock();
double iterSecs = static_cast<double>(endT - startT) /
static_cast<double>(CLOCKS_PER_SEC);
elapsedSecs += iterSecs;
minSecs = std::min(minSecs, iterSecs);
maxSecs = std::max(maxSecs, iterSecs);
}
aveSecs = elapsedSecs / 100.0;
printf("FTUtils Total: %9.5f Min: %9.5f Max: %9.5f Ave: %9.5f\n",
elapsedSecs, minSecs, maxSecs, aveSecs);
return EXIT_SUCCESS;
}
......@@ -37,20 +37,5 @@ if(${Module_vtkRenderingMatplotlib})
${matplotlib_tests})
endif()
# This benchmark takes a while to run and can't fail, so disable it by default:
option(VTK_BUILD_FREETYPE_BENCHMARK
"Build a BenchmarkFreeTypeRendering test that benchmarks freetype rendering performance."
OFF)
mark_as_advanced(VTK_BUILD_FREETYPE_BENCHMARK)
if(VTK_BUILD_FREETYPE_BENCHMARK)
vtk_add_test_cxx(${vtk-module}CxxTests bench_tests
NO_VALID
BenchmarkFreeTypeRendering.cxx
)
list(APPEND tests
${bench_tests})
endif()
vtk_test_cxx_executable(${vtk-module}CxxTests tests
RENDERING_FACTORY)
This diff is collapsed.
This diff is collapsed.
......@@ -14,7 +14,6 @@
=========================================================================*/
#include "vtkMathTextUtilities.h"
#include "vtkFreeTypeUtilities.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
......
......@@ -5,7 +5,6 @@
#include "vtkDataSet.h"
#include "vtkDataSetAttributes.h"
#include "vtkFieldData.h"
#include "vtkFreeTypeUtilities.h"
#include "vtkGraph.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
......@@ -18,6 +17,7 @@
#include "vtkStringArray.h"
#include "vtkTable.h"
#include "vtkTextProperty.h"
#include "vtkTextRenderer.h"
#include <map>
......@@ -28,16 +28,17 @@ public:
};
vtkStandardNewMacro(vtkLabelSizeCalculator);
vtkCxxSetObjectMacro(vtkLabelSizeCalculator,FontUtil,vtkFreeTypeUtilities);
vtkCxxSetObjectMacro(vtkLabelSizeCalculator,FontUtil,vtkTextRenderer);
vtkLabelSizeCalculator::vtkLabelSizeCalculator()
{
this->Implementation = new Internals;
// Always defined but user may set to NULL.
this->Implementation->FontProperties[0] = vtkSmartPointer<vtkTextProperty>::New();
this->FontUtil = vtkFreeTypeUtilities::New(); // Never a NULL moment.
this->FontUtil = vtkTextRenderer::New(); // Never a NULL moment.
this->LabelSizeArrayName = NULL;
this->SetLabelSizeArrayName( "LabelSize" );
this->SetDPI(72);
this->SetInputArrayToProcess(0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "LabelText");
this->SetInputArrayToProcess(1, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, "Type");
}
......@@ -235,7 +236,7 @@ vtkIntArray* vtkLabelSizeCalculator::LabelSizesForArray(
prop = this->Implementation->FontProperties[0];
}
this->FontUtil->GetBoundingBox(
prop, labels->GetVariantValue( i ).ToString().c_str(), bbox );
prop, labels->GetVariantValue(i).ToString().c_str(), bbox, this->DPI);
bds[0] = bbox[1] - bbox[0];
bds[1] = bbox[3] - bbox[2];
bds[2] = bbox[0];
......
......@@ -39,7 +39,7 @@
#include "vtkPassInputTypeAlgorithm.h"
class vtkIntArray;
class vtkFreeTypeUtilities;
class vtkTextRenderer;
class vtkStringArray;
class vtkTextProperty;
......@@ -64,6 +64,12 @@ public:
vtkSetStringMacro(LabelSizeArrayName);
vtkGetStringMacro(LabelSizeArrayName);
// Description:
// Get/Set the DPI at which the labels are to be rendered. Defaults to 72.
// @sa vtkWindow::GetDPI()
vtkSetMacro(DPI, int)
vtkGetMacro(DPI, int)
protected:
vtkLabelSizeCalculator();
virtual ~vtkLabelSizeCalculator();
......@@ -76,12 +82,14 @@ protected:
virtual vtkIntArray* LabelSizesForArray( vtkAbstractArray* labels, vtkIntArray* types );
virtual void SetFontUtil( vtkFreeTypeUtilities* fontProp );
vtkGetObjectMacro(FontUtil,vtkFreeTypeUtilities);
virtual void SetFontUtil( vtkTextRenderer* fontProp );
vtkGetObjectMacro(FontUtil,vtkTextRenderer);
vtkFreeTypeUtilities* FontUtil;
vtkTextRenderer* FontUtil;
char* LabelSizeArrayName;
int DPI;
//BTX
class Internals;
Internals* Implementation;
......
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