Update of /cvsroot/ufraw/ufraw
In directory sfp-cvsdas-2.v30.ch3.sourceforge.com:/tmp/cvs-serv5651

Modified Files:
        dcraw.cc dcraw.h dcraw_api.cc dcraw_api.h dcraw_indi.c 
        ufraw-batch.c ufraw.h ufraw_preview.c ufraw_ufraw.c 
        ufraw_writer.c 
Added Files:
        uf_progress.h 
Log Message:
Replace the old progress bar. Patch by Frank van Maarseveen.

Index: ufraw_writer.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_writer.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- ufraw_writer.c      21 Nov 2009 05:51:59 -0000      1.67
+++ ufraw_writer.c      25 Nov 2009 16:15:45 -0000      1.68
@@ -215,9 +215,9 @@
     int byteDepth = (bitDepth+7)/8;
     guint8 pixbuf8[width * 3 * byteDepth * DEVELOP_BATCH];
 
+    progress(PROGRESS_SAVE, -height);
     for (row0 = 0; row0 < height; row0 += DEVELOP_BATCH) {
-       preview_progress(uf->widget, _("Saving image"),
-               0.5 + 0.5*row0/height);
+       progress(PROGRESS_SAVE, DEVELOP_BATCH);
 #ifdef _OPENMP
 #pragma omp parallel for default(shared) private(row)
 #endif
@@ -616,10 +616,9 @@
        // Avoid FITS images being saved upside down
        ufraw_flip_image(uf, 2);
 
+       progress(PROGRESS_SAVE, -height);
        for (row=0; row<height; row++) {
-           if (row%100==99)
-               preview_progress(uf->widget, _("Saving image"),
-                       0.5 + 0.5*row/height);
+           progress(PROGRESS_SAVE, 1);
            for (i=0; i < width; i++)
            {
                offset = row*width + i;

Index: dcraw_indi.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/dcraw_indi.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- dcraw_indi.c        18 Oct 2009 16:00:18 -0000      1.78
+++ dcraw_indi.c        25 Nov 2009 16:15:45 -0000      1.79
@@ -25,6 +25,7 @@
 #include <glib.h>
 #include <glib/gi18n.h> /*For _(String) definition - NKBJ*/
 #include "dcraw_api.h"
+#include "uf_progress.h"
 
 #ifdef _OPENMP
 #include <omp.h>
@@ -139,6 +140,7 @@
   float temp[iheight + iwidth];
 #endif
   if ((nc = colors) == 3 && filters) nc++;
+  progress(PROGRESS_WAVELET_DENOISE, -nc*5);
 #ifdef _OPENMP
 #pragma omp parallel for                               \
   default(none)                                                \
@@ -150,6 +152,7 @@
     for (i=0; i < size; i++)
       fimg[i] = 256 * sqrt(image[i][c] /*<< scale*/);
     for (hpass=lev=0; lev < 5; lev++) {
+      progress(PROGRESS_WAVELET_DENOISE, 1);
       lpass = size*((lev & 1)+1);
       for (row=0; row < iheight; row++) {
        hat_transform (temp, fimg+hpass+row*iwidth, 1, iwidth, 1 << lev);
@@ -481,6 +484,7 @@
          *ip++ = 0;
       }
     }
+    progress(PROGRESS_INTERPOLATE, -height);
 #ifdef _OPENMP
 #pragma omp parallel                                   \
     default(none)                                      \
@@ -492,6 +496,7 @@
     int start_row = 2 + slice * uf_omp_get_thread_num();
     int end_row = MIN(start_row + slice, height - 2);
     for (row=start_row; row < end_row; row++) {        /* Do VNG interpolation 
*/
+      progress(PROGRESS_INTERPOLATE, 1);
       for (g = 0; g < 4; g++)
        brow[g] = &rowtmp[(row + g - 2) % 4];
       for (col=2; col < width-2; col++) {
@@ -669,10 +674,12 @@
   lab  = (short (*)[TS][TS][3])(buffer + 12*TS*TS);
   homo = (char  (*)[TS][TS])   (buffer + 24*TS*TS);
 
+  progress(PROGRESS_INTERPOLATE, -height);
 #ifdef _OPENMP
 #pragma omp for
 #endif
-  for (top=2; top < height-5; top += TS-6)
+  for (top=2; top < height-5; top += TS-6) {
+    progress(PROGRESS_INTERPOLATE, TS-6);
     for (left=2; left < width-5; left += TS-6) {
 
 /*  Interpolate green horizontally and vertically:             */
@@ -764,8 +771,9 @@
        }
       }
     }
-  free (buffer);
   }
+  free (buffer);
+  }    /* _OPENMP */
 }
 #undef TS
 

Index: dcraw.cc
===================================================================
RCS file: /cvsroot/ufraw/ufraw/dcraw.cc,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -d -r1.203 -r1.204
--- dcraw.cc    30 Oct 2009 06:30:25 -0000      1.203
+++ dcraw.cc    25 Nov 2009 16:15:44 -0000      1.204
@@ -18,6 +18,9 @@
 #ifdef HAVE_CONFIG_H /*For UFRaw config system - NKBJ*/
 #include "config.h"
 #endif
+extern "C" {
+#include "uf_progress.h"
+}
 
 #define DCRAW_VERSION "8.98"
 
@@ -139,7 +142,6 @@
 ifpReadCount = 0;
 ifpSize = 0;
 ifpStepProgress = 0;
-progressHandle = NULL;
 }
 
 CLASS ~DCRaw()
