Skip to content

Commit

Permalink
GUI2/Canvas: made use of CVideo::render_copy
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Jul 9, 2017
1 parent f08c8a3 commit 59fbd47
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/gui/core/canvas.cpp
Expand Up @@ -1052,7 +1052,7 @@ void image_shape::dimension_validation(unsigned value, const std::string& name,
void image_shape::draw(
const int /*canvas_w*/,
const int /*canvas_h*/,
SDL_Renderer* renderer,
SDL_Renderer* /*renderer*/,
wfl::map_formula_callable& variables)
{
DBG_GUI_D << "Image: draw.\n";
Expand Down Expand Up @@ -1180,6 +1180,8 @@ void image_shape::draw(
surf = image_;
}

const bool flip_v = vertical_mirror_(local_variables);

#ifdef SW_RENDERING_LEGACY_MODE
/* HACK: not sure why, but SW rendering has some problems with copying the surface to the texture and
* corrupts certain semi-transparent pixels. This is a hacky workaround.
Expand All @@ -1198,11 +1200,7 @@ void image_shape::draw(
*/
texture txt(surf);

if(vertical_mirror_(local_variables)) {
SDL_RenderCopyEx(renderer, txt, nullptr, &dst_clip, 0, nullptr, SDL_FLIP_VERTICAL);
} else {
SDL_RenderCopy(renderer, txt, nullptr, &dst_clip);
}
CVideo::get_singleton().render_copy(txt, nullptr, &dst_clip, false, flip_v);
}

image_shape::resize_mode image_shape::get_resize_mode(const std::string& resize_mode)
Expand Down Expand Up @@ -1306,7 +1304,7 @@ text_shape::text_shape(const config& cfg)
void text_shape::draw(
const int canvas_w,
const int canvas_h,
SDL_Renderer* renderer,
SDL_Renderer* /*renderer*/,
wfl::map_formula_callable& variables)
{
assert(variables.has_key("text"));
Expand Down Expand Up @@ -1394,7 +1392,7 @@ void text_shape::draw(
*/
texture txt(surf);

SDL_RenderCopy(renderer, txt, nullptr, &dst);
CVideo::get_singleton().render_copy(txt, nullptr, &dst);
}

/***** ***** ***** ***** ***** CANVAS ***** ***** ***** ***** *****/
Expand Down Expand Up @@ -1484,7 +1482,7 @@ void canvas::render()
#endif

// Copy the entire texture to the full viewport.
SDL_RenderCopy(renderer_, texture_, nullptr, nullptr);
CVideo::get_singleton().render_copy(texture_);
}

void canvas::parse_cfg(const config& cfg)
Expand Down

0 comments on commit 59fbd47

Please sign in to comment.