Gentoo Archives: gentoo-commits

From: Heather Cynede <cynede@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/dotnet:master commit in: dev-dotnet/libgdiplus/, dev-dotnet/libgdiplus/files/
Date: Wed, 24 Feb 2016 13:02:43
Message-Id: 1455876707.8f975abd595dddd8a26601598fe29cff6c8a5f48.cynede@gentoo
1 commit: 8f975abd595dddd8a26601598fe29cff6c8a5f48
2 Author: ArsenShnurkov <Arsen.Shnurkov <AT> gmail <DOT> com>
3 AuthorDate: Fri Feb 19 10:11:47 2016 +0000
4 Commit: Heather Cynede <cynede <AT> gentoo <DOT> org>
5 CommitDate: Fri Feb 19 10:11:47 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/dotnet.git/commit/?id=8f975abd
7
8 patch restored
9
10 .../libgdiplus-4.2-giflib-quantizebuffer.patch | 297 +++++++++++++++++++++
11 dev-dotnet/libgdiplus/libgdiplus-4.2-r2.ebuild | 14 +-
12 2 files changed, 310 insertions(+), 1 deletion(-)
13
14 diff --git a/dev-dotnet/libgdiplus/files/libgdiplus-4.2-giflib-quantizebuffer.patch b/dev-dotnet/libgdiplus/files/libgdiplus-4.2-giflib-quantizebuffer.patch
15 new file mode 100644
16 index 0000000..6f816d4
17 --- /dev/null
18 +++ b/dev-dotnet/libgdiplus/files/libgdiplus-4.2-giflib-quantizebuffer.patch
19 @@ -0,0 +1,297 @@
20 +diff --git a/src/gifcodec.c b/src/gifcodec.c
21 +index 6f8dedb..0868713 100644
22 +--- a/src/gifcodec.c
23 ++++ b/src/gifcodec.c
24 +@@ -39,6 +39,292 @@ GUID gdip_gif_image_format_guid = {0xb96b3cb0U, 0x0728U, 0x11d3U, {0x9d, 0x7b, 0
25 +
26 + #include "gifcodec.h"
27 +
28 ++#define COLOR_ARRAY_SIZE 32768
29 ++#define BITS_PER_PRIM_COLOR 5
30 ++#define MAX_PRIM_COLOR 0x1f
31 ++
32 ++static int SortRGBAxis;
33 ++
34 ++typedef struct QuantizedColorType {
35 ++ GifByteType RGB[3];
36 ++ GifByteType NewColorIndex;
37 ++ long Count;
38 ++ struct QuantizedColorType *Pnext;
39 ++} QuantizedColorType;
40 ++
41 ++typedef struct NewColorMapType {
42 ++ GifByteType RGBMin[3], RGBWidth[3];
43 ++ unsigned int NumEntries; /* # of QuantizedColorType in linked list below */
44 ++ unsigned long Count; /* Total number of pixels in all the entries */
45 ++ QuantizedColorType *QuantizedColors;
46 ++} NewColorMapType;
47 ++
48 ++
49 ++/****************************************************************************
50 ++ * Routine called by qsort to compare two entries.
51 ++ ****************************************************************************/
52 ++static int
53 ++SortCmpRtn(const void *Entry1,
54 ++ const void *Entry2) {
55 ++
56 ++ return (*((QuantizedColorType **) Entry1))->RGB[SortRGBAxis] -
57 ++ (*((QuantizedColorType **) Entry2))->RGB[SortRGBAxis];
58 ++}
59 ++
60 ++/******************************************************************************
61 ++ * Routine to subdivide the RGB space recursively using median cut in each
62 ++ * axes alternatingly until ColorMapSize different cubes exists.
63 ++ * The biggest cube in one dimension is subdivide unless it has only one entry.
64 ++ * Returns GIF_ERROR if failed, otherwise GIF_OK.
65 ++ ******************************************************************************/
66 ++static int
67 ++SubdivColorMap(NewColorMapType * NewColorSubdiv,
68 ++ unsigned int ColorMapSize,
69 ++ unsigned int *NewColorMapSize) {
70 ++
71 ++ int MaxSize;
72 ++ unsigned int i, j, Index = 0, NumEntries, MinColor, MaxColor;
73 ++ long Sum, Count;
74 ++ QuantizedColorType *QuantizedColor, **SortArray;
75 ++
76 ++ while (ColorMapSize > *NewColorMapSize) {
77 ++ /* Find candidate for subdivision: */
78 ++ MaxSize = -1;
79 ++ for (i = 0; i < *NewColorMapSize; i++) {
80 ++ for (j = 0; j < 3; j++) {
81 ++ if ((((int)NewColorSubdiv[i].RGBWidth[j]) > MaxSize) &&
82 ++ (NewColorSubdiv[i].NumEntries > 1)) {
83 ++ MaxSize = NewColorSubdiv[i].RGBWidth[j];
84 ++ Index = i;
85 ++ SortRGBAxis = j;
86 ++ }
87 ++ }
88 ++ }
89 ++
90 ++ if (MaxSize == -1)
91 ++ return GIF_OK;
92 ++
93 ++ /* Split the entry Index into two along the axis SortRGBAxis: */
94 ++
95 ++ /* Sort all elements in that entry along the given axis and split at
96 ++ * the median. */
97 ++ SortArray = (QuantizedColorType **)malloc(
98 ++ sizeof(QuantizedColorType *) *
99 ++ NewColorSubdiv[Index].NumEntries);
100 ++ if (SortArray == NULL)
101 ++ return GIF_ERROR;
102 ++ for (j = 0, QuantizedColor = NewColorSubdiv[Index].QuantizedColors;
103 ++ j < NewColorSubdiv[Index].NumEntries && QuantizedColor != NULL;
104 ++ j++, QuantizedColor = QuantizedColor->Pnext)
105 ++ SortArray[j] = QuantizedColor;
106 ++
107 ++ qsort(SortArray, NewColorSubdiv[Index].NumEntries,
108 ++ sizeof(QuantizedColorType *), SortCmpRtn);
109 ++
110 ++ /* Relink the sorted list into one: */
111 ++ for (j = 0; j < NewColorSubdiv[Index].NumEntries - 1; j++)
112 ++ SortArray[j]->Pnext = SortArray[j + 1];
113 ++ SortArray[NewColorSubdiv[Index].NumEntries - 1]->Pnext = NULL;
114 ++ NewColorSubdiv[Index].QuantizedColors = QuantizedColor = SortArray[0];
115 ++ free((char *)SortArray);
116 ++
117 ++ /* Now simply add the Counts until we have half of the Count: */
118 ++ Sum = NewColorSubdiv[Index].Count / 2 - QuantizedColor->Count;
119 ++ NumEntries = 1;
120 ++ Count = QuantizedColor->Count;
121 ++ while (QuantizedColor->Pnext != NULL &&
122 ++ (Sum -= QuantizedColor->Pnext->Count) >= 0 &&
123 ++ QuantizedColor->Pnext->Pnext != NULL) {
124 ++ QuantizedColor = QuantizedColor->Pnext;
125 ++ NumEntries++;
126 ++ Count += QuantizedColor->Count;
127 ++ }
128 ++ /* Save the values of the last color of the first half, and first
129 ++ * of the second half so we can update the Bounding Boxes later.
130 ++ * Also as the colors are quantized and the BBoxes are full 0..255,
131 ++ * they need to be rescaled.
132 ++ */
133 ++ MaxColor = QuantizedColor->RGB[SortRGBAxis]; /* Max. of first half */
134 ++ /* coverity[var_deref_op] */
135 ++ MinColor = QuantizedColor->Pnext->RGB[SortRGBAxis]; /* of second */
136 ++ MaxColor <<= (8 - BITS_PER_PRIM_COLOR);
137 ++ MinColor <<= (8 - BITS_PER_PRIM_COLOR);
138 ++
139 ++ /* Partition right here: */
140 ++ NewColorSubdiv[*NewColorMapSize].QuantizedColors =
141 ++ QuantizedColor->Pnext;
142 ++ QuantizedColor->Pnext = NULL;
143 ++ NewColorSubdiv[*NewColorMapSize].Count = Count;
144 ++ NewColorSubdiv[Index].Count -= Count;
145 ++ NewColorSubdiv[*NewColorMapSize].NumEntries =
146 ++ NewColorSubdiv[Index].NumEntries - NumEntries;
147 ++ NewColorSubdiv[Index].NumEntries = NumEntries;
148 ++ for (j = 0; j < 3; j++) {
149 ++ NewColorSubdiv[*NewColorMapSize].RGBMin[j] =
150 ++ NewColorSubdiv[Index].RGBMin[j];
151 ++ NewColorSubdiv[*NewColorMapSize].RGBWidth[j] =
152 ++ NewColorSubdiv[Index].RGBWidth[j];
153 ++ }
154 ++ NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] =
155 ++ NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] +
156 ++ NewColorSubdiv[*NewColorMapSize].RGBWidth[SortRGBAxis] - MinColor;
157 ++ NewColorSubdiv[*NewColorMapSize].RGBMin[SortRGBAxis] = MinColor;
158 ++
159 ++ NewColorSubdiv[Index].RGBWidth[SortRGBAxis] =
160 ++ MaxColor - NewColorSubdiv[Index].RGBMin[SortRGBAxis];
161 ++
162 ++ (*NewColorMapSize)++;
163 ++ }
164 ++
165 ++ return GIF_OK;
166 ++}
167 ++
168 ++/******************************************************************************
169 ++ * Quantize high resolution image into lower one. Input image consists of a
170 ++ * 2D array for each of the RGB colors with size Width by Height. There is no
171 ++ * Color map for the input. Output is a quantized image with 2D array of
172 ++ * indexes into the output color map.
173 ++ * Note input image can be 24 bits at the most (8 for red/green/blue) and
174 ++ * the output has 256 colors at the most (256 entries in the color map.).
175 ++ * ColorMapSize specifies size of color map up to 256 and will be updated to
176 ++ * real size before returning.
177 ++ * Also non of the parameter are allocated by this routine.
178 ++ * This function returns GIF_OK if succesfull, GIF_ERROR otherwise.
179 ++ ******************************************************************************/
180 ++static int
181 ++QuantizeBuffer(unsigned int Width,
182 ++ unsigned int Height,
183 ++ int *ColorMapSize,
184 ++ GifByteType * RedInput,
185 ++ GifByteType * GreenInput,
186 ++ GifByteType * BlueInput,
187 ++ GifByteType * OutputBuffer,
188 ++ GifColorType * OutputColorMap) {
189 ++
190 ++ unsigned int Index, NumOfEntries;
191 ++ int i, j, MaxRGBError[3];
192 ++ unsigned int NewColorMapSize;
193 ++ long Red, Green, Blue;
194 ++ NewColorMapType NewColorSubdiv[256];
195 ++ QuantizedColorType *ColorArrayEntries, *QuantizedColor;
196 ++
197 ++ ColorArrayEntries = (QuantizedColorType *)malloc(
198 ++ sizeof(QuantizedColorType) * COLOR_ARRAY_SIZE);
199 ++ if (ColorArrayEntries == NULL) {
200 ++ return GIF_ERROR;
201 ++ }
202 ++
203 ++ for (i = 0; i < COLOR_ARRAY_SIZE; i++) {
204 ++ ColorArrayEntries[i].RGB[0] = i >> (2 * BITS_PER_PRIM_COLOR);
205 ++ ColorArrayEntries[i].RGB[1] = (i >> BITS_PER_PRIM_COLOR) &
206 ++ MAX_PRIM_COLOR;
207 ++ ColorArrayEntries[i].RGB[2] = i & MAX_PRIM_COLOR;
208 ++ ColorArrayEntries[i].Count = 0;
209 ++ }
210 ++
211 ++ /* Sample the colors and their distribution: */
212 ++ for (i = 0; i < (int)(Width * Height); i++) {
213 ++ Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
214 ++ (2 * BITS_PER_PRIM_COLOR)) +
215 ++ ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
216 ++ BITS_PER_PRIM_COLOR) +
217 ++ (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
218 ++ ColorArrayEntries[Index].Count++;
219 ++ }
220 ++
221 ++ /* Put all the colors in the first entry of the color map, and call the
222 ++ * recursive subdivision process. */
223 ++ for (i = 0; i < 256; i++) {
224 ++ NewColorSubdiv[i].QuantizedColors = NULL;
225 ++ NewColorSubdiv[i].Count = NewColorSubdiv[i].NumEntries = 0;
226 ++ for (j = 0; j < 3; j++) {
227 ++ NewColorSubdiv[i].RGBMin[j] = 0;
228 ++ NewColorSubdiv[i].RGBWidth[j] = 255;
229 ++ }
230 ++ }
231 ++
232 ++ /* Find the non empty entries in the color table and chain them: */
233 ++ for (i = 0; i < COLOR_ARRAY_SIZE; i++)
234 ++ if (ColorArrayEntries[i].Count > 0)
235 ++ break;
236 ++ QuantizedColor = NewColorSubdiv[0].QuantizedColors = &ColorArrayEntries[i];
237 ++ NumOfEntries = 1;
238 ++ while (++i < COLOR_ARRAY_SIZE)
239 ++ if (ColorArrayEntries[i].Count > 0) {
240 ++ QuantizedColor->Pnext = &ColorArrayEntries[i];
241 ++ QuantizedColor = &ColorArrayEntries[i];
242 ++ NumOfEntries++;
243 ++ }
244 ++ QuantizedColor->Pnext = NULL;
245 ++
246 ++ NewColorSubdiv[0].NumEntries = NumOfEntries; /* Different sampled colors */
247 ++ NewColorSubdiv[0].Count = ((long)Width) * Height; /* Pixels */
248 ++ NewColorMapSize = 1;
249 ++ if (SubdivColorMap(NewColorSubdiv, *ColorMapSize, &NewColorMapSize) !=
250 ++ GIF_OK) {
251 ++ free((char *)ColorArrayEntries);
252 ++ return GIF_ERROR;
253 ++ }
254 ++ if (NewColorMapSize < *ColorMapSize) {
255 ++ /* And clear rest of color map: */
256 ++ for (i = NewColorMapSize; i < *ColorMapSize; i++)
257 ++ OutputColorMap[i].Red = OutputColorMap[i].Green =
258 ++ OutputColorMap[i].Blue = 0;
259 ++ }
260 ++
261 ++ /* Average the colors in each entry to be the color to be used in the
262 ++ * output color map, and plug it into the output color map itself. */
263 ++ for (i = 0; i < NewColorMapSize; i++) {
264 ++ if ((j = NewColorSubdiv[i].NumEntries) > 0) {
265 ++ QuantizedColor = NewColorSubdiv[i].QuantizedColors;
266 ++ Red = Green = Blue = 0;
267 ++ while (QuantizedColor) {
268 ++ QuantizedColor->NewColorIndex = i;
269 ++ Red += QuantizedColor->RGB[0];
270 ++ Green += QuantizedColor->RGB[1];
271 ++ Blue += QuantizedColor->RGB[2];
272 ++ QuantizedColor = QuantizedColor->Pnext;
273 ++ }
274 ++ OutputColorMap[i].Red = (Red << (8 - BITS_PER_PRIM_COLOR)) / j;
275 ++ OutputColorMap[i].Green = (Green << (8 - BITS_PER_PRIM_COLOR)) / j;
276 ++ OutputColorMap[i].Blue = (Blue << (8 - BITS_PER_PRIM_COLOR)) / j;
277 ++ } else
278 ++ fprintf(stderr,
279 ++ "\n%s: Null entry in quantized color map - that's weird.\n",
280 ++ "libgdiplus");
281 ++ }
282 ++
283 ++ /* Finally scan the input buffer again and put the mapped index in the
284 ++ * output buffer. */
285 ++ MaxRGBError[0] = MaxRGBError[1] = MaxRGBError[2] = 0;
286 ++ for (i = 0; i < (int)(Width * Height); i++) {
287 ++ Index = ((RedInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
288 ++ (2 * BITS_PER_PRIM_COLOR)) +
289 ++ ((GreenInput[i] >> (8 - BITS_PER_PRIM_COLOR)) <<
290 ++ BITS_PER_PRIM_COLOR) +
291 ++ (BlueInput[i] >> (8 - BITS_PER_PRIM_COLOR));
292 ++ Index = ColorArrayEntries[Index].NewColorIndex;
293 ++ OutputBuffer[i] = Index;
294 ++ if (MaxRGBError[0] < ABS(OutputColorMap[Index].Red - RedInput[i]))
295 ++ MaxRGBError[0] = ABS(OutputColorMap[Index].Red - RedInput[i]);
296 ++ if (MaxRGBError[1] < ABS(OutputColorMap[Index].Green - GreenInput[i]))
297 ++ MaxRGBError[1] = ABS(OutputColorMap[Index].Green - GreenInput[i]);
298 ++ if (MaxRGBError[2] < ABS(OutputColorMap[Index].Blue - BlueInput[i]))
299 ++ MaxRGBError[2] = ABS(OutputColorMap[Index].Blue - BlueInput[i]);
300 ++ }
301 ++
302 ++#ifdef DEBUG
303 ++ fprintf(stderr,
304 ++ "Quantization L(0) errors: Red = %d, Green = %d, Blue = %d.\n",
305 ++ MaxRGBError[0], MaxRGBError[1], MaxRGBError[2]);
306 ++#endif /* DEBUG */
307 ++
308 ++ free((char *)ColorArrayEntries);
309 ++
310 ++ *ColorMapSize = NewColorMapSize;
311 ++
312 ++ return GIF_OK;
313 ++}
314 +
315 + /* Data structure used for callback */
316 + typedef struct
317
318 diff --git a/dev-dotnet/libgdiplus/libgdiplus-4.2-r2.ebuild b/dev-dotnet/libgdiplus/libgdiplus-4.2-r2.ebuild
319 index 2265860..56b287e 100644
320 --- a/dev-dotnet/libgdiplus/libgdiplus-4.2-r2.ebuild
321 +++ b/dev-dotnet/libgdiplus/libgdiplus-4.2-r2.ebuild
322 @@ -2,7 +2,7 @@
323 # Distributed under the terms of the GNU General Public License v2
324 # $Id$
325
326 -EAPI=5
327 +EAPI=6
328
329 inherit eutils dotnet
330
331 @@ -31,6 +31,18 @@ RDEPEND=">=dev-libs/glib-2.2.3:2
332 !cairo? ( >=x11-libs/pango-1.20 )"
333 DEPEND="${RDEPEND}"
334
335 +src_prepare() {
336 + # ${PV} = Package version (excluding revision, if any), for example 6.3
337 + eapply "${FILESDIR}/libgdiplus-${PV}-giflib-quantizebuffer.patch"
338 + sed -i -e 's:ungif:gif:g' configure.ac || die
339 + #append-flags -fno-strict-aliasing
340 + # append-flags: command not found
341 + #eautoreconf
342 + # eautoreconf: command not found
343 +
344 + eapply_user
345 +}
346 +
347 src_configure() {
348 econf \
349 --disable-dependency-tracking \