@@ -152,8 +154,14 @@
     ifpReadCount += readCount;
     if (ifpSize==0) return;
     unsigned newStepProgress = STEPS * ifpReadCount / ifpSize;
-    if (newStepProgress!=ifpStepProgress && progressHandle!=NULL )
-        (*progressHandle)(progressUserData, (double)ifpReadCount/ifpSize);
+    if (newStepProgress > ifpStepProgress) {
+#ifdef DCRAW_NOMAIN
+       if (ifpStepProgress)
+           progress(PROGRESS_LOAD, newStepProgress - ifpStepProgress);
+       else
+           progress(PROGRESS_LOAD, -STEPS);
+#endif
+    }
     ifpStepProgress = newStepProgress;
 }
 

Index: ufraw-batch.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw-batch.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- ufraw-batch.c       3 Nov 2009 06:41:31 -0000       1.29
+++ ufraw-batch.c       25 Nov 2009 16:15:45 -0000      1.30
@@ -173,10 +173,3 @@
     parentWindow = parentWindow;
     if (!silentMessenger) ufraw_batch_messenger(message);
 }
-
-void preview_progress(void *widget, char *text, double progress)
-{
-    widget = widget;
-    text = text;
-    progress = progress;
-}

Index: ufraw.h
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw.h,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -d -r1.137 -r1.138
--- ufraw.h     21 Nov 2009 05:51:59 -0000      1.137
+++ ufraw.h     25 Nov 2009 16:15:45 -0000      1.138
@@ -18,6 +18,7 @@
 #endif /* HAVE_LENSFUN */
 
 #include "nikon_curve.h"
+#include "uf_progress.h"
 
 /* macro to clamp a number between two values */
 #ifndef LIM
@@ -368,7 +369,6 @@
        long (*save_func)());
 void ufraw_focus(void *window, gboolean focus);
 void ufraw_messenger(char *message, void *parentWindow);
-void preview_progress(void *widget, char *text, double progress);
 
 /* prototypes for functions in ufraw_routines.c */
 const char *uf_get_home_dir();

Index: ufraw_ufraw.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_ufraw.c,v
retrieving revision 1.219
retrieving revision 1.220
diff -u -d -r1.219 -r1.220
--- ufraw_ufraw.c       21 Nov 2009 06:17:05 -0000      1.219
+++ ufraw_ufraw.c       25 Nov 2009 16:15:45 -0000      1.220
@@ -33,6 +33,8 @@
 #include "nikon_curve.h"
 #include "ufraw.h"
 
+void (*ufraw_progress)(int what, int ticks);
+
 #ifdef HAVE_LENSFUN
 /* What about LF_MODIFY_ALL? */
 #define UF_LF_ALL (LF_MODIFY_TCA | LF_MODIFY_VIGNETTING | \
@@ -560,11 +562,6 @@
     return UFRAW_SUCCESS;
 }
 
