| 1516 | } |
| 1517 | |
| 1518 | int |
| 1519 | SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, |
| 1520 | const void *pixels, int pitch) |
| 1521 | { |
| 1522 | SDL_Rect full_rect; |
| 1523 | |
| 1524 | CHECK_TEXTURE_MAGIC(texture, -1); |
| 1525 | |
| 1526 | if (!pixels) { |
| 1527 | return SDL_InvalidParamError("pixels"); |
| 1528 | } |
| 1529 | if (!pitch) { |
| 1530 | return SDL_InvalidParamError("pitch"); |
| 1531 | } |
| 1532 | |
| 1533 | if (!rect) { |
| 1534 | full_rect.x = 0; |
| 1535 | full_rect.y = 0; |
| 1536 | full_rect.w = texture->w; |
| 1537 | full_rect.h = texture->h; |
| 1538 | rect = &full_rect; |
| 1539 | } |
| 1540 | |
| 1541 | if ((rect->w == 0) || (rect->h == 0)) { |
| 1542 | return 0; /* nothing to do. */ |
| 1543 | #if SDL_HAVE_YUV |
| 1544 | } else if (texture->yuv) { |
| 1545 | return SDL_UpdateTextureYUV(texture, rect, pixels, pitch); |
| 1546 | #endif |
| 1547 | } else if (texture->native) { |
| 1548 | return SDL_UpdateTextureNative(texture, rect, pixels, pitch); |
| 1549 | } else { |
| 1550 | SDL_Renderer *renderer = texture->renderer; |
| 1551 | if (FlushRenderCommandsIfTextureNeeded(texture) < 0) { |
| 1552 | return -1; |
| 1553 | } |
| 1554 | return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch); |
| 1555 | } |
| 1556 | } |
| 1557 | |
| 1558 | #if SDL_HAVE_YUV |
| 1559 | static int |