1 #include "dxpcconf.h"
2
3 #include <stdlib.h>
4 #include "ClientCache.H"
5 #include "constants.H"
6
7
8 // Histograms used to build static Huffman codes for run-length-encoding
9 // of images...generated by profiling lots of bitmapped text and images
10 // produced by FrameMaker
11
12 static const unsigned int PIXEL_COUNT_0 = 63;
13 static const unsigned int PixelHistogram0[PIXEL_COUNT_0] = {
14 82551,
15 69015,
16 30616,
17 24739,
18 15491,
19 10108,
20 7422,
21 7569,
22 3408,
23 3457,
24 2013,
25 2144,
26 3527,
27 3187,
28 2883,
29 1717,
30 1487,
31 1024,
32 789,
33 618,
34 993,
35 1029,
36 664,
37 711,
38 667,
39 736,
40 572,
41 492,
42 909,
43 432,
44 422,
45 306,
46 269,
47 265,
48 522,
49 445,
50 249,
51 210,
52 252,
53 150,
54 189,
55 181,
56 253,
57 217,
58 251,
59 272,
60 183,
61 231,
62 198,
63 186,
64 177,
65 196,
66 134,
67 287,
68 190,
69 327,
70 150,
71 155,
72 119,
73 138,
74 230,
75 262
76 };
77 static const unsigned int PIXEL_OVERFLOW_COUNT_0 = 15400;
78
79 static const unsigned int PIXEL_COUNT_1 = 32;
80 static const unsigned int PixelHistogram1[PIXEL_COUNT_1] = {
81 181385,
82 57253,
83 51214,
84 19913,
85 14296,
86 8104,
87 3138,
88 1706,
89 1985,
90 1244,
91 1011,
92 581,
93 869,
94 327,
95 456,
96 397,
97 661,
98 191,
99 198,
100 155,
101 95,
102 76,
103 28,
104 18,
105 10,
106 3,
107 3,
108 11,
109 2,
110 0,
111 6,
112 2
113 };
114 static const unsigned int PIXEL_OVERFLOW_COUNT_1 = 4;
115
116
117 static const unsigned int COLUMN_PIXEL_COUNT_0 = 32;
118 static const unsigned int ColumnPixelHistogram0[COLUMN_PIXEL_COUNT_0] = {
119 4646,
120 5347,
121 7237,
122 10526,
123 11306,
124 4105,
125 2643,
126 1766,
127 6663,
128 3805,
129 2908,
130 1225,
131 502,
132 1161,
133 758,
134 363,
135 186,
136 75,
137 61,
138 513,
139 120,
140 4,
141 21,
142 4,
143 0,
144 0,
145 29,
146 1,
147 0,
148 0,
149 0,
150 0
151 };
152
153
154 static const unsigned int COLUMN_PIXEL_COUNT_1 = 32;
155 static const unsigned int ColumnPixelHistogram1[COLUMN_PIXEL_COUNT_1] = {
156 20339,
157 8153,
158 4903,
159 2193,
160 933,
161 310,
162 1024,
163 402,
164 486,
165 645,
166 598,
167 132,
168 162,
169 92,
170 35,
171 5,
172 3,
173 7,
174 10,
175 0,
176 0,
177 0,
178 0,
179 0,
180 0,
181 0,
182 0,
183 0,
184 0,
185 0,
186 0,
187 0
188 };
189
190
191 // Precomputed static prefix code for encoding of run length deltas
192 // between scan lines...based on Group 4 FAX encoding. (Reference:
193 // "FAX: Digital Facsimile Technology and Applications," 2nd Edition;
194 // McConnel, Bodson, and Schaphorst; Artech House, 1992; ISBN 0-89006-495-4)
195 static const char *ScanLineDiffCodes[SD_NUM_CODES] = {
196 "0", // Vertical +0
197 "100", // Vertical +1
198 "110", // Vertical -1
199 "101", // Horizontal
200 "1111", // Pass
201 "11100", // Vertical +2
202 "11101", // Vertical -2
203 };
204
205
206
ClientCache()207 ClientCache::ClientCache():
208 cursorCache(16), gcCache(16), drawableCache(16), windowCache(16),
209 colormapCache(16), visualCache(16), lastFont(0), lastRequestSequenceNum(0),
210 lastOpcode(0),
211 changePropertyPropertyCache(16), changePropertyTypeCache(16),
212 changePropertyData32Cache(16),
213 changePropertyTextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE),
214 configureWindowBitmaskCache(4),
215 convertSelectionRequestorCache(16),
216 convertSelectionLastTimestamp(0),
217 copyPlaneBitPlaneCache(8),
218 createGCBitmaskCache(8),
219 createPixmapLastPixmap(0), createPixmapXCache(8), createPixmapYCache(8),
220 createWindowBitmaskCache(8),
221 fillPolyNumPointsCache(8), fillPolyIndex(0),
222 getSelectionOwnerSelectionCache(8),
223 grabButtonEventMaskCache(8), grabButtonConfineCache(8),
224 grabButtonModifierCache(8),
225 grabKeyboardLastTimestamp(0),
226 imageText8LastX(0), imageText8LastY(0), imageText8CacheX(8),
227 imageText8CacheY(8), imageText8TextCompressor(textCache,
228 CLIENT_TEXT_CACHE_SIZE),
229 internAtomTextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE),
230 openFontTextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE),
231 polySegmentCacheX(8), polySegmentCacheY(8), polySegmentCacheIndex(0),
232 polyText8LastX(0), polyText8LastY(0), polyText8CacheX(8),
233 polyText8CacheY(8), polyText8FontCache(8),
234 polyText8TextCompressor(textCache, CLIENT_TEXT_CACHE_SIZE),
235 putImageWidthCache(8), putImageHeightCache(8), putImageLastX(0),
236 putImageLastY(0), putImageXCache(8), putImageYCache(8),
237 putImagePixel0Coder(PIXEL_COUNT_0, PixelHistogram0, PIXEL_OVERFLOW_COUNT_0),
238 putImagePixel1Coder(PIXEL_COUNT_1, PixelHistogram1, PIXEL_OVERFLOW_COUNT_1),
239 putImageDiffCoder(SD_NUM_CODES, ScanLineDiffCodes),
240 putImageLastPixels(3),
241 columnPixel0Coder(COLUMN_PIXEL_COUNT_0, ColumnPixelHistogram0, 0),
242 columnPixel1Coder(COLUMN_PIXEL_COUNT_1, ColumnPixelHistogram1, 0),
243 putImageReferenceLine(NULL), putImageCodingLine(NULL),
244 putImageLineSize(0),
245 queryColorsLastPixel(0),
246 setClipRectanglesXCache(8), setClipRectanglesYCache(8),
247 setDashesLengthCache(8), setDashesOffsetCache(8),
248 setSelectionOwnerCache(8), setSelectionOwnerTimestampCache(8),
249 translateCoordsSrcCache(8), translateCoordsDestCache(8),
250 translateCoordsXCache(8), translateCoordsYCache(8)
251 {
252 unsigned int i;
253
254 for (i = 0; i < 3; i++)
255 {
256 allocColorRGBCache[i] = new IntCache(8);
257 convertSelectionAtomCache[i] = new IntCache(8);
258 }
259
260 for (i = 0; i < 4; i++)
261 clearAreaGeomCache[i] = new IntCache(8);
262
263 for (i = 0; i < 7; i++)
264 configureWindowAttrCache[i] = new IntCache(8);
265
266 for (i = 0; i < 6; i++)
267 {
268 copyAreaGeomCache[i] = new IntCache(8);
269 copyPlaneGeomCache[i] = new IntCache(8);
270 }
271
272 for (i = 0; i < 23; i++)
273 createGCAttrCache[i] = new IntCache(CREATEGC_FIELD_WIDTH[i]);
274
275 for (i = 0; i < 6; i++)
276 createWindowGeomCache[i] = new IntCache(8);
277 for (i = 0; i < 15; i++)
278 createWindowAttrCache[i] = new IntCache(8);
279
280 for (i = 0; i < FILL_POLY_MAX_POINTS; i++)
281 {
282 fillPolyXRelCache[i] = new IntCache(8);
283 fillPolyXAbsCache[i] = new IntCache(8);
284 fillPolyYRelCache[i] = new IntCache(8);
285 fillPolyYAbsCache[i] = new IntCache(8);
286 }
287 for (i = 0; i < 8; i++)
288 {
289 fillPolyRecentX[i] = 0;
290 fillPolyRecentY[i] = 0;
291 }
292
293 for (i = 0; i < 2; i++)
294 {
295 polyFillRectangleCacheX[i] = new IntCache(8);
296 polyFillRectangleCacheY[i] = new IntCache(8);
297 polyFillRectangleCacheWidth[i] = new IntCache(8);
298 polyFillRectangleCacheHeight[i] = new IntCache(8);
299 }
300
301 for (i = 0; i < 2; i++)
302 {
303 polyLineCacheX[i] = new IntCache(8);
304 polyLineCacheY[i] = new IntCache(8);
305 }
306
307 for (i = 0; i < 2; i++)
308 {
309 polyPointCacheX[i] = new IntCache(8);
310 polyPointCacheY[i] = new IntCache(8);
311 }
312
313 for (i = 0; i < 4; i++)
314 polyRectangleGeomCache[i] = new IntCache(8);
315
316 for (i = 0; i < 2; i++)
317 {
318 polySegmentLastX[i] = 0;
319 polySegmentLastY[i] = 0;
320 }
321
322 for (i = 0; i < 4; i++)
323 setClipRectanglesGeomCache[i] = new IntCache(8);
324 }
325
326
~ClientCache()327 ClientCache::~ClientCache()
328 {
329 unsigned int i;
330
331 for (i = 0; i < 3; i++)
332 {
333 delete allocColorRGBCache[i];
334 delete convertSelectionAtomCache[i];
335 }
336
337 for (i = 0; i < 4; i++)
338 delete clearAreaGeomCache[i];
339
340 for (i = 0; i < 7; i++)
341 delete configureWindowAttrCache[i];
342
343 for (i = 0; i < 6; i++)
344 {
345 delete copyAreaGeomCache[i];
346 delete copyPlaneGeomCache[i];
347 }
348
349 for (i = 0; i < 23; i++)
350 delete createGCAttrCache[i];
351
352 for (i = 0; i < 6; i++)
353 delete createWindowGeomCache[i];
354
355 for (i = 0; i < 15; i++)
356 delete createWindowAttrCache[i];
357
358 for (i = 0; i < FILL_POLY_MAX_POINTS; i++)
359 {
360 delete fillPolyXRelCache[i];
361 delete fillPolyXAbsCache[i];
362 delete fillPolyYRelCache[i];
363 delete fillPolyYAbsCache[i];
364 }
365
366 for (i = 0; i < 2; i++)
367 {
368 delete polyFillRectangleCacheX[i];
369 delete polyFillRectangleCacheY[i];
370 delete polyFillRectangleCacheWidth[i];
371 delete polyFillRectangleCacheHeight[i];
372 }
373
374 for (i = 0; i < 2; i++)
375 {
376 delete polyLineCacheX[i];
377 delete polyLineCacheY[i];
378 }
379
380 for (i = 0; i < 2; i++)
381 {
382 delete polyPointCacheX[i];
383 delete polyPointCacheY[i];
384 }
385
386 for (i = 0; i < 4; i++)
387 delete polyRectangleGeomCache[i];
388
389 delete[]putImageReferenceLine;
390 delete[]putImageCodingLine;
391
392 for (i = 0; i < 4; i++)
393 delete setClipRectanglesGeomCache[i];
394 }
395