diff options
Diffstat (limited to 'src/ui/paint.c')
-rw-r--r-- | src/ui/paint.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c index 5e66f521..5f19ec3e 100644 --- a/src/ui/paint.c +++ b/src/ui/paint.c | |||
@@ -71,18 +71,19 @@ void endTarget_Paint(iPaint *d) { | |||
71 | 71 | ||
72 | void setClip_Paint(iPaint *d, iRect rect) { | 72 | void setClip_Paint(iPaint *d, iRect rect) { |
73 | addv_I2(&rect.pos, origin_Paint); | 73 | addv_I2(&rect.pos, origin_Paint); |
74 | if (isEmpty_Rect(rect)) { | ||
75 | rect = init_Rect(0, 0, 1, 1); | ||
76 | } | ||
77 | iRect targetRect = zero_Rect(); | 74 | iRect targetRect = zero_Rect(); |
78 | SDL_Texture *target = SDL_GetRenderTarget(renderer_Paint_(d)); | 75 | SDL_Texture *target = SDL_GetRenderTarget(renderer_Paint_(d)); |
79 | if (target) { | 76 | if (target) { |
80 | SDL_QueryTexture(target, NULL, NULL, &targetRect.size.x, &targetRect.size.y); | 77 | SDL_QueryTexture(target, NULL, NULL, &targetRect.size.x, &targetRect.size.y); |
81 | rect = intersect_Rect(rect, targetRect); | 78 | rect = intersect_Rect(rect, targetRect); |
82 | } | 79 | } |
83 | else { | 80 | /* The origin is non-zero when drawing into a widget's own buffer. */ |
81 | if (isEqual_I2(zero_I2(), origin_Paint)) { | ||
84 | rect = intersect_Rect(rect, rect_Root(get_Root())); | 82 | rect = intersect_Rect(rect, rect_Root(get_Root())); |
85 | } | 83 | } |
84 | if (isEmpty_Rect(rect)) { | ||
85 | rect = init_Rect(0, 0, 1, 1); | ||
86 | } | ||
86 | SDL_RenderSetClipRect(renderer_Paint_(d), (const SDL_Rect *) &rect); | 87 | SDL_RenderSetClipRect(renderer_Paint_(d), (const SDL_Rect *) &rect); |
87 | } | 88 | } |
88 | 89 | ||