From be15f8c1d671310ee4f95f7d4d3a78f5c7de88ed Mon Sep 17 00:00:00 2001 From: Dmitry Marakasov Date: Thu, 15 Jan 2015 17:13:00 +0300 Subject: [PATCH] Implement Texture::UpdateYUV() --- SDL2pp/Texture.cc | 5 +++++ SDL2pp/Texture.hh | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/SDL2pp/Texture.cc b/SDL2pp/Texture.cc index 16c5b1d..a4f8854 100644 --- a/SDL2pp/Texture.cc +++ b/SDL2pp/Texture.cc @@ -93,6 +93,11 @@ void Texture::Update(const Optional& rect, const void* pixels, int pitch) throw Exception("SDL_UpdateTexture failed"); } +void Texture::UpdateYUV(const Optional& rect, const Uint8* yplane, int ypitch, const Uint8* uplane, int upitch, const Uint8* vplane, int vpitch) { + if (SDL_UpdateYUVTexture(texture_, rect ? &*rect : nullptr, yplane, ypitch, uplane, upitch, vplane, vpitch) != 0) + throw Exception("SDL_UpdateYUVTexture failed"); +} + void Texture::SetBlendMode(SDL_BlendMode blendMode) { if (SDL_SetTextureBlendMode(texture_, blendMode) != 0) throw Exception("SDL_SetTextureBlendMode failed"); diff --git a/SDL2pp/Texture.hh b/SDL2pp/Texture.hh index 18fe936..035ff2d 100644 --- a/SDL2pp/Texture.hh +++ b/SDL2pp/Texture.hh @@ -311,6 +311,25 @@ public: //////////////////////////////////////////////////////////// void Update(const Optional& rect, const void* pixels, int pitch); + //////////////////////////////////////////////////////////// + /// \brief Update the given texture rectangle with new pixel data + /// + /// \param[in] rect Rect representing the area to update, or NullOpt to + /// update the entire texture + /// \param[in] yplane Raw pixel data for the Y plane + /// \param[in] ypitch Number of bytes between rows of pixel data for the Y plane + /// \param[in] uplane Raw pixel data for the U plane + /// \param[in] upitch Number of bytes between rows of pixel data for the U plane + /// \param[in] vplane Raw pixel data for the V plane + /// \param[in] vpitch Number of bytes between rows of pixel data for the V plane + /// + /// \throws SDL2pp::Exception + /// + /// \see http://wiki.libsdl.org/SDL_UpdateYUVTexture + /// + //////////////////////////////////////////////////////////// + void UpdateYUV(const Optional& rect, const Uint8* yplane, int ypitch, const Uint8* uplane, int upitch, const Uint8* vplane, int vpitch); + //////////////////////////////////////////////////////////// /// \brief Set the blend mode for a texture, used by SDL2pp::Renderer::Copy ///