comparison src/SDL_compat.c @ 2786:6bacfecbf27e

indent
author Sam Lantinga <slouken@libsdl.org>
date Tue, 25 Nov 2008 02:21:53 +0000
parents 5651642f4a78
children 9f6601537163
comparison
equal deleted inserted replaced
2785:fa1095d42a5b 2786:6bacfecbf27e
1348 struct private_yuvhwdata 1348 struct private_yuvhwdata
1349 { 1349 {
1350 Uint16 pitches[3]; 1350 Uint16 pitches[3];
1351 Uint8 *planes[3]; 1351 Uint8 *planes[3];
1352 1352
1353 SDL_SW_YUVTexture *sw; 1353 SDL_SW_YUVTexture *sw;
1354 1354
1355 SDL_TextureID textureID; 1355 SDL_TextureID textureID;
1356 }; 1356 };
1357 1357
1358 SDL_Overlay * 1358 SDL_Overlay *
1433 } 1433 }
1434 1434
1435 overlay->hwdata->textureID = 1435 overlay->hwdata->textureID =
1436 SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h); 1436 SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h);
1437 if (overlay->hwdata->textureID) { 1437 if (overlay->hwdata->textureID) {
1438 overlay->hwdata->sw = NULL; 1438 overlay->hwdata->sw = NULL;
1439 } else { 1439 } else {
1440 overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h); 1440 overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h);
1441 if (!overlay->hwdata->sw) { 1441 if (!overlay->hwdata->sw) {
1442 SDL_FreeYUVOverlay(overlay); 1442 SDL_FreeYUVOverlay(overlay);
1443 return NULL; 1443 return NULL;
1444 } 1444 }
1445 1445
1446 /* Create a supported RGB format texture for display */ 1446 /* Create a supported RGB format texture for display */
1447 overlay->hwdata->textureID = 1447 overlay->hwdata->textureID =
1448 SDL_CreateTexture(SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, w, h); 1448 SDL_CreateTexture(SDL_PIXELFORMAT_RGB888,
1449 } 1449 SDL_TEXTUREACCESS_STREAMING, w, h);
1450 if (!overlay->hwdata->textureID) { 1450 }
1451 if (!overlay->hwdata->textureID) {
1451 SDL_FreeYUVOverlay(overlay); 1452 SDL_FreeYUVOverlay(overlay);
1452 return NULL; 1453 return NULL;
1453 } 1454 }
1454 1455
1455 return overlay; 1456 return overlay;
1463 1464
1464 if (!overlay) { 1465 if (!overlay) {
1465 SDL_SetError("Passed a NULL overlay"); 1466 SDL_SetError("Passed a NULL overlay");
1466 return -1; 1467 return -1;
1467 } 1468 }
1468 if (overlay->hwdata->sw) { 1469 if (overlay->hwdata->sw) {
1469 if (SDL_SW_QueryYUVTexturePixels(overlay->hwdata->sw, &pixels, &pitch) < 0) { 1470 if (SDL_SW_QueryYUVTexturePixels(overlay->hwdata->sw, &pixels, &pitch)
1470 return -1; 1471 < 0) {
1471 } 1472 return -1;
1472 } else { 1473 }
1473 if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) 1474 } else {
1474 < 0) { 1475 if (SDL_LockTexture
1475 return -1; 1476 (overlay->hwdata->textureID, NULL, 1, &pixels, &pitch)
1476 } 1477 < 0) {
1477 } 1478 return -1;
1479 }
1480 }
1478 overlay->pixels[0] = (Uint8 *) pixels; 1481 overlay->pixels[0] = (Uint8 *) pixels;
1479 overlay->pitches[0] = pitch; 1482 overlay->pitches[0] = pitch;
1480 switch (overlay->format) { 1483 switch (overlay->format) {
1481 case SDL_YV12_OVERLAY: 1484 case SDL_YV12_OVERLAY:
1482 case SDL_IYUV_OVERLAY: 1485 case SDL_IYUV_OVERLAY:
1499 SDL_UnlockYUVOverlay(SDL_Overlay * overlay) 1502 SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
1500 { 1503 {
1501 if (!overlay) { 1504 if (!overlay) {
1502 return; 1505 return;
1503 } 1506 }
1504 if (overlay->hwdata->sw) { 1507 if (overlay->hwdata->sw) {
1505 void *pixels; 1508 void *pixels;
1506 int pitch; 1509 int pitch;
1507 if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) == 0) { 1510 if (SDL_LockTexture
1508 SDL_Rect srcrect; 1511 (overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) == 0) {
1509 1512 SDL_Rect srcrect;
1510 srcrect.x = 0; 1513
1511 srcrect.y = 0; 1514 srcrect.x = 0;
1512 srcrect.w = overlay->w; 1515 srcrect.y = 0;
1513 srcrect.h = overlay->h; 1516 srcrect.w = overlay->w;
1514 SDL_SW_CopyYUVToRGB(overlay->hwdata->sw, &srcrect, SDL_PIXELFORMAT_RGB888, overlay->w, overlay->h, pixels, pitch); 1517 srcrect.h = overlay->h;
1515 SDL_UnlockTexture(overlay->hwdata->textureID); 1518 SDL_SW_CopyYUVToRGB(overlay->hwdata->sw, &srcrect,
1516 } 1519 SDL_PIXELFORMAT_RGB888, overlay->w,
1517 } else { 1520 overlay->h, pixels, pitch);
1518 SDL_UnlockTexture(overlay->hwdata->textureID); 1521 SDL_UnlockTexture(overlay->hwdata->textureID);
1519 } 1522 }
1523 } else {
1524 SDL_UnlockTexture(overlay->hwdata->textureID);
1525 }
1520 } 1526 }
1521 1527
1522 int 1528 int
1523 SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) 1529 SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
1524 { 1530 {