-static void ufraw_load_raw_progress(void *user_data, double progress)
-{
-    preview_progress(user_data, _("Loading preview"), progress);
-}
-
 /* Scale pixel values: occupy 16 bits to get more precision. In addition
  * this normalizes the pixel values which is good for non-linear algorithms
  * which forget to check rgbMax or assume a particular value. */
@@ -606,7 +603,6 @@
        uf->thumb.width = thumb.width;
        return ufraw_read_embedded(uf);
     }
-    dcraw_set_progress_handle(raw, ufraw_load_raw_progress, uf->widget);
     if ( (status=dcraw_load_raw(raw))!=DCRAW_SUCCESS ) {
        ufraw_message(UFRAW_SET_LOG, raw->message);
        ufraw_message(status, raw->message);
@@ -1075,8 +1071,10 @@
        if (passes[c] > maxpass)
            maxpass = passes[c];
     }
+    progress(PROGRESS_DESPECKLE, -maxpass * colors);
     for (pass = maxpass - 1; pass >= 0; --pass) {
        for (c = 0; c < colors; ++c) {
+           progress(PROGRESS_DESPECKLE, 1);
            if (pass >= passes[c])
                continue;
 #ifdef _OPENMP

Index: ufraw_preview.c
===================================================================
RCS file: /cvsroot/ufraw/ufraw/ufraw_preview.c,v
retrieving revision 1.310
retrieving revision 1.311
diff -u -d -r1.310 -r1.311
--- ufraw_preview.c     23 Nov 2009 16:30:12 -0000      1.310
+++ ufraw_preview.c     25 Nov 2009 16:15:45 -0000      1.311
@@ -683,13 +683,18 @@
     return FALSE;
 }
 
+static gboolean is_rendering(preview_data *data)
+{
+    return data->RenderSubArea >= 0;
+}
+
 static gboolean switch_highlights(gpointer ptr)
 {
     preview_data *data = ptr;
     /* Only redraw the highlights in the default rendering mode. */
     if (data->RenderMode!=render_default || data->FreezeDialog)
        return TRUE;
-    if (data->RenderSubArea == -1) {
+    if (!is_rendering(data)) {
        /* Set the area to redraw based on the crop rectangle and view port. */
        int x1, x2, y1, y2;
        scale_crop_to_final_image(data->UF, &x1, &x2, &y1, &y2);
@@ -766,7 +771,6 @@
     gtk_progress_bar_set_fraction(data->ProgressBar, 0);
 }
 
-static gboolean render_prepare(preview_data *data);
 static gboolean render_raw_histogram(preview_data *data);
 static gboolean render_preview_image(preview_data *data);
 static gboolean render_live_histogram(preview_data *data);
@@ -807,23 +811,118 @@
                xc - vp.width / 2, yc - vp.height / 2, FALSE);
 
     }
-    render_status_text(data);
 }
 
-void render_preview(preview_data *data)
+static GtkProgressBar *ProgressBar;
+static GTimer *ProgressTimer;
+static void preview_progress(int what, int ticks)
 {
-    if (data->FreezeDialog) return;
+    static int last_what, todo, done;
+    char *text;
+    double start, stop, fraction;
+    gboolean update = FALSE;
+    gboolean events = TRUE;
 
-    data->RenderSubArea = 0;
-    while (g_idle_remove_by_data(data))
-       ;
-    g_idle_add_full(G_PRIORITY_DEFAULT_IDLE-10,
-           (GSourceFunc)(render_prepare), data, NULL);
+#ifdef _OPENMP
+#pragma omp master
+#endif
+    update = TRUE;
+#ifdef _OPENMP
+#pragma omp critical(preview_progress)
+    {
+#endif
+       if (ticks < 0) {
+           todo = -ticks;
+           done = 0;
+           last_what = what;
+       } else {
+           if (last_what == what)
+               done += ticks;
+           else
+               update = FALSE;
+       }
+#ifdef _OPENMP
+    }
+#endif
+    if (!update)
+       return;         // wrong thread for GTK or "what" mismatch
+    if (g_timer_elapsed(ProgressTimer, NULL) < 0.07 && ticks >= 0)
+       return;         // avoid progress bar rendering hog
+    g_timer_start(ProgressTimer);
+    switch (what) {
+    case PROGRESS_WAVELET_DENOISE:
+       text = _("Wavelet denoising");
+       start = 0.0;
+       stop = 0.33;
+       break;
+    case PROGRESS_DESPECKLE:
+       text = _("Despeckling");
+       start = 0.0;
+       stop = 0.33;
+       break;
+    case PROGRESS_INTERPOLATE:
+       text = _("Interpolating");
+       start = 0.33;
+       stop = 0.66;
+       break;
+    case PROGRESS_RENDER:
+       text = _("Rendering");
+       start = 0.67;
+       stop = 1.0;
+       events = FALSE;
+       break;
+    case PROGRESS_LOAD:
+       text = _("Loading preview");
+       start = 0.0;
+       stop = 1.0;
+       break;
+    case PROGRESS_SAVE:
+       text = _("Saving image");
+       start = 0.0;
+       stop = 1.0;
+       break;
+    case PROGRESS_RESET:
+    default:
+       text = NULL;
+       start = stop = 0.0;
+       todo = done = 0;
+       events = FALSE;
+    }
+    if (ticks < 0 && text)
+       gtk_progress_bar_set_text(ProgressBar, text);
+    fraction = todo ? start + (stop - start) * done / todo : 0;
+    if (fraction > stop)
+       fraction = stop;
+    gtk_progress_bar_set_fraction(ProgressBar, fraction);
+    if (events)
+       while (gtk_events_pending())
+           gtk_main_iteration();
 }
 
