diff options
Diffstat (limited to 'src/fb.c')
| -rw-r--r-- | src/fb.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -3,7 +3,7 @@ struct pw_framebuffer *pw_fb_init(SDL_Renderer *renderer) { if (!renderer) { SDL_InvalidParamError("renderer"); - return false; + return NULL; } SDL_Texture *texture = NULL; @@ -32,10 +32,10 @@ struct pw_framebuffer *pw_fb_init(SDL_Renderer *renderer) { return fb; error: - if (!texture) { + if (texture) { SDL_DestroyTexture(texture); } - if (!fb) { + if (fb) { SDL_free(fb); } return NULL; @@ -127,15 +127,17 @@ bool pw_fb_blit(struct pw_framebuffer *fb, void *buffer; int pitch; - if (!SDL_LockTexture(fb->texture, NULL, &buffer, &pitch) || - pitch != sizeof(uint32_t[PW_FB_WIDTH])) { + if (!SDL_LockTexture(fb->texture, NULL, &buffer, &pitch)) { return false; } - SDL_memcpy(buffer, pixels, sizeof(uint32_t[PW_FB_WIDTH * PW_FB_HEIGHT])); - SDL_UnlockTexture(fb->texture); + bool ok = pitch == sizeof(uint32_t[PW_FB_WIDTH]); + if (ok) { + SDL_memcpy(buffer, pixels, sizeof(uint32_t[PW_FB_WIDTH * PW_FB_HEIGHT])); + } - return true; + SDL_UnlockTexture(fb->texture); + return ok; } bool pw_fb_render(struct pw_framebuffer *fb) { |
