comparison src/SDL_compat.c @ 2202:98e76ba7d5a4

Merged fix for bug #457 from SDL 1.2
author Sam Lantinga <slouken@libsdl.org>
date Sun, 15 Jul 2007 21:54:16 +0000
parents 760c1bd2d625
children 926294b2bb4e
comparison
equal deleted inserted replaced
2201:6280c111ee80 2202:98e76ba7d5a4
1397 int 1397 int
1398 SDL_LockYUVOverlay(SDL_Overlay * overlay) 1398 SDL_LockYUVOverlay(SDL_Overlay * overlay)
1399 { 1399 {
1400 void *pixels; 1400 void *pixels;
1401 int pitch; 1401 int pitch;
1402
1403 if (!overlay) {
1404 SDL_SetError("Passed a NULL overlay");
1405 return -1;
1406 }
1402 if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch) 1407 if (SDL_LockTexture(overlay->hwdata->textureID, NULL, 1, &pixels, &pitch)
1403 < 0) { 1408 < 0) {
1404 return -1; 1409 return -1;
1405 } 1410 }
1406 switch (overlay->format) { 1411 switch (overlay->format) {
1422 } 1427 }
1423 1428
1424 void 1429 void
1425 SDL_UnlockYUVOverlay(SDL_Overlay * overlay) 1430 SDL_UnlockYUVOverlay(SDL_Overlay * overlay)
1426 { 1431 {
1432 if (!overlay) {
1433 return;
1434 }
1427 SDL_UnlockTexture(overlay->hwdata->textureID); 1435 SDL_UnlockTexture(overlay->hwdata->textureID);
1428 } 1436 }
1429 1437
1430 int 1438 int
1431 SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) 1439 SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect)
1432 { 1440 {
1441 if (!overlay || !dstrect) {
1442 SDL_SetError("Passed a NULL overlay or dstrect");
1443 return -1;
1444 }
1433 if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect) < 0) { 1445 if (SDL_RenderCopy(overlay->hwdata->textureID, NULL, dstrect) < 0) {
1434 return -1; 1446 return -1;
1435 } 1447 }
1436 SDL_RenderPresent(); 1448 SDL_RenderPresent();
1437 return 0; 1449 return 0;
1438 } 1450 }
1439 1451
1440 void 1452 void
1441 SDL_FreeYUVOverlay(SDL_Overlay * overlay) 1453 SDL_FreeYUVOverlay(SDL_Overlay * overlay)
1442 { 1454 {
1443 if (overlay) { 1455 if (!overlay) {
1444 if (overlay->hwdata) { 1456 return;
1445 if (overlay->hwdata->textureID) { 1457 }
1446 SDL_DestroyTexture(overlay->hwdata->textureID); 1458 if (overlay->hwdata) {
1447 } 1459 if (overlay->hwdata->textureID) {
1448 SDL_free(overlay->hwdata); 1460 SDL_DestroyTexture(overlay->hwdata->textureID);
1449 } 1461 }
1450 SDL_free(overlay); 1462 SDL_free(overlay->hwdata);
1451 } 1463 }
1464 SDL_free(overlay);
1452 } 1465 }
1453 1466
1454 void 1467 void
1455 SDL_GL_SwapBuffers(void) 1468 SDL_GL_SwapBuffers(void)
1456 { 1469 {