-static gboolean render_prepare(preview_data *data)
+static void preview_progress_enable(preview_data *data)
 {
-    if (data->FreezeDialog) return FALSE;
+    ProgressBar = data->ProgressBar;
+    ProgressTimer = g_timer_new();
+    preview_progress(PROGRESS_RESET, 0);
+    ufraw_progress = preview_progress;
+}
+
+static void preview_progress_disable(preview_data *data)
+{
+    preview_progress(PROGRESS_RESET, 0);
+    ufraw_progress = NULL;
+    g_timer_destroy(ProgressTimer);
+    render_status_text(data);
+}
+
+static gboolean render_preview_now(preview_data *data)
+{
+    if (data->FreezeDialog)
+       return FALSE;
+
+    while (g_idle_remove_by_data(data))
+       ;
+    data->RenderSubArea = 0;
 
     if (CFG->autoExposure == apply_state) {
        ufraw_auto_expose(data->UF);
@@ -850,6 +949,7 @@
            CFG->curve[CFG->curveIndex].m_anchors[0].x);
     gtk_label_set_text(GTK_LABEL(data->BlackLabel), text);
 
+    ufraw_developer_prepare(data->UF, display_developer);
     if ( CFG->profileIndex[display_profile]==0 ) {
        guint8 *displayProfile;
        gint profileSize;
@@ -863,23 +963,34 @@
                CFG->profile[display_profile]
                        [CFG->profileIndex[display_profile]].productName);
     }
-    ufraw_developer_prepare(data->UF, display_developer);
     ufraw_convert_prepare_buffers(data->UF);
 
-    /* The reset of the rendering can be triggered only after the call to
-     * ufraw_developer_preare(). Otherwise error messages in this function
-     * would cause timing problems. */
-    g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
-           (GSourceFunc)(render_raw_histogram), data, NULL);
-    g_idle_add_full(G_PRIORITY_DEFAULT_IDLE+10,
-           (GSourceFunc)(render_preview_image), data, NULL);
-    g_idle_add_full(G_PRIORITY_DEFAULT_IDLE+20,
-           (GSourceFunc)(render_live_histogram), data, NULL);
-    g_idle_add_full(G_PRIORITY_DEFAULT_IDLE+20,
-           (GSourceFunc)(render_spot), data, NULL);
+    /* This will trigger the untiled phases if necessary. The progress bar
+     * updates require gtk_main_iteration() calls which can only be
+     * done when there are no pending idle tasks which could recurse
+     * into ufraw_convert_image_area(). */
+    preview_progress_enable(data);
+    gboolean again = render_preview_image(data);
+
+    if (again) {
+       preview_progress(PROGRESS_RENDER, -32);
+       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+               (GSourceFunc)(render_preview_image), data, NULL);
+    }
     return FALSE;
 }
 
