From 501c516474b78dd23e5d1d7892d757aa0a1248b6 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Wed, 30 Jul 2014 07:52:57 +0200 Subject: [PATCH] Implemented horizontal flipping in SDLRenderer --- src/video/sdl/sdl_renderer.cpp | 55 +++++++++++++++++++++++++++++++++--------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/src/video/sdl/sdl_renderer.cpp b/src/video/sdl/sdl_renderer.cpp index b4d958ff6..53b55d3b4 100644 --- a/src/video/sdl/sdl_renderer.cpp +++ b/src/video/sdl/sdl_renderer.cpp @@ -192,11 +192,28 @@ SDLRenderer::draw_surface(const DrawingRequest& request) dst_rect.w = sdltexture->get_image_width(); dst_rect.h = sdltexture->get_image_height(); -#ifdef OLD_SDL1 - // FIXME: Use SDL_RenderCopyEx() to handle flipping -#endif - - SDL_RenderCopy(renderer, sdltexture->get_texture(), NULL, &dst_rect); + if (surface->get_flipx()) + { + SDL_RenderCopyEx(renderer, sdltexture->get_texture(), NULL, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); + } + else + { + switch(request.drawing_effect) + { + case VERTICAL_FLIP: + SDL_RenderCopyEx(renderer, sdltexture->get_texture(), NULL, &dst_rect, 0, NULL, SDL_FLIP_VERTICAL); + break; + + case HORIZONTAL_FLIP: + SDL_RenderCopyEx(renderer, sdltexture->get_texture(), NULL, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); + break; + + default: + case NO_EFFECT: + SDL_RenderCopy(renderer, sdltexture->get_texture(), NULL, &dst_rect); + break; + } + } #ifdef OLD_SDL1 SDLSurfaceData *surface_data = reinterpret_cast(surface->get_surface_data()); @@ -282,12 +299,28 @@ SDLRenderer::draw_surface_part(const DrawingRequest& request) dst_rect.w = surfacepartrequest->size.x; dst_rect.h = surfacepartrequest->size.y; -#ifdef OLD_SDL1 - // FIXME: Use SDL_RenderCopyEx() to handle flipping -#endif - - SDL_RenderCopy(renderer, sdltexture->get_texture(), - &src_rect, &dst_rect); + if (surface->surface->get_flipx()) + { + SDL_RenderCopyEx(renderer, sdltexture->get_texture(), &src_rect, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); + } + else + { + switch(request.drawing_effect) + { + case VERTICAL_FLIP: + SDL_RenderCopyEx(renderer, sdltexture->get_texture(), &src_rect, &dst_rect, 0, NULL, SDL_FLIP_VERTICAL); + break; + + case HORIZONTAL_FLIP: + SDL_RenderCopyEx(renderer, sdltexture->get_texture(), &src_rect, &dst_rect, 0, NULL, SDL_FLIP_HORIZONTAL); + break; + + default: + case NO_EFFECT: + SDL_RenderCopy(renderer, sdltexture->get_texture(), &src_rect, &dst_rect); + break; + } + } #ifdef OLD_SDL1 const SurfacePartRequest* surfacepartrequest -- 2.11.0