Updates will be applied - 3:30pm EDT (UTC -400). No downtime expected.

Commit 41f5902e authored by David Lonie's avatar David Lonie Committed by Kitware Robot

Merge topic 'remove-ftgl'

dafc433d Rerun the back buffer test if front buffer test fails.
33b23386 Remove the ftgl third party module.
3a1cd1f1 Remove Rendering/FreeType/vtkFreeTypeUtilities.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !660
parents 9788ede1 dafc433d
......@@ -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)
......@@ -13,7 +13,6 @@ vtk_module(vtkRenderingFreeType
DEPENDS
vtkRenderingCore
vtkfreetype
vtkftgl
TEST_DEPENDS
${optional_test_depends}
vtkTestingRendering
......
......@@ -28,10 +28,6 @@
#include "vtkStdString.h"
#include "vtkUnicodeString.h"
// FTGL
#include "vtkftglConfig.h"
#include "FTLibrary.h"
// The embedded fonts
#include "fonts/vtkEmbeddedFonts.h"
......@@ -45,10 +41,6 @@
#include <map>
#include <vector>
#ifdef FTGL_USE_NAMESPACE
using namespace ftgl;
#endif
// Print debug info
#define VTK_FTFC_DEBUG 0
#define VTK_FTFC_DEBUG_CD 0
......@@ -133,41 +125,12 @@ struct EmbeddedFontStruct
unsigned char *ptr;
};
//----------------------------------------------------------------------------
// This callback will be called by the FTGLibrary singleton cleanup destructor
// if it happens to be destroyed before our singleton (this order is not
// deterministic). It will destroy our singleton, if needed.
static void vtkFreeTypeToolsCleanupCallback ()
{
#if VTK_FTFC_DEBUG_CD
printf("vtkFreeTypeToolsCleanupCallback\n");
#endif
vtkFreeTypeTools::SetInstance(NULL);
}
//----------------------------------------------------------------------------
// Create the singleton cleanup
// Register our singleton cleanup callback against the FTLibrary so that
// it might be called before the FTLibrary singleton is destroyed.
vtkFreeTypeToolsCleanup::vtkFreeTypeToolsCleanup()
{
#if VTK_FTFC_DEBUG_CD
printf("vtkFreeTypeToolsCleanup::vtkFreeTypeToolsCleanup\n");
#endif
FTLibraryCleanup::AddDependency(&vtkFreeTypeToolsCleanupCallback);
}
//----------------------------------------------------------------------------
// Delete the singleton cleanup
// The callback called here might have been called by the FTLibrary singleton
// cleanup first (depending on the destruction order), but in case ours is
// destroyed first, let's call it too.
//------------------------------------------------------------------------------
// Clean up the vtkFreeTypeTools instance at exit. Using a separate class allows
// us to delay initialization of the vtkFreeTypeTools class.
vtkFreeTypeToolsCleanup::~vtkFreeTypeToolsCleanup()
{
#if VTK_FTFC_DEBUG_CD
printf("vtkFreeTypeToolsCleanup::~vtkFreeTypeToolsCleanup\n");
#endif
vtkFreeTypeToolsCleanupCallback();
vtkFreeTypeTools::SetInstance(NULL);
}
//----------------------------------------------------------------------------
......@@ -225,6 +188,18 @@ vtkFreeTypeTools::vtkFreeTypeTools()
this->ImageCache = NULL;
this->CMapCache = NULL;
this->ScaleToPowerTwo = true;
// Ideally this should be thread-local to support SMP:
FT_Error err;
this->Library = new FT_Library;
err = FT_Init_FreeType(this->Library);
if (err)
{
vtkErrorMacro("FreeType library initialization failed with error code: "
<< err << ".");
delete this->Library;
this->Library = NULL;
}
}
//----------------------------------------------------------------------------
......@@ -235,6 +210,9 @@ vtkFreeTypeTools::~vtkFreeTypeTools()
#endif
this->ReleaseCacheManager();
delete TextPropertyLookup;
FT_Done_FreeType(*this->Library);
this->Library = NULL;
}
//----------------------------------------------------------------------------
......@@ -244,13 +222,7 @@ FT_Library* vtkFreeTypeTools::GetLibrary()
printf("vtkFreeTypeTools::GetLibrary\n");
#endif
FTLibrary * ftgl_lib = FTLibrary::GetInstance();
if (ftgl_lib)
{
return ftgl_lib->GetLibrary();
}
return NULL;
return this->Library;
}
//----------------------------------------------------------------------------
......
......@@ -49,7 +49,6 @@ class vtkTextPropertyLookup;
class VTKRENDERINGFREETYPE_EXPORT vtkFreeTypeToolsCleanup
{
public:
vtkFreeTypeToolsCleanup();
~vtkFreeTypeToolsCleanup();
};
......@@ -304,6 +303,10 @@ protected:
// Lookup table that maps free type font cache face ids to vtkTextProperties
vtkTextPropertyLookup *TextPropertyLookup;
// Description:
// FreeType library instance.
FT_Library *Library;
// Description:
// The cache manager, image cache and charmap cache
FTC_Manager *CacheManager;
......
This diff is collapsed.
This diff is collapsed.
......@@ -14,7 +14,6 @@
=========================================================================*/
#include "vtkMathTextUtilities.h"
#include "vtkFreeTypeUtilities.h"
#include "vtkMath.h"
#include "vtkObjectFactory.h"
......
6ffe5ff5814929cec5ac89bccce67352
f772e3804b50551463c751df1b7767f3
95bc74d792d762d3fa4ba49b5fd89fe2
9933986344c7db276c5bbbbefcec29dd
......@@ -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;
......
......@@ -408,7 +408,18 @@ int vtkTesting::RegressionTest(double thresh, ostream &os)
rtW2if->ReadFrontBufferOn();
rtW2if->Update();
res = this->RegressionTest(rtW2if.Get(), thresh, out2);
os << out2.str();
// If both tests fail, rerun the backbuffer tests to recreate the test
// image. Otherwise an incorrect image will be uploaded to CDash.
if (res == PASSED)
{
os << out2.str();
}
else
{
rtW2if->ReadFrontBufferOff();
rtW2if->Update();
return this->RegressionTest(rtW2if.Get(), thresh, os);
}
}
else
{
......
PROJECT (VTKFTGL)
set(vtkftgl_THIRD_PARTY 1)
set(vtkftgl_LIBRARIES vtkftgl)
set(vtkftgl_INCLUDE_DIRS ${VTKFTGL_SOURCE_DIR}/src)
vtk_module_export_info()
set(VTK_FREETYPE_LIBRARIES ${vtkfreetype_LIBRARIES})
#
# Dependency mask
#
INCLUDE_REGULAR_EXPRESSION(".*")
#
# Collect the required libs
#
SET (VTKFTGL_LIBS "")
#
# Do not use the STL (portability issue)
#
SET (VTKFTGL_DO_NOT_USE_STL 1)
#
# Source files
#
SET (FTGL_SRCS
src/FTBitmapGlyph.cpp
src/FTBitmapGlyphRenderOpenGL.cpp
src/FTCharmap.cpp
src/FTFace.cpp
src/FTFont.cpp
src/FTGLBitmapFont.cpp
src/FTGLBitmapFontRenderOpenGL.cpp
src/FTGLPixmapFont.cpp
src/FTGLPixmapFontRenderOpenGL.cpp
src/FTGlyph.cpp
src/FTGlyphContainer.cpp
src/FTLibrary.cpp
src/FTPixmapGlyph.cpp
src/FTPixmapGlyphRenderOpenGL.cpp
src/FTSize.cpp
)
#
# Do not use texture fonts (crash on Type1 fonts)
#
SET (VTKFTGL_DO_NOT_USE_TEXTURE_FONT 1)
IF (NOT VTKFTGL_DO_NOT_USE_TEXTURE_FONT)
SET (FTGL_SRCS ${FTGL_SRCS}
src/FTGLTextureFont.cpp
src/FTTextureGlyph.cpp
)
ENDIF ()
#
# Do not use vector fonts (we only need pixmap and bitmaps and vector fonts
# needs glu). Might be an option at some point, but set it to 'true' for now.
#
SET (VTKFTGL_DO_NOT_USE_VECTORISER 1)
IF (NOT VTKFTGL_DO_NOT_USE_VECTORISER)
SET (FTGL_SRCS ${FTGL_SRCS}
src/FTExtrdGlyph.cpp
src/FTGLExtrdFont.cpp
src/FTGLOutlineFont.cpp
src/FTGLPolygonFont.cpp
src/FTOutlineGlyph.cpp
src/FTPolyGlyph.cpp
)
ENDIF ()
#
# Shared/static lib settings)
#
IF (BUILD_SHARED_LIBS)
SET (VTKFTGL_DLL 1)
ELSE ()
SET (VTKFTGL_STATIC 1)
ENDIF ()
#
# Win32 flags (and shared/static lib settings)
#
IF (WIN32)
# This will add -DUSE_STD_NAMESPACE and -DWIN32
SET (VTKFTGL_WIN32_FLAGS 1)
ENDIF ()
#
# Unix flags
#
IF (UNIX)
IF(CMAKE_SYSTEM MATCHES "HP-UX.*")
SET (VTKFTGL_HPUX_SOURCE 1)
ENDIF()
ENDIF ()
include(vtkOpenGL)
IF (OPENGL_INCLUDE_PATH)
INCLUDE_DIRECTORIES (${OPENGL_INCLUDE_PATH})
ENDIF ()
#
# We obviously need FreeType
#
SET (VTKFTGL_LIBS "${VTKFTGL_LIBS};${VTK_FREETYPE_LIBRARIES}")
#
# Define the library (and install it)
#
VTK_ADD_LIBRARY (vtkftgl ${FTGL_SRCS})
vtk_opengl_link(vtkftgl)
TARGET_LINK_LIBRARIES(vtkftgl LINK_PRIVATE ${VTKFTGL_LIBS})
#
# Create the configuration file
#
ADD_DEFINITIONS (-DVTKFTGL)
CONFIGURE_FILE(${VTKFTGL_SOURCE_DIR}/vtkftglConfig.h.in
${VTKFTGL_BINARY_DIR}/vtkftglConfig.h)
#
# Build examples (testing purposes)
# (Warning, they use Glut)
#
#OPTION (FTGL_BUILD_EXAMPLES "Build FTGL examples (warning: you need Glut)" OFF)
#MARK_AS_ADVANCED (FTGL_BUILD_EXAMPLES)
SET(FTGL_BUILD_EXAMPLES 0)
IF (FTGL_BUILD_EXAMPLES)
#
# Need GLU and GLUT
#
FIND_PACKAGE(GLU)
FIND_PACKAGE(GLUT)
IF (GLU_LIBRARY AND GLUT_LIBRARY)
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_LIBS}")
IF (GLUT_INCLUDE_PATH)
INCLUDE_DIRECTORIES (${GLUT_INCLUDE_PATH})
ENDIF ()
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};${GLUT_LIBRARY}")
IF (GLU_INCLUDE_PATH)
INCLUDE_DIRECTORIES (${GLU_INCLUDE_PATH})
ENDIF ()
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};${GLU_LIBRARY}")
#
# Do we need X ?
#
IF (VTK_USE_X)
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};-lXt")
FIND_LIBRARY (XMU_LIBRARY Xmu
/usr/lib
/usr/local/lib
/opt/graphics/OpenGL/lib
/usr/openwin/lib
/usr/X11R6/lib
/usr/contrib/X11R6/lib
)
MARK_AS_ADVANCED (XMU_LIBRARY)
IF (XMU_LIBRARY)
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};${XMU_LIBRARY}")
ENDIF ()
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};${X11_LIBRARIES}")
ENDIF ()
#
# Win32 flags
#
IF (WIN32)
# - Avoid the glutCreateMenu_ATEXIT_HACK pb.
# - Sort-of a hack to avoid the bug in glut.h to avoid
# ambiguity between 'std::exit(int)' and 'std::exit(int)' in function
ADD_DEFINITIONS (-DGLUT_DISABLE_ATEXIT_HACK)
ADD_DEFINITIONS (-DGLUT_BUILDING_LIB)
ENDIF ()
#
# Apple libraries.
#
IF (APPLE)
SET (VTKFTGL_EXAMPLES_LIBS "-framework OpenGL" "-framework GLUT" ${VTKFTGL_EXAMPLES_LIBS})
ENDIF ()
#
# Link examples to FTGL and Freetype
#
SET (VTKFTGL_EXAMPLES_LIBS "${VTKFTGL_EXAMPLES_LIBS};vtkftgl;${VTK_FREETYPE_LIBRARIES}")
#
# Example 1
#
SET(FTGL_DEMO_SRCS
demo/tb.c
demo/trackball.c
demo/FTGLDemo.cpp
)
ADD_EXECUTABLE (ftgl_demo ${FTGL_DEMO_SRCS})
vtk_opengl_link(ftgl_demo)
TARGET_LINK_LIBRARIES(ftgl_demo LINK_PRIVATE ${VTKFTGL_EXAMPLES_LIBS})
#
# Example 2
#
ADD_EXECUTABLE (ftgl_demo2 demo/demo.cpp)
vtk_opengl_link(ftgl_demo2)
TARGET_LINK_LIBRARIES(ftgl_demo2 LINK_PRIVATE ${VTKFTGL_EXAMPLES_LIBS})
ENDIF ()
ENDIF ()
This directory contains a subset of the FTGL library (1.32).
We only include enough of distribution to build it.
We'd like to thank Henry Maddocks for distributing this library.
henryj@paradise.net.nz
http://homepages.paradise.net.nz/henryj/code/index.html#FTGL
Modifications
-------------
A lot (including new code in src/NoSTL, speedups, portability issues).
FTGL 1.32
April 23 2002
DESCRIPTION:
FTGL is a free open source library to enable developers to use arbitrary
fonts in their OpenGL (www.opengl.org) applications.
Unlike other OpenGL font libraries FTGL uses standard font file formats
so doesn't need a preprocessing step to convert the high quality font data
into a lesser quality, proprietary format.
FTGL uses the Freetype (www.freetype.org) font library to open and 'decode'
the fonts. It then takes that output and stores it in a format most efficient
for OpenGL rendering.