forked from mirrors/nixpkgs
124 lines
4 KiB
Diff
124 lines
4 KiB
Diff
Based on https://github.com/niftools/nifskope/commit/7261b0a119a549b11006d8e41ba990d706171f1c
|
|
|
|
diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/ColorBlock.cpp nifskope-1.1.3/gl/dds/ColorBlock.cpp
|
|
--- nifskope-1.1.3-orig/gl/dds/ColorBlock.cpp 2012-11-17 23:40:31.000000000 +0100
|
|
+++ nifskope-1.1.3/gl/dds/ColorBlock.cpp 2017-09-10 10:50:36.766909836 +0200
|
|
@@ -78,8 +78,8 @@
|
|
|
|
void ColorBlock::init(const Image * img, uint x, uint y)
|
|
{
|
|
- const uint bw = min(img->width() - x, 4U);
|
|
- const uint bh = min(img->height() - y, 4U);
|
|
+ const uint bw = std::min(img->width() - x, 4U);
|
|
+ const uint bh = std::min(img->height() - y, 4U);
|
|
|
|
static int remainder[] = {
|
|
0, 0, 0, 0,
|
|
diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/Common.h nifskope-1.1.3/gl/dds/Common.h
|
|
--- nifskope-1.1.3-orig/gl/dds/Common.h 2012-11-17 23:40:31.000000000 +0100
|
|
+++ nifskope-1.1.3/gl/dds/Common.h 2017-09-10 10:48:08.462099032 +0200
|
|
@@ -33,14 +33,10 @@
|
|
#ifndef _DDS_COMMON_H
|
|
#define _DDS_COMMON_H
|
|
|
|
-#ifndef min
|
|
-#define min(a,b) ((a) <= (b) ? (a) : (b))
|
|
-#endif
|
|
-#ifndef max
|
|
-#define max(a,b) ((a) >= (b) ? (a) : (b))
|
|
-#endif
|
|
+#include <algorithm>
|
|
+
|
|
#ifndef clamp
|
|
-#define clamp(x,a,b) min(max((x), (a)), (b))
|
|
+#define clamp(x,a,b) std::min( std::max( (x), (a) ), (b) )
|
|
#endif
|
|
|
|
template<typename T>
|
|
diff -ru -x '*~' nifskope-1.1.3-orig/gl/dds/DirectDrawSurface.cpp nifskope-1.1.3/gl/dds/DirectDrawSurface.cpp
|
|
--- nifskope-1.1.3-orig/gl/dds/DirectDrawSurface.cpp 2012-11-17 23:40:31.000000000 +0100
|
|
+++ nifskope-1.1.3/gl/dds/DirectDrawSurface.cpp 2017-09-10 10:48:45.912056969 +0200
|
|
@@ -63,6 +63,7 @@
|
|
#include "DirectDrawSurface.h"
|
|
#include "BlockDXT.h"
|
|
#include "PixelFormat.h"
|
|
+#include "Common.h"
|
|
|
|
#include <stdio.h> // printf
|
|
#include <math.h> // sqrt
|
|
@@ -685,8 +686,8 @@
|
|
// Compute width and height.
|
|
for (uint m = 0; m < mipmap; m++)
|
|
{
|
|
- w = max(1U, w / 2);
|
|
- h = max(1U, h / 2);
|
|
+ w = std::max(1U, w / 2);
|
|
+ h = std::max(1U, h / 2);
|
|
}
|
|
|
|
img->allocate(w, h);
|
|
@@ -787,9 +788,9 @@
|
|
readBlock(&block);
|
|
|
|
// Write color block.
|
|
- for (uint y = 0; y < min(4U, h-4*by); y++)
|
|
+ for (uint y = 0; y < std::min(4U, h-4*by); y++)
|
|
{
|
|
- for (uint x = 0; x < min(4U, w-4*bx); x++)
|
|
+ for (uint x = 0; x < std::min(4U, w-4*bx); x++)
|
|
{
|
|
img->pixel(4*bx+x, 4*by+y) = block.color(x, y);
|
|
}
|
|
@@ -909,9 +910,9 @@
|
|
|
|
for (uint m = 0; m < mipmap; m++)
|
|
{
|
|
- w = max(1U, w / 2);
|
|
- h = max(1U, h / 2);
|
|
- d = max(1U, d / 2);
|
|
+ w = std::max(1U, w / 2);
|
|
+ h = std::max(1U, h / 2);
|
|
+ d = std::max(1U, d / 2);
|
|
}
|
|
|
|
if (header.pf.flags & DDPF_FOURCC)
|
|
diff -ru -x '*~' nifskope-1.1.3-orig/gl/gltexloaders.cpp nifskope-1.1.3/gl/gltexloaders.cpp
|
|
--- nifskope-1.1.3-orig/gl/gltexloaders.cpp 2012-11-17 23:40:31.000000000 +0100
|
|
+++ nifskope-1.1.3/gl/gltexloaders.cpp 2017-09-10 10:51:23.586839810 +0200
|
|
@@ -1736,8 +1736,8 @@
|
|
|
|
// generate next offset, resize
|
|
mipmapOffset += mipmapWidth * mipmapHeight * 4;
|
|
- mipmapWidth = max( 1, mipmapWidth / 2 );
|
|
- mipmapHeight = max( 1, mipmapHeight / 2 );
|
|
+ mipmapWidth = std::max( 1, mipmapWidth / 2 );
|
|
+ mipmapHeight = std::max( 1, mipmapHeight / 2 );
|
|
}
|
|
|
|
// set total pixel size
|
|
@@ -1932,11 +1932,11 @@
|
|
{
|
|
if ( ddsHeader.ddsPixelFormat.dwFourCC == FOURCC_DXT1 )
|
|
{
|
|
- mipmapOffset += max( 8, ( mipmapWidth * mipmapHeight / 2 ) );
|
|
+ mipmapOffset += std::max( 8, ( mipmapWidth * mipmapHeight / 2 ) );
|
|
}
|
|
else if ( ddsHeader.ddsPixelFormat.dwFourCC == FOURCC_DXT5 )
|
|
{
|
|
- mipmapOffset += max( 16, ( mipmapWidth * mipmapHeight ) );
|
|
+ mipmapOffset += std::max( 16, ( mipmapWidth * mipmapHeight ) );
|
|
}
|
|
}
|
|
else if ( ddsHeader.ddsPixelFormat.dwBPP == 24 )
|
|
@@ -1947,8 +1947,8 @@
|
|
{
|
|
mipmapOffset += ( mipmapWidth * mipmapHeight * 4 );
|
|
}
|
|
- mipmapWidth = max( 1, mipmapWidth / 2 );
|
|
- mipmapHeight = max( 1, mipmapHeight / 2 );
|
|
+ mipmapWidth = std::max( 1, mipmapWidth / 2 );
|
|
+ mipmapHeight = std::max( 1, mipmapHeight / 2 );
|
|
}
|
|
|
|
nif->set<quint32>( iData, "Num Pixels", mipmapOffset );
|