+void render_preview(preview_data *data)
+{
+    if (is_rendering(data))
+       return;
+
+    while (g_idle_remove_by_data(data))
+       ;
+    g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+           (GSourceFunc)(render_preview_now), data, NULL);
+}
+
 static gboolean render_raw_histogram(preview_data *data)
 {
     if (data->FreezeDialog) return FALSE;
@@ -1077,6 +1188,7 @@
                subarea, ufraw_phases_num - 1);
        UFRectangle area = ufraw_image_get_subarea_rectangle(img1, subarea);
        preview_draw_area(data, area.x, area.y, area.width, area.height);
+       progress(PROGRESS_RENDER, 1);
        again = TRUE;
     }
 
@@ -1084,6 +1196,15 @@
     }
 #endif
 
+    if (!again) {
+       preview_progress_disable(data);
+       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+               (GSourceFunc)(render_raw_histogram), data, NULL);
+       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+               (GSourceFunc)(render_live_histogram), data, NULL);
+       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+               (GSourceFunc)(render_spot), data, NULL);
+    }
     return again;
 }
 
@@ -1493,7 +1614,7 @@
 
     data->FreezeDialog = FALSE;
     update_shrink_ranges(data);
-    render_preview(data);
+    render_preview_now(data);
 }
 
 static void curve_update(GtkWidget *widget, long curveType)
@@ -1698,8 +1819,9 @@
        draw_spot(data, FALSE);
        data->SpotX1 = data->SpotX2 = event->x;
        data->SpotY1 = data->SpotY2 = event->y;
-       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE+20,
-               (GSourceFunc)(render_spot), data, NULL);
+       if (!is_rendering(data))
+           g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+                   (GSourceFunc)(render_spot), data, NULL);
        return TRUE;
     }
     if ( data->PageNum==data->PageNumCrop ) {
@@ -1830,8 +1952,9 @@
     event_coordinate_rescale(&event->x, &event->y, data);
     data->SpotX2 = event->x;
     data->SpotY2 = event->y;
-    g_idle_add_full(G_PRIORITY_DEFAULT_IDLE+20,
-           (GSourceFunc)(render_spot), data, NULL);
+    if (!is_rendering(data))
+       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+               (GSourceFunc)(render_spot), data, NULL);
     return TRUE;
 }
 
@@ -1961,8 +2084,9 @@
        data->DrawCropID = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE+30,
                (GSourceFunc)(preview_draw_crop), data, NULL);
     }
-    g_idle_add_full(G_PRIORITY_DEFAULT_IDLE+20,
-           (GSourceFunc)(render_live_histogram), data, NULL);
+    if (!is_rendering(data))
+       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+               (GSourceFunc)(render_live_histogram), data, NULL);
 }
 
 static void crop_reset(GtkWidget *widget, gpointer user_data)
@@ -2138,10 +2262,9 @@
     --data->FreezeDialog;
 
     render_init(data);
-    if ( data->RenderSubArea >= 0 ) {
-       /* We are in the middle or a rendering scan,
-        * so just start from the beginning. */
-       data->RenderSubArea = 0;        /* TODO: feature does not exist */
+    if (is_rendering(data)) {
+       /* TODO: We are in the middle or a rendering scan,
+        * so we should restart from the beginning. */
     } else {
        /* Full image was already rendered.
         * We only need to draw the flipped image. */
@@ -3776,18 +3899,21 @@
                    "expander-maximized", (gpointer)FALSE);
        }
     }
-    // Redraw histograms if size allocation has changed
-    GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(data->RawHisto));
-    rawHisHeight = data->RawHisto->allocation.height;
-    if ( pixbuf==NULL || gdk_pixbuf_get_height(pixbuf)!=rawHisHeight )
-       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
-               (GSourceFunc)(render_raw_histogram), data, NULL);
 
