From 981f0ed0d90babfd6535fcd519f39ab9fc3e684e Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 28 Apr 2020 07:13:27 -0400 Subject: [PATCH] First stab at building a vtkm_io library target. --- vtkm/io/CMakeLists.txt | 14 ++++++++++++++ vtkm/{rendering => io}/DecodePNG.cxx | 7 ++++--- vtkm/{rendering => io}/DecodePNG.h | 13 ++++++------- vtkm/{rendering => io}/EncodePNG.cxx | 6 +++--- vtkm/{rendering => io}/EncodePNG.h | 15 +++++++-------- vtkm/rendering/CMakeLists.txt | 7 +------ vtkm/rendering/Canvas.cxx | 9 +++++---- 7 files changed, 40 insertions(+), 31 deletions(-) rename vtkm/{rendering => io}/DecodePNG.cxx (93%) rename vtkm/{rendering => io}/DecodePNG.h (82%) rename vtkm/{rendering => io}/EncodePNG.cxx (96%) rename vtkm/{rendering => io}/EncodePNG.h (79%) diff --git a/vtkm/io/CMakeLists.txt b/vtkm/io/CMakeLists.txt index 2cb4fad43..de929c800 100644 --- a/vtkm/io/CMakeLists.txt +++ b/vtkm/io/CMakeLists.txt @@ -10,10 +10,24 @@ set(headers ErrorIO.h + DecodePNG.h + EncodePNG.h +) + +set(sources + DecodePNG.cxx + EncodePNG.cxx ) vtkm_declare_headers(${headers}) +vtkm_library( NAME vtkm_io + SOURCES ${sources} + HEADERS ${headers} + ) + +target_link_libraries(vtkm_io PRIVATE vtkm_lodepng) + add_subdirectory(internal) add_subdirectory(reader) add_subdirectory(writer) diff --git a/vtkm/rendering/DecodePNG.cxx b/vtkm/io/DecodePNG.cxx similarity index 93% rename from vtkm/rendering/DecodePNG.cxx rename to vtkm/io/DecodePNG.cxx index ab2a656e4..8d89e15b9 100644 --- a/vtkm/rendering/DecodePNG.cxx +++ b/vtkm/io/DecodePNG.cxx @@ -8,18 +8,19 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ -#include +#include #include #include + VTKM_THIRDPARTY_PRE_INCLUDE #include VTKM_THIRDPARTY_POST_INCLUDE namespace vtkm { -namespace rendering +namespace io { vtkm::UInt32 DecodePNG(std::vector& out_image, @@ -39,4 +40,4 @@ vtkm::UInt32 DecodePNG(std::vector& out_image, return retcode; } } -} // namespace vtkm::rendering +} // namespace vtkm::io diff --git a/vtkm/rendering/DecodePNG.h b/vtkm/io/DecodePNG.h similarity index 82% rename from vtkm/rendering/DecodePNG.h rename to vtkm/io/DecodePNG.h index 5f97f06a5..d4deed9de 100644 --- a/vtkm/rendering/DecodePNG.h +++ b/vtkm/io/DecodePNG.h @@ -7,17 +7,16 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ -#ifndef vtk_m_rendering_DecodePNG_h -#define vtk_m_rendering_DecodePNG_h +#ifndef vtk_m_io_DecodePNG_h +#define vtk_m_io_DecodePNG_h #include -#include #include namespace vtkm { -namespace rendering +namespace io { /// Decodes a PNG file buffer in memory, into a raw pixel buffer @@ -25,13 +24,13 @@ namespace rendering /// no matter what color type the original PNG image had. This gives predictable, /// usable data from any random input PNG. /// -VTKM_RENDERING_EXPORT +VTKM_ALWAYS_EXPORT vtkm::UInt32 DecodePNG(std::vector& out_image, unsigned long& image_width, unsigned long& image_height, const unsigned char* in_png, std::size_t in_size); } -} // vtkm::rendering +} // vtkm::io -#endif //vtk_m_rendering_DecodePNG_h +#endif //vtk_m_io_DecodePNG_h diff --git a/vtkm/rendering/EncodePNG.cxx b/vtkm/io/EncodePNG.cxx similarity index 96% rename from vtkm/rendering/EncodePNG.cxx rename to vtkm/io/EncodePNG.cxx index 11dbb14ed..046f97afc 100644 --- a/vtkm/rendering/EncodePNG.cxx +++ b/vtkm/io/EncodePNG.cxx @@ -8,7 +8,7 @@ // PURPOSE. See the above copyright notice for more information. //============================================================================ #include // for std::equal -#include +#include #include #include @@ -19,7 +19,7 @@ VTKM_THIRDPARTY_POST_INCLUDE namespace vtkm { -namespace rendering +namespace io { vtkm::UInt32 EncodePNG(std::vector const& image, @@ -68,4 +68,4 @@ vtkm::UInt32 SavePNG(std::string const& filename, return error; } } -} // namespace vtkm::rendering +} // namespace vtkm::io diff --git a/vtkm/rendering/EncodePNG.h b/vtkm/io/EncodePNG.h similarity index 79% rename from vtkm/rendering/EncodePNG.h rename to vtkm/io/EncodePNG.h index bfca11c93..4eba8eeb8 100644 --- a/vtkm/rendering/EncodePNG.h +++ b/vtkm/io/EncodePNG.h @@ -7,32 +7,31 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //============================================================================ -#ifndef vtk_m_rendering_EncodePNG_h -#define vtk_m_rendering_EncodePNG_h +#ifndef vtk_m_io_EncodePNG_h +#define vtk_m_io_EncodePNG_h #include -#include #include namespace vtkm { -namespace rendering +namespace io { -VTKM_RENDERING_EXPORT +VTKM_ALWAYS_EXPORT vtkm::UInt32 EncodePNG(std::vector const& image, unsigned long width, unsigned long height, unsigned char* out_png, std::size_t out_size); -VTKM_RENDERING_EXPORT +VTKM_ALWAYS_EXPORT vtkm::UInt32 SavePNG(std::string const& filename, std::vector const& image, unsigned long width, unsigned long height); } -} // vtkm::rendering +} // vtkm::io -#endif //vtk_m_rendering_EncodePNG_h +#endif //vtk_m_io_EncodePNG_h diff --git a/vtkm/rendering/CMakeLists.txt b/vtkm/rendering/CMakeLists.txt index 2c80d8cda..207e863f7 100644 --- a/vtkm/rendering/CMakeLists.txt +++ b/vtkm/rendering/CMakeLists.txt @@ -50,8 +50,6 @@ set(headers ColorLegendAnnotation.h ConnectivityProxy.h Cylinderizer.h - DecodePNG.h - EncodePNG.h LineRenderer.h MatrixHelpers.h Scene.h @@ -85,8 +83,6 @@ set(sources Camera.cxx Color.cxx - DecodePNG.cxx - EncodePNG.cxx raytracing/Logger.cxx ) @@ -200,8 +196,7 @@ elseif(VTKm_ENABLE_EGL_CONTEXT) endif() #----------------------------------------------------------------------------- -target_link_libraries(vtkm_rendering PUBLIC vtkm_filter - PRIVATE vtkm_lodepng) +target_link_libraries(vtkm_rendering PUBLIC vtkm_filter vtkm_io) if(UNIX AND NOT APPLE) target_link_libraries(vtkm_rendering PRIVATE rt) endif() diff --git a/vtkm/rendering/Canvas.cxx b/vtkm/rendering/Canvas.cxx index 431c9e64d..8b510536f 100644 --- a/vtkm/rendering/Canvas.cxx +++ b/vtkm/rendering/Canvas.cxx @@ -12,9 +12,9 @@ #include #include +#include +#include #include -#include -#include #include #include #include @@ -523,7 +523,7 @@ bool Canvas::LoadFont() const const std::vector& rawPNG = Internals->Font.GetRawImageData(); std::vector rgba; unsigned long textureWidth, textureHeight; - auto error = DecodePNG(rgba, textureWidth, textureHeight, &rawPNG[0], rawPNG.size()); + auto error = io::DecodePNG(rgba, textureWidth, textureHeight, &rawPNG[0], rawPNG.size()); if (error != 0) { return false; @@ -598,7 +598,8 @@ void Canvas::SaveAs(const std::string& fileName) const } } - SavePNG(fileName, img, static_cast(width), static_cast(height)); + vtkm::io::SavePNG( + fileName, img, static_cast(width), static_cast(height)); return; }