diff options
author | Neil Roberts <neil@linux.intel.com> | 2013-05-17 15:13:41 +0100 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2013-05-29 17:45:28 +0100 |
commit | 945689a62903990a20abb87a85d2c96eb3985fe7 (patch) | |
tree | 78dfa0b01817298689df0b019077fb88eb5b23b2 /cogl/cogl-framebuffer.c | |
parent | 88eed85b52c29f66659ea112038f3522c9bd864e (diff) | |
download | cogl-945689a62903990a20abb87a85d2c96eb3985fe7.tar.gz |
wayland: Don't delay resize if nothing is drawn since last swap
After discussing with Kristian Høgsberg it seems that the semantics of
wl_egl_window_resize is meant to be that if nothing has been drawn to
the framebuffer since the last swap then the resize will take effect
immediately. Cogl was previously always delaying the call to
wl_egl_window_resize until the next swap. That meant that if you
wanted to resize the surface you would have to call
cogl_wayland_onscreen_resize and then redundantly draw a frame at the
old size so that you can swap to get the resize to occur before
drawing again at the right size. Typically an application would decide
to resize at the start of its paint sequence so it should be able to
just resize immediately.
In current Mesa master it seems that there is a bug which means that
it won't actually delay a resize that is done mid-scene and instead it
will just discard what came before. To get consistent behaviour in
Cogl, the code to delay the call to wl_egl_window_resize is still used
if it determines that the buffer is dirty. There is an existing
_cogl_framebuffer_mark_mid_scene call which was being used to track
when the framebuffer becomes dirty since the last clear. This function
is now also used to track a new flag to track whether something has
been drawn since the last swap. It is called ‘mid_scene’ under the
assumption that this may also be useful for other things later.
cogl_framebuffer_clear has been slightly altered to always call
_cogl_framebuffer_mark_mid_scene even if it determines that it doesn't
need to clear because the framebuffer should still be considered to be
in the middle of a scene. Adding a quad to the journal now also begins
the scene.
This also fixes a potential bug where it looks like pending_dx/dy were
never cleared so they would always be accumulated even after the
resize is flushed.
Reviewed-by: Robert Bragg <robert@linux.intel.com>
Diffstat (limited to 'cogl/cogl-framebuffer.c')
-rw-r--r-- | cogl/cogl-framebuffer.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index a6a9a8db..4faad61e 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -228,6 +228,7 @@ void _cogl_framebuffer_mark_mid_scene (CoglFramebuffer *framebuffer) { framebuffer->clear_clip_dirty = TRUE; + framebuffer->mid_scene = TRUE; } void @@ -353,6 +354,8 @@ cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer, cleared: + _cogl_framebuffer_mark_mid_scene (framebuffer); + if (buffers & COGL_BUFFER_BIT_COLOR && buffers & COGL_BUFFER_BIT_DEPTH) { /* For our fast-path for reading back a single pixel of simple @@ -380,8 +383,6 @@ cleared: /* FIXME: set degenerate clip */ } } - else - _cogl_framebuffer_mark_mid_scene (framebuffer); } /* Note: the 'buffers' and 'color' arguments were switched around on |