| 1698 | } |
| 1699 | |
| 1700 | int |
| 1701 | SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, |
| 1702 | void **pixels, int *pitch) |
| 1703 | { |
| 1704 | SDL_Rect full_rect; |
| 1705 | |
| 1706 | CHECK_TEXTURE_MAGIC(texture, -1); |
| 1707 | |
| 1708 | if (texture->access != SDL_TEXTUREACCESS_STREAMING) { |
| 1709 | return SDL_SetError("SDL_LockTexture(): texture must be streaming"); |
| 1710 | } |
| 1711 | |
| 1712 | if (!rect) { |
| 1713 | full_rect.x = 0; |
| 1714 | full_rect.y = 0; |
| 1715 | full_rect.w = texture->w; |
| 1716 | full_rect.h = texture->h; |
| 1717 | rect = &full_rect; |
| 1718 | } |
| 1719 | |
| 1720 | #if SDL_HAVE_YUV |
| 1721 | if (texture->yuv) { |
| 1722 | if (FlushRenderCommandsIfTextureNeeded(texture) < 0) { |
| 1723 | return -1; |
| 1724 | } |
| 1725 | return SDL_LockTextureYUV(texture, rect, pixels, pitch); |
| 1726 | } else |
| 1727 | #endif |
| 1728 | if (texture->native) { |
| 1729 | /* Calls a real SDL_LockTexture/SDL_UnlockTexture on unlock, flushing then. */ |
| 1730 | return SDL_LockTextureNative(texture, rect, pixels, pitch); |
| 1731 | } else { |
| 1732 | SDL_Renderer *renderer = texture->renderer; |
| 1733 | if (FlushRenderCommandsIfTextureNeeded(texture) < 0) { |
| 1734 | return -1; |
| 1735 | } |
| 1736 | return renderer->LockTexture(renderer, texture, rect, pixels, pitch); |
| 1737 | } |
| 1738 | } |
| 1739 | |
| 1740 | int |
| 1741 | SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, |