~ubuntu-branches/ubuntu/gutsy/gimp/gutsy

« back to all changes in this revision

Viewing changes to libgimpwidgets/test-preview-area.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-06-22 17:33:56 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070622173356-ncevaebpjiwyxkif
Tags: 2.3.18-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/control: Maintainer change.
  - debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch,
    debian/patches/10_dont_show_wizard.patch: Distro patches.
  - debian/rules:
    - use dh_iconcache,
    - i18n magic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
test_run (GtkWidget *area,
45
45
          gboolean   visible)
46
46
{
47
 
  guchar       *buf;
 
47
  guchar        buf[WIDTH * HEIGHT * 8];
48
48
  gint          i, j;
49
 
  gint          offset, offset2, offset3;
50
49
  gint          num_iters = NUM_ITERS;
51
50
  guchar        val;
52
51
  gdouble       start_time, total_time;
59
58
 
60
59
  gtk_widget_realize (area);
61
60
 
62
 
  g_print ("\nPerformance tests for GimpPreviewArea (%s, %d iterations):\n\n",
63
 
           visible ? "visible" : "hidden", num_iters);
64
 
 
65
 
  buf = g_malloc (WIDTH * HEIGHT * 8);
 
61
  g_print ("\nPerformance tests for GimpPreviewArea "
 
62
           "(%d x %d, %s, %d iterations):\n\n",
 
63
           WIDTH, HEIGHT, visible ? "visible" : "hidden", num_iters);
66
64
 
67
65
  val = 0;
68
66
  for (j = 0; j < WIDTH * HEIGHT * 8; j++)
71
69
      buf[j] = val;
72
70
    }
73
71
 
74
 
  gimp_preview_area_set_cmap (GIMP_PREVIEW_AREA (area), buf, 256);
 
72
  gimp_preview_area_set_colormap (GIMP_PREVIEW_AREA (area), buf, 256);
75
73
 
76
74
  /* Let's warm up the cache, and also wait for the window manager
77
75
     to settle. */
78
76
  for (i = 0; i < NUM_ITERS; i++)
79
77
    {
80
 
      offset = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
78
      gint offset = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
79
 
81
80
      gimp_preview_area_draw (GIMP_PREVIEW_AREA (area),
82
81
                              0, 0, WIDTH, HEIGHT,
83
82
                              GIMP_RGB_IMAGE,
99
98
 
100
99
      for (i = 0; i < num_iters; i++)
101
100
        {
102
 
          offset = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
101
          gint offset = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
102
 
103
103
          gimp_preview_area_draw (GIMP_PREVIEW_AREA (area),
104
104
                                  0, 0, WIDTH, HEIGHT,
105
105
                                  enum_value->value,
112
112
      gdk_flush ();
113
113
      total_time = g_timer_elapsed (timer, NULL) - start_time;
114
114
 
115
 
      g_print ("%-16s "
 
115
      g_print ("%-20s "
116
116
               "draw  :  %5.2fs, %8.1f fps, %8.2f megapixels/s\n",
117
117
               enum_value->value_name,
118
118
               total_time,
124
124
 
125
125
      for (i = 0; i < num_iters; i++)
126
126
        {
127
 
          offset  = (rand () % (WIDTH * HEIGHT * 4)) & -4;
128
 
          offset2 = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
127
          gint offset  = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
128
          gint offset2 = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
129
 
129
130
          gimp_preview_area_blend (GIMP_PREVIEW_AREA (area),
130
131
                                   0, 0, WIDTH, HEIGHT,
131
132
                                   enum_value->value,
141
142
      gdk_flush ();
142
143
      total_time = g_timer_elapsed (timer, NULL) - start_time;
143
144
 
144
 
      g_print ("%-16s "
 
145
      g_print ("%-20s "
145
146
               "blend :  %5.2fs, %8.1f fps, %8.2f megapixels/s\n",
146
147
               enum_value->value_name,
147
148
               total_time,
153
154
 
154
155
      for (i = 0; i < num_iters; i++)
155
156
        {
156
 
          offset  = (rand () % (WIDTH * HEIGHT * 4)) & -4;
157
 
          offset2 = (rand () % (WIDTH * HEIGHT * 4)) & -4;
158
 
          offset3 = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
157
          gint offset  = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
158
          gint offset2 = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
159
          gint offset3 = (rand () % (WIDTH * HEIGHT * 4)) & -4;
 
160
 
159
161
          gimp_preview_area_mask (GIMP_PREVIEW_AREA (area),
160
162
                                  0, 0, WIDTH, HEIGHT,
161
163
                                  enum_value->value,
172
174
      gdk_flush ();
173
175
      total_time = g_timer_elapsed (timer, NULL) - start_time;
174
176
 
175
 
      g_print ("%-16s "
 
177
      g_print ("%-20s "
176
178
               "mask  :  %5.2fs, %8.1f fps, %8.2f megapixels/s\n",
177
179
               enum_value->value_name,
178
180
               total_time,
198
200
 
199
201
  gdk_flush ();
200
202
  total_time = g_timer_elapsed (timer, NULL) - start_time;
201
 
  g_print ("%-16s "
 
203
  g_print ("%-20s "
202
204
           "fill  :  %5.2fs, %8.1f fps, %8.2f megapixels/s\n",
203
205
           "Color fill",
204
206
           total_time,
205
207
           num_iters / total_time,
206
208
           num_iters * (WIDTH * HEIGHT * 1e-6) / total_time);
207
209
  g_print ("\n");
208
 
 
209
 
  g_free (buf);
210
210
}
211
211
 
212
212
static void
217
217
 
218
218
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
219
219
 
 
220
  gtk_window_set_accept_focus (GTK_WINDOW (window), FALSE);
 
221
 
220
222
  area = gimp_preview_area_new ();
221
223
  gtk_container_add (GTK_CONTAINER (window), area);
222
224
  gtk_widget_show (area);