turn lodepng into a library

This commit is contained in:
nadavi 2020-04-08 14:29:40 -06:00
parent 94f0d2f8a5
commit e925d6d54c
6 changed files with 43 additions and 20 deletions

@ -88,7 +88,7 @@ set(sources
DecodePNG.cxx
EncodePNG.cxx
raytracing/Logger.cxx
)
)
# This list of sources has code that uses devices and so might need to be
# compiled with a device-specific compiler (like CUDA).
@ -103,6 +103,7 @@ set(device_sources
ColorBarAnnotation.cxx
ColorLegendAnnotation.cxx
ConnectivityProxy.cxx
DecodePNG.cxx
LineRenderer.cxx
Mapper.cxx
MapperConnectivity.cxx

@ -523,7 +523,8 @@ bool Canvas::LoadFont() const
const std::vector<unsigned char>& rawPNG = Internals->Font.GetRawImageData();
std::vector<unsigned char> rgba;
unsigned long textureWidth, textureHeight;
auto error = DecodePNG(rgba, textureWidth, textureHeight, &rawPNG[0], rawPNG.size());
auto error =
vtkm::rendering::DecodePNG(rgba, textureWidth, textureHeight, &rawPNG[0], rawPNG.size());
if (error != 0)
{
return false;

@ -14,8 +14,8 @@
#include <vtkm/internal/Configure.h>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.cpp>
VTKM_THIRDPARTY_PRE_INCLUDE
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.h>
VTKM_THIRDPARTY_POST_INCLUDE
namespace vtkm
{

@ -8,14 +8,13 @@
// PURPOSE. See the above copyright notice for more information.
//============================================================================
#include <vtkm/rendering/WorldAnnotatorGL.h>
#include <vtkm/Matrix.h>
#include <vtkm/rendering/BitmapFontFactory.h>
#include <vtkm/rendering/Color.h>
#include <vtkm/rendering/DecodePNG.h>
#include <vtkm/rendering/MatrixHelpers.h>
#include <vtkm/rendering/Scene.h>
#include <vtkm/rendering/WorldAnnotatorGL.h>
#include <vtkm/rendering/internal/OpenGLHeaders.h>
@ -103,7 +102,7 @@ void WorldAnnotatorGL::RenderText(vtkm::Float32 scale,
const std::vector<unsigned char>& rawpngdata = this->Font.GetRawImageData();
std::vector<unsigned char> rgba;
unsigned long width, height;
unsigned width, height;
int error = vtkm::rendering::DecodePNG(rgba, width, height, &rawpngdata[0], rawpngdata.size());
if (error != 0)
{

@ -27,7 +27,7 @@ set(unit_tests
UnitTestScalarRenderer.cxx
)
vtkm_unit_tests(SOURCES ${unit_tests} ALL_BACKENDS LIBRARIES vtkm_rendering)
vtkm_unit_tests(SOURCES ${unit_tests} ALL_BACKENDS LIBRARIES vtkm_rendering vtkm_lodepng)
if(VTKm_ENABLE_GL_CONTEXT)
# message(STATUS "rendering testing/glfw needs a FindGLFW")

@ -7,19 +7,41 @@
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
## PURPOSE. See the above copyright notice for more information.
##============================================================================
add_library(vtkm_lodepng INTERFACE)
vtkm_get_kit_name(kit_name kit_dir)
set(headers
vtkmlodepng/lodepng.h
)
set(sources
vtkmlodepng/lodepng.cpp
)
# vtkm_library(NAME vtkm_lodepng HEADERS ${headers} SOURCES ${sources})
add_library(vtkm_lodepng STATIC ${headers} ${sources})
if(DEFINED VTKm_CUSTOM_LIBRARY_SUFFIX)
set(_lib_suffix "${VTKm_CUSTOM_LIBRARY_SUFFIX}")
else()
set(_lib_suffix "-${VTKm_VERSION_MAJOR}.${VTKm_VERSION_MINOR}")
endif()
set_target_properties(vtkm_lodepng
PROPERTIES
OUTPUT_NAME "vtkm_lodepng${_lib_suffix}"
LIBRARY_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}
ARCHIVE_OUTPUT_DIRECTORY ${VTKm_LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${VTKm_EXECUTABLE_OUTPUT_PATH}
VERSION 1
SOVERSION 1
)
vtkm_generate_export_header(vtkm_lodepng)
target_include_directories(vtkm_lodepng INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng>)
$<INSTALL_INTERFACE:${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng>
)
install(DIRECTORY vtkmlodepng
DESTINATION "${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng"
)
install(TARGETS vtkm_lodepng
EXPORT ${VTKm_EXPORT_NAME})
## Install headers
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
install(DIRECTORY vtkmlodepng
DESTINATION ${VTKm_INSTALL_INCLUDE_DIR}/${kit_dir}/)
endif()
EXPORT ${VTKm_EXPORT_NAME}
LIBRARY DESTINATION ${VTKm_INSTALL_LIB_DIR}
ARCHIVE DESTINATION ${VTKm_INSTALL_LIB_DIR}
RUNTIME DESTINATION ${VTKm_INSTALL_BIN_DIR}
COMPONENT libraries
)