From 981f0ed0d90babfd6535fcd519f39ab9fc3e684e Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 28 Apr 2020 07:13:27 -0400 Subject: [PATCH 1/5] 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; } From 1a16299b8c2dd89e5148597e4ac64256e549ea18 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 28 Apr 2020 07:47:31 -0400 Subject: [PATCH 2/5] Fix build error. --- vtkm/io/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vtkm/io/CMakeLists.txt b/vtkm/io/CMakeLists.txt index de929c800..2e5a15f11 100644 --- a/vtkm/io/CMakeLists.txt +++ b/vtkm/io/CMakeLists.txt @@ -26,7 +26,7 @@ vtkm_library( NAME vtkm_io HEADERS ${headers} ) -target_link_libraries(vtkm_io PRIVATE vtkm_lodepng) +target_link_libraries(vtkm_io PUBLIC vtkm_cont PRIVATE vtkm_lodepng) add_subdirectory(internal) add_subdirectory(reader) From 54e15e8f14402689dafea008b69554ceb8801b92 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 28 Apr 2020 09:12:11 -0400 Subject: [PATCH 3/5] Export symbol as VTK_IO_EXPORT. --- vtkm/io/DecodePNG.h | 3 ++- vtkm/io/EncodePNG.h | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/vtkm/io/DecodePNG.h b/vtkm/io/DecodePNG.h index d4deed9de..1cc886d23 100644 --- a/vtkm/io/DecodePNG.h +++ b/vtkm/io/DecodePNG.h @@ -11,6 +11,7 @@ #define vtk_m_io_DecodePNG_h #include +#include #include @@ -24,7 +25,7 @@ namespace io /// no matter what color type the original PNG image had. This gives predictable, /// usable data from any random input PNG. /// -VTKM_ALWAYS_EXPORT +VTKM_IO_EXPORT vtkm::UInt32 DecodePNG(std::vector& out_image, unsigned long& image_width, unsigned long& image_height, diff --git a/vtkm/io/EncodePNG.h b/vtkm/io/EncodePNG.h index 4eba8eeb8..8b012973b 100644 --- a/vtkm/io/EncodePNG.h +++ b/vtkm/io/EncodePNG.h @@ -11,6 +11,7 @@ #define vtk_m_io_EncodePNG_h #include +#include #include @@ -19,14 +20,14 @@ namespace vtkm namespace io { -VTKM_ALWAYS_EXPORT +VTKM_IO_EXPORT vtkm::UInt32 EncodePNG(std::vector const& image, unsigned long width, unsigned long height, unsigned char* out_png, std::size_t out_size); -VTKM_ALWAYS_EXPORT +VTKM_IO_EXPORT vtkm::UInt32 SavePNG(std::string const& filename, std::vector const& image, unsigned long width, From 277a0c7f7d673849a58687b29baec45a7b09b15d Mon Sep 17 00:00:00 2001 From: NAThompson Date: Tue, 28 Apr 2020 11:14:51 -0400 Subject: [PATCH 4/5] Deprecate EncodePNG and DecodePNG from vtkm::rendering. --- vtkm/rendering/CMakeLists.txt | 2 ++ vtkm/rendering/DecodePNG.h | 34 ++++++++++++++++++++++++++++ vtkm/rendering/EncodePNG.h | 42 +++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 vtkm/rendering/DecodePNG.h create mode 100644 vtkm/rendering/EncodePNG.h diff --git a/vtkm/rendering/CMakeLists.txt b/vtkm/rendering/CMakeLists.txt index 207e863f7..add1b528f 100644 --- a/vtkm/rendering/CMakeLists.txt +++ b/vtkm/rendering/CMakeLists.txt @@ -50,6 +50,8 @@ set(headers ColorLegendAnnotation.h ConnectivityProxy.h Cylinderizer.h + DecodePNG.h # deprecated + EncodePNG.h # deprecated LineRenderer.h MatrixHelpers.h Scene.h diff --git a/vtkm/rendering/DecodePNG.h b/vtkm/rendering/DecodePNG.h new file mode 100644 index 000000000..66cdbd70a --- /dev/null +++ b/vtkm/rendering/DecodePNG.h @@ -0,0 +1,34 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtk_m_rendering_DecodePNG_h +#define vtk_m_rendering_DecodePNG_h +#include +#include +#include + +namespace vtkm +{ +namespace rendering +{ + +VTKM_RENDERING_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_DEPRECATED("Please use vtkm::io::DecodePNG") +{ + return vtkm::io::DecodePNG(out_image, image_width, image_height, in_png, in_size); +} +} +} // vtkm::io + + +#endif \ No newline at end of file diff --git a/vtkm/rendering/EncodePNG.h b/vtkm/rendering/EncodePNG.h new file mode 100644 index 000000000..4bcb37735 --- /dev/null +++ b/vtkm/rendering/EncodePNG.h @@ -0,0 +1,42 @@ +//============================================================================ +// 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. +//============================================================================ +#ifndef vtk_m_rendering_EncodePNG_h +#define vtk_m_rendering_EncodePNG_h + +#include +#include + +namespace vtkm +{ +namespace rendering +{ + +VTKM_RENDERING_EXPORT +vtkm::UInt32 EncodePNG(std::vector const& image, + unsigned long width, + unsigned long height, + unsigned char* out_png, + std::size_t out_size) VTKM_DEPRECATED("Please use vtkm::io::EncodePNG.") +{ + return io::EncodePNG(image, width, height, out_png, out_size); +} + +VTKM_IO_EXPORT +vtkm::UInt32 SavePNG(std::string const& filename, + std::vector const& image, + unsigned long width, + unsigned long height) VTKM_DEPRECATED("Please use SavePNG from vtkm::io") +{ + return io::SavePNG(filename, image, width, height); +} +} +} // vtkm::rendering + +#endif //vtk_m_rendering_EncodePNG_h From 820b8c8a8a81ab8d2d9d0e2a65e259b5521d955d Mon Sep 17 00:00:00 2001 From: NAThompson Date: Tue, 28 Apr 2020 11:24:09 -0400 Subject: [PATCH 5/5] Fix comment and new line. --- vtkm/rendering/DecodePNG.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vtkm/rendering/DecodePNG.h b/vtkm/rendering/DecodePNG.h index 66cdbd70a..5f35b4b6c 100644 --- a/vtkm/rendering/DecodePNG.h +++ b/vtkm/rendering/DecodePNG.h @@ -28,7 +28,7 @@ vtkm::UInt32 DecodePNG(std::vector& out_image, return vtkm::io::DecodePNG(out_image, image_width, image_height, in_png, in_size); } } -} // vtkm::io +} // vtkm::rendering -#endif \ No newline at end of file +#endif