Changeset 38298 in vbox for trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c
- Timestamp:
- Aug 3, 2011 11:20:01 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/crOpenGL/pack/packspu_pixel.c
r35263 r38298 175 175 } 176 176 177 static const CRPixelPackState _defaultPacking = { 178 0, /* rowLength */ 179 0, /* skipRows */ 180 0, /* skipPixels */ 181 1, /* alignment */ 182 0, /* imageHeight */ 183 0, /* skipImages */ 184 GL_FALSE, /* swapBytes */ 185 GL_FALSE, /* psLSBFirst */ 186 }; 187 188 #define APPLY_IF_NEQ(state, field, enum) \ 189 if (state.field != _defaultPacking.field) \ 190 { \ 191 crPackPixelStorei(enum, state.field); \ 192 } 193 194 #define RESTORE_IF_NEQ(state, field, enum) \ 195 if (state.field != _defaultPacking.field) \ 196 { \ 197 crPackPixelStorei(enum, _defaultPacking.field); \ 198 } 199 200 static void packspu_ApplyUnpackState() 201 { 202 GET_THREAD(thread); 203 ContextInfo *ctx = thread->currentContext; 204 CRClientState *clientState = &(ctx->clientState->client); 205 206 APPLY_IF_NEQ(clientState->unpack, rowLength, GL_UNPACK_ROW_LENGTH); 207 APPLY_IF_NEQ(clientState->unpack, skipRows, GL_UNPACK_SKIP_ROWS); 208 APPLY_IF_NEQ(clientState->unpack, skipPixels, GL_UNPACK_SKIP_PIXELS); 209 APPLY_IF_NEQ(clientState->unpack, alignment, GL_UNPACK_ALIGNMENT); 210 APPLY_IF_NEQ(clientState->unpack, imageHeight, GL_UNPACK_IMAGE_HEIGHT); 211 APPLY_IF_NEQ(clientState->unpack, skipImages, GL_UNPACK_SKIP_IMAGES); 212 APPLY_IF_NEQ(clientState->unpack, swapBytes, GL_UNPACK_SWAP_BYTES); 213 APPLY_IF_NEQ(clientState->unpack, psLSBFirst, GL_UNPACK_LSB_FIRST); 214 } 215 216 static void packspu_RestoreUnpackState() 217 { 218 GET_THREAD(thread); 219 ContextInfo *ctx = thread->currentContext; 220 CRClientState *clientState = &(ctx->clientState->client); 221 222 RESTORE_IF_NEQ(clientState->unpack, rowLength, GL_UNPACK_ROW_LENGTH); 223 RESTORE_IF_NEQ(clientState->unpack, skipRows, GL_UNPACK_SKIP_ROWS); 224 RESTORE_IF_NEQ(clientState->unpack, skipPixels, GL_UNPACK_SKIP_PIXELS); 225 RESTORE_IF_NEQ(clientState->unpack, alignment, GL_UNPACK_ALIGNMENT); 226 RESTORE_IF_NEQ(clientState->unpack, imageHeight, GL_UNPACK_IMAGE_HEIGHT); 227 RESTORE_IF_NEQ(clientState->unpack, skipImages, GL_UNPACK_SKIP_IMAGES); 228 RESTORE_IF_NEQ(clientState->unpack, swapBytes, GL_UNPACK_SWAP_BYTES); 229 RESTORE_IF_NEQ(clientState->unpack, psLSBFirst, GL_UNPACK_LSB_FIRST); 230 } 231 232 static void packspu_ApplyPackState() 233 { 234 GET_THREAD(thread); 235 ContextInfo *ctx = thread->currentContext; 236 CRClientState *clientState = &(ctx->clientState->client); 237 238 APPLY_IF_NEQ(clientState->pack, rowLength, GL_PACK_ROW_LENGTH); 239 APPLY_IF_NEQ(clientState->pack, skipRows, GL_PACK_SKIP_ROWS); 240 APPLY_IF_NEQ(clientState->pack, skipPixels, GL_PACK_SKIP_PIXELS); 241 APPLY_IF_NEQ(clientState->pack, alignment, GL_PACK_ALIGNMENT); 242 APPLY_IF_NEQ(clientState->pack, imageHeight, GL_PACK_IMAGE_HEIGHT); 243 APPLY_IF_NEQ(clientState->pack, skipImages, GL_PACK_SKIP_IMAGES); 244 APPLY_IF_NEQ(clientState->pack, swapBytes, GL_PACK_SWAP_BYTES); 245 APPLY_IF_NEQ(clientState->pack, psLSBFirst, GL_PACK_LSB_FIRST); 246 } 247 248 static void packspu_RestorePackState() 249 { 250 GET_THREAD(thread); 251 ContextInfo *ctx = thread->currentContext; 252 CRClientState *clientState = &(ctx->clientState->client); 253 254 RESTORE_IF_NEQ(clientState->pack, rowLength, GL_PACK_ROW_LENGTH); 255 RESTORE_IF_NEQ(clientState->pack, skipRows, GL_PACK_SKIP_ROWS); 256 RESTORE_IF_NEQ(clientState->pack, skipPixels, GL_PACK_SKIP_PIXELS); 257 RESTORE_IF_NEQ(clientState->pack, alignment, GL_PACK_ALIGNMENT); 258 RESTORE_IF_NEQ(clientState->pack, imageHeight, GL_PACK_IMAGE_HEIGHT); 259 RESTORE_IF_NEQ(clientState->pack, skipImages, GL_PACK_SKIP_IMAGES); 260 RESTORE_IF_NEQ(clientState->pack, swapBytes, GL_PACK_SWAP_BYTES); 261 RESTORE_IF_NEQ(clientState->pack, psLSBFirst, GL_PACK_LSB_FIRST); 262 } 263 177 264 void PACKSPU_APIENTRY packspu_PixelStoref( GLenum pname, GLfloat param ) 178 265 { … … 195 282 ContextInfo *ctx = thread->currentContext; 196 283 CRClientState *clientState = &(ctx->clientState->client); 197 if (pack_spu.swap) 198 crPackDrawPixelsSWAP( width, height, format, type, pixels, &(clientState->unpack) ); 199 else 200 crPackDrawPixels( width, height, format, type, pixels, &(clientState->unpack) ); 284 285 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 286 { 287 packspu_ApplyUnpackState(); 288 } 289 290 crPackDrawPixels( width, height, format, type, pixels, &(clientState->unpack) ); 291 292 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 293 { 294 packspu_RestoreUnpackState(); 295 } 201 296 } 202 297 … … 208 303 int writeback; 209 304 210 if (pack_spu.swap) 211 { 212 crPackReadPixelsSWAP(x, y, width, height, format, type, pixels, 213 &(clientState->pack), &writeback); 214 } 215 else 216 { 217 crPackReadPixels(x, y, width, height, format, type, pixels, 218 &(clientState->pack), &writeback); 305 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 306 { 307 packspu_ApplyPackState(); 308 } 309 310 crPackReadPixels(x, y, width, height, format, type, pixels, &(clientState->pack), &writeback); 311 312 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 313 { 314 packspu_RestorePackState(); 219 315 } 220 316 … … 231 327 } 232 328 329 /*@todo check with pbo's*/ 233 330 void PACKSPU_APIENTRY packspu_CopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ) 234 331 { … … 246 343 GET_CONTEXT(ctx); 247 344 CRClientState *clientState = &(ctx->clientState->client); 248 if (pack_spu.swap) 249 crPackBitmapSWAP( width, height, xorig, yorig, xmove, ymove, bitmap, &(clientState->unpack) ); 250 else 251 crPackBitmap( width, height, xorig, yorig, xmove, ymove, bitmap, &(clientState->unpack) ); 345 346 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 347 { 348 packspu_ApplyUnpackState(); 349 } 350 351 crPackBitmap(width, height, xorig, yorig, xmove, ymove, bitmap, &(clientState->unpack)); 352 353 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 354 { 355 packspu_RestoreUnpackState(); 356 } 252 357 } 253 358 … … 269 374 } 270 375 376 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 377 { 378 packspu_ApplyUnpackState(); 379 } 380 271 381 if (pack_spu.swap) 272 382 crPackTexImage1DSWAP( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) ); 273 383 else 274 384 crPackTexImage1D( target, level, internalformat, width, border, format, type, pixels, &(clientState->unpack) ); 385 386 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 387 { 388 packspu_RestoreUnpackState(); 389 } 275 390 } 276 391 … … 292 407 } 293 408 409 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 410 { 411 packspu_ApplyUnpackState(); 412 } 413 294 414 if (pack_spu.swap) 295 415 crPackTexImage2DSWAP( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) ); 296 416 else 297 417 crPackTexImage2D( target, level, internalformat, width, height, border, format, type, pixels, &(clientState->unpack) ); 418 419 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 420 { 421 packspu_RestoreUnpackState(); 422 } 298 423 } 299 424 … … 304 429 CRClientState *clientState = &(ctx->clientState->client); 305 430 431 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 432 { 433 packspu_ApplyUnpackState(); 434 } 435 306 436 if (pack_spu.swap) 307 437 crPackTexImage3DEXTSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) ); 308 438 else 309 439 crPackTexImage3DEXT( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) ); 440 441 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 442 { 443 packspu_RestoreUnpackState(); 444 } 310 445 } 311 446 #endif … … 316 451 GET_CONTEXT(ctx); 317 452 CRClientState *clientState = &(ctx->clientState->client); 453 454 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 455 { 456 packspu_ApplyUnpackState(); 457 } 458 318 459 if (pack_spu.swap) 319 460 crPackTexImage3DSWAP( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) ); 320 461 else 321 462 crPackTexImage3D( target, level, internalformat, width, height, depth, border, format, type, pixels, &(clientState->unpack) ); 463 464 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 465 { 466 packspu_RestoreUnpackState(); 467 } 322 468 } 323 469 #endif /* CR_OPENGL_VERSION_1_2 */ … … 334 480 } 335 481 482 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 483 { 484 packspu_ApplyUnpackState(); 485 } 486 336 487 if (pack_spu.swap) 337 488 crPackTexSubImage1DSWAP( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) ); 338 489 else 339 490 crPackTexSubImage1D( target, level, xoffset, width, format, type, pixels, &(clientState->unpack) ); 491 492 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 493 { 494 packspu_RestoreUnpackState(); 495 } 340 496 } 341 497 … … 351 507 } 352 508 509 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 510 { 511 packspu_ApplyUnpackState(); 512 } 513 353 514 if (pack_spu.swap) 354 515 crPackTexSubImage2DSWAP( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) ); 355 516 else 356 517 crPackTexSubImage2D( target, level, xoffset, yoffset, width, height, format, type, pixels, &(clientState->unpack) ); 518 519 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 520 { 521 packspu_RestoreUnpackState(); 522 } 357 523 } 358 524 … … 362 528 GET_CONTEXT(ctx); 363 529 CRClientState *clientState = &(ctx->clientState->client); 530 531 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 532 { 533 packspu_ApplyUnpackState(); 534 } 535 364 536 if (pack_spu.swap) 365 537 crPackTexSubImage3DSWAP( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) ); 366 538 else 367 539 crPackTexSubImage3D( target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, &(clientState->unpack) ); 540 541 if (crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) 542 { 543 packspu_RestoreUnpackState(); 544 } 368 545 } 369 546 #endif /* CR_OPENGL_VERSION_1_2 */ … … 385 562 CRClientState *clientState = &(ctx->clientState->client); 386 563 int writeback = 1; 387 /* XXX note: we're not observing the pixel pack parameters here. 564 565 /* XXX note: we're not observing the pixel pack parameters here unless PACK PBO is bound 388 566 * To do so, we'd have to allocate a temporary image buffer (how large???) 389 567 * and copy the image to the user's buffer using the pixel pack params. 390 568 */ 569 570 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 571 { 572 packspu_ApplyPackState(); 573 } 574 391 575 if (pack_spu.swap) 392 576 crPackGetTexImageSWAP( target, level, format, type, pixels, &(clientState->pack), &writeback ); 393 577 else 394 578 crPackGetTexImage( target, level, format, type, pixels, &(clientState->pack), &writeback ); 579 580 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 581 { 582 packspu_RestorePackState(); 583 } 395 584 396 585 #ifdef CR_ARB_pixel_buffer_object … … 409 598 int writeback = 1; 410 599 600 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 601 { 602 packspu_ApplyPackState(); 603 } 604 411 605 if (pack_spu.swap) 412 606 { … … 416 610 { 417 611 crPackGetCompressedTexImageARB( target, level, img, &writeback ); 612 } 613 614 if (crStateIsBufferBound(GL_PIXEL_PACK_BUFFER_ARB)) 615 { 616 packspu_RestorePackState(); 418 617 } 419 618
Note:
See TracChangeset
for help on using the changeset viewer.