summary refs log tree commit diff
path: root/pkgs/tools/graphics/nifskope/gcc-6.patch
blob: 2bb8af9cfe4c2ea1d342fb755ecaa85fc06537d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
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 );