diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 51b5e9617..106dffd7c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -529,17 +529,17 @@ if( HAVE_MMX ) add_definitions( -DHAVE_MMX=1 ) set( SYSTEM_SOURCES ${SYSTEM_SOURCES} - gamedata/textures/hires/hqnx_asm/hq2x_asm.cpp - gamedata/textures/hires/hqnx_asm/hq3x_asm.cpp - gamedata/textures/hires/hqnx_asm/hq4x_asm.cpp - gamedata/textures/hires/hqnx_asm/hqnx_asm_Image.cpp) + common/textures/hires/hqnx_asm/hq2x_asm.cpp + common/textures/hires/hqnx_asm/hq3x_asm.cpp + common/textures/hires/hqnx_asm/hq4x_asm.cpp + common/textures/hires/hqnx_asm/hqnx_asm_Image.cpp) if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) set_source_files_properties( - gamedata/textures/hires/hqnx_asm/hq2x_asm.cpp - gamedata/textures/hires/hqnx_asm/hq3x_asm.cpp - gamedata/textures/hires/hqnx_asm/hq4x_asm.cpp - gamedata/textures/hires/hqresize.cpp + common/textures/hires/hqnx_asm/hq2x_asm.cpp + common/textures/hires/hqnx_asm/hq3x_asm.cpp + common/textures/hires/hqnx_asm/hq4x_asm.cpp + common/textures/hires/hqresize.cpp PROPERTIES COMPILE_FLAGS "-mmmx" ) endif( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE ) endif( HAVE_MMX ) @@ -593,10 +593,6 @@ file( GLOB HEADER_FILES gamedata/*.h gamedata/resourcefiles/*.h gamedata/fonts/*.h - gamedata/textures/*.h - gamedata/textures/hires/hqnx/*.h - gamedata/textures/hires/hqnx_asm/*.h - gamedata/textures/hires/xbr/*.h gamedata/xlat/*.h intermission/*.h maploader/*.h @@ -616,6 +612,9 @@ file( GLOB HEADER_FILES common/utility/*.h common/engine/*.h common/filesystem/*.h + common/textures/hires/hqnx/*.h + common/textures/hires/hqnx_asm/*.h + common/textures/hires/xbr/*.h common/thirdparty/*.h common/thirdparty/rapidjson/*.h common/thirdparty/math./*h @@ -758,12 +757,12 @@ set( FASTMATH_SOURCES rendering/swrenderer/r_all.cpp rendering/swrenderer/r_swscene.cpp rendering/polyrenderer/poly_all.cpp - gamedata/textures/hires/hqnx/init.cpp - gamedata/textures/hires/hqnx/hq2x.cpp - gamedata/textures/hires/hqnx/hq3x.cpp - gamedata/textures/hires/hqnx/hq4x.cpp - gamedata/textures/hires/xbr/xbrz.cpp - gamedata/textures/hires/xbr/xbrz_old.cpp + common/textures/hires/hqnx/init.cpp + common/textures/hires/hqnx/hq2x.cpp + common/textures/hires/hqnx/hq3x.cpp + common/textures/hires/hqnx/hq4x.cpp + common/textures/hires/xbr/xbrz.cpp + common/textures/hires/xbr/xbrz_old.cpp rendering/gl_load/gl_load.c rendering/hwrenderer/postprocessing/hw_postprocess_cvars.cpp rendering/hwrenderer/postprocessing/hw_postprocessshader.cpp @@ -1004,34 +1003,7 @@ set (PCH_SOURCES menu/resolutionmenu.cpp gamedata/textures/animations.cpp gamedata/textures/anim_switches.cpp - gamedata/textures/bitmap.cpp - gamedata/textures/texture.cpp - gamedata/textures/image.cpp - gamedata/textures/imagetexture.cpp - gamedata/textures/texturemanager.cpp - gamedata/textures/multipatchtexturebuilder.cpp - gamedata/textures/skyboxtexture.cpp gamedata/textures/buildloader.cpp - gamedata/textures/formats/automaptexture.cpp - gamedata/textures/formats/brightmaptexture.cpp - gamedata/textures/formats/buildtexture.cpp - gamedata/textures/formats/canvastexture.cpp - gamedata/textures/formats/ddstexture.cpp - gamedata/textures/formats/flattexture.cpp - gamedata/textures/formats/fontchars.cpp - gamedata/textures/formats/imgztexture.cpp - gamedata/textures/formats/jpegtexture.cpp - gamedata/textures/formats/md5check.cpp - gamedata/textures/formats/multipatchtexture.cpp - gamedata/textures/formats/patchtexture.cpp - gamedata/textures/formats/pcxtexture.cpp - gamedata/textures/formats/pngtexture.cpp - gamedata/textures/formats/rawpagetexture.cpp - gamedata/textures/formats/emptytexture.cpp - gamedata/textures/formats/shadertexture.cpp - gamedata/textures/formats/tgatexture.cpp - gamedata/textures/formats/stbtexture.cpp - gamedata/textures/hires/hqresize.cpp gamedata/fonts/singlelumpfont.cpp gamedata/fonts/singlepicfont.cpp gamedata/fonts/specialfont.cpp @@ -1107,7 +1079,35 @@ set (PCH_SOURCES common/audio/music/i_soundfont.cpp common/audio/music/music_config.cpp common/thirdparty/sfmt/SFMT.cpp + common/textures/hw_ihwtexture.cpp + common/textures/bitmap.cpp common/textures/m_png.cpp + common/textures/texture.cpp + common/textures/image.cpp + common/textures/imagetexture.cpp + common/textures/texturemanager.cpp + common/textures/multipatchtexturebuilder.cpp + common/textures/skyboxtexture.cpp + common/textures/formats/automaptexture.cpp + common/textures/formats/brightmaptexture.cpp + common/textures/formats/buildtexture.cpp + common/textures/formats/canvastexture.cpp + common/textures/formats/ddstexture.cpp + common/textures/formats/flattexture.cpp + common/textures/formats/fontchars.cpp + common/textures/formats/imgztexture.cpp + common/textures/formats/jpegtexture.cpp + common/textures/formats/md5check.cpp + common/textures/formats/multipatchtexture.cpp + common/textures/formats/patchtexture.cpp + common/textures/formats/pcxtexture.cpp + common/textures/formats/pngtexture.cpp + common/textures/formats/rawpagetexture.cpp + common/textures/formats/emptytexture.cpp + common/textures/formats/shadertexture.cpp + common/textures/formats/tgatexture.cpp + common/textures/formats/stbtexture.cpp + common/textures/hires/hqresize.cpp common/console/c_commandline.cpp common/console/c_buttons.cpp common/console/c_bind.cpp @@ -1233,6 +1233,8 @@ include_directories( . common/audio/sound common/audio/music common/thirdparty + common/textures/formats + common/textures/hires common/filesystem common/utility common/console @@ -1361,12 +1363,6 @@ install(TARGETS zdoom source_group("Audio Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/sound/.+") source_group("Game Data" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/.+") source_group("Game Data\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/fonts/.+") -source_group("Game Data\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/.+") -source_group("Game Data\\Textures\\Hires" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/hires/.+") -source_group("Game Data\\Textures\\Hires\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/hires/hqnx/.+") -source_group("Game Data\\Textures\\Hires\\HQ Resize MMX version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/hires/hqnx_asm/.+") -source_group("Game Data\\Textures\\Hires\\XBRZ" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/hires/xbr/.+") -source_group("Game Data\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/gamedata/textures/formats/.+") source_group("Intermission" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/intermission/.+") source_group("Map Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/maploader/.+") source_group("Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/menu/.+") @@ -1440,6 +1436,11 @@ source_group("Common\\Console" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/ source_group("Common\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/utility/.+") source_group("Common\\Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/engine/.+") source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+") +source_group("Common\\Textures\\Hires" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/.+") +source_group("Common\\Textures\\Hires\\HQ Resize" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/hqnx/.+") +source_group("Common\\Textures\\Hires\\HQ Resize MMX version" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/hqnx_asm/.+") +source_group("Common\\Textures\\Hires\\XBRZ" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/hires/xbr/.+") +source_group("Common\\Textures\\Formats" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/formats/.+") source_group("Common\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/.+") source_group("Common\\Third Party\\Math" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/math/.+") source_group("Common\\Third Party\\RapidJSON" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/thirdparty/rapidjson/.+") diff --git a/src/gamedata/textures/formats/automaptexture.cpp b/src/common/textures/formats/automaptexture.cpp similarity index 100% rename from src/gamedata/textures/formats/automaptexture.cpp rename to src/common/textures/formats/automaptexture.cpp diff --git a/src/gamedata/textures/formats/brightmaptexture.cpp b/src/common/textures/formats/brightmaptexture.cpp similarity index 100% rename from src/gamedata/textures/formats/brightmaptexture.cpp rename to src/common/textures/formats/brightmaptexture.cpp diff --git a/src/gamedata/textures/formats/buildtexture.cpp b/src/common/textures/formats/buildtexture.cpp similarity index 100% rename from src/gamedata/textures/formats/buildtexture.cpp rename to src/common/textures/formats/buildtexture.cpp diff --git a/src/gamedata/textures/formats/canvastexture.cpp b/src/common/textures/formats/canvastexture.cpp similarity index 100% rename from src/gamedata/textures/formats/canvastexture.cpp rename to src/common/textures/formats/canvastexture.cpp diff --git a/src/gamedata/textures/formats/ddstexture.cpp b/src/common/textures/formats/ddstexture.cpp similarity index 100% rename from src/gamedata/textures/formats/ddstexture.cpp rename to src/common/textures/formats/ddstexture.cpp diff --git a/src/gamedata/textures/formats/emptytexture.cpp b/src/common/textures/formats/emptytexture.cpp similarity index 100% rename from src/gamedata/textures/formats/emptytexture.cpp rename to src/common/textures/formats/emptytexture.cpp diff --git a/src/gamedata/textures/formats/flattexture.cpp b/src/common/textures/formats/flattexture.cpp similarity index 100% rename from src/gamedata/textures/formats/flattexture.cpp rename to src/common/textures/formats/flattexture.cpp diff --git a/src/gamedata/textures/formats/fontchars.cpp b/src/common/textures/formats/fontchars.cpp similarity index 100% rename from src/gamedata/textures/formats/fontchars.cpp rename to src/common/textures/formats/fontchars.cpp diff --git a/src/gamedata/textures/formats/fontchars.h b/src/common/textures/formats/fontchars.h similarity index 100% rename from src/gamedata/textures/formats/fontchars.h rename to src/common/textures/formats/fontchars.h diff --git a/src/gamedata/textures/formats/imgztexture.cpp b/src/common/textures/formats/imgztexture.cpp similarity index 100% rename from src/gamedata/textures/formats/imgztexture.cpp rename to src/common/textures/formats/imgztexture.cpp diff --git a/src/gamedata/textures/formats/jpegtexture.cpp b/src/common/textures/formats/jpegtexture.cpp similarity index 100% rename from src/gamedata/textures/formats/jpegtexture.cpp rename to src/common/textures/formats/jpegtexture.cpp diff --git a/src/gamedata/textures/formats/md5check.cpp b/src/common/textures/formats/md5check.cpp similarity index 100% rename from src/gamedata/textures/formats/md5check.cpp rename to src/common/textures/formats/md5check.cpp diff --git a/src/gamedata/textures/formats/multipatchtexture.cpp b/src/common/textures/formats/multipatchtexture.cpp similarity index 100% rename from src/gamedata/textures/formats/multipatchtexture.cpp rename to src/common/textures/formats/multipatchtexture.cpp diff --git a/src/gamedata/textures/formats/multipatchtexture.h b/src/common/textures/formats/multipatchtexture.h similarity index 100% rename from src/gamedata/textures/formats/multipatchtexture.h rename to src/common/textures/formats/multipatchtexture.h diff --git a/src/gamedata/textures/formats/patchtexture.cpp b/src/common/textures/formats/patchtexture.cpp similarity index 100% rename from src/gamedata/textures/formats/patchtexture.cpp rename to src/common/textures/formats/patchtexture.cpp diff --git a/src/gamedata/textures/formats/pcxtexture.cpp b/src/common/textures/formats/pcxtexture.cpp similarity index 100% rename from src/gamedata/textures/formats/pcxtexture.cpp rename to src/common/textures/formats/pcxtexture.cpp diff --git a/src/gamedata/textures/formats/pngtexture.cpp b/src/common/textures/formats/pngtexture.cpp similarity index 100% rename from src/gamedata/textures/formats/pngtexture.cpp rename to src/common/textures/formats/pngtexture.cpp diff --git a/src/gamedata/textures/formats/rawpagetexture.cpp b/src/common/textures/formats/rawpagetexture.cpp similarity index 100% rename from src/gamedata/textures/formats/rawpagetexture.cpp rename to src/common/textures/formats/rawpagetexture.cpp diff --git a/src/gamedata/textures/formats/shadertexture.cpp b/src/common/textures/formats/shadertexture.cpp similarity index 100% rename from src/gamedata/textures/formats/shadertexture.cpp rename to src/common/textures/formats/shadertexture.cpp diff --git a/src/gamedata/textures/formats/stb_image.h b/src/common/textures/formats/stb_image.h similarity index 100% rename from src/gamedata/textures/formats/stb_image.h rename to src/common/textures/formats/stb_image.h diff --git a/src/gamedata/textures/formats/stbtexture.cpp b/src/common/textures/formats/stbtexture.cpp similarity index 100% rename from src/gamedata/textures/formats/stbtexture.cpp rename to src/common/textures/formats/stbtexture.cpp diff --git a/src/gamedata/textures/formats/tgatexture.cpp b/src/common/textures/formats/tgatexture.cpp similarity index 100% rename from src/gamedata/textures/formats/tgatexture.cpp rename to src/common/textures/formats/tgatexture.cpp diff --git a/src/gamedata/textures/hires/hqnx/common.h b/src/common/textures/hires/hqnx/common.h similarity index 100% rename from src/gamedata/textures/hires/hqnx/common.h rename to src/common/textures/hires/hqnx/common.h diff --git a/src/gamedata/textures/hires/hqnx/hq2x.cpp b/src/common/textures/hires/hqnx/hq2x.cpp similarity index 100% rename from src/gamedata/textures/hires/hqnx/hq2x.cpp rename to src/common/textures/hires/hqnx/hq2x.cpp diff --git a/src/gamedata/textures/hires/hqnx/hq3x.cpp b/src/common/textures/hires/hqnx/hq3x.cpp similarity index 100% rename from src/gamedata/textures/hires/hqnx/hq3x.cpp rename to src/common/textures/hires/hqnx/hq3x.cpp diff --git a/src/gamedata/textures/hires/hqnx/hq4x.cpp b/src/common/textures/hires/hqnx/hq4x.cpp similarity index 100% rename from src/gamedata/textures/hires/hqnx/hq4x.cpp rename to src/common/textures/hires/hqnx/hq4x.cpp diff --git a/src/gamedata/textures/hires/hqnx/hqx.h b/src/common/textures/hires/hqnx/hqx.h similarity index 100% rename from src/gamedata/textures/hires/hqnx/hqx.h rename to src/common/textures/hires/hqnx/hqx.h diff --git a/src/gamedata/textures/hires/hqnx/init.cpp b/src/common/textures/hires/hqnx/init.cpp similarity index 100% rename from src/gamedata/textures/hires/hqnx/init.cpp rename to src/common/textures/hires/hqnx/init.cpp diff --git a/src/gamedata/textures/hires/hqnx_asm/hq2x_asm.cpp b/src/common/textures/hires/hqnx_asm/hq2x_asm.cpp similarity index 100% rename from src/gamedata/textures/hires/hqnx_asm/hq2x_asm.cpp rename to src/common/textures/hires/hqnx_asm/hq2x_asm.cpp diff --git a/src/gamedata/textures/hires/hqnx_asm/hq3x_asm.cpp b/src/common/textures/hires/hqnx_asm/hq3x_asm.cpp similarity index 100% rename from src/gamedata/textures/hires/hqnx_asm/hq3x_asm.cpp rename to src/common/textures/hires/hqnx_asm/hq3x_asm.cpp diff --git a/src/gamedata/textures/hires/hqnx_asm/hq4x_asm.cpp b/src/common/textures/hires/hqnx_asm/hq4x_asm.cpp similarity index 100% rename from src/gamedata/textures/hires/hqnx_asm/hq4x_asm.cpp rename to src/common/textures/hires/hqnx_asm/hq4x_asm.cpp diff --git a/src/gamedata/textures/hires/hqnx_asm/hqnx_asm.h b/src/common/textures/hires/hqnx_asm/hqnx_asm.h similarity index 100% rename from src/gamedata/textures/hires/hqnx_asm/hqnx_asm.h rename to src/common/textures/hires/hqnx_asm/hqnx_asm.h diff --git a/src/gamedata/textures/hires/hqnx_asm/hqnx_asm_Image.cpp b/src/common/textures/hires/hqnx_asm/hqnx_asm_Image.cpp similarity index 100% rename from src/gamedata/textures/hires/hqnx_asm/hqnx_asm_Image.cpp rename to src/common/textures/hires/hqnx_asm/hqnx_asm_Image.cpp diff --git a/src/gamedata/textures/hires/hqnx_asm/hqnx_asm_Image.h b/src/common/textures/hires/hqnx_asm/hqnx_asm_Image.h similarity index 100% rename from src/gamedata/textures/hires/hqnx_asm/hqnx_asm_Image.h rename to src/common/textures/hires/hqnx_asm/hqnx_asm_Image.h diff --git a/src/gamedata/textures/hires/hqresize.cpp b/src/common/textures/hires/hqresize.cpp similarity index 100% rename from src/gamedata/textures/hires/hqresize.cpp rename to src/common/textures/hires/hqresize.cpp diff --git a/src/gamedata/textures/hires/xbr/xbrz.cpp b/src/common/textures/hires/xbr/xbrz.cpp similarity index 100% rename from src/gamedata/textures/hires/xbr/xbrz.cpp rename to src/common/textures/hires/xbr/xbrz.cpp diff --git a/src/gamedata/textures/hires/xbr/xbrz.h b/src/common/textures/hires/xbr/xbrz.h similarity index 100% rename from src/gamedata/textures/hires/xbr/xbrz.h rename to src/common/textures/hires/xbr/xbrz.h diff --git a/src/gamedata/textures/hires/xbr/xbrz_config.h b/src/common/textures/hires/xbr/xbrz_config.h similarity index 100% rename from src/gamedata/textures/hires/xbr/xbrz_config.h rename to src/common/textures/hires/xbr/xbrz_config.h diff --git a/src/gamedata/textures/hires/xbr/xbrz_config_old.h b/src/common/textures/hires/xbr/xbrz_config_old.h similarity index 100% rename from src/gamedata/textures/hires/xbr/xbrz_config_old.h rename to src/common/textures/hires/xbr/xbrz_config_old.h diff --git a/src/gamedata/textures/hires/xbr/xbrz_old.cpp b/src/common/textures/hires/xbr/xbrz_old.cpp similarity index 100% rename from src/gamedata/textures/hires/xbr/xbrz_old.cpp rename to src/common/textures/hires/xbr/xbrz_old.cpp diff --git a/src/gamedata/textures/hires/xbr/xbrz_old.h b/src/common/textures/hires/xbr/xbrz_old.h similarity index 100% rename from src/gamedata/textures/hires/xbr/xbrz_old.h rename to src/common/textures/hires/xbr/xbrz_old.h diff --git a/src/gamedata/textures/hires/xbr/xbrz_tools.h b/src/common/textures/hires/xbr/xbrz_tools.h similarity index 100% rename from src/gamedata/textures/hires/xbr/xbrz_tools.h rename to src/common/textures/hires/xbr/xbrz_tools.h diff --git a/src/common/textures/hw_ihwtexture.cpp b/src/common/textures/hw_ihwtexture.cpp new file mode 100644 index 000000000..aebf387d4 --- /dev/null +++ b/src/common/textures/hw_ihwtexture.cpp @@ -0,0 +1,137 @@ +/* +** ihwtexture.cpp +** Interface for hardware textures +** +**--------------------------------------------------------------------------- +** Copyright 2006-2020 Christoph Oelckers +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#include "hw_ihwtexture.h" +#include "templates.h" +#include "tarray.h" +#include "xs_Float.h" + +//=========================================================================== +// +// Quick'n dirty image rescaling. +// +// This will only be used when the source texture is larger than +// what the hardware can manage (extremely rare in Doom) +// +// Code taken from wxWidgets +// +//=========================================================================== + +struct BoxPrecalc +{ + int boxStart; + int boxEnd; +}; + +static void ResampleBoxPrecalc(TArray& boxes, int oldDim) +{ + int newDim = boxes.Size(); + const double scale_factor_1 = double(oldDim) / newDim; + const int scale_factor_2 = (int)(scale_factor_1 / 2); + + for (int dst = 0; dst < newDim; ++dst) + { + // Source pixel in the Y direction + const int src_p = int(dst * scale_factor_1); + + BoxPrecalc& precalc = boxes[dst]; + precalc.boxStart = clamp(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1); + precalc.boxEnd = clamp(MAX(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1); + } +} + +void IHardwareTexture::Resize(int swidth, int sheight, int width, int height, unsigned char *src_data, unsigned char *dst_data) +{ + + // This function implements a simple pre-blur/box averaging method for + // downsampling that gives reasonably smooth results To scale the image + // down we will need to gather a grid of pixels of the size of the scale + // factor in each direction and then do an averaging of the pixels. + + TArray vPrecalcs(height, true); + TArray hPrecalcs(width, true); + + ResampleBoxPrecalc(vPrecalcs, sheight); + ResampleBoxPrecalc(hPrecalcs, swidth); + + int averaged_pixels, averaged_alpha, src_pixel_index; + double sum_r, sum_g, sum_b, sum_a; + + for (int y = 0; y < height; y++) // Destination image - Y direction + { + // Source pixel in the Y direction + const BoxPrecalc& vPrecalc = vPrecalcs[y]; + + for (int x = 0; x < width; x++) // Destination image - X direction + { + // Source pixel in the X direction + const BoxPrecalc& hPrecalc = hPrecalcs[x]; + + // Box of pixels to average + averaged_pixels = 0; + averaged_alpha = 0; + sum_r = sum_g = sum_b = sum_a = 0.0; + + for (int j = vPrecalc.boxStart; j <= vPrecalc.boxEnd; ++j) + { + for (int i = hPrecalc.boxStart; i <= hPrecalc.boxEnd; ++i) + { + // Calculate the actual index in our source pixels + src_pixel_index = j * swidth + i; + + int a = src_data[src_pixel_index * 4 + 3]; + if (a > 0) // do not use color from fully transparent pixels + { + sum_r += src_data[src_pixel_index * 4 + 0]; + sum_g += src_data[src_pixel_index * 4 + 1]; + sum_b += src_data[src_pixel_index * 4 + 2]; + sum_a += a; + averaged_pixels++; + } + averaged_alpha++; + + } + } + + // Calculate the average from the sum and number of averaged pixels + dst_data[0] = (unsigned char)xs_CRoundToInt(sum_r / averaged_pixels); + dst_data[1] = (unsigned char)xs_CRoundToInt(sum_g / averaged_pixels); + dst_data[2] = (unsigned char)xs_CRoundToInt(sum_b / averaged_pixels); + dst_data[3] = (unsigned char)xs_CRoundToInt(sum_a / averaged_alpha); + dst_data += 4; + } + } +} + diff --git a/src/rendering/hwrenderer/textures/hw_ihwtexture.h b/src/common/textures/hw_ihwtexture.h similarity index 100% rename from src/rendering/hwrenderer/textures/hw_ihwtexture.h rename to src/common/textures/hw_ihwtexture.h diff --git a/src/rendering/hwrenderer/textures/hw_texcontainer.h b/src/common/textures/hw_texcontainer.h similarity index 98% rename from src/rendering/hwrenderer/textures/hw_texcontainer.h rename to src/common/textures/hw_texcontainer.h index ad57cfe60..247279fb0 100644 --- a/src/rendering/hwrenderer/textures/hw_texcontainer.h +++ b/src/common/textures/hw_texcontainer.h @@ -1,7 +1,7 @@ #pragma once #include "tarray.h" -#include "hwrenderer/textures/hw_ihwtexture.h" +#include "hw_ihwtexture.h" #include "palettecontainer.h" struct FTextureBuffer; diff --git a/src/gamedata/textures/image.cpp b/src/common/textures/image.cpp similarity index 100% rename from src/gamedata/textures/image.cpp rename to src/common/textures/image.cpp diff --git a/src/gamedata/textures/image.h b/src/common/textures/image.h similarity index 100% rename from src/gamedata/textures/image.h rename to src/common/textures/image.h diff --git a/src/gamedata/textures/imagehelpers.h b/src/common/textures/imagehelpers.h similarity index 100% rename from src/gamedata/textures/imagehelpers.h rename to src/common/textures/imagehelpers.h diff --git a/src/gamedata/textures/imagetexture.cpp b/src/common/textures/imagetexture.cpp similarity index 100% rename from src/gamedata/textures/imagetexture.cpp rename to src/common/textures/imagetexture.cpp diff --git a/src/gamedata/textures/multipatchtexturebuilder.cpp b/src/common/textures/multipatchtexturebuilder.cpp similarity index 100% rename from src/gamedata/textures/multipatchtexturebuilder.cpp rename to src/common/textures/multipatchtexturebuilder.cpp diff --git a/src/gamedata/textures/skyboxtexture.cpp b/src/common/textures/skyboxtexture.cpp similarity index 100% rename from src/gamedata/textures/skyboxtexture.cpp rename to src/common/textures/skyboxtexture.cpp diff --git a/src/gamedata/textures/skyboxtexture.h b/src/common/textures/skyboxtexture.h similarity index 100% rename from src/gamedata/textures/skyboxtexture.h rename to src/common/textures/skyboxtexture.h diff --git a/src/gamedata/textures/texmanip.h b/src/common/textures/texmanip.h similarity index 100% rename from src/gamedata/textures/texmanip.h rename to src/common/textures/texmanip.h diff --git a/src/gamedata/textures/texture.cpp b/src/common/textures/texture.cpp similarity index 100% rename from src/gamedata/textures/texture.cpp rename to src/common/textures/texture.cpp diff --git a/src/gamedata/textures/textureid.h b/src/common/textures/textureid.h similarity index 100% rename from src/gamedata/textures/textureid.h rename to src/common/textures/textureid.h diff --git a/src/gamedata/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp similarity index 100% rename from src/gamedata/textures/texturemanager.cpp rename to src/common/textures/texturemanager.cpp diff --git a/src/gamedata/textures/texturemanager.h b/src/common/textures/texturemanager.h similarity index 100% rename from src/gamedata/textures/texturemanager.h rename to src/common/textures/texturemanager.h diff --git a/src/gamedata/textures/textures.h b/src/common/textures/textures.h similarity index 99% rename from src/gamedata/textures/textures.h rename to src/common/textures/textures.h index fee24dc1a..12d6f953c 100644 --- a/src/gamedata/textures/textures.h +++ b/src/common/textures/textures.h @@ -41,7 +41,7 @@ #include "renderstyle.h" #include "textureid.h" #include -#include "hwrenderer/textures/hw_texcontainer.h" +#include "hw_texcontainer.h" // 15 because 0th texture is our texture #define MAX_CUSTOM_HW_SHADER_TEXTURES 15 diff --git a/src/gamedata/fonts/font.cpp b/src/gamedata/fonts/font.cpp index e437bae15..d91cbb743 100644 --- a/src/gamedata/fonts/font.cpp +++ b/src/gamedata/fonts/font.cpp @@ -56,8 +56,8 @@ #include "image.h" #include "utf8.h" #include "myiswalpha.h" -#include "textures/formats/fontchars.h" -#include "textures/formats/multipatchtexture.h" +#include "fontchars.h" +#include "multipatchtexture.h" #include "texturemanager.h" #include "r_translate.h" diff --git a/src/gamedata/fonts/singlelumpfont.cpp b/src/gamedata/fonts/singlelumpfont.cpp index 393f9e783..70ebb08b5 100644 --- a/src/gamedata/fonts/singlelumpfont.cpp +++ b/src/gamedata/fonts/singlelumpfont.cpp @@ -39,7 +39,7 @@ #include "v_font.h" #include "filesystem.h" #include "utf8.h" -#include "textures/formats/fontchars.h" +#include "fontchars.h" #include "texturemanager.h" #include "fontinternals.h" diff --git a/src/gamedata/fonts/specialfont.cpp b/src/gamedata/fonts/specialfont.cpp index f2ce0ece8..519ccf8dd 100644 --- a/src/gamedata/fonts/specialfont.cpp +++ b/src/gamedata/fonts/specialfont.cpp @@ -36,7 +36,7 @@ #include "v_font.h" #include "textures.h" #include "image.h" -#include "textures/formats/fontchars.h" +#include "fontchars.h" #include "texturemanager.h" #include "fontinternals.h" diff --git a/src/gamedata/fonts/v_font.cpp b/src/gamedata/fonts/v_font.cpp index d00a7b0f9..a0639ed10 100644 --- a/src/gamedata/fonts/v_font.cpp +++ b/src/gamedata/fonts/v_font.cpp @@ -54,7 +54,7 @@ #include "vm.h" #include "image.h" #include "utf8.h" -#include "textures/formats/fontchars.h" +#include "fontchars.h" #include "texturemanager.h" #include "fontinternals.h" diff --git a/src/gamedata/p_terrain.h b/src/gamedata/p_terrain.h index f041ef7a6..a225b8a73 100644 --- a/src/gamedata/p_terrain.h +++ b/src/gamedata/p_terrain.h @@ -35,7 +35,7 @@ #define __P_TERRAIN_H__ #include "s_sound.h" -#include "textures/textures.h" +#include "textures.h" class PClass; diff --git a/src/gamedata/textures/anim_switches.cpp b/src/gamedata/textures/anim_switches.cpp index f6acd67b0..7767539ab 100644 --- a/src/gamedata/textures/anim_switches.cpp +++ b/src/gamedata/textures/anim_switches.cpp @@ -33,7 +33,7 @@ */ #include "templates.h" -#include "textures/textures.h" +#include "textures.h" #include "s_sound.h" #include "r_state.h" #include "filesystem.h" diff --git a/src/gamedata/textures/buildloader.cpp b/src/gamedata/textures/buildloader.cpp index e1516ebe3..9faaab186 100644 --- a/src/gamedata/textures/buildloader.cpp +++ b/src/gamedata/textures/buildloader.cpp @@ -40,7 +40,7 @@ #include "cmdlib.h" #include "colormatcher.h" #include "bitmap.h" -#include "textures/textures.h" +#include "textures.h" #include "resourcefile.h" #include "image.h" #include "animations.h" diff --git a/src/intermission/intermission.h b/src/intermission/intermission.h index 15cc604b7..69e753b32 100644 --- a/src/intermission/intermission.h +++ b/src/intermission/intermission.h @@ -4,7 +4,7 @@ #include "doomdef.h" #include "dobject.h" #include "m_fixed.h" -#include "textures/textures.h" +#include "textures.h" #include "s_sound.h" #include "v_font.h" #include "g_game.h" diff --git a/src/menu/menu.h b/src/menu/menu.h index d93dabd8c..98fd2addb 100644 --- a/src/menu/menu.h +++ b/src/menu/menu.h @@ -10,7 +10,7 @@ #include "c_cvars.h" #include "v_font.h" #include "gi.h" -#include "textures/textures.h" +#include "textures.h" EXTERN_CVAR(Float, snd_menuvolume) EXTERN_CVAR(Int, m_use_mouse); diff --git a/src/p_conversation.h b/src/p_conversation.h index 4b0497a51..84f0fb407 100644 --- a/src/p_conversation.h +++ b/src/p_conversation.h @@ -4,7 +4,7 @@ #include #include "s_sound.h" -#include "textures/textures.h" +#include "textures.h" struct FStrifeDialogueReply; class FTexture; diff --git a/src/playsim/actor.h b/src/playsim/actor.h index f992dd777..91a582043 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -40,7 +40,7 @@ #include "info.h" #include "doomdef.h" -#include "textures/textures.h" +#include "textures.h" #include "renderstyle.h" #include "s_sound.h" #include "memarena.h" diff --git a/src/playsim/p_trace.h b/src/playsim/p_trace.h index 5e733b4c4..ef5318678 100644 --- a/src/playsim/p_trace.h +++ b/src/playsim/p_trace.h @@ -37,7 +37,7 @@ #include #include "actor.h" #include "cmdlib.h" -#include "textures/textures.h" +#include "textures.h" struct sector_t; struct line_t; diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index e0f6deff0..2aeac8f42 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -44,7 +44,7 @@ #include "g_levellocals.h" #include "a_dynlight.h" #include "v_video.h" -#include "textures/skyboxtexture.h" +#include "skyboxtexture.h" #include "hwrenderer/postprocessing/hw_postprocessshader.h" #include "hwrenderer/textures/hw_material.h" #include "texturemanager.h" diff --git a/src/rendering/2d/v_drawtext.cpp b/src/rendering/2d/v_drawtext.cpp index 8857e9d7f..be5d9230d 100644 --- a/src/rendering/2d/v_drawtext.cpp +++ b/src/rendering/2d/v_drawtext.cpp @@ -44,7 +44,7 @@ #include "v_video.h" #include "filesystem.h" #include "image.h" -#include "textures/formats/multipatchtexture.h" +#include "multipatchtexture.h" #include "gstrings.h" #include "vm.h" diff --git a/src/rendering/gl/textures/gl_hwtexture.h b/src/rendering/gl/textures/gl_hwtexture.h index faaa4febb..c32dd25f7 100644 --- a/src/rendering/gl/textures/gl_hwtexture.h +++ b/src/rendering/gl/textures/gl_hwtexture.h @@ -11,7 +11,7 @@ #include "tarray.h" #include "gl_load/gl_interface.h" -#include "hwrenderer/textures/hw_ihwtexture.h" +#include "hw_ihwtexture.h" class FCanvasTexture; class AActor; diff --git a/src/rendering/hwrenderer/scene/hw_drawstructs.h b/src/rendering/hwrenderer/scene/hw_drawstructs.h index 72ab1d04f..036811fa0 100644 --- a/src/rendering/hwrenderer/scene/hw_drawstructs.h +++ b/src/rendering/hwrenderer/scene/hw_drawstructs.h @@ -6,7 +6,7 @@ //========================================================================== #include "r_defs.h" #include "renderstyle.h" -#include "textures/textures.h" +#include "textures.h" #include "r_data/colormaps.h" #ifdef _MSC_VER diff --git a/src/rendering/hwrenderer/scene/hw_skydome.cpp b/src/rendering/hwrenderer/scene/hw_skydome.cpp index 4c0e62281..ebe6491cc 100644 --- a/src/rendering/hwrenderer/scene/hw_skydome.cpp +++ b/src/rendering/hwrenderer/scene/hw_skydome.cpp @@ -62,7 +62,7 @@ #include "r_sky.h" #include "cmdlib.h" -#include "textures/skyboxtexture.h" +#include "skyboxtexture.h" #include "hwrenderer/textures/hw_material.h" #include "hw_skydome.h" #include "hw_renderstate.h" diff --git a/src/rendering/hwrenderer/scene/hw_skyportal.cpp b/src/rendering/hwrenderer/scene/hw_skyportal.cpp index 31f13825c..98811286e 100644 --- a/src/rendering/hwrenderer/scene/hw_skyportal.cpp +++ b/src/rendering/hwrenderer/scene/hw_skyportal.cpp @@ -29,7 +29,7 @@ #include "hwrenderer/scene/hw_skydome.h" #include "hwrenderer/scene/hw_portal.h" #include "hwrenderer/scene/hw_renderstate.h" -#include "textures/skyboxtexture.h" +#include "skyboxtexture.h" diff --git a/src/rendering/hwrenderer/textures/hw_material.cpp b/src/rendering/hwrenderer/textures/hw_material.cpp index 5c2dc1269..28f79fe47 100644 --- a/src/rendering/hwrenderer/textures/hw_material.cpp +++ b/src/rendering/hwrenderer/textures/hw_material.cpp @@ -31,103 +31,6 @@ #include "hw_material.h" #include "texturemanager.h" -//=========================================================================== -// -// Quick'n dirty image rescaling. -// -// This will only be used when the source texture is larger than -// what the hardware can manage (extremely rare in Doom) -// -// Code taken from wxWidgets -// -//=========================================================================== - -struct BoxPrecalc -{ - int boxStart; - int boxEnd; -}; - -static void ResampleBoxPrecalc(TArray& boxes, int oldDim) -{ - int newDim = boxes.Size(); - const double scale_factor_1 = double(oldDim) / newDim; - const int scale_factor_2 = (int)(scale_factor_1 / 2); - - for (int dst = 0; dst < newDim; ++dst) - { - // Source pixel in the Y direction - const int src_p = int(dst * scale_factor_1); - - BoxPrecalc& precalc = boxes[dst]; - precalc.boxStart = clamp(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1); - precalc.boxEnd = clamp(MAX(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1); - } -} - -void IHardwareTexture::Resize(int swidth, int sheight, int width, int height, unsigned char *src_data, unsigned char *dst_data) -{ - - // This function implements a simple pre-blur/box averaging method for - // downsampling that gives reasonably smooth results To scale the image - // down we will need to gather a grid of pixels of the size of the scale - // factor in each direction and then do an averaging of the pixels. - - TArray vPrecalcs(height, true); - TArray hPrecalcs(width, true); - - ResampleBoxPrecalc(vPrecalcs, sheight); - ResampleBoxPrecalc(hPrecalcs, swidth); - - int averaged_pixels, averaged_alpha, src_pixel_index; - double sum_r, sum_g, sum_b, sum_a; - - for (int y = 0; y < height; y++) // Destination image - Y direction - { - // Source pixel in the Y direction - const BoxPrecalc& vPrecalc = vPrecalcs[y]; - - for (int x = 0; x < width; x++) // Destination image - X direction - { - // Source pixel in the X direction - const BoxPrecalc& hPrecalc = hPrecalcs[x]; - - // Box of pixels to average - averaged_pixels = 0; - averaged_alpha = 0; - sum_r = sum_g = sum_b = sum_a = 0.0; - - for (int j = vPrecalc.boxStart; j <= vPrecalc.boxEnd; ++j) - { - for (int i = hPrecalc.boxStart; i <= hPrecalc.boxEnd; ++i) - { - // Calculate the actual index in our source pixels - src_pixel_index = j * swidth + i; - - int a = src_data[src_pixel_index * 4 + 3]; - if (a > 0) // do not use color from fully transparent pixels - { - sum_r += src_data[src_pixel_index * 4 + 0]; - sum_g += src_data[src_pixel_index * 4 + 1]; - sum_b += src_data[src_pixel_index * 4 + 2]; - sum_a += a; - averaged_pixels++; - } - averaged_alpha++; - - } - } - - // Calculate the average from the sum and number of averaged pixels - dst_data[0] = (unsigned char)xs_CRoundToInt(sum_r / averaged_pixels); - dst_data[1] = (unsigned char)xs_CRoundToInt(sum_g / averaged_pixels); - dst_data[2] = (unsigned char)xs_CRoundToInt(sum_b / averaged_pixels); - dst_data[3] = (unsigned char)xs_CRoundToInt(sum_a / averaged_alpha); - dst_data += 4; - } - } -} - //=========================================================================== // // Constructor diff --git a/src/rendering/hwrenderer/textures/hw_material.h b/src/rendering/hwrenderer/textures/hw_material.h index 7debe882f..9c19202e1 100644 --- a/src/rendering/hwrenderer/textures/hw_material.h +++ b/src/rendering/hwrenderer/textures/hw_material.h @@ -3,7 +3,7 @@ #define __GL_MATERIAL_H #include "m_fixed.h" -#include "textures/textures.h" +#include "textures.h" #include "r_defs.h" diff --git a/src/rendering/hwrenderer/textures/hw_precache.cpp b/src/rendering/hwrenderer/textures/hw_precache.cpp index c4a1fe1d3..d8049dc03 100644 --- a/src/rendering/hwrenderer/textures/hw_precache.cpp +++ b/src/rendering/hwrenderer/textures/hw_precache.cpp @@ -31,7 +31,7 @@ #include "r_state.h" #include "actor.h" #include "r_data/models/models.h" -#include "textures/skyboxtexture.h" +#include "skyboxtexture.h" #include "hwrenderer/textures/hw_material.h" #include "image.h" #include "v_video.h" diff --git a/src/rendering/polyrenderer/backend/poly_hwtexture.h b/src/rendering/polyrenderer/backend/poly_hwtexture.h index 2aeba3b55..3d7565b58 100644 --- a/src/rendering/polyrenderer/backend/poly_hwtexture.h +++ b/src/rendering/polyrenderer/backend/poly_hwtexture.h @@ -8,7 +8,7 @@ #define DIRECT_PALETTE -2 #include "tarray.h" -#include "hwrenderer/textures/hw_ihwtexture.h" +#include "hw_ihwtexture.h" #include "volk/volk.h" struct FMaterialState; diff --git a/src/rendering/r_sky.h b/src/rendering/r_sky.h index 9d80740c9..f2aa868fc 100644 --- a/src/rendering/r_sky.h +++ b/src/rendering/r_sky.h @@ -28,7 +28,7 @@ #ifndef __R_SKY_H__ #define __R_SKY_H__ -#include "textures/textures.h" +#include "textures.h" struct FLevelLocals; diff --git a/src/rendering/swrenderer/r_swrenderer.cpp b/src/rendering/swrenderer/r_swrenderer.cpp index aa56f5947..c099b4b16 100644 --- a/src/rendering/swrenderer/r_swrenderer.cpp +++ b/src/rendering/swrenderer/r_swrenderer.cpp @@ -45,7 +45,7 @@ #include "scene/r_opaque_pass.h" #include "scene/r_3dfloors.h" #include "scene/r_portal.h" -#include "textures/textures.h" +#include "textures.h" #include "r_data/voxels.h" #include "drawers/r_draw_rgba.h" #include "p_setup.h" diff --git a/src/rendering/swrenderer/r_swscene.cpp b/src/rendering/swrenderer/r_swscene.cpp index 3b6e5afc9..5991d3ca1 100644 --- a/src/rendering/swrenderer/r_swscene.cpp +++ b/src/rendering/swrenderer/r_swscene.cpp @@ -25,7 +25,7 @@ ** */ -#include "hwrenderer/textures/hw_ihwtexture.h" +#include "hw_ihwtexture.h" #include "hwrenderer/textures/hw_material.h" #include "swrenderer/r_renderer.h" #include "r_swscene.h" diff --git a/src/rendering/swrenderer/textures/r_swtexture.h b/src/rendering/swrenderer/textures/r_swtexture.h index 181465561..bbf679af2 100644 --- a/src/rendering/swrenderer/textures/r_swtexture.h +++ b/src/rendering/swrenderer/textures/r_swtexture.h @@ -1,5 +1,5 @@ #pragma once -#include "textures/textures.h" +#include "textures.h" #include "v_video.h" #include "g_levellocals.h" diff --git a/src/rendering/vulkan/textures/vk_hwtexture.h b/src/rendering/vulkan/textures/vk_hwtexture.h index 160f9060a..6dd2f8ea9 100644 --- a/src/rendering/vulkan/textures/vk_hwtexture.h +++ b/src/rendering/vulkan/textures/vk_hwtexture.h @@ -8,7 +8,7 @@ #define DIRECT_PALETTE -2 #include "tarray.h" -#include "hwrenderer/textures/hw_ihwtexture.h" +#include "hw_ihwtexture.h" #include "volk/volk.h" #include "vk_imagetransition.h"