From 9ebcff93de061030ef5e73bf89befd0db126685a Mon Sep 17 00:00:00 2001 From: castano Date: Wed, 6 Apr 2011 02:14:32 +0000 Subject: [PATCH] More tweaks. --- src/nvcore/CMakeLists.txt | 1 - src/nvcore/Debug.cpp | 2 +- src/nvcore/HashMap.h | 6 ++++++ src/nvimage/ImageIO.cpp | 36 +++++++++++++++++++----------------- src/nvimage/ImageIO.h | 10 ++-------- src/nvtt/OutputOptions.h | 2 +- src/nvtt/tools/compress.cpp | 4 ++-- 7 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/nvcore/CMakeLists.txt b/src/nvcore/CMakeLists.txt index 3070340..fa3fd5c 100644 --- a/src/nvcore/CMakeLists.txt +++ b/src/nvcore/CMakeLists.txt @@ -10,7 +10,6 @@ SET(CORE_SRCS DefsVcWin32.h FileSystem.h FileSystem.cpp ForEach.h - HashMap.h Library.h Library.cpp Memory.h Memory.cpp Ptr.h diff --git a/src/nvcore/Debug.cpp b/src/nvcore/Debug.cpp index bcfaef8..bdde41c 100644 --- a/src/nvcore/Debug.cpp +++ b/src/nvcore/Debug.cpp @@ -1,7 +1,7 @@ // This code is in the public domain -- Ignacio Castaņo #include "Debug.h" -#include "StrLib.h" +#include "StrLib.h" // StringBuilder // Extern #if NV_OS_WIN32 //&& NV_CC_MSVC diff --git a/src/nvcore/HashMap.h b/src/nvcore/HashMap.h index 044f277..4da6f08 100644 --- a/src/nvcore/HashMap.h +++ b/src/nvcore/HashMap.h @@ -6,6 +6,12 @@ /* HashMap based on Thatcher Ulrich container, donated to the Public Domain. + +I'd like to do something to reduce the amount of code generated with this template. The type of +U is largely irrelevant to the generated code, except for calls to constructors and destructors, +but the combination of all T and U pairs, generate a large amounts of code. + +HashMap is not used in NVTT, so it could be removed from the repository. */ diff --git a/src/nvimage/ImageIO.cpp b/src/nvimage/ImageIO.cpp index fa08973..d79e765 100644 --- a/src/nvimage/ImageIO.cpp +++ b/src/nvimage/ImageIO.cpp @@ -64,7 +64,7 @@ namespace nv static Image * loadFreeImage(FREE_IMAGE_FORMAT fif, Stream & s); static FloatImage * loadFloatFreeImage(FREE_IMAGE_FORMAT fif, Stream & s); - static bool saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image * img, const ImageMetaData * tags); + static bool saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image * img, const char * tags); static bool saveFloatFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const FloatImage * img, uint base_component, uint num_components); #else // defined(HAVE_FREEIMAGE) @@ -82,7 +82,7 @@ namespace nv #if defined(HAVE_PNG) static Image * loadPNG(Stream & s); - static bool savePNG(Stream & s, const Image * img, const ImageMetaData * tags); + static bool savePNG(Stream & s, const Image * img, const char * tags); #endif #if defined(HAVE_JPEG) @@ -166,7 +166,7 @@ Image * nv::ImageIO::load(const char * fileName, Stream & s) return NULL; } -bool nv::ImageIO::save(const char * fileName, Stream & s, const Image * img, const ImageMetaData * tags/*=NULL*/) +bool nv::ImageIO::save(const char * fileName, Stream & s, const Image * img, const char * tags/*=NULL*/) { nvDebugCheck(fileName != NULL); nvDebugCheck(s.isSaving()); @@ -194,7 +194,7 @@ bool nv::ImageIO::save(const char * fileName, Stream & s, const Image * img, con return false; } -bool nv::ImageIO::save(const char * fileName, const Image * img, const ImageMetaData * tags/*=NULL*/) +bool nv::ImageIO::save(const char * fileName, const Image * img, const char * tags/*=NULL*/) { nvDebugCheck(fileName != NULL); nvDebugCheck(img != NULL); @@ -598,7 +598,7 @@ FloatImage * nv::ImageIO::loadFloatFreeImage(FREE_IMAGE_FORMAT fif, Stream & s) return floatImage; } -bool nv::ImageIO::saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image * img, const ImageMetaData * tags) +bool nv::ImageIO::saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image * img, const char * tags) { nvCheck(!s.isError()); @@ -1241,7 +1241,7 @@ static void user_write_data(png_structp png_ptr, png_bytep data, png_size_t leng static void user_write_flush(png_structp png_ptr) { } -bool nv::ImageIO::savePNG(Stream & s, const Image * img, const ImageMetaData * tags/*=NULL*/) +bool nv::ImageIO::savePNG(Stream & s, const Image * img, const char * tags/*=NULL*/) { nvCheck(!s.isError()); nvCheck(img != NULL); @@ -1291,19 +1291,21 @@ bool nv::ImageIO::savePNG(Stream & s, const Image * img, const ImageMetaData * t png_set_rows(png_ptr, info_ptr, row_data); png_text * text = NULL; - if (tags != NULL && tags->tagMap.count() > 0) + if (tags != NULL) { - text = new png_text[tags->tagMap.count()]; - memset(text, 0, tags->tagMap.count() * sizeof(png_text)); - int n = 0; - foreach (i, tags->tagMap) - { - text[n].compression = PNG_TEXT_COMPRESSION_NONE; - text[n].key = const_cast (tags->tagMap[i].key.str()); - text[n].text = const_cast (tags->tagMap[i].value.str()); - n++; + int count = 0; + while(tags[2 * count] != NULL) count++; + + text = new png_text[count]; + memset(text, 0, count * sizeof(png_text); + + for (int i = 0; i < count; i++) { + text[i].compression = PNG_TEXT_COMPRESSION_NONE; + text[i].key = tags[2 * i + 0]; + text[i].text = tags[2 * i + 1]; } - png_set_text(png_ptr, info_ptr, text, tags->tagMap.count()); + + png_set_text(png_ptr, info_ptr, text, count); } png_write_png(png_ptr, info_ptr, diff --git a/src/nvimage/ImageIO.h b/src/nvimage/ImageIO.h index 1d8fb36..b554345 100644 --- a/src/nvimage/ImageIO.h +++ b/src/nvimage/ImageIO.h @@ -7,7 +7,6 @@ #include "nvimage.h" #include "nvcore/StrLib.h" -#include "nvcore/HashMap.h" namespace nv @@ -18,19 +17,14 @@ namespace nv namespace ImageIO { - struct ImageMetaData - { - HashMap tagMap; - }; - NVIMAGE_API Image * load(const char * fileName); NVIMAGE_API Image * load(const char * fileName, Stream & s); NVIMAGE_API FloatImage * loadFloat(const char * fileName); NVIMAGE_API FloatImage * loadFloat(const char * fileName, Stream & s); - NVIMAGE_API bool save(const char * fileName, const Image * img, const ImageMetaData * tags=NULL); - NVIMAGE_API bool save(const char * fileName, Stream & s, const Image * img, const ImageMetaData * tags=NULL); + NVIMAGE_API bool save(const char * fileName, const Image * img, const char * tags=NULL); // NULL terminated list. + NVIMAGE_API bool save(const char * fileName, Stream & s, const Image * img, const char * tags=NULL); NVIMAGE_API bool saveFloat(const char * fileName, const FloatImage * fimage, uint baseComponent, uint componentCount); NVIMAGE_API bool saveFloat(const char * fileName, Stream & s, const FloatImage * fimage, uint baseComponent, uint componentCount); diff --git a/src/nvtt/OutputOptions.h b/src/nvtt/OutputOptions.h index 06dd2c2..5645a70 100644 --- a/src/nvtt/OutputOptions.h +++ b/src/nvtt/OutputOptions.h @@ -25,7 +25,7 @@ #ifndef NV_TT_OUTPUTOPTIONS_H #define NV_TT_OUTPUTOPTIONS_H -#include +#include // Path #include #include "nvtt.h" diff --git a/src/nvtt/tools/compress.cpp b/src/nvtt/tools/compress.cpp index abde2a1..4d69185 100644 --- a/src/nvtt/tools/compress.cpp +++ b/src/nvtt/tools/compress.cpp @@ -30,8 +30,8 @@ #include #include -#include -#include +#include // AutoPtr +#include // Path #include #include #include