aboutsummaryrefslogtreecommitdiff
path: root/src/fb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fb.c')
-rw-r--r--src/fb.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/fb.c b/src/fb.c
index f59c700..bb229ba 100644
--- a/src/fb.c
+++ b/src/fb.c
@@ -96,34 +96,34 @@ bool pw_fb_coordinates(struct pw_framebuffer *fb, float wx, float wy,
return true;
}
-bool pw_fb_blit(struct pw_framebuffer *fb, uint8_t const pixels[PW_FB_SIZE]) {
+uint8_t *pw_fb_lock(struct pw_framebuffer *fb) {
if (!fb) {
SDL_InvalidParamError("fb");
- return false;
- }
- if (!pixels) {
- SDL_InvalidParamError("pixels");
- return false;
- }
-
- SDL_Renderer *renderer = SDL_GetRendererFromTexture(fb->texture);
- if (!renderer) {
- return false;
+ return NULL;
}
void *buffer;
int pitch;
if (!SDL_LockTexture(fb->texture, NULL, &buffer, &pitch)) {
- return false;
+ return NULL;
}
- bool ok = pitch == PW_FB_WIDTH * PW_FB_BYTES_PER_PIXEL;
- if (ok) {
- SDL_memcpy(buffer, pixels, PW_FB_SIZE);
+ if (pitch != PW_FB_WIDTH * PW_FB_BYTES_PER_PIXEL) {
+ SDL_UnlockTexture(fb->texture);
+ SDL_SetError("unexpected framebuffer pitch");
+ return NULL;
+ }
+
+ return buffer;
+}
+
+void pw_fb_unlock(struct pw_framebuffer *fb) {
+ if (!fb) {
+ SDL_InvalidParamError("fb");
+ return;
}
SDL_UnlockTexture(fb->texture);
- return ok;
}
bool pw_fb_render(struct pw_framebuffer *fb) {