mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-05 01:49:02 +00:00
lodepng: remove interface dependency
It also avoid installing lodepng.a in the vtk-m shared build.
This commit is contained in:
parent
6a6bc011a6
commit
c92abc4093
@ -114,6 +114,8 @@ function(do_verify root_dir prefix)
|
|||||||
|
|
||||||
set(file_exceptions
|
set(file_exceptions
|
||||||
thirdparty/diy/vtkmdiy/cmake/mpi_types.h
|
thirdparty/diy/vtkmdiy/cmake/mpi_types.h
|
||||||
|
thirdparty/lodepng/vtkmlodepng/lodepng.h
|
||||||
|
thirdparty/loguru/vtkmloguru/loguru.hpp
|
||||||
|
|
||||||
# Ignore deprecated virtual classes (which are not installed if VTKm_NO_DEPRECATED_VIRTUAL
|
# Ignore deprecated virtual classes (which are not installed if VTKm_NO_DEPRECATED_VIRTUAL
|
||||||
# is on). These exceptions can be removed when these files are completely removed.
|
# is on). These exceptions can be removed when these files are completely removed.
|
||||||
|
@ -27,6 +27,5 @@ Libs: -L${libdir} \
|
|||||||
-lvtkm_worklet-@VTKm_VERSION@ \
|
-lvtkm_worklet-@VTKm_VERSION@ \
|
||||||
-lvtkm_source-@VTKm_VERSION@ \
|
-lvtkm_source-@VTKm_VERSION@ \
|
||||||
-lvtkm_io-@VTKm_VERSION@ \
|
-lvtkm_io-@VTKm_VERSION@ \
|
||||||
-lvtkm_lodepng-@VTKm_VERSION@ \
|
|
||||||
-lvtkm_cont-@VTKm_VERSION@ \
|
-lvtkm_cont-@VTKm_VERSION@ \
|
||||||
-lvtkmdiympi_nompi
|
-lvtkmdiympi_nompi
|
||||||
|
@ -34,6 +34,5 @@ VTKm_LIB_FLAGS = -L $(VTKm_DIR)/lib \
|
|||||||
-lvtkm_worklet-$(VTKM_VERSION) \
|
-lvtkm_worklet-$(VTKM_VERSION) \
|
||||||
-lvtkm_source-$(VTKM_VERSION) \
|
-lvtkm_source-$(VTKM_VERSION) \
|
||||||
-lvtkm_io-$(VTKM_VERSION) \
|
-lvtkm_io-$(VTKM_VERSION) \
|
||||||
-lvtkm_lodepng-$(VTKM_VERSION) \
|
|
||||||
-lvtkm_cont-$(VTKM_VERSION) \
|
-lvtkm_cont-$(VTKM_VERSION) \
|
||||||
-lvtkmdiympi_nompi
|
-lvtkmdiympi_nompi
|
||||||
|
@ -48,6 +48,7 @@ set(sources
|
|||||||
ImageWriterBase.cxx
|
ImageWriterBase.cxx
|
||||||
ImageWriterPNG.cxx
|
ImageWriterPNG.cxx
|
||||||
ImageWriterPNM.cxx
|
ImageWriterPNM.cxx
|
||||||
|
PixelTypes.cxx
|
||||||
VTKDataSetReader.cxx
|
VTKDataSetReader.cxx
|
||||||
VTKDataSetReaderBase.cxx
|
VTKDataSetReaderBase.cxx
|
||||||
VTKDataSetWriter.cxx
|
VTKDataSetWriter.cxx
|
||||||
@ -82,6 +83,7 @@ vtkm_library(
|
|||||||
TEMPLATE_SOURCES ${template_sources}
|
TEMPLATE_SOURCES ${template_sources}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# CMAKE 3.12 does not know about PRIVATE TARGET_OBJECTS
|
||||||
target_link_libraries(vtkm_io PUBLIC vtkm_cont PRIVATE vtkm_lodepng)
|
target_link_libraries(vtkm_io PUBLIC vtkm_cont PRIVATE vtkm_lodepng)
|
||||||
if (VTKm_ENABLE_HDF5_IO)
|
if (VTKm_ENABLE_HDF5_IO)
|
||||||
target_include_directories(vtkm_io PRIVATE $<BUILD_INTERFACE:${HDF5_INCLUDE_DIR}>)
|
target_include_directories(vtkm_io PRIVATE $<BUILD_INTERFACE:${HDF5_INCLUDE_DIR}>)
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
|
|
||||||
#include <vtkm/io/PixelTypes.h>
|
#include <vtkm/io/PixelTypes.h>
|
||||||
|
|
||||||
|
VTKM_THIRDPARTY_PRE_INCLUDE
|
||||||
|
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.h>
|
||||||
|
VTKM_THIRDPARTY_POST_INCLUDE
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -23,12 +27,13 @@ vtkm::io::ImageReaderBase::ColorArrayType ReadFromPNG(const std::string& fileNam
|
|||||||
{
|
{
|
||||||
unsigned char* imageData;
|
unsigned char* imageData;
|
||||||
unsigned uwidth, uheight;
|
unsigned uwidth, uheight;
|
||||||
vtkm::png::lodepng_decode_file(&imageData,
|
vtkm::png::lodepng_decode_file(
|
||||||
&uwidth,
|
&imageData,
|
||||||
&uheight,
|
&uwidth,
|
||||||
fileName.c_str(),
|
&uheight,
|
||||||
PixelType::PNG_COLOR_TYPE,
|
fileName.c_str(),
|
||||||
PixelType::BIT_DEPTH);
|
static_cast<vtkm::png::LodePNGColorType>(PixelType::GetColorType()),
|
||||||
|
PixelType::GetBitDepth());
|
||||||
|
|
||||||
width = static_cast<vtkm::Id>(uwidth);
|
width = static_cast<vtkm::Id>(uwidth);
|
||||||
height = static_cast<vtkm::Id>(uheight);
|
height = static_cast<vtkm::Id>(uheight);
|
||||||
|
@ -56,12 +56,13 @@ void ImageWriterPNG::WriteToFile(vtkm::Id width, vtkm::Id height, const ColorArr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vtkm::png::lodepng_encode_file(this->FileName.c_str(),
|
vtkm::png::lodepng_encode_file(
|
||||||
imageData.data(),
|
this->FileName.c_str(),
|
||||||
static_cast<unsigned>(width),
|
imageData.data(),
|
||||||
static_cast<unsigned>(height),
|
static_cast<unsigned>(width),
|
||||||
PixelType::PNG_COLOR_TYPE,
|
static_cast<unsigned>(height),
|
||||||
PixelType::BIT_DEPTH);
|
static_cast<vtkm::png::LodePNGColorType>(PixelType::GetColorType()),
|
||||||
|
PixelType::GetBitDepth());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // namespace vtkm::io
|
} // namespace vtkm::io
|
||||||
|
19
vtkm/io/PixelTypes.cxx
Normal file
19
vtkm/io/PixelTypes.cxx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
//============================================================================
|
||||||
|
// Copyright (c) Kitware, Inc.
|
||||||
|
// All rights reserved.
|
||||||
|
// See LICENSE.txt 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 <vtkm/io/PixelTypes.h>
|
||||||
|
|
||||||
|
VTKM_THIRDPARTY_PRE_INCLUDE
|
||||||
|
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.h>
|
||||||
|
VTKM_THIRDPARTY_POST_INCLUDE
|
||||||
|
|
||||||
|
int vtkm::io::internal::GreyColorType = static_cast<int>(vtkm::png::LodePNGColorType::LCT_GREY);
|
||||||
|
|
||||||
|
int vtkm::io::internal::RGBColorType = static_cast<int>(vtkm::png::LodePNGColorType::LCT_RGB);
|
@ -13,15 +13,20 @@
|
|||||||
#include <vtkm/Types.h>
|
#include <vtkm/Types.h>
|
||||||
#include <vtkm/VecTraits.h>
|
#include <vtkm/VecTraits.h>
|
||||||
|
|
||||||
VTKM_THIRDPARTY_PRE_INCLUDE
|
|
||||||
#include <vtkm/thirdparty/lodepng/vtkmlodepng/lodepng.h>
|
|
||||||
VTKM_THIRDPARTY_POST_INCLUDE
|
|
||||||
|
|
||||||
namespace vtkm
|
namespace vtkm
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace io
|
namespace io
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace internal
|
||||||
|
{
|
||||||
|
|
||||||
|
extern int GreyColorType;
|
||||||
|
extern int RGBColorType;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Define custom SFINAE structures to calculate the VTKM types associated
|
// Define custom SFINAE structures to calculate the VTKM types associated
|
||||||
// with provided BitDepths
|
// with provided BitDepths
|
||||||
@ -75,6 +80,10 @@ public:
|
|||||||
static constexpr vtkm::IdComponent MAX_COLOR_VALUE = (1 << BitDepth) - 1;
|
static constexpr vtkm::IdComponent MAX_COLOR_VALUE = (1 << BitDepth) - 1;
|
||||||
static constexpr vtkm::IdComponent NUM_CHANNELS = Superclass::NUM_COMPONENTS;
|
static constexpr vtkm::IdComponent NUM_CHANNELS = Superclass::NUM_COMPONENTS;
|
||||||
static constexpr vtkm::IdComponent BYTES_PER_PIXEL = NUM_CHANNELS * NUM_BYTES;
|
static constexpr vtkm::IdComponent BYTES_PER_PIXEL = NUM_CHANNELS * NUM_BYTES;
|
||||||
|
static constexpr vtkm::IdComponent GetBitDepth()
|
||||||
|
{
|
||||||
|
return BasePixel<BitDepth, Channels>::BIT_DEPTH;
|
||||||
|
}
|
||||||
|
|
||||||
using Superclass::Superclass;
|
using Superclass::Superclass;
|
||||||
BasePixel() = default;
|
BasePixel() = default;
|
||||||
@ -131,8 +140,6 @@ public:
|
|||||||
// RGB values are stored in a vtkm::Vec<ComponentType, 3>
|
// RGB values are stored in a vtkm::Vec<ComponentType, 3>
|
||||||
using Superclass = BasePixel<BitDepth, 3>;
|
using Superclass = BasePixel<BitDepth, 3>;
|
||||||
using ComponentType = typename Superclass::ComponentType;
|
using ComponentType = typename Superclass::ComponentType;
|
||||||
static constexpr vtkm::png::LodePNGColorType PNG_COLOR_TYPE =
|
|
||||||
vtkm::png::LodePNGColorType::LCT_RGB;
|
|
||||||
|
|
||||||
using Superclass::Superclass;
|
using Superclass::Superclass;
|
||||||
RGBPixel() = default;
|
RGBPixel() = default;
|
||||||
@ -145,6 +152,9 @@ public:
|
|||||||
|
|
||||||
virtual ~RGBPixel() = default;
|
virtual ~RGBPixel() = default;
|
||||||
|
|
||||||
|
// Get the implementation specific color type (Gray|RGB) value
|
||||||
|
static int GetColorType();
|
||||||
|
|
||||||
ComponentType Diff(const Superclass& pixel) const override;
|
ComponentType Diff(const Superclass& pixel) const override;
|
||||||
vtkm::Vec4f_32 ToVec4f() const override;
|
vtkm::Vec4f_32 ToVec4f() const override;
|
||||||
|
|
||||||
@ -169,8 +179,6 @@ public:
|
|||||||
// in order to simplify the pixel helper functions
|
// in order to simplify the pixel helper functions
|
||||||
using Superclass = BasePixel<BitDepth, 1>;
|
using Superclass = BasePixel<BitDepth, 1>;
|
||||||
using ComponentType = typename Superclass::ComponentType;
|
using ComponentType = typename Superclass::ComponentType;
|
||||||
static constexpr vtkm::png::LodePNGColorType PNG_COLOR_TYPE =
|
|
||||||
vtkm::png::LodePNGColorType::LCT_GREY;
|
|
||||||
|
|
||||||
using Superclass::Superclass;
|
using Superclass::Superclass;
|
||||||
GreyPixel() = default;
|
GreyPixel() = default;
|
||||||
@ -182,6 +190,9 @@ public:
|
|||||||
|
|
||||||
virtual ~GreyPixel() = default;
|
virtual ~GreyPixel() = default;
|
||||||
|
|
||||||
|
// Get the implementation specific color type (Gray|RGB) value
|
||||||
|
static int GetColorType();
|
||||||
|
|
||||||
ComponentType Diff(const Superclass& pixel) const override;
|
ComponentType Diff(const Superclass& pixel) const override;
|
||||||
vtkm::Vec4f_32 ToVec4f() const override;
|
vtkm::Vec4f_32 ToVec4f() const override;
|
||||||
|
|
||||||
|
@ -78,6 +78,17 @@ vtkm::Vec4f_32 GreyPixel<B>::ToVec4f() const
|
|||||||
1);
|
1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <const vtkm::Id B>
|
||||||
|
int RGBPixel<B>::GetColorType()
|
||||||
|
{
|
||||||
|
return internal::RGBColorType;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <const vtkm::Id B>
|
||||||
|
int GreyPixel<B>::GetColorType()
|
||||||
|
{
|
||||||
|
return internal::GreyColorType;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace io
|
} // namespace io
|
||||||
} // namespace vtkm
|
} // namespace vtkm
|
||||||
|
@ -16,7 +16,7 @@ set(unit_tests
|
|||||||
UnitTestVTKDataSetWriter.cxx
|
UnitTestVTKDataSetWriter.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
set(unit_test_libraries vtkm_lodepng vtkm_io)
|
set(unit_test_libraries vtkm_io)
|
||||||
|
|
||||||
if(VTKm_ENABLE_RENDERING)
|
if(VTKm_ENABLE_RENDERING)
|
||||||
list(APPEND unit_tests
|
list(APPEND unit_tests
|
||||||
|
@ -106,6 +106,7 @@ void TestGreyPixelConstructors()
|
|||||||
"Incorrect Conversion");
|
"Incorrect Conversion");
|
||||||
VTKM_TEST_ASSERT(vtkm::Vec<vtkm::UInt16, 1>(10) == pixel_7, "Bad Vec4f_32 construction");
|
VTKM_TEST_ASSERT(vtkm::Vec<vtkm::UInt16, 1>(10) == pixel_7, "Bad Vec4f_32 construction");
|
||||||
|
|
||||||
|
VTKM_TEST_ASSERT(GreyPixel<16>::GetBitDepth() == 16, "Bad BitDepth");
|
||||||
VTKM_TEST_ASSERT(GreyPixel<16>::BIT_DEPTH == 16, "Bad BitDepth");
|
VTKM_TEST_ASSERT(GreyPixel<16>::BIT_DEPTH == 16, "Bad BitDepth");
|
||||||
VTKM_TEST_ASSERT(GreyPixel<16>::NUM_BYTES == 2, "Bad NumBytes");
|
VTKM_TEST_ASSERT(GreyPixel<16>::NUM_BYTES == 2, "Bad NumBytes");
|
||||||
VTKM_TEST_ASSERT(GreyPixel<16>::MAX_COLOR_VALUE == 65535, "Bad NumBytes");
|
VTKM_TEST_ASSERT(GreyPixel<16>::MAX_COLOR_VALUE == 65535, "Bad NumBytes");
|
||||||
@ -146,6 +147,7 @@ void TestRGBPixelConstructors()
|
|||||||
"Incorrect Conversion");
|
"Incorrect Conversion");
|
||||||
VTKM_TEST_ASSERT(vtkm::Vec<vtkm::UInt16, 3>(10, 10, 10) == pixel_8, "Bad Vec4f_32 construction");
|
VTKM_TEST_ASSERT(vtkm::Vec<vtkm::UInt16, 3>(10, 10, 10) == pixel_8, "Bad Vec4f_32 construction");
|
||||||
|
|
||||||
|
VTKM_TEST_ASSERT(RGBPixel<16>::GetBitDepth() == 16, "Bad BitDepth");
|
||||||
VTKM_TEST_ASSERT(RGBPixel<16>::BIT_DEPTH == 16, "Bad BitDepth");
|
VTKM_TEST_ASSERT(RGBPixel<16>::BIT_DEPTH == 16, "Bad BitDepth");
|
||||||
VTKM_TEST_ASSERT(RGBPixel<16>::NUM_BYTES == 2, "Bad NumBytes");
|
VTKM_TEST_ASSERT(RGBPixel<16>::NUM_BYTES == 2, "Bad NumBytes");
|
||||||
VTKM_TEST_ASSERT(RGBPixel<16>::MAX_COLOR_VALUE == 65535, "Bad NumBytes");
|
VTKM_TEST_ASSERT(RGBPixel<16>::MAX_COLOR_VALUE == 65535, "Bad NumBytes");
|
||||||
|
53
vtkm/thirdparty/lodepng/CMakeLists.txt
vendored
53
vtkm/thirdparty/lodepng/CMakeLists.txt
vendored
@ -7,53 +7,12 @@
|
|||||||
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
## the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
## PURPOSE. See the above copyright notice for more information.
|
## PURPOSE. See the above copyright notice for more information.
|
||||||
##============================================================================
|
##============================================================================
|
||||||
set(headers
|
|
||||||
vtkmlodepng/lodepng.h
|
|
||||||
)
|
|
||||||
set(sources
|
|
||||||
vtkmlodepng/lodepng.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
# Mark this lib as STATIC for usage in Windows without requiring dll_export
|
add_library(vtkm_lodepng OBJECT vtkmlodepng/lodepng.cpp)
|
||||||
# if a SHARED lib is ever required you will need to generate the export
|
|
||||||
# headers and add them to the lodepng functions that should be shared
|
|
||||||
add_library(vtkm_lodepng STATIC ${headers} ${sources})
|
|
||||||
|
|
||||||
if(DEFINED VTKm_CUSTOM_LIBRARY_SUFFIX)
|
# To be consumed by other potentially PIC libraries
|
||||||
set(_lib_suffix "${VTKm_CUSTOM_LIBRARY_SUFFIX}")
|
set_target_properties(vtkm_lodepng PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||||
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}
|
|
||||||
POSITION_INDEPENDENT_CODE ON
|
|
||||||
)
|
|
||||||
if (NOT VTKm_SKIP_LIBRARY_VERSIONS)
|
|
||||||
set_target_properties(vtkm_lodepng
|
|
||||||
PROPERTIES
|
|
||||||
VERSION 1
|
|
||||||
SOVERSION 1
|
|
||||||
)
|
|
||||||
endif ()
|
|
||||||
target_include_directories(vtkm_lodepng INTERFACE
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
|
||||||
$<INSTALL_INTERFACE:${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng>
|
|
||||||
)
|
|
||||||
|
|
||||||
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
|
# This will not install anything but it is needed for CMake <= 3.21 since it
|
||||||
install(FILES ${headers}
|
# does not fully support $<TARGET_OBJECTS> in target_link_library.
|
||||||
DESTINATION "${VTKm_INSTALL_INCLUDE_DIR}/vtkm/thirdparty/lodepng/vtkmlodepng/"
|
install(TARGETS vtkm_lodepng EXPORT ${VTKm_EXPORT_NAME})
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
install(TARGETS vtkm_lodepng
|
|
||||||
EXPORT ${VTKm_EXPORT_NAME}
|
|
||||||
LIBRARY DESTINATION ${VTKm_INSTALL_LIB_DIR}
|
|
||||||
ARCHIVE DESTINATION ${VTKm_INSTALL_LIB_DIR}
|
|
||||||
RUNTIME DESTINATION ${VTKm_INSTALL_BIN_DIR}
|
|
||||||
COMPONENT libraries
|
|
||||||
)
|
|
||||||
|
6
vtkm/thirdparty/loguru/CMakeLists.txt
vendored
6
vtkm/thirdparty/loguru/CMakeLists.txt
vendored
@ -22,9 +22,3 @@ target_link_libraries(vtkm_loguru INTERFACE ${CMAKE_DL_LIBS} Threads::Threads)
|
|||||||
|
|
||||||
install(TARGETS vtkm_loguru
|
install(TARGETS vtkm_loguru
|
||||||
EXPORT ${VTKm_EXPORT_NAME})
|
EXPORT ${VTKm_EXPORT_NAME})
|
||||||
|
|
||||||
## Install headers
|
|
||||||
if(NOT VTKm_INSTALL_ONLY_LIBRARIES)
|
|
||||||
install(DIRECTORY vtkmloguru
|
|
||||||
DESTINATION ${VTKm_INSTALL_INCLUDE_DIR}/${kit_dir}/)
|
|
||||||
endif()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user