eglglessink: Correctly implement ::expose()

We don't need the past buffer for this, the old one is still available
as texture and we just need to draw our rectangle again.
This commit is contained in:
Sebastian Dröge 2012-09-24 14:43:50 +02:00
parent 18e473307f
commit 2323c40f1b

View file

@ -1163,9 +1163,6 @@ gst_eglglessink_create_window (GstEglGlesSink * eglglessink, gint width,
return window; return window;
} }
/* XXX: Should implement (redisplay)
* We need at least the last buffer stored for this to work
*/
static void static void
gst_eglglessink_expose (GstXOverlay * overlay) gst_eglglessink_expose (GstXOverlay * overlay)
{ {
@ -1178,7 +1175,6 @@ gst_eglglessink_expose (GstXOverlay * overlay)
/* Logic would be to get _render_and_display() to use /* Logic would be to get _render_and_display() to use
* last seen buffer to render from when NULL it's * last seen buffer to render from when NULL it's
* passed on */ * passed on */
GST_WARNING_OBJECT (eglglessink, "_expose() not implemented");
ret = gst_eglglessink_render_and_display (eglglessink, NULL); ret = gst_eglglessink_render_and_display (eglglessink, NULL);
if (ret == GST_FLOW_ERROR) if (ret == GST_FLOW_ERROR)
GST_ERROR_OBJECT (eglglessink, "Redisplay failed"); GST_ERROR_OBJECT (eglglessink, "Redisplay failed");
@ -1814,17 +1810,12 @@ gst_eglglessink_render_and_display (GstEglGlesSink * eglglessink,
}; };
#endif #endif
if (!buf) {
GST_ERROR_OBJECT (eglglessink, "Null buffer, no past queue implemented");
goto HANDLE_ERROR;
}
w = GST_VIDEO_SINK_WIDTH (eglglessink); w = GST_VIDEO_SINK_WIDTH (eglglessink);
h = GST_VIDEO_SINK_HEIGHT (eglglessink); h = GST_VIDEO_SINK_HEIGHT (eglglessink);
GST_DEBUG_OBJECT (eglglessink, GST_DEBUG_OBJECT (eglglessink,
"Got good buffer %p. Sink geometry is %dx%d size %d", buf, w, h, "Got good buffer %p. Sink geometry is %dx%d size %d", buf, w, h,
GST_BUFFER_SIZE (buf)); buf ? GST_BUFFER_SIZE (buf) : -1);
switch (eglglessink->rendering_path) { switch (eglglessink->rendering_path) {
#ifdef EGL_FAST_RENDERING_POSSIBLE #ifdef EGL_FAST_RENDERING_POSSIBLE
@ -1845,6 +1836,7 @@ gst_eglglessink_render_and_display (GstEglGlesSink * eglglessink,
#endif #endif
default: /* case GST_EGLGLESSINK_RENDER_SLOW */ default: /* case GST_EGLGLESSINK_RENDER_SLOW */
if (buf) {
switch (eglglessink->selected_fmt->fmt) { switch (eglglessink->selected_fmt->fmt) {
case GST_EGLGLESSINK_IMAGE_RGB888: case GST_EGLGLESSINK_IMAGE_RGB888:
glActiveTexture (GL_TEXTURE0); glActiveTexture (GL_TEXTURE0);
@ -1887,10 +1879,10 @@ gst_eglglessink_render_and_display (GstEglGlesSink * eglglessink,
gint coffset, cw, ch; gint coffset, cw, ch;
coffset = coffset =
gst_video_format_get_component_offset (eglglessink->format, 0, gst_video_format_get_component_offset (eglglessink->format,
w, h); 0, w, h);
cw = gst_video_format_get_component_width (eglglessink->format, 0, cw = gst_video_format_get_component_width (eglglessink->format,
w); 0, w);
ch = gst_video_format_get_component_height (eglglessink->format, ch = gst_video_format_get_component_height (eglglessink->format,
0, h); 0, h);
glActiveTexture (GL_TEXTURE0); glActiveTexture (GL_TEXTURE0);
@ -1899,10 +1891,10 @@ gst_eglglessink_render_and_display (GstEglGlesSink * eglglessink,
cw, ch, 0, GL_LUMINANCE, cw, ch, 0, GL_LUMINANCE,
GL_UNSIGNED_BYTE, GST_BUFFER_DATA (buf) + coffset); GL_UNSIGNED_BYTE, GST_BUFFER_DATA (buf) + coffset);
coffset = coffset =
gst_video_format_get_component_offset (eglglessink->format, 1, gst_video_format_get_component_offset (eglglessink->format,
w, h); 1, w, h);
cw = gst_video_format_get_component_width (eglglessink->format, 1, cw = gst_video_format_get_component_width (eglglessink->format,
w); 1, w);
ch = gst_video_format_get_component_height (eglglessink->format, ch = gst_video_format_get_component_height (eglglessink->format,
1, h); 1, h);
glActiveTexture (GL_TEXTURE1); glActiveTexture (GL_TEXTURE1);
@ -1911,10 +1903,10 @@ gst_eglglessink_render_and_display (GstEglGlesSink * eglglessink,
cw, ch, 0, GL_LUMINANCE, cw, ch, 0, GL_LUMINANCE,
GL_UNSIGNED_BYTE, GST_BUFFER_DATA (buf) + coffset); GL_UNSIGNED_BYTE, GST_BUFFER_DATA (buf) + coffset);
coffset = coffset =
gst_video_format_get_component_offset (eglglessink->format, 2, gst_video_format_get_component_offset (eglglessink->format,
w, h); 2, w, h);
cw = gst_video_format_get_component_width (eglglessink->format, 2, cw = gst_video_format_get_component_width (eglglessink->format,
w); 2, w);
ch = gst_video_format_get_component_height (eglglessink->format, ch = gst_video_format_get_component_height (eglglessink->format,
2, h); 2, h);
glActiveTexture (GL_TEXTURE2); glActiveTexture (GL_TEXTURE2);
@ -1942,10 +1934,10 @@ gst_eglglessink_render_and_display (GstEglGlesSink * eglglessink,
gint coffset, cw, ch; gint coffset, cw, ch;
coffset = coffset =
gst_video_format_get_component_offset (eglglessink->format, 0, gst_video_format_get_component_offset (eglglessink->format,
w, h); 0, w, h);
cw = gst_video_format_get_component_width (eglglessink->format, 0, cw = gst_video_format_get_component_width (eglglessink->format,
w); 0, w);
ch = gst_video_format_get_component_height (eglglessink->format, ch = gst_video_format_get_component_height (eglglessink->format,
0, h); 0, h);
glActiveTexture (GL_TEXTURE0); glActiveTexture (GL_TEXTURE0);
@ -1956,9 +1948,10 @@ gst_eglglessink_render_and_display (GstEglGlesSink * eglglessink,
coffset = coffset =
gst_video_format_get_component_offset (eglglessink->format, gst_video_format_get_component_offset (eglglessink->format,
(eglglessink->format == GST_VIDEO_FORMAT_NV12 ? 1 : 2), w, h); (eglglessink->format == GST_VIDEO_FORMAT_NV12 ? 1 : 2), w,
cw = gst_video_format_get_component_width (eglglessink->format, 1, h);
w); cw = gst_video_format_get_component_width (eglglessink->format,
1, w);
ch = gst_video_format_get_component_height (eglglessink->format, ch = gst_video_format_get_component_height (eglglessink->format,
1, h); 1, h);
glActiveTexture (GL_TEXTURE1); glActiveTexture (GL_TEXTURE1);
@ -1976,6 +1969,7 @@ gst_eglglessink_render_and_display (GstEglGlesSink * eglglessink,
if (got_gl_error ("glTexImage2D")) if (got_gl_error ("glTexImage2D"))
goto HANDLE_ERROR; goto HANDLE_ERROR;
}
/* If no one has set a display rectangle on us initialize /* If no one has set a display rectangle on us initialize
* a sane default. According to the docs on the xOverlay * a sane default. According to the docs on the xOverlay