-    pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(data->LiveHisto));
-    liveHisHeight = data->LiveHisto->allocation.height;
-    if ( pixbuf==NULL || gdk_pixbuf_get_height(pixbuf)!=liveHisHeight )
-       g_idle_add_full(G_PRIORITY_DEFAULT_IDLE+20,
-               (GSourceFunc)(render_live_histogram), data, NULL);
+    if (!is_rendering(data)) {
+       // Redraw histograms if size allocation has changed
+       GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(data->RawHisto));
+       rawHisHeight = data->RawHisto->allocation.height;
+       if ( pixbuf==NULL || gdk_pixbuf_get_height(pixbuf)!=rawHisHeight )
+           g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+                   (GSourceFunc)(render_raw_histogram), data, NULL);
+
+       pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(data->LiveHisto));
+       liveHisHeight = data->LiveHisto->allocation.height;
+       if ( pixbuf==NULL || gdk_pixbuf_get_height(pixbuf)!=liveHisHeight )
+           g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
+                   (GSourceFunc)(render_live_histogram), data, NULL);
+    }
 }
 
 static gboolean histogram_menu(GtkMenu *menu, GdkEventButton *event)
@@ -3799,16 +3925,6 @@
     return TRUE;
 }
 
-void preview_progress(void *widget, char *text, double progress)
-{
-    if (widget==NULL) return;
-    preview_data *data = get_preview_data(widget);
-    if (data->ProgressBar==NULL) return;
-    gtk_progress_bar_set_text(data->ProgressBar, text);
-    gtk_progress_bar_set_fraction(data->ProgressBar, progress);
-    while (gtk_events_pending()) gtk_main_iteration();
-}
-
 static void control_button_event(GtkWidget *widget, long type)
 {
     preview_data *data = get_preview_data(widget);
@@ -3842,7 +3958,9 @@
            response = UFRAW_RESPONSE_DELETE;
        break;
     case save_button:
+       preview_progress_enable(data);
        status = ufraw_save_now(data->UF, widget);
+       preview_progress_disable(data);
        if (status == UFRAW_SUCCESS)
            response = GTK_RESPONSE_OK;
        break;
@@ -5697,9 +5815,6 @@
        gtk_widget_hide(GTK_WIDGET(data->LightnessAdjustmentTable[i]));
     gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), data->PageNumSpot);
 
-    // preview_progress() changes the size of the progress bar
-    // and processes the event queue.
-    preview_progress(previewWindow, _("Loading preview"), 0.2);
 #if !GTK_CHECK_VERSION(2,8,0)
     /* There is a bug that causes the mouse location to be misplaced
      * in the event-box. The following voodoo seems to fix the mapping. */
@@ -5733,7 +5848,9 @@
        data->Cursor[i] = gdk_cursor_new(Cursors[i]);
     gdk_window_set_cursor(PreviewEventBox->window, data->Cursor[spot_cursor]);
     gtk_widget_set_sensitive(data->Controls, FALSE);
+    preview_progress_enable(data);
     ufraw_load_raw(uf);
+    preview_progress_disable(data);
     gtk_widget_set_sensitive(data->Controls, TRUE);
 
     // Set shrink/size values for preview rendering
@@ -5747,18 +5864,6 @@
        CFG->size = 0;
     }
 
-    /* Collect raw histogram data */
-    memset(data->raw_his, 0, sizeof(data->raw_his));
-    /* minor issue: this triggers the first phase conversion too soon */
-    ufraw_developer_prepare(uf, display_developer);
-    ufraw_image_data *image = ufraw_rgb_image(data->UF, TRUE, NULL);
-    for (i=0; i<image->height*image->width; i++) {
-           guint16 *buf = (guint16*)(image->buffer+i*image->depth);
-           for (c=0; c<data->UF->colors; c++)
-               data->raw_his[MIN( buf[c] *
-                       (raw_his_size-1) / data->UF->rgbMax,
-                       raw_his_size-1) ][c]++;
-    }
     /* Save initial WB data for the sake of "Reset WB" */
     g_strlcpy(data->initialWB, CFG->wb, max_name);
     data->initialTemperature = CFG->temperature;
@@ -5769,10 +5874,24 @@
     curveeditor_widget_set_curve(data->CurveWidget,
            &CFG->curve[CFG->curveIndex]);
 
+    memset(data->raw_his, 0, sizeof(data->raw_his));
+    data->RenderSubArea = -1;
     data->FreezeDialog = FALSE;
     data->RenderMode = render_default;
-    update_crop_ranges(data, FALSE);
+
+    /* This will start the conversion and enqueue rendering functions */
     update_scales(data);
