1 #ifndef ClientCache_H
2 # define ClientCache_H
3 
4 # include "constants.H"
5 # include "EncodeBuffer.H"
6 # include "IntCache.H"
7 # include "CharCache.H"
8 # include "TextCompressor.H"
9 # include "HuffmanCoder.H"
10 # include "PixelCache.H"
11 # include "LastPixels.H"
12 
13 
14 static const unsigned int PUT_IMAGE_PIXEL_CACHE_SIZE = 251;
15 static const unsigned int CLIENT_TEXT_CACHE_SIZE = 9999;
16 
17 
18 class ClientCache
19 {
20   public:
21     ClientCache();
22     ~ClientCache();
23 
24     // General-purpose caches:
25     CharCache textCache[CLIENT_TEXT_CACHE_SIZE];
26     IntCache cursorCache;
27     IntCache gcCache;
28     IntCache drawableCache;
29     IntCache windowCache;
30     IntCache colormapCache;
31     IntCache visualCache;
32     CharCache depthCache;
33     unsigned int lastFont;
34     unsigned int lastRequestSequenceNum;
35 
36     // Opcode prediction caches (predict next opcode based on previous one)
37     CharCache opcodeCache[256];
38     unsigned char lastOpcode;
39 
40     // AllocColor request
41     IntCache *allocColorRGBCache[3];
42 
43     // ChangeProperty request
44     CharCache changePropertyFormatCache;
45     IntCache changePropertyPropertyCache;
46     IntCache changePropertyTypeCache;
47     IntCache changePropertyData32Cache;
48     TextCompressor changePropertyTextCompressor;
49 
50     // ClearArea request
51     IntCache *clearAreaGeomCache[4];
52 
53     // ConfigureWindow request
54     IntCache configureWindowBitmaskCache;
55     IntCache *configureWindowAttrCache[7];
56 
57     // ConvertSelection request
58     IntCache convertSelectionRequestorCache;
59     IntCache *convertSelectionAtomCache[3];
60     unsigned int convertSelectionLastTimestamp;
61 
62     // CopyArea request
63     IntCache *copyAreaGeomCache[6];
64 
65     // CopyPlane request
66     IntCache *copyPlaneGeomCache[6];
67     IntCache copyPlaneBitPlaneCache;
68 
69     // CreateGC request
70     IntCache createGCBitmaskCache;
71     IntCache *createGCAttrCache[23];
72 
73     // CreatePixmap request
74     unsigned int createPixmapLastPixmap;
75     IntCache createPixmapXCache;
76     IntCache createPixmapYCache;
77 
78     // CreateWindow request
79     IntCache *createWindowGeomCache[6];
80     IntCache createWindowBitmaskCache;
81     IntCache *createWindowAttrCache[15];
82 
83     // FillPoly request
84     IntCache fillPolyNumPointsCache;
85     IntCache *fillPolyXRelCache[FILL_POLY_MAX_POINTS];
86     IntCache *fillPolyXAbsCache[FILL_POLY_MAX_POINTS];
87     IntCache *fillPolyYRelCache[FILL_POLY_MAX_POINTS];
88     IntCache *fillPolyYAbsCache[FILL_POLY_MAX_POINTS];
89     unsigned int fillPolyRecentX[8];
90     unsigned int fillPolyRecentY[8];
91     unsigned int fillPolyIndex;
92 
93     // GetSelectionOwner request
94     IntCache getSelectionOwnerSelectionCache;
95 
96     // GrabButton request
97     // (also used for GrabPointer)
98     IntCache grabButtonEventMaskCache;
99     IntCache grabButtonConfineCache;
100     CharCache grabButtonButtonCache;
101     IntCache grabButtonModifierCache;
102 
103     // GrabKeyboard request
104     unsigned int grabKeyboardLastTimestamp;
105 
106     // ImageText8 request
107     unsigned int imageText8LastX;
108     unsigned int imageText8LastY;
109     IntCache imageText8CacheX;
110     IntCache imageText8CacheY;
111     TextCompressor imageText8TextCompressor;
112 
113     // InternAtom request
114     TextCompressor internAtomTextCompressor;
115 
116     // OpenFont request
117     TextCompressor openFontTextCompressor;
118 
119     // PolyFillRectangle request
120     IntCache *polyFillRectangleCacheX[2];
121     IntCache *polyFillRectangleCacheY[2];
122     IntCache *polyFillRectangleCacheWidth[2];
123     IntCache *polyFillRectangleCacheHeight[2];
124 
125     // PolyLine request
126     IntCache *polyLineCacheX[2];
127     IntCache *polyLineCacheY[2];
128 
129     // PolyPoint request
130     IntCache *polyPointCacheX[2];
131     IntCache *polyPointCacheY[2];
132 
133     // PolyRectangle request
134     IntCache *polyRectangleGeomCache[4];
135 
136     // PolySegment request
137     IntCache polySegmentCacheX;
138     IntCache polySegmentCacheY;
139     unsigned int polySegmentLastX[2];
140     unsigned int polySegmentLastY[2];
141     unsigned int polySegmentCacheIndex;
142 
143     // PolyText8 request
144     unsigned int polyText8LastX;
145     unsigned int polyText8LastY;
146     IntCache polyText8CacheX;
147     IntCache polyText8CacheY;
148     IntCache polyText8FontCache;
149     CharCache polyText8DeltaCache;
150     TextCompressor polyText8TextCompressor;
151 
152     // PutImage request
153     IntCache putImageWidthCache;
154     IntCache putImageHeightCache;
155     unsigned int putImageLastX;
156     unsigned int putImageLastY;
157     IntCache putImageXCache;
158     IntCache putImageYCache;
159     CharCache putImageOffsetCache;
160     HuffmanCoder putImagePixel0Coder;
161     HuffmanCoder putImagePixel1Coder;
162     HuffmanCoder putImageDiffCoder;
163     PixelCache putImagePixelCache[PUT_IMAGE_PIXEL_CACHE_SIZE];
164     LastPixels putImageLastPixels;
165     HuffmanCoder columnPixel0Coder;
166     HuffmanCoder columnPixel1Coder;
167     unsigned int *putImageReferenceLine;
168     unsigned int *putImageCodingLine;
169     unsigned int putImageLineSize;
170     CharCache putImageByteCache;
171 
172     // QueryColors request
173     unsigned int queryColorsLastPixel;
174 
175     // SetClipRectangles request
176     IntCache setClipRectanglesXCache;
177     IntCache setClipRectanglesYCache;
178     IntCache *setClipRectanglesGeomCache[4];
179 
180     // SetDashes request
181     IntCache setDashesLengthCache;
182     IntCache setDashesOffsetCache;
183     CharCache setDashesDashCache_[2];
184 
185     // SetSelectionOwner request
186     IntCache setSelectionOwnerCache;
187     IntCache setSelectionOwnerTimestampCache;
188 
189     // TranslateCoords request
190     IntCache translateCoordsSrcCache;
191     IntCache translateCoordsDestCache;
192     IntCache translateCoordsXCache;
193     IntCache translateCoordsYCache;
194 };
195 
196 
197 // Codes for representing patterns between scan lines of a compressed bitmap:
198 enum ScanlineDiff
199 {
200     SD_VERTICAL_0, SD_VERTICAL_PLUS_1, SD_VERTICAL_MINUS_1,
201     SD_HORIZONTAL, SD_PASS, SD_VERTICAL_MINUS_2,
202     SD_VERTICAL_PLUS_2, SD_NUM_CODES
203 };
204 
205 #endif /* ClientCache_H */
206