VirtualBox

source: vbox/trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_pixel.c@ 70601

最後變更 在這個檔案從70601是 70601,由 vboxsync 提交於 7 年 前

3D: SharedOpenGL code cleanup, bugref:9043

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 26.7 KB
 
1/* Copyright (c) 2001, Stanford University
2 * All rights reserved
3 *
4 * See the file LICENSE.txt for information on redistributing this software.
5 */
6
7#include <stdio.h>
8#include "cr_mem.h"
9#include "state.h"
10#include "state/cr_statetypes.h"
11#include "state_internals.h"
12
13void crStatePixelInit(CRContext *ctx)
14{
15 CRPixelState *p = &ctx->pixel;
16 CRStateBits *sb = GetCurrentBits();
17 CRPixelBits *pb = &(sb->pixel);
18 GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f};
19 GLcolorf one_color = {1.0f, 1.0f, 1.0f, 1.0f};
20
21 p->mapColor = GL_FALSE;
22 p->mapStencil = GL_FALSE;
23 p->indexShift = 0;
24 p->indexOffset = 0;
25 p->scale = one_color;
26 p->depthScale = 1.0f;
27 p->bias = zero_color;
28 p->depthBias = 0.0f;
29 p->xZoom = 1.0f;
30 p->yZoom = 1.0f;
31 RESET(pb->transfer, ctx->bitid);
32 RESET(pb->zoom, ctx->bitid);
33
34 p->mapStoS[0] = 0;
35 p->mapItoI[0] = 0;
36 p->mapItoR[0] = 0.0;
37 p->mapItoG[0] = 0.0;
38 p->mapItoB[0] = 0.0;
39 p->mapItoA[0] = 0.0;
40 p->mapRtoR[0] = 0.0;
41 p->mapGtoG[0] = 0.0;
42 p->mapBtoB[0] = 0.0;
43 p->mapAtoA[0] = 0.0;
44
45 p->mapItoIsize = 1;
46 p->mapStoSsize = 1;
47 p->mapItoRsize = 1;
48 p->mapItoGsize = 1;
49 p->mapItoBsize = 1;
50 p->mapItoAsize = 1;
51 p->mapRtoRsize = 1;
52 p->mapGtoGsize = 1;
53 p->mapBtoBsize = 1;
54 p->mapAtoAsize = 1;
55 RESET(pb->maps, ctx->bitid);
56
57 RESET(pb->dirty, ctx->bitid);
58}
59
60void STATE_APIENTRY crStatePixelTransferi (GLenum pname, GLint param)
61{
62 crStatePixelTransferf( pname, (GLfloat) param );
63}
64
65void STATE_APIENTRY crStatePixelTransferf (GLenum pname, GLfloat param)
66{
67 CRContext *g = GetCurrentContext();
68 CRPixelState *p = &(g->pixel);
69 CRStateBits *sb = GetCurrentBits();
70 CRPixelBits *pb = &(sb->pixel);
71
72 if (g->current.inBeginEnd)
73 {
74 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelTransfer{if} called in Begin/End");
75 return;
76 }
77
78 FLUSH();
79
80 switch( pname )
81 {
82 case GL_MAP_COLOR:
83 p->mapColor = (GLboolean) ((param == 0.0f) ? GL_FALSE : GL_TRUE);
84 break;
85 case GL_MAP_STENCIL:
86 p->mapStencil = (GLboolean) ((param == 0.0f) ? GL_FALSE : GL_TRUE);
87 break;
88 case GL_INDEX_SHIFT:
89 p->indexShift = (GLint) param;
90 break;
91 case GL_INDEX_OFFSET:
92 p->indexOffset = (GLint) param;
93 break;
94 case GL_RED_SCALE:
95 p->scale.r = param;
96 break;
97 case GL_GREEN_SCALE:
98 p->scale.g = param;
99 break;
100 case GL_BLUE_SCALE:
101 p->scale.b = param;
102 break;
103 case GL_ALPHA_SCALE:
104 p->scale.a = param;
105 break;
106 case GL_DEPTH_SCALE:
107 p->depthScale = param;
108 break;
109 case GL_RED_BIAS:
110 p->bias.r = param;
111 break;
112 case GL_GREEN_BIAS:
113 p->bias.g = param;
114 break;
115 case GL_BLUE_BIAS:
116 p->bias.b = param;
117 break;
118 case GL_ALPHA_BIAS:
119 p->bias.a = param;
120 break;
121 case GL_DEPTH_BIAS:
122 p->depthBias = param;
123 break;
124 default:
125 crStateError( __LINE__, __FILE__, GL_INVALID_VALUE, "Unknown glPixelTransfer pname: %d", pname );
126 return;
127 }
128 DIRTY(pb->transfer, g->neg_bitid);
129 DIRTY(pb->dirty, g->neg_bitid);
130}
131
132void STATE_APIENTRY crStatePixelZoom (GLfloat xfactor, GLfloat yfactor)
133{
134 CRContext *g = GetCurrentContext();
135 CRPixelState *p = &(g->pixel);
136 CRStateBits *sb = GetCurrentBits();
137 CRPixelBits *pb = &(sb->pixel);
138
139 if (g->current.inBeginEnd)
140 {
141 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelZoom called in Begin/End");
142 return;
143 }
144
145 FLUSH();
146
147 p->xZoom = xfactor;
148 p->yZoom = yfactor;
149 DIRTY(pb->zoom, g->neg_bitid);
150 DIRTY(pb->dirty, g->neg_bitid);
151}
152
153
154void STATE_APIENTRY crStateBitmap( GLsizei width, GLsizei height,
155 GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove,
156 const GLubyte *bitmap)
157{
158 CRContext *g = GetCurrentContext();
159 CRCurrentState *c = &(g->current);
160 CRStateBits *sb = GetCurrentBits();
161 CRCurrentBits *cb = &(sb->current);
162
163 (void) xorig;
164 (void) yorig;
165 (void) bitmap;
166
167 if (g->lists.mode == GL_COMPILE)
168 return;
169
170 if (g->current.inBeginEnd)
171 {
172 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
173 "Bitmap called in begin/end");
174 return;
175 }
176
177 if (width < 0 || height < 0)
178 {
179 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE,
180 "Bitmap called with neg dims: %dx%d", width, height);
181 return;
182 }
183
184 if (!c->rasterValid)
185 {
186 return;
187 }
188
189 c->rasterAttrib[VERT_ATTRIB_POS][0] += xmove;
190 c->rasterAttrib[VERT_ATTRIB_POS][1] += ymove;
191 DIRTY(cb->rasterPos, g->neg_bitid);
192 DIRTY(cb->dirty, g->neg_bitid);
193
194 c->rasterAttribPre[VERT_ATTRIB_POS][0] += xmove;
195 c->rasterAttribPre[VERT_ATTRIB_POS][1] += ymove;
196}
197
198
199#define UNUSED(x) ((void)(x))
200
201#define CLAMP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x)))
202
203void STATE_APIENTRY crStatePixelMapfv (GLenum map, GLint mapsize, const GLfloat * values)
204{
205 CRContext *g = GetCurrentContext();
206 CRPixelState *p = &(g->pixel);
207 CRStateBits *sb = GetCurrentBits();
208 CRPixelBits *pb = &(sb->pixel);
209 GLint i;
210 GLboolean unpackbuffer = crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB);
211
212 if (g->current.inBeginEnd) {
213 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelMap called in Begin/End");
214 return;
215 }
216
217 FLUSH();
218
219 if (mapsize < 0 || mapsize > CR_MAX_PIXEL_MAP_TABLE) {
220 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "PixelMap(mapsize)");
221 return;
222 }
223
224 if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
225 /* XXX check that mapsize is a power of two */
226 }
227
228 switch (map) {
229 case GL_PIXEL_MAP_S_TO_S:
230 p->mapStoSsize = mapsize;
231 if (!unpackbuffer)
232 for (i=0;i<mapsize;i++) {
233 p->mapStoS[i] = (GLint) values[i];
234 }
235 break;
236 case GL_PIXEL_MAP_I_TO_I:
237 p->mapItoIsize = mapsize;
238 if (!unpackbuffer)
239 for (i=0;i<mapsize;i++) {
240 p->mapItoI[i] = (GLint) values[i];
241 }
242 break;
243 case GL_PIXEL_MAP_I_TO_R:
244 p->mapItoRsize = mapsize;
245 if (!unpackbuffer)
246 for (i=0;i<mapsize;i++) {
247 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
248 p->mapItoR[i] = val;
249 }
250 break;
251 case GL_PIXEL_MAP_I_TO_G:
252 p->mapItoGsize = mapsize;
253 if (!unpackbuffer)
254 for (i=0;i<mapsize;i++) {
255 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
256 p->mapItoG[i] = val;
257 }
258 break;
259 case GL_PIXEL_MAP_I_TO_B:
260 p->mapItoBsize = mapsize;
261 if (!unpackbuffer)
262 for (i=0;i<mapsize;i++) {
263 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
264 p->mapItoB[i] = val;
265 }
266 break;
267 case GL_PIXEL_MAP_I_TO_A:
268 p->mapItoAsize = mapsize;
269 if (!unpackbuffer)
270 for (i=0;i<mapsize;i++) {
271 GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
272 p->mapItoA[i] = val;
273 }
274 break;
275 case GL_PIXEL_MAP_R_TO_R:
276 p->mapRtoRsize = mapsize;
277 if (!unpackbuffer)
278 for (i=0;i<mapsize;i++) {
279 p->mapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F );
280 }
281 break;
282 case GL_PIXEL_MAP_G_TO_G:
283 p->mapGtoGsize = mapsize;
284 if (!unpackbuffer)
285 for (i=0;i<mapsize;i++) {
286 p->mapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F );
287 }
288 break;
289 case GL_PIXEL_MAP_B_TO_B:
290 p->mapBtoBsize = mapsize;
291 if (!unpackbuffer)
292 for (i=0;i<mapsize;i++) {
293 p->mapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F );
294 }
295 break;
296 case GL_PIXEL_MAP_A_TO_A:
297 p->mapAtoAsize = mapsize;
298 if (!unpackbuffer)
299 for (i=0;i<mapsize;i++) {
300 p->mapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F );
301 }
302 break;
303 default:
304 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "PixelMap(map)");
305 return;
306 }
307
308 DIRTY(pb->maps, g->neg_bitid);
309 DIRTY(pb->dirty, g->neg_bitid);
310}
311
312void STATE_APIENTRY crStatePixelMapuiv (GLenum map, GLint mapsize, const GLuint * values)
313{
314 if (mapsize < 0 || mapsize > CR_MAX_PIXEL_MAP_TABLE)
315 {
316 crError("crStatePixelMapuiv: parameter 'mapsize' is out of range");
317 return;
318 }
319
320 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
321 {
322 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE];
323 GLint i;
324
325 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
326 for (i=0;i<mapsize;i++) {
327 fvalues[i] = (GLfloat) values[i];
328 }
329 }
330 else {
331 for (i=0;i<mapsize;i++) {
332 fvalues[i] = values[i] / 4294967295.0F;
333 }
334 }
335 crStatePixelMapfv(map, mapsize, fvalues);
336 }
337 else
338 {
339 crStatePixelMapfv(map, mapsize, (const GLfloat*) values);
340 }
341}
342
343void STATE_APIENTRY crStatePixelMapusv (GLenum map, GLint mapsize, const GLushort * values)
344{
345 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE];
346 GLint i;
347
348 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
349 {
350 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
351 for (i=0;i<mapsize;i++) {
352 fvalues[i] = (GLfloat) values[i];
353 }
354 }
355 else {
356 for (i=0;i<mapsize;i++) {
357 fvalues[i] = values[i] / 65535.0F;
358 }
359 }
360 crStatePixelMapfv(map, mapsize, fvalues);
361 }
362 else
363 {
364 crStatePixelMapfv(map, mapsize, (const GLfloat*) values);
365 }
366}
367
368
369void STATE_APIENTRY crStateGetPixelMapfv (GLenum map, GLfloat * values)
370{
371 CRContext *g = GetCurrentContext();
372 CRPixelState *p = &(g->pixel);
373 GLint i;
374
375 if (g->current.inBeginEnd) {
376 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
377 "GetPixelMapfv called in Begin/End");
378 return;
379 }
380
381 switch (map) {
382 case GL_PIXEL_MAP_S_TO_S:
383 for (i = 0; i < p->mapStoSsize; i++) {
384 values[i] = (GLfloat) p->mapStoS[i];
385 }
386 break;
387 case GL_PIXEL_MAP_I_TO_I:
388 for (i = 0; i < p->mapItoIsize; i++) {
389 values[i] = (GLfloat) p->mapItoI[i];
390 }
391 break;
392 case GL_PIXEL_MAP_I_TO_R:
393 crMemcpy(values, p->mapItoR, p->mapItoRsize * sizeof(GLfloat));
394 break;
395 case GL_PIXEL_MAP_I_TO_G:
396 crMemcpy(values, p->mapItoG, p->mapItoGsize * sizeof(GLfloat));
397 break;
398 case GL_PIXEL_MAP_I_TO_B:
399 crMemcpy(values, p->mapItoB, p->mapItoBsize * sizeof(GLfloat));
400 break;
401 case GL_PIXEL_MAP_I_TO_A:
402 crMemcpy(values, p->mapItoA, p->mapItoAsize * sizeof(GLfloat));
403 break;
404 case GL_PIXEL_MAP_R_TO_R:
405 crMemcpy(values, p->mapRtoR, p->mapRtoRsize * sizeof(GLfloat));
406 break;
407 case GL_PIXEL_MAP_G_TO_G:
408 crMemcpy(values, p->mapGtoG, p->mapGtoGsize * sizeof(GLfloat));
409 break;
410 case GL_PIXEL_MAP_B_TO_B:
411 crMemcpy(values, p->mapBtoB, p->mapBtoBsize * sizeof(GLfloat));
412 break;
413 case GL_PIXEL_MAP_A_TO_A:
414 crMemcpy(values, p->mapAtoA, p->mapAtoAsize * sizeof(GLfloat));
415 break;
416 default:
417 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMap(map)");
418 return;
419 }
420}
421
422void STATE_APIENTRY crStateGetPixelMapuiv (GLenum map, GLuint * values)
423{
424 CRContext *g = GetCurrentContext();
425 const GLfloat maxUint = 4294967295.0F;
426 CRPixelState *p = &(g->pixel);
427 GLint i;
428
429 if (g->current.inBeginEnd) {
430 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
431 "GetPixelMapuiv called in Begin/End");
432 return;
433 }
434
435 switch (map) {
436 case GL_PIXEL_MAP_S_TO_S:
437 for (i = 0; i < p->mapStoSsize; i++) {
438 values[i] = p->mapStoS[i];
439 }
440 break;
441 case GL_PIXEL_MAP_I_TO_I:
442 for (i = 0; i < p->mapItoIsize; i++) {
443 values[i] = p->mapItoI[i];
444 }
445 break;
446 case GL_PIXEL_MAP_I_TO_R:
447 for (i = 0; i < p->mapItoRsize; i++) {
448 values[i] = (GLuint) (p->mapItoR[i] * maxUint);
449 }
450 break;
451 case GL_PIXEL_MAP_I_TO_G:
452 for (i = 0; i < p->mapItoGsize; i++) {
453 values[i] = (GLuint) (p->mapItoG[i] * maxUint);
454 }
455 break;
456 case GL_PIXEL_MAP_I_TO_B:
457 for (i = 0; i < p->mapItoBsize; i++) {
458 values[i] = (GLuint) (p->mapItoB[i] * maxUint);
459 }
460 break;
461 case GL_PIXEL_MAP_I_TO_A:
462 for (i = 0; i < p->mapItoAsize; i++) {
463 values[i] = (GLuint) (p->mapItoA[i] * maxUint);
464 }
465 break;
466 case GL_PIXEL_MAP_R_TO_R:
467 for (i = 0; i < p->mapRtoRsize; i++) {
468 values[i] = (GLuint) (p->mapRtoR[i] * maxUint);
469 }
470 break;
471 case GL_PIXEL_MAP_G_TO_G:
472 for (i = 0; i < p->mapGtoGsize; i++) {
473 values[i] = (GLuint) (p->mapGtoG[i] * maxUint);
474 }
475 break;
476 case GL_PIXEL_MAP_B_TO_B:
477 for (i = 0; i < p->mapBtoBsize; i++) {
478 values[i] = (GLuint) (p->mapBtoB[i] * maxUint);
479 }
480 break;
481 case GL_PIXEL_MAP_A_TO_A:
482 for (i = 0; i < p->mapAtoAsize; i++) {
483 values[i] = (GLuint) (p->mapAtoA[i] * maxUint);
484 }
485 break;
486 default:
487 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapuiv(map)");
488 return;
489 }
490}
491
492void STATE_APIENTRY crStateGetPixelMapusv (GLenum map, GLushort * values)
493{
494 CRContext *g = GetCurrentContext();
495 const GLfloat maxUshort = 65535.0F;
496 CRPixelState *p = &(g->pixel);
497 GLint i;
498
499 if (g->current.inBeginEnd) {
500 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
501 "GetPixelMapusv called in Begin/End");
502 return;
503 }
504
505 switch (map) {
506 case GL_PIXEL_MAP_S_TO_S:
507 for (i = 0; i < p->mapStoSsize; i++) {
508 values[i] = p->mapStoS[i];
509 }
510 break;
511 case GL_PIXEL_MAP_I_TO_I:
512 for (i = 0; i < p->mapItoIsize; i++) {
513 values[i] = p->mapItoI[i];
514 }
515 break;
516 case GL_PIXEL_MAP_I_TO_R:
517 for (i = 0; i < p->mapItoRsize; i++) {
518 values[i] = (GLushort) (p->mapItoR[i] * maxUshort);
519 }
520 break;
521 case GL_PIXEL_MAP_I_TO_G:
522 for (i = 0; i < p->mapItoGsize; i++) {
523 values[i] = (GLushort) (p->mapItoG[i] * maxUshort);
524 }
525 break;
526 case GL_PIXEL_MAP_I_TO_B:
527 for (i = 0; i < p->mapItoBsize; i++) {
528 values[i] = (GLushort) (p->mapItoB[i] * maxUshort);
529 }
530 break;
531 case GL_PIXEL_MAP_I_TO_A:
532 for (i = 0; i < p->mapItoAsize; i++) {
533 values[i] = (GLushort) (p->mapItoA[i] * maxUshort);
534 }
535 break;
536 case GL_PIXEL_MAP_R_TO_R:
537 for (i = 0; i < p->mapRtoRsize; i++) {
538 values[i] = (GLushort) (p->mapRtoR[i] * maxUshort);
539 }
540 break;
541 case GL_PIXEL_MAP_G_TO_G:
542 for (i = 0; i < p->mapGtoGsize; i++) {
543 values[i] = (GLushort) (p->mapGtoG[i] * maxUshort);
544 }
545 break;
546 case GL_PIXEL_MAP_B_TO_B:
547 for (i = 0; i < p->mapBtoBsize; i++) {
548 values[i] = (GLushort) (p->mapBtoB[i] * maxUshort);
549 }
550 break;
551 case GL_PIXEL_MAP_A_TO_A:
552 for (i = 0; i < p->mapAtoAsize; i++) {
553 values[i] = (GLushort) (p->mapAtoA[i] * maxUshort);
554 }
555 break;
556 default:
557 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapusv(map)");
558 return;
559 }
560}
561
562void crStatePixelDiff(CRPixelBits *b, CRbitvalue *bitID,
563 CRContext *fromCtx, CRContext *toCtx)
564{
565 CRPixelState *from = &(fromCtx->pixel);
566 CRPixelState *to = &(toCtx->pixel);
567 int j, i;
568 CRbitvalue nbitID[CR_MAX_BITARRAY];
569 for (j=0;j<CR_MAX_BITARRAY;j++)
570 nbitID[j] = ~bitID[j];
571 i = 0; /* silence compiler */
572 if (CHECKDIRTY(b->transfer, bitID))
573 {
574 if (from->mapColor != to->mapColor)
575 {
576 diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor);
577 from->mapColor = to->mapColor;
578 }
579 if (from->mapStencil != to->mapStencil)
580 {
581 diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil);
582 from->mapStencil = to->mapStencil;
583 }
584 if (from->indexOffset != to->indexOffset)
585 {
586 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset);
587 from->indexOffset = to->indexOffset;
588 }
589 if (from->indexShift != to->indexShift)
590 {
591 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift);
592 from->indexShift = to->indexShift;
593 }
594 if (from->scale.r != to->scale.r)
595 {
596 diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r);
597 from->scale.r = to->scale.r;
598 }
599 if (from->scale.g != to->scale.g)
600 {
601 diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g);
602 from->scale.g = to->scale.g;
603 }
604 if (from->scale.b != to->scale.b)
605 {
606 diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b);
607 from->scale.b = to->scale.b;
608 }
609 if (from->scale.a != to->scale.a)
610 {
611 diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a);
612 from->scale.a = to->scale.a;
613 }
614 if (from->bias.r != to->bias.r)
615 {
616 diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r);
617 from->bias.r = to->bias.r;
618 }
619 if (from->bias.g != to->bias.g)
620 {
621 diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g);
622 from->bias.g = to->bias.g;
623 }
624 if (from->bias.b != to->bias.b)
625 {
626 diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b);
627 from->bias.b = to->bias.b;
628 }
629 if (from->bias.a != to->bias.a)
630 {
631 diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a);
632 from->bias.a = to->bias.a;
633 }
634 if (from->depthScale != to->depthScale)
635 {
636 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale);
637 from->depthScale = to->depthScale;
638 }
639 if (from->depthBias != to->depthBias)
640 {
641 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias);
642 from->depthBias = to->depthBias;
643 }
644 CLEARDIRTY(b->transfer, nbitID);
645 }
646 if (CHECKDIRTY(b->zoom, bitID))
647 {
648 if (from->xZoom != to->xZoom ||
649 from->yZoom != to->yZoom)
650 {
651 diff_api.PixelZoom (to->xZoom,
652 to->yZoom);
653 from->xZoom = to->xZoom;
654 from->yZoom = to->yZoom;
655 }
656 CLEARDIRTY(b->zoom, nbitID);
657 }
658 if (CHECKDIRTY(b->maps, bitID))
659 {
660 if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
661 diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS);
662 if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
663 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI);
664 if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
665 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR);
666 if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
667 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG);
668 if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
669 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB);
670 if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
671 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA);
672 if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
673 diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR);
674 if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
675 diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG);
676 if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
677 diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB);
678 if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
679 diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA);
680 CLEARDIRTY(b->maps, nbitID);
681 }
682 CLEARDIRTY(b->dirty, nbitID);
683}
684
685void crStatePixelSwitch(CRPixelBits *b, CRbitvalue *bitID,
686 CRContext *fromCtx, CRContext *toCtx)
687{
688 CRPixelState *from = &(fromCtx->pixel);
689 CRPixelState *to = &(toCtx->pixel);
690 int j, i;
691 CRbitvalue nbitID[CR_MAX_BITARRAY];
692 for (j=0;j<CR_MAX_BITARRAY;j++)
693 nbitID[j] = ~bitID[j];
694 i = 0; /* silence compiler */
695 if (CHECKDIRTY(b->transfer, bitID))
696 {
697 if (from->mapColor != to->mapColor)
698 {
699 diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor);
700 FILLDIRTY(b->transfer);
701 FILLDIRTY(b->dirty);
702 }
703 if (from->mapStencil != to->mapStencil)
704 {
705 diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil);
706 FILLDIRTY(b->transfer);
707 FILLDIRTY(b->dirty);
708 }
709 if (from->indexOffset != to->indexOffset)
710 {
711 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset);
712 FILLDIRTY(b->transfer);
713 FILLDIRTY(b->dirty);
714 }
715 if (from->indexShift != to->indexShift)
716 {
717 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift);
718 FILLDIRTY(b->transfer);
719 FILLDIRTY(b->dirty);
720 }
721 if (from->scale.r != to->scale.r)
722 {
723 diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r);
724 FILLDIRTY(b->transfer);
725 FILLDIRTY(b->dirty);
726 }
727 if (from->scale.g != to->scale.g)
728 {
729 diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g);
730 FILLDIRTY(b->transfer);
731 FILLDIRTY(b->dirty);
732 }
733 if (from->scale.b != to->scale.b)
734 {
735 diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b);
736 FILLDIRTY(b->transfer);
737 FILLDIRTY(b->dirty);
738 }
739 if (from->scale.a != to->scale.a)
740 {
741 diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a);
742 FILLDIRTY(b->transfer);
743 FILLDIRTY(b->dirty);
744 }
745 if (from->bias.r != to->bias.r)
746 {
747 diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r);
748 FILLDIRTY(b->transfer);
749 FILLDIRTY(b->dirty);
750 }
751 if (from->bias.g != to->bias.g)
752 {
753 diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g);
754 FILLDIRTY(b->transfer);
755 FILLDIRTY(b->dirty);
756 }
757 if (from->bias.b != to->bias.b)
758 {
759 diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b);
760 FILLDIRTY(b->transfer);
761 FILLDIRTY(b->dirty);
762 }
763 if (from->bias.a != to->bias.a)
764 {
765 diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a);
766 FILLDIRTY(b->transfer);
767 FILLDIRTY(b->dirty);
768 }
769 if (from->depthScale != to->depthScale)
770 {
771 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale);
772 FILLDIRTY(b->transfer);
773 FILLDIRTY(b->dirty);
774 }
775 if (from->depthBias != to->depthBias)
776 {
777 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias);
778 FILLDIRTY(b->transfer);
779 FILLDIRTY(b->dirty);
780 }
781 CLEARDIRTY(b->transfer, nbitID);
782 }
783 if (CHECKDIRTY(b->zoom, bitID))
784 {
785 if (from->xZoom != to->xZoom ||
786 from->yZoom != to->yZoom)
787 {
788 diff_api.PixelZoom (to->xZoom,
789 to->yZoom);
790 FILLDIRTY(b->zoom);
791 FILLDIRTY(b->dirty);
792 }
793 CLEARDIRTY(b->zoom, nbitID);
794 }
795 if (CHECKDIRTY(b->maps, bitID))
796 {
797 if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE)) {
798 diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS);
799 FILLDIRTY(b->maps);
800 FILLDIRTY(b->dirty);
801 }
802 if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE)) {
803 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI);
804 FILLDIRTY(b->maps);
805 FILLDIRTY(b->dirty);
806 }
807 if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE)) {
808 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR);
809 FILLDIRTY(b->maps);
810 FILLDIRTY(b->dirty);
811 }
812 if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE)) {
813 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG);
814 FILLDIRTY(b->maps);
815 FILLDIRTY(b->dirty);
816 }
817 if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE)) {
818 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB);
819 FILLDIRTY(b->maps);
820 FILLDIRTY(b->dirty);
821 }
822 if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE)) {
823 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA);
824 FILLDIRTY(b->maps);
825 FILLDIRTY(b->dirty);
826 }
827 if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE)) {
828 diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR);
829 FILLDIRTY(b->maps);
830 FILLDIRTY(b->dirty);
831 }
832 if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE)) {
833 diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG);
834 FILLDIRTY(b->maps);
835 FILLDIRTY(b->dirty);
836 }
837 if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE)) {
838 diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB);
839 FILLDIRTY(b->maps);
840 FILLDIRTY(b->dirty);
841 }
842 if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE)) {
843 diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA);
844 FILLDIRTY(b->maps);
845 FILLDIRTY(b->dirty);
846 }
847 CLEARDIRTY(b->maps, nbitID);
848 }
849 CLEARDIRTY(b->dirty, nbitID);
850}
851
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette