VirtualBox

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

最後變更 在這個檔案從76811是 74890,由 vboxsync 提交於 6 年 前

3D: Memory allocations fixed, bugref:9251. Merged changes r125768, r125779, r125780, r125812.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Id Revision
檔案大小: 26.9 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 if (mapsize < 0 || mapsize > CR_MAX_PIXEL_MAP_TABLE)
346 {
347 crError("crStatePixelMapusv: parameter 'mapsize' is out of range");
348 return;
349 }
350
351 if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB))
352 {
353 GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE];
354 GLint i;
355
356 if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
357 for (i=0;i<mapsize;i++) {
358 fvalues[i] = (GLfloat) values[i];
359 }
360 }
361 else {
362 for (i=0;i<mapsize;i++) {
363 fvalues[i] = values[i] / 65535.0F;
364 }
365 }
366 crStatePixelMapfv(map, mapsize, fvalues);
367 }
368 else
369 {
370 crStatePixelMapfv(map, mapsize, (const GLfloat*) values);
371 }
372}
373
374
375void STATE_APIENTRY crStateGetPixelMapfv (GLenum map, GLfloat * values)
376{
377 CRContext *g = GetCurrentContext();
378 CRPixelState *p = &(g->pixel);
379 GLint i;
380
381 if (g->current.inBeginEnd) {
382 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
383 "GetPixelMapfv called in Begin/End");
384 return;
385 }
386
387 switch (map) {
388 case GL_PIXEL_MAP_S_TO_S:
389 for (i = 0; i < p->mapStoSsize; i++) {
390 values[i] = (GLfloat) p->mapStoS[i];
391 }
392 break;
393 case GL_PIXEL_MAP_I_TO_I:
394 for (i = 0; i < p->mapItoIsize; i++) {
395 values[i] = (GLfloat) p->mapItoI[i];
396 }
397 break;
398 case GL_PIXEL_MAP_I_TO_R:
399 crMemcpy(values, p->mapItoR, p->mapItoRsize * sizeof(GLfloat));
400 break;
401 case GL_PIXEL_MAP_I_TO_G:
402 crMemcpy(values, p->mapItoG, p->mapItoGsize * sizeof(GLfloat));
403 break;
404 case GL_PIXEL_MAP_I_TO_B:
405 crMemcpy(values, p->mapItoB, p->mapItoBsize * sizeof(GLfloat));
406 break;
407 case GL_PIXEL_MAP_I_TO_A:
408 crMemcpy(values, p->mapItoA, p->mapItoAsize * sizeof(GLfloat));
409 break;
410 case GL_PIXEL_MAP_R_TO_R:
411 crMemcpy(values, p->mapRtoR, p->mapRtoRsize * sizeof(GLfloat));
412 break;
413 case GL_PIXEL_MAP_G_TO_G:
414 crMemcpy(values, p->mapGtoG, p->mapGtoGsize * sizeof(GLfloat));
415 break;
416 case GL_PIXEL_MAP_B_TO_B:
417 crMemcpy(values, p->mapBtoB, p->mapBtoBsize * sizeof(GLfloat));
418 break;
419 case GL_PIXEL_MAP_A_TO_A:
420 crMemcpy(values, p->mapAtoA, p->mapAtoAsize * sizeof(GLfloat));
421 break;
422 default:
423 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMap(map)");
424 return;
425 }
426}
427
428void STATE_APIENTRY crStateGetPixelMapuiv (GLenum map, GLuint * values)
429{
430 CRContext *g = GetCurrentContext();
431 const GLfloat maxUint = 4294967295.0F;
432 CRPixelState *p = &(g->pixel);
433 GLint i;
434
435 if (g->current.inBeginEnd) {
436 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
437 "GetPixelMapuiv called in Begin/End");
438 return;
439 }
440
441 switch (map) {
442 case GL_PIXEL_MAP_S_TO_S:
443 for (i = 0; i < p->mapStoSsize; i++) {
444 values[i] = p->mapStoS[i];
445 }
446 break;
447 case GL_PIXEL_MAP_I_TO_I:
448 for (i = 0; i < p->mapItoIsize; i++) {
449 values[i] = p->mapItoI[i];
450 }
451 break;
452 case GL_PIXEL_MAP_I_TO_R:
453 for (i = 0; i < p->mapItoRsize; i++) {
454 values[i] = (GLuint) (p->mapItoR[i] * maxUint);
455 }
456 break;
457 case GL_PIXEL_MAP_I_TO_G:
458 for (i = 0; i < p->mapItoGsize; i++) {
459 values[i] = (GLuint) (p->mapItoG[i] * maxUint);
460 }
461 break;
462 case GL_PIXEL_MAP_I_TO_B:
463 for (i = 0; i < p->mapItoBsize; i++) {
464 values[i] = (GLuint) (p->mapItoB[i] * maxUint);
465 }
466 break;
467 case GL_PIXEL_MAP_I_TO_A:
468 for (i = 0; i < p->mapItoAsize; i++) {
469 values[i] = (GLuint) (p->mapItoA[i] * maxUint);
470 }
471 break;
472 case GL_PIXEL_MAP_R_TO_R:
473 for (i = 0; i < p->mapRtoRsize; i++) {
474 values[i] = (GLuint) (p->mapRtoR[i] * maxUint);
475 }
476 break;
477 case GL_PIXEL_MAP_G_TO_G:
478 for (i = 0; i < p->mapGtoGsize; i++) {
479 values[i] = (GLuint) (p->mapGtoG[i] * maxUint);
480 }
481 break;
482 case GL_PIXEL_MAP_B_TO_B:
483 for (i = 0; i < p->mapBtoBsize; i++) {
484 values[i] = (GLuint) (p->mapBtoB[i] * maxUint);
485 }
486 break;
487 case GL_PIXEL_MAP_A_TO_A:
488 for (i = 0; i < p->mapAtoAsize; i++) {
489 values[i] = (GLuint) (p->mapAtoA[i] * maxUint);
490 }
491 break;
492 default:
493 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapuiv(map)");
494 return;
495 }
496}
497
498void STATE_APIENTRY crStateGetPixelMapusv (GLenum map, GLushort * values)
499{
500 CRContext *g = GetCurrentContext();
501 const GLfloat maxUshort = 65535.0F;
502 CRPixelState *p = &(g->pixel);
503 GLint i;
504
505 if (g->current.inBeginEnd) {
506 crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION,
507 "GetPixelMapusv called in Begin/End");
508 return;
509 }
510
511 switch (map) {
512 case GL_PIXEL_MAP_S_TO_S:
513 for (i = 0; i < p->mapStoSsize; i++) {
514 values[i] = p->mapStoS[i];
515 }
516 break;
517 case GL_PIXEL_MAP_I_TO_I:
518 for (i = 0; i < p->mapItoIsize; i++) {
519 values[i] = p->mapItoI[i];
520 }
521 break;
522 case GL_PIXEL_MAP_I_TO_R:
523 for (i = 0; i < p->mapItoRsize; i++) {
524 values[i] = (GLushort) (p->mapItoR[i] * maxUshort);
525 }
526 break;
527 case GL_PIXEL_MAP_I_TO_G:
528 for (i = 0; i < p->mapItoGsize; i++) {
529 values[i] = (GLushort) (p->mapItoG[i] * maxUshort);
530 }
531 break;
532 case GL_PIXEL_MAP_I_TO_B:
533 for (i = 0; i < p->mapItoBsize; i++) {
534 values[i] = (GLushort) (p->mapItoB[i] * maxUshort);
535 }
536 break;
537 case GL_PIXEL_MAP_I_TO_A:
538 for (i = 0; i < p->mapItoAsize; i++) {
539 values[i] = (GLushort) (p->mapItoA[i] * maxUshort);
540 }
541 break;
542 case GL_PIXEL_MAP_R_TO_R:
543 for (i = 0; i < p->mapRtoRsize; i++) {
544 values[i] = (GLushort) (p->mapRtoR[i] * maxUshort);
545 }
546 break;
547 case GL_PIXEL_MAP_G_TO_G:
548 for (i = 0; i < p->mapGtoGsize; i++) {
549 values[i] = (GLushort) (p->mapGtoG[i] * maxUshort);
550 }
551 break;
552 case GL_PIXEL_MAP_B_TO_B:
553 for (i = 0; i < p->mapBtoBsize; i++) {
554 values[i] = (GLushort) (p->mapBtoB[i] * maxUshort);
555 }
556 break;
557 case GL_PIXEL_MAP_A_TO_A:
558 for (i = 0; i < p->mapAtoAsize; i++) {
559 values[i] = (GLushort) (p->mapAtoA[i] * maxUshort);
560 }
561 break;
562 default:
563 crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapusv(map)");
564 return;
565 }
566}
567
568void crStatePixelDiff(CRPixelBits *b, CRbitvalue *bitID,
569 CRContext *fromCtx, CRContext *toCtx)
570{
571 CRPixelState *from = &(fromCtx->pixel);
572 CRPixelState *to = &(toCtx->pixel);
573 int j, i;
574 CRbitvalue nbitID[CR_MAX_BITARRAY];
575 for (j=0;j<CR_MAX_BITARRAY;j++)
576 nbitID[j] = ~bitID[j];
577 i = 0; /* silence compiler */
578 if (CHECKDIRTY(b->transfer, bitID))
579 {
580 if (from->mapColor != to->mapColor)
581 {
582 diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor);
583 from->mapColor = to->mapColor;
584 }
585 if (from->mapStencil != to->mapStencil)
586 {
587 diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil);
588 from->mapStencil = to->mapStencil;
589 }
590 if (from->indexOffset != to->indexOffset)
591 {
592 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset);
593 from->indexOffset = to->indexOffset;
594 }
595 if (from->indexShift != to->indexShift)
596 {
597 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift);
598 from->indexShift = to->indexShift;
599 }
600 if (from->scale.r != to->scale.r)
601 {
602 diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r);
603 from->scale.r = to->scale.r;
604 }
605 if (from->scale.g != to->scale.g)
606 {
607 diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g);
608 from->scale.g = to->scale.g;
609 }
610 if (from->scale.b != to->scale.b)
611 {
612 diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b);
613 from->scale.b = to->scale.b;
614 }
615 if (from->scale.a != to->scale.a)
616 {
617 diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a);
618 from->scale.a = to->scale.a;
619 }
620 if (from->bias.r != to->bias.r)
621 {
622 diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r);
623 from->bias.r = to->bias.r;
624 }
625 if (from->bias.g != to->bias.g)
626 {
627 diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g);
628 from->bias.g = to->bias.g;
629 }
630 if (from->bias.b != to->bias.b)
631 {
632 diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b);
633 from->bias.b = to->bias.b;
634 }
635 if (from->bias.a != to->bias.a)
636 {
637 diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a);
638 from->bias.a = to->bias.a;
639 }
640 if (from->depthScale != to->depthScale)
641 {
642 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale);
643 from->depthScale = to->depthScale;
644 }
645 if (from->depthBias != to->depthBias)
646 {
647 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias);
648 from->depthBias = to->depthBias;
649 }
650 CLEARDIRTY(b->transfer, nbitID);
651 }
652 if (CHECKDIRTY(b->zoom, bitID))
653 {
654 if (from->xZoom != to->xZoom ||
655 from->yZoom != to->yZoom)
656 {
657 diff_api.PixelZoom (to->xZoom,
658 to->yZoom);
659 from->xZoom = to->xZoom;
660 from->yZoom = to->yZoom;
661 }
662 CLEARDIRTY(b->zoom, nbitID);
663 }
664 if (CHECKDIRTY(b->maps, bitID))
665 {
666 if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
667 diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS);
668 if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
669 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI);
670 if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
671 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR);
672 if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
673 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG);
674 if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
675 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB);
676 if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
677 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA);
678 if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
679 diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR);
680 if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
681 diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG);
682 if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
683 diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB);
684 if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat)))
685 diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA);
686 CLEARDIRTY(b->maps, nbitID);
687 }
688 CLEARDIRTY(b->dirty, nbitID);
689}
690
691void crStatePixelSwitch(CRPixelBits *b, CRbitvalue *bitID,
692 CRContext *fromCtx, CRContext *toCtx)
693{
694 CRPixelState *from = &(fromCtx->pixel);
695 CRPixelState *to = &(toCtx->pixel);
696 int j, i;
697 CRbitvalue nbitID[CR_MAX_BITARRAY];
698 for (j=0;j<CR_MAX_BITARRAY;j++)
699 nbitID[j] = ~bitID[j];
700 i = 0; /* silence compiler */
701 if (CHECKDIRTY(b->transfer, bitID))
702 {
703 if (from->mapColor != to->mapColor)
704 {
705 diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor);
706 FILLDIRTY(b->transfer);
707 FILLDIRTY(b->dirty);
708 }
709 if (from->mapStencil != to->mapStencil)
710 {
711 diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil);
712 FILLDIRTY(b->transfer);
713 FILLDIRTY(b->dirty);
714 }
715 if (from->indexOffset != to->indexOffset)
716 {
717 diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset);
718 FILLDIRTY(b->transfer);
719 FILLDIRTY(b->dirty);
720 }
721 if (from->indexShift != to->indexShift)
722 {
723 diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift);
724 FILLDIRTY(b->transfer);
725 FILLDIRTY(b->dirty);
726 }
727 if (from->scale.r != to->scale.r)
728 {
729 diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r);
730 FILLDIRTY(b->transfer);
731 FILLDIRTY(b->dirty);
732 }
733 if (from->scale.g != to->scale.g)
734 {
735 diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g);
736 FILLDIRTY(b->transfer);
737 FILLDIRTY(b->dirty);
738 }
739 if (from->scale.b != to->scale.b)
740 {
741 diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b);
742 FILLDIRTY(b->transfer);
743 FILLDIRTY(b->dirty);
744 }
745 if (from->scale.a != to->scale.a)
746 {
747 diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a);
748 FILLDIRTY(b->transfer);
749 FILLDIRTY(b->dirty);
750 }
751 if (from->bias.r != to->bias.r)
752 {
753 diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r);
754 FILLDIRTY(b->transfer);
755 FILLDIRTY(b->dirty);
756 }
757 if (from->bias.g != to->bias.g)
758 {
759 diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g);
760 FILLDIRTY(b->transfer);
761 FILLDIRTY(b->dirty);
762 }
763 if (from->bias.b != to->bias.b)
764 {
765 diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b);
766 FILLDIRTY(b->transfer);
767 FILLDIRTY(b->dirty);
768 }
769 if (from->bias.a != to->bias.a)
770 {
771 diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a);
772 FILLDIRTY(b->transfer);
773 FILLDIRTY(b->dirty);
774 }
775 if (from->depthScale != to->depthScale)
776 {
777 diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale);
778 FILLDIRTY(b->transfer);
779 FILLDIRTY(b->dirty);
780 }
781 if (from->depthBias != to->depthBias)
782 {
783 diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias);
784 FILLDIRTY(b->transfer);
785 FILLDIRTY(b->dirty);
786 }
787 CLEARDIRTY(b->transfer, nbitID);
788 }
789 if (CHECKDIRTY(b->zoom, bitID))
790 {
791 if (from->xZoom != to->xZoom ||
792 from->yZoom != to->yZoom)
793 {
794 diff_api.PixelZoom (to->xZoom,
795 to->yZoom);
796 FILLDIRTY(b->zoom);
797 FILLDIRTY(b->dirty);
798 }
799 CLEARDIRTY(b->zoom, nbitID);
800 }
801 if (CHECKDIRTY(b->maps, bitID))
802 {
803 if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE)) {
804 diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS);
805 FILLDIRTY(b->maps);
806 FILLDIRTY(b->dirty);
807 }
808 if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE)) {
809 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI);
810 FILLDIRTY(b->maps);
811 FILLDIRTY(b->dirty);
812 }
813 if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE)) {
814 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR);
815 FILLDIRTY(b->maps);
816 FILLDIRTY(b->dirty);
817 }
818 if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE)) {
819 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG);
820 FILLDIRTY(b->maps);
821 FILLDIRTY(b->dirty);
822 }
823 if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE)) {
824 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB);
825 FILLDIRTY(b->maps);
826 FILLDIRTY(b->dirty);
827 }
828 if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE)) {
829 diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA);
830 FILLDIRTY(b->maps);
831 FILLDIRTY(b->dirty);
832 }
833 if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE)) {
834 diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR);
835 FILLDIRTY(b->maps);
836 FILLDIRTY(b->dirty);
837 }
838 if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE)) {
839 diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG);
840 FILLDIRTY(b->maps);
841 FILLDIRTY(b->dirty);
842 }
843 if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE)) {
844 diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB);
845 FILLDIRTY(b->maps);
846 FILLDIRTY(b->dirty);
847 }
848 if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE)) {
849 diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA);
850 FILLDIRTY(b->maps);
851 FILLDIRTY(b->dirty);
852 }
853 CLEARDIRTY(b->maps, nbitID);
854 }
855 CLEARDIRTY(b->dirty, nbitID);
856}
857
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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