| 1738 | } |
| 1739 | |
| 1740 | int |
| 1741 | SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, |
| 1742 | SDL_Surface **surface) |
| 1743 | { |
| 1744 | SDL_Rect real_rect; |
| 1745 | void *pixels = NULL; |
| 1746 | int pitch, ret; |
| 1747 | |
| 1748 | if (texture == NULL || surface == NULL) { |
| 1749 | return -1; |
| 1750 | } |
| 1751 | |
| 1752 | real_rect.x = 0; |
| 1753 | real_rect.y = 0; |
| 1754 | real_rect.w = texture->w; |
| 1755 | real_rect.h = texture->h; |
| 1756 | |
| 1757 | if (rect) { |
| 1758 | SDL_IntersectRect(rect, &real_rect, &real_rect); |
| 1759 | } |
| 1760 | |
| 1761 | ret = SDL_LockTexture(texture, &real_rect, &pixels, &pitch); |
| 1762 | if (ret < 0) { |
| 1763 | return ret; |
| 1764 | } |
| 1765 | |
| 1766 | texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, 0, pitch, texture->format); |
| 1767 | if (texture->locked_surface == NULL) { |
| 1768 | SDL_UnlockTexture(texture); |
| 1769 | return -1; |
| 1770 | } |
| 1771 | |
| 1772 | *surface = texture->locked_surface; |
| 1773 | return 0; |
| 1774 | } |
| 1775 | |
| 1776 | #if SDL_HAVE_YUV |
| 1777 | static void |
nothing calls this directly
no test coverage detected