diff options
-rw-r--r-- | src/ui/paint.c | 18 | ||||
-rw-r--r-- | src/ui/paint.h | 3 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/ui/paint.c b/src/ui/paint.c index 0166e398..d0a4a579 100644 --- a/src/ui/paint.c +++ b/src/ui/paint.c | |||
@@ -36,18 +36,28 @@ static void setColor_Paint_(const iPaint *d, int color) { | |||
36 | 36 | ||
37 | void init_Paint(iPaint *d) { | 37 | void init_Paint(iPaint *d) { |
38 | d->dst = get_Window(); | 38 | d->dst = get_Window(); |
39 | d->setTarget = NULL; | ||
39 | d->oldTarget = NULL; | 40 | d->oldTarget = NULL; |
40 | } | 41 | } |
41 | 42 | ||
42 | void beginTarget_Paint(iPaint *d, SDL_Texture *target) { | 43 | void beginTarget_Paint(iPaint *d, SDL_Texture *target) { |
43 | SDL_Renderer *rend = renderer_Paint_(d); | 44 | SDL_Renderer *rend = renderer_Paint_(d); |
44 | d->oldTarget = SDL_GetRenderTarget(rend); | 45 | if (!d->setTarget) { |
45 | SDL_SetRenderTarget(rend, target); | 46 | d->oldTarget = SDL_GetRenderTarget(rend); |
47 | SDL_SetRenderTarget(rend, target); | ||
48 | d->setTarget = target; | ||
49 | } | ||
50 | else { | ||
51 | iAssert(d->setTarget == target); | ||
52 | } | ||
46 | } | 53 | } |
47 | 54 | ||
48 | void endTarget_Paint(iPaint *d) { | 55 | void endTarget_Paint(iPaint *d) { |
49 | SDL_SetRenderTarget(renderer_Paint_(d), d->oldTarget); | 56 | if (d->setTarget) { |
50 | d->oldTarget = NULL; | 57 | SDL_SetRenderTarget(renderer_Paint_(d), d->oldTarget); |
58 | d->oldTarget = NULL; | ||
59 | d->setTarget = NULL; | ||
60 | } | ||
51 | } | 61 | } |
52 | 62 | ||
53 | void setClip_Paint(iPaint *d, iRect rect) { | 63 | void setClip_Paint(iPaint *d, iRect rect) { |
diff --git a/src/ui/paint.h b/src/ui/paint.h index 7c9e5e51..28931815 100644 --- a/src/ui/paint.h +++ b/src/ui/paint.h | |||
@@ -30,7 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ | |||
30 | iDeclareType(Paint) | 30 | iDeclareType(Paint) |
31 | 31 | ||
32 | struct Impl_Paint { | 32 | struct Impl_Paint { |
33 | iWindow *dst; | 33 | iWindow * dst; |
34 | SDL_Texture *setTarget; | ||
34 | SDL_Texture *oldTarget; | 35 | SDL_Texture *oldTarget; |
35 | }; | 36 | }; |
36 | 37 | ||