diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-25 00:12:12 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2013-04-25 00:12:12 +0400 |
commit | 18b1ab1598b6b5b2623c170369ce0765c7e63533 (patch) | |
tree | 4e1695c15650a0702664207ce5c17877ee2f024d | |
parent | a0e03a6c77f19c042cbb7aea922d64404f2e35da (diff) |
Fix #34714: cycles viewport render would restart when minimizing and unminimizing
a maximized Blender window in Ubuntu Unity. The window size would slightly change
as part of the unminimize effect.
Now cycles waits 0.2 seconds before restarting rendering after a viewport resize,
also a bit less flickery when changing the 3d view size in Blender itself.
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 45 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.h | 1 |
2 files changed, 35 insertions, 11 deletions
diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index f60da169bb1..c1d123af32f 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -50,7 +50,8 @@ BlenderSession::BlenderSession(BL::RenderEngine b_engine_, BL::UserPreferences b height = (int)(b_render.resolution_y()*b_render.resolution_percentage()/100); background = true; - last_redraw_time = 0.0f; + last_redraw_time = 0.0; + start_resize_time = 0.0; create_session(); } @@ -66,7 +67,8 @@ BlenderSession::BlenderSession(BL::RenderEngine b_engine_, BL::UserPreferences b width = width_; height = height_; background = false; - last_redraw_time = 0.0f; + last_redraw_time = 0.0; + start_resize_time = 0.0; create_session(); session->start(); @@ -85,6 +87,7 @@ void BlenderSession::create_session() /* reset status/progress */ last_status = ""; last_progress = -1.0f; + start_resize_time = 0.0; /* create scene */ scene = new Scene(scene_params, session_params.device); @@ -163,6 +166,9 @@ void BlenderSession::reset_session(BL::BlendData b_data_, BL::Scene b_scene_) session->reset(buffer_params, session_params.samples); b_engine.use_highlight_tiles(session_params.progressive_refine == false); + + /* reset time */ + start_resize_time = 0.0; } void BlenderSession::free_session() @@ -487,6 +493,9 @@ void BlenderSession::synchronize() if(scene->need_reset()) { BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_scene, b_v3d, b_rv3d, scene->camera, width, height); session->reset(buffer_params, session_params.samples); + + /* reset time */ + start_resize_time = 0.0; } } @@ -497,6 +506,25 @@ bool BlenderSession::draw(int w, int h) if(session->ready_to_reset()) { bool reset = false; + /* if dimensions changed, reset */ + if(width != w || height != h) { + if(start_resize_time == 0.0) { + /* don't react immediately to resizes to avoid flickery resizing + * of the viewport, and some window managers changing the window + * size temporarily on unminimize */ + start_resize_time = time_dt(); + tag_redraw(); + } + else if(time_dt() - start_resize_time < 0.2f) { + tag_redraw(); + } + else { + width = w; + height = h; + reset = true; + } + } + /* try to acquire mutex. if we can't, come back later */ if(!session->scene->mutex.try_lock()) { tag_update(); @@ -504,7 +532,7 @@ bool BlenderSession::draw(int w, int h) else { /* update camera from 3d view */ - sync->sync_view(b_v3d, b_rv3d, w, h); + sync->sync_view(b_v3d, b_rv3d, width, height); if(scene->camera->need_update) reset = true; @@ -512,19 +540,14 @@ bool BlenderSession::draw(int w, int h) session->scene->mutex.unlock(); } - /* if dimensions changed, reset */ - if(width != w || height != h) { - width = w; - height = h; - reset = true; - } - /* reset if requested */ if(reset) { SessionParams session_params = BlenderSync::get_session_params(b_engine, b_userpref, b_scene, background); - BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_scene, b_v3d, b_rv3d, scene->camera, w, h); + BufferParams buffer_params = BlenderSync::get_buffer_params(b_render, b_scene, b_v3d, b_rv3d, scene->camera, width, height); session->reset(buffer_params, session_params.samples); + + start_resize_time = 0.0; } } else { diff --git a/intern/cycles/blender/blender_session.h b/intern/cycles/blender/blender_session.h index a25030df4f4..4d3caeee40f 100644 --- a/intern/cycles/blender/blender_session.h +++ b/intern/cycles/blender/blender_session.h @@ -90,6 +90,7 @@ public: float last_progress; int width, height; + double start_resize_time; protected: void do_write_update_render_result(BL::RenderResult b_rr, BL::RenderLayer b_rlay, RenderTile& rtile, bool do_update_only); |