update resource pixmap settings even if asset not drawn
authorGood Guy <good1.2guy@gmail.com>
Thu, 27 Sep 2018 03:09:42 +0000 (21:09 -0600)
committerGood Guy <good1.2guy@gmail.com>
Thu, 27 Sep 2018 03:09:42 +0000 (21:09 -0600)
cinelerra-5.1/cinelerra/resourcepixmap.C
cinelerra-5.1/cinelerra/resourcepixmap.h
cinelerra-5.1/cinelerra/trackcanvas.C

index cdc1e1b1d4b8b2d79a425f5bc8c4494cc22cf4a0..2ffd86ca58287ecc74747ca45926331e82f4f38f 100644 (file)
@@ -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 )
index 7d1394fdfe901de73db8a2edb723d1e4e9825a9a..1a2e1827914049f5812b2f61431e6657bf008f11 100644 (file)
@@ -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,
index 47edc557ddc370c9307c6a42709904f6ccbe4204..061545bac18728ba5f25be967788c789a304367f 100644 (file)
@@ -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,