GUI2/Canvas: set clip rect when tiling images

This fixes an issue where images could be tiled outside their desired size area.
This commit is contained in:
Charles Dang 2017-06-20 06:00:39 +11:00
parent af861f7292
commit c8f36d2758

View file

@ -1110,14 +1110,18 @@ void image_shape::draw(
const unsigned int dst_w = w ? w : info.w;
const unsigned int dst_h = h ? h : info.h;
dst_clip.w = dst_w;
dst_clip.h = dst_h;
// TODO: remove stretch mode
switch(resize_mode_) {
case scale:
case stretch: {
DBG_GUI_D << "Image: scaling from " << info.w << ',' << info.h << " to " << w << ',' << h << std::endl;
dst_clip.w = dst_w;
dst_clip.h = dst_h;
//
// Textures are automatically sized to the dst rect.
//
video.render_copy(image_, nullptr, &dst_clip, mirror, false);
break;
@ -1127,6 +1131,8 @@ void image_shape::draw(
case tile: {
DBG_GUI_D << "Image: tiling from " << info.w << ',' << info.h << " to " << w << ',' << h << std::endl;
render_clip_rect_setter tile_clip_setter(&dst_clip);
const unsigned int w_count = static_cast<int>(std::ceil(static_cast<double>(dst_w) / static_cast<double>(info.w)));
const unsigned int h_count = static_cast<int>(std::ceil(static_cast<double>(dst_h) / static_cast<double>(info.h)));