From: Good Guy Date: Thu, 27 Sep 2018 03:09:42 +0000 (-0600) Subject: update resource pixmap settings even if asset not drawn X-Git-Url: https://git.cinelerra-gg.org/git/?a=commitdiff_plain;h=9f0e523f895dabf635f694efc854f2be479d712c;p=goodguy%2Fhistory.git update resource pixmap settings even if asset not drawn --- diff --git a/cinelerra-5.1/cinelerra/resourcepixmap.C b/cinelerra-5.1/cinelerra/resourcepixmap.C index cdc1e1b1..2ffd86ca 100644 --- a/cinelerra-5.1/cinelerra/resourcepixmap.C +++ b/cinelerra-5.1/cinelerra/resourcepixmap.C @@ -115,6 +115,33 @@ void ResourcePixmap::resize(int w, int h) BC_Pixmap::resize(new_w, new_h); } +void ResourcePixmap::update_settings(Edit *edit, + int64_t edit_x, int64_t edit_w, + int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h) +{ + this->edit_id = edit->id; + this->edit_x = edit_x; + this->pixmap_x = pixmap_x; + this->pixmap_w = pixmap_w; + this->pixmap_h = pixmap_h; + + startsource = edit->startsource; + if( edit->asset ) + source_framerate = edit->asset->frame_rate; + else + if( edit->nested_edl ) + source_framerate = edit->nested_edl->session->frame_rate; + if( edit->asset ) + source_samplerate = edit->asset->sample_rate; + else if( edit->nested_edl ) + source_samplerate = edit->nested_edl->session->sample_rate; + + project_framerate = edit->edl->session->frame_rate; + project_samplerate = edit->edl->session->sample_rate; + zoom_sample = mwindow->edl->local_session->zoom_sample; + zoom_track = mwindow->edl->local_session->zoom_track; + zoom_y = mwindow->edl->local_session->zoom_y; +} void ResourcePixmap::draw_data(TrackCanvas *canvas, Edit *edit, int64_t edit_x, int64_t edit_w, @@ -133,7 +160,6 @@ void ResourcePixmap::draw_data(TrackCanvas *canvas, if( edit->track->show_titles() ) y += mwindow->theme->get_image("title_bg_data")->get_h(); - // If want indexes only & index can't be drawn, don't do anything. int need_redraw = 0; int64_t index_zoom = 0; @@ -161,197 +187,10 @@ void ResourcePixmap::draw_data(TrackCanvas *canvas, return; } - -// Redraw everything /* Incremental drawing is not possible with resource thread */ - if( 1 ) -// edit->startsource != this->startsource || -// mwindow->edl->session->sample_rate != project_samplerate || -// !EQUIV(mwindow->edl->session->frame_rate, project_framerate) || -// mwindow->edl->local_session->zoom_sample != zoom_sample || -// mwindow->edl->local_session->zoom_track != zoom_track || -// this->pixmap_h != pixmap_h || -// (data_type == TRACK_AUDIO && -// mwindow->edl->local_session->zoom_y != zoom_y) || -// (mode == 2) || -// need_redraw) - { -// Redraw the whole thing. - refresh_x = 0; - refresh_w = pixmap_w; - } - else { -// Start translated right - if( pixmap_w == this->pixmap_w && edit_x < this->edit_x && edit_w != pixmap_w ) { - refresh_w = this->edit_x - edit_x; - refresh_x = this->pixmap_w - refresh_w; - -// Moved completely off the pixmap - if( refresh_w > this->pixmap_w ) { - refresh_w = this->pixmap_w; - refresh_x = 0; - } - else { - copy_area(refresh_w, - y, - refresh_x, - mwindow->edl->local_session->zoom_track, - 0, - y); - } - } - else -// Start translated left - if( pixmap_w == this->pixmap_w && edit_x > this->edit_x && edit_w != pixmap_w ) { - refresh_x = 0; - refresh_w = edit_x - this->edit_x; - -// Moved completely off the pixmap - if( refresh_w > this->pixmap_w ) { - refresh_w = this->pixmap_w; - } - else { - copy_area(0, - y, - this->pixmap_w - refresh_w, - mwindow->edl->local_session->zoom_track, - refresh_w, - y); - } - } - else -// Start translated right and pixmap came off of right side - if( pixmap_w < this->pixmap_w && edit_x < this->edit_x && - this->edit_x + edit_w > this->pixmap_x + this->pixmap_w ) { - refresh_w = (this->edit_x + edit_w) - (this->pixmap_x + this->pixmap_w); - refresh_x = pixmap_w - refresh_w; - - if( refresh_w >= pixmap_w ) { - refresh_x = 0; - refresh_w = pixmap_w; - } - else { - copy_area(this->edit_x - edit_x, - y, - pixmap_w - refresh_w, - mwindow->edl->local_session->zoom_track, - 0, - y); - } - } - else -// Start translated right and reduced in size on the right. - if( pixmap_w < this->pixmap_w && edit_x < this->edit_x ) { - refresh_x = 0; - refresh_w = 0; - - copy_area(this->pixmap_w - pixmap_w, - y, - pixmap_w, - mwindow->edl->local_session->zoom_track, - 0, - y); - } - else -// Start translated left and pixmap came off left side - if( edit_x >= 0 && this->edit_x < 0 ) { - refresh_x = 0; - refresh_w = -this->edit_x; - - if( refresh_w > pixmap_w ) { - refresh_w = pixmap_w; - } - else { - copy_area(0, - y, - this->pixmap_w, - mwindow->edl->local_session->zoom_track, - refresh_w, - y); - } - } - else -// Start translated left and reduced in size on the right - if( pixmap_w < this->pixmap_w && edit_x > this->edit_x ) { - refresh_x = 0; - refresh_w = 0; - } - else -// Start translated right and left went into left side. - if( pixmap_w > this->pixmap_w && edit_x < 0 && this->edit_x > 0 ) { - refresh_w = pixmap_w - (edit_x + this->pixmap_w); - refresh_x = pixmap_w - refresh_w; - -// Moved completely off new pixmap - if( refresh_w > pixmap_w ) { - refresh_w = pixmap_w; - refresh_x = 0; - } - else { - copy_area(-edit_x, - y, - refresh_x, - mwindow->edl->local_session->zoom_track, - 0, - y); - } - } - else -// Start translated right and increased in size on the right - if( pixmap_w > this->pixmap_w && edit_x <= this->edit_x ) { - refresh_w = pixmap_w - this->pixmap_w; - refresh_x = pixmap_w - refresh_w; - } - else -// Start translated left and increased in size on the right - if( pixmap_w > this->pixmap_w && edit_x > this->edit_x ) { - refresh_x = 0; - refresh_w = edit_x - this->edit_x; - -// Moved completely off new pixmap - if( refresh_w > this->pixmap_w ) { - refresh_w = pixmap_w; - refresh_x = 0; - } -// Shift and insert - else { - copy_area(0, - y, - this->pixmap_w, - mwindow->edl->local_session->zoom_track, - refresh_w, - y); - } - } - } - -// Update pixmap settings - this->edit_id = edit->id; - this->startsource = edit->startsource; - - if( edit->asset ) - this->source_framerate = edit->asset->frame_rate; - else - if( edit->nested_edl ) - this->source_framerate = edit->nested_edl->session->frame_rate; - - if( edit->asset ) - this->source_samplerate = edit->asset->sample_rate; - else - if( edit->nested_edl ) - this->source_samplerate = edit->nested_edl->session->sample_rate; - - this->project_framerate = edit->edl->session->frame_rate; - this->project_samplerate = edit->edl->session->sample_rate; - this->edit_x = edit_x; - this->pixmap_x = pixmap_x; - this->pixmap_w = pixmap_w; - this->pixmap_h = pixmap_h; - this->zoom_sample = mwindow->edl->local_session->zoom_sample; - this->zoom_track = mwindow->edl->local_session->zoom_track; - this->zoom_y = mwindow->edl->local_session->zoom_y; - - +// Redraw everything + refresh_x = 0; + refresh_w = pixmap_w; // Draw background image if( refresh_w > 0 ) diff --git a/cinelerra-5.1/cinelerra/resourcepixmap.h b/cinelerra-5.1/cinelerra/resourcepixmap.h index 7d1394fd..1a2e1827 100644 --- a/cinelerra-5.1/cinelerra/resourcepixmap.h +++ b/cinelerra-5.1/cinelerra/resourcepixmap.h @@ -39,6 +39,9 @@ public: ~ResourcePixmap(); void resize(int w, int h); + void update_settings(Edit *edit, + int64_t edit_x, int64_t edit_w, + int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h); void draw_data(TrackCanvas *canvas, Edit *edit, int64_t edit_x, int64_t edit_w, int64_t pixmap_x, int64_t pixmap_w, int64_t pixmap_h, diff --git a/cinelerra-5.1/cinelerra/trackcanvas.C b/cinelerra-5.1/cinelerra/trackcanvas.C index 47edc557..061545ba 100644 --- a/cinelerra-5.1/cinelerra/trackcanvas.C +++ b/cinelerra-5.1/cinelerra/trackcanvas.C @@ -797,15 +797,14 @@ void TrackCanvas::draw_resources(int mode, if(pixmap_w && pixmap_h) { // Create pixmap if it doesn't exist - ResourcePixmap* pixmap = create_pixmap(edit, - edit_x, - pixmap_x, - pixmap_w, - pixmap_h); + ResourcePixmap* pixmap = create_pixmap(edit, edit_x, + pixmap_x, pixmap_w, pixmap_h); // Resize it if it's bigger - if(pixmap_w > pixmap->pixmap_w || - pixmap_h > pixmap->pixmap_h) + if( pixmap_w > pixmap->pixmap_w || + pixmap_h > pixmap->pixmap_h) pixmap->resize(pixmap_w, pixmap_h); + pixmap->update_settings(edit, edit_x, edit_w, + pixmap_x, pixmap_w, pixmap_h); // Draw data if( current->show_assets() ) pixmap->draw_data(this,