+    update_crop_ranges(data, FALSE);   // calls ufraw_final_image(uf, FALSE)
+
+    /* Collect raw histogram data */
+    ufraw_image_data *image = ufraw_rgb_image(data->UF, TRUE, G_STRFUNC);
+    for (i=0; i<image->height*image->width; i++) {
+           guint16 *buf = (guint16*)(image->buffer+i*image->depth);
+           for (c=0; c<data->UF->colors; c++)
+               data->raw_his[MIN( buf[c] *
+                       (raw_his_size-1) / data->UF->rgbMax,
+                       raw_his_size-1) ][c]++;
+    }
 
     data->OverUnderTicker = 0;
 

Index: dcraw.h
===================================================================
RCS file: /cvsroot/ufraw/ufraw/dcraw.h,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- dcraw.h     30 Aug 2009 15:55:45 -0000      1.55
+++ dcraw.h     25 Nov 2009 16:15:45 -0000      1.56
@@ -94,8 +94,6 @@
 unsigned ifpSize;
 unsigned ifpStepProgress;
 #define STEPS 50
-void (*progressHandle)(void *user_data, double progress);
-void *progressUserData;
 void ifpProgress(unsigned readCount);
 // Override standard io function for integrity checks and progress report
 size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);

Index: dcraw_api.h
===================================================================
RCS file: /cvsroot/ufraw/ufraw/dcraw_api.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- dcraw_api.h 28 Oct 2009 04:44:05 -0000      1.36
+++ dcraw_api.h 25 Nov 2009 16:15:45 -0000      1.37
@@ -59,9 +59,6 @@
     dcraw_none_interpolation };
 enum { unknown_thumb_type, jpeg_thumb_type, ppm_thumb_type };
 int dcraw_open(dcraw_data *h, char *filename);
-void dcraw_set_progress_handle(dcraw_data *h,
-       void (*progressHandle)(void *user_data, double progress),
-       void *progressUserData);
 int dcraw_load_raw(dcraw_data *h);
 int dcraw_load_thumb(dcraw_data *h, dcraw_image_data *thumb);
 int dcraw_finalize_shrink(dcraw_image_data *f, dcraw_data *h,

Index: dcraw_api.cc
===================================================================
RCS file: /cvsroot/ufraw/ufraw/dcraw_api.cc,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- dcraw_api.cc        29 Oct 2009 05:14:59 -0000      1.60
+++ dcraw_api.cc        25 Nov 2009 16:15:45 -0000      1.61
@@ -153,15 +153,6 @@
     return d->lastStatus;
 }
 
-void dcraw_set_progress_handle(dcraw_data *h,
-       void (*progressHandle)(void *user_data, double progress),
-       void *progressUserData)
-{
-    DCRaw *d = (DCRaw *)h->dcraw;
-    d->progressHandle = progressHandle;
-    d->progressUserData = progressUserData;
-}
-
 int dcraw_image_dimensions(dcraw_data *raw, int flip, int *height, int *width)
 {
     if (raw->fuji_width) {

--- NEW FILE: uf_progress.h ---
/*
 * UFRaw - Unidentified Flying Raw converter for digital camera images
 *
 * uf_progress.h - progress bar header
 * Copyright 2009 by Frank van Maarseveen
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

#ifndef _UF_PROGRESS_H
#define _UF_PROGRESS_H

#define PROGRESS_RESET                  0       /* special */
#define PROGRESS_WAVELET_DENOISE        1
#define PROGRESS_DESPECKLE              2
#define PROGRESS_INTERPOLATE            3
#define PROGRESS_RENDER                 4       /* tiled work */

#define PROGRESS_LOAD                   5
#define PROGRESS_SAVE                   6

extern void (*ufraw_progress)(int what, int ticks);

/*
 * The first call for a PROGRESS_* activity should specify a negative number
 * of ticks. This call will prepare the corresponding progress bar segment.
 * Subsequent calls for the same activity should specify a non-negative number
 * of ticks corresponding to the amount of work just done. The total number
 * of ticks including the initialization call should be approximately zero.
 *
 * This function is thread safe. See also preview_progress().
 */
static inline void progress(int what, int ticks)
{
    if (ufraw_progress)
        ufraw_progress(what, ticks);
}

#endif /* _UF_PROGRESS_H */


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
ufraw-cvs mailing list
ufraw-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ufraw-cvs

Reply via email to