diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-09 13:14:04 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-11-09 14:00:16 +0000 |
commit | 8fdbd01c94c0f6f56247feed8f225901ba39e18e (patch) | |
tree | bb6621689de186d528df9607c623b08cbb4e6e9e | |
parent | 436a78684507129ca1245e065ff68870eb27624b (diff) |
sna/video: Use the normal bo cache for texture video streams
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/sna_video.c | 41 | ||||
-rw-r--r-- | src/sna/sna_video.h | 11 | ||||
-rw-r--r-- | src/sna/sna_video_overlay.c | 9 | ||||
-rw-r--r-- | src/sna/sna_video_textured.c | 10 |
4 files changed, 41 insertions, 30 deletions
diff --git a/src/sna/sna_video.c b/src/sna/sna_video.c index fd5f3f19..d3788fd0 100644 --- a/src/sna/sna_video.c +++ b/src/sna/sna_video.c @@ -94,16 +94,25 @@ void sna_video_free_buffers(struct sna *sna, struct sna_video *video) } } -void sna_video_frame_fini(struct sna *sna, - struct sna_video *video, - struct sna_video_frame *frame) +struct kgem_bo * +sna_video_buffer(struct sna *sna, + struct sna_video *video, + struct sna_video_frame *frame) { - struct kgem_bo *bo; + /* Free the current buffer if we're going to have to reallocate */ + if (video->buf && video->buf->size < frame->size) + sna_video_free_buffers(sna, video); - if (!frame->bo->reusable) { - kgem_bo_destroy(&sna->kgem, frame->bo); - return; - } + if (video->buf == NULL) + video->buf = kgem_create_linear(&sna->kgem, frame->size); + + return video->buf; +} + +void sna_video_buffer_fini(struct sna *sna, + struct sna_video *video) +{ + struct kgem_bo *bo; bo = video->old_buf[1]; video->old_buf[1] = video->old_buf[0]; @@ -245,21 +254,6 @@ sna_video_frame_init(struct sna *sna, } } -static struct kgem_bo * -sna_video_buffer(struct sna *sna, - struct sna_video *video, - struct sna_video_frame *frame) -{ - /* Free the current buffer if we're going to have to reallocate */ - if (video->buf && video->buf->size < frame->size) - sna_video_free_buffers(sna, video); - - if (video->buf == NULL) - video->buf = kgem_create_linear(&sna->kgem, frame->size); - - return video->buf; -} - static void sna_memcpy_plane(uint8_t *dst, const uint8_t *src, int height, int width, int dstPitch, int srcPitch, @@ -442,7 +436,6 @@ sna_video_copy_data(struct sna *sna, { uint8_t *dst; - frame->bo = sna_video_buffer(sna, video, frame); if (frame->bo == NULL) return FALSE; diff --git a/src/sna/sna_video.h b/src/sna/sna_video.h index ab8289b6..47ddab0f 100644 --- a/src/sna/sna_video.h +++ b/src/sna/sna_video.h @@ -117,15 +117,20 @@ sna_video_frame_init(struct sna *sna, int id, short width, short height, struct sna_video_frame *frame); +struct kgem_bo * +sna_video_buffer(struct sna *sna, + struct sna_video *video, + struct sna_video_frame *frame); + Bool sna_video_copy_data(struct sna *sna, struct sna_video *video, struct sna_video_frame *frame, const uint8_t *buf); -void sna_video_frame_fini(struct sna *sna, - struct sna_video *video, - struct sna_video_frame *frame); +void sna_video_buffer_fini(struct sna *sna, + struct sna_video *video); + void sna_video_free_buffers(struct sna *sna, struct sna_video *video); #endif /* SNA_VIDEO_H */ diff --git a/src/sna/sna_video_overlay.c b/src/sna/sna_video_overlay.c index 491baa87..9ba78ef4 100644 --- a/src/sna/sna_video_overlay.c +++ b/src/sna/sna_video_overlay.c @@ -504,6 +504,13 @@ sna_video_overlay_put_image(ScrnInfoPtr scrn, /* overlay can't handle rotation natively, store it for the copy func */ video->rotation = crtc->rotation; + + frame.bo = sna_video_buffer(sna, video, &frame); + if (frame.bo == NULL) { + DBG(("%s: failed to allocate video bo\n", __FUNCTION__)); + return BadAlloc; + } + if (!sna_video_copy_data(sna, video, &frame, buf)) { DBG(("%s: failed to copy video data\n", __FUNCTION__)); return BadAlloc; @@ -515,7 +522,7 @@ sna_video_overlay_put_image(ScrnInfoPtr scrn, return BadAlloc; } - sna_video_frame_fini(sna, video, &frame); + sna_video_buffer_fini(sna, video); /* update cliplist */ if (!REGION_EQUAL(scrn->pScreen, &video->clip, clip)) { diff --git a/src/sna/sna_video_textured.c b/src/sna/sna_video_textured.c index 3461dc54..dadf8b93 100644 --- a/src/sna/sna_video_textured.c +++ b/src/sna/sna_video_textured.c @@ -262,8 +262,14 @@ sna_video_textured_put_image(ScrnInfoPtr scrn, if (frame.bo == NULL) return BadAlloc; } else { - if (!sna_video_copy_data(sna, video, &frame, buf)) + frame.bo = kgem_create_linear(&sna->kgem, frame.size); + if (frame.bo == NULL) + return BadAlloc; + + if (!sna_video_copy_data(sna, video, &frame, buf)) { + kgem_bo_destroy(&sna->kgem, frame.bo); return BadAlloc; + } } if (crtc && video->SyncToVblank != 0) @@ -275,7 +281,7 @@ sna_video_textured_put_image(ScrnInfoPtr scrn, drw_w, drw_h, pixmap); - sna_video_frame_fini(sna, video, &frame); + kgem_bo_destroy(&sna->kgem, frame.bo); DamageDamageRegion(drawable, clip); |