~bratsche/ubuntu/maverick/gtk+2.0/menu-activation-fix

« back to all changes in this revision

Viewing changes to gdk-pixbuf/pixops/timescale.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2010-07-22 21:41:30 UTC
  • mfrom: (1.11.7 upstream) (72.1.16 experimental)
  • Revision ID: james.westby@ubuntu.com-20100722214130-5uzyvpb9g4m0ts2c
Tags: 2.21.5-1ubuntu1
* Merge with Debian experimental, Ubuntu changes:
* debian/control.in:
  - Add introspection build-depends
  - Add Vcs-Bzr link
  - Add gir1.0-gtk-2.0 package
  - libgtk2.0-dev replaces gir-repository-dev
  - Conflict with appmenu-gtk (<< 0.1.3) to prevent menu proxy breakage
* debian/rules:
  - Build with --enable-introspection
  - Add gir1.0-gtk-2.0 package to BINARY_ARCH_PKGS
  - Add dh_girepository call
  - Disable devhelp files
* debian/dh_gtkmodules.in:
  - Remove obsolete script content
* debian/libgtk2.0-0.symbols:
  - Add Ubuntu specific symbols
* debian/libgtk2.0-dev.install.in:
  - Add gir files
* debian/libgtk2.0-doc.install.in
  - Disable devhelp files
* debian/gir1.0-gtk-2.0.install.in
  - Introspection package
* debian/patches/043_menu_proxy.patch
  - Add GtkMenuProxy support for remoting menus.
* debian/patches/062_dnd_menubar.patch:
  - Allow click on menubars for dnd
* debian/patches/063_treeview_almost_fixed.patch:
  - Add an ubuntu-almost-fixed-height-mode property, (required for
    software-center)
* debian/patches/071_no_offscreen_widgets_grabbing.patch:
  - Don't let offscreen widgets do grabbing
* debian/patches/072_indicator_menu_update.patch:
  - change by Cody Russell to send an update event on menu changes,
    should make the bluetooth indicator refresh correctly
* debian/patches/091_bugzilla_tooltip_refresh.patch:
  - Upstream bugzilla change to have better looking tooltips the gtk theme
    need to set "new-tooltip-style" to use those
* debian/watch:
  - Watch for unstable versions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2000 Red Hat, Inc
3
 
 *
4
 
 * This library is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU Lesser General Public
6
 
 * License as published by the Free Software Foundation; either
7
 
 * version 2 of the License, or (at your option) any later version.
8
 
 *
9
 
 * This library is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 
 * Lesser General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU Lesser General Public
15
 
 * License along with this library; if not, write to the
16
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 
 * Boston, MA 02111-1307, USA.
18
 
 */
19
 
#include "config.h"
20
 
#include <glib.h>
21
 
#include <string.h>
22
 
#include <stdlib.h>
23
 
#include <stdio.h>
24
 
 
25
 
#include "pixops.h"
26
 
 
27
 
static GTimeVal start_time;
28
 
 
29
 
static void 
30
 
start_timing (void)
31
 
{
32
 
  g_get_current_time (&start_time);
33
 
}
34
 
 
35
 
static double
36
 
stop_timing (const char *test, int iterations, int bytes)
37
 
{
38
 
  GTimeVal stop_time;
39
 
  double msecs;
40
 
  
41
 
  g_get_current_time (&stop_time);
42
 
  if (stop_time.tv_usec < start_time.tv_usec)
43
 
    {
44
 
      stop_time.tv_usec += 1000000;
45
 
      stop_time.tv_sec -= 1;
46
 
    }
47
 
 
48
 
  msecs = (stop_time.tv_sec - start_time.tv_sec) * 1000. +
49
 
          (stop_time.tv_usec - start_time.tv_usec) / 1000.;
50
 
 
51
 
  printf("%s%d\t%.1f\t\t%.2f\t\t%.2f\n",
52
 
         test, iterations, msecs, msecs / iterations, ((double)bytes * iterations) / (1000*msecs));
53
 
 
54
 
  return ((double)bytes * iterations) / (1000*msecs);
55
 
}
56
 
 
57
 
static void
58
 
init_array (double times[3][3][4])
59
 
{
60
 
  int i, j, k;
61
 
  
62
 
  for (i=0; i<3; i++)
63
 
    for (j=0; j<3; j++)
64
 
      for (k=0; k<4; k++)
65
 
        times[i][j][k] = -1;
66
 
}
67
 
 
68
 
static void
69
 
dump_array (double times[3][3][4])
70
 
{
71
 
  int i, j;
72
 
  
73
 
  printf("        3\t4\t4a\n");
74
 
  for (i=0; i<3; i++)
75
 
    {
76
 
      for (j=0; j<4; j++)
77
 
        {
78
 
          if (j == 0)
79
 
            switch (i)
80
 
              {
81
 
              case 0:
82
 
                printf("3  ");
83
 
                break;
84
 
              case 1:
85
 
                printf("4  ");
86
 
                break;
87
 
              case 2:
88
 
                printf("4a ");
89
 
                break;
90
 
              }
91
 
          else
92
 
            printf("   ");
93
 
 
94
 
          printf("%6.2f  %6.2f   %6.2f",
95
 
                 times[i][0][j], times[i][1][j], times[i][2][j]);
96
 
 
97
 
          switch (j)
98
 
            {
99
 
            case PIXOPS_INTERP_NEAREST:
100
 
              printf ("  NEAREST\n");
101
 
              break;
102
 
            case PIXOPS_INTERP_TILES:
103
 
              printf ("  TILES\n");
104
 
              break;
105
 
            case PIXOPS_INTERP_BILINEAR:
106
 
              printf ("  BILINEAR\n");
107
 
              break;
108
 
            case PIXOPS_INTERP_HYPER:
109
 
              printf ("  HYPER\n");
110
 
              break;
111
 
            }
112
 
        }
113
 
    }
114
 
  printf("\n");
115
 
}
116
 
 
117
 
#define ITERS 10
118
 
 
119
 
int main (int argc, char **argv)
120
 
{
121
 
  int src_width, src_height, dest_width, dest_height;
122
 
  unsigned char *src_buf, *dest_buf;
123
 
  int src_index, dest_index;
124
 
  int i;
125
 
  double scale_times[3][3][4];
126
 
  double composite_times[3][3][4];
127
 
  double composite_color_times[3][3][4];
128
 
 
129
 
  if (argc == 5)
130
 
    {
131
 
      src_width = atoi(argv[1]);
132
 
      src_height = atoi(argv[2]);
133
 
      dest_width = atoi(argv[3]);
134
 
      dest_height = atoi(argv[4]);
135
 
    }
136
 
  else if (argc == 1)
137
 
    {
138
 
      src_width = 343;
139
 
      src_height = 343;
140
 
      dest_width = 711;
141
 
      dest_height = 711;
142
 
    }
143
 
  else
144
 
    {
145
 
      fprintf (stderr, "Usage: scale [src_width src_height dest_width dest_height]\n");
146
 
      exit(1);
147
 
    }
148
 
 
149
 
 
150
 
  printf ("Scaling from (%d, %d) to (%d, %d)\n\n", src_width, src_height, dest_width, dest_height);
151
 
 
152
 
  init_array (scale_times);
153
 
  init_array (composite_times);
154
 
  init_array (composite_color_times);
155
 
 
156
 
  for (src_index = 0; src_index < 3; src_index++)
157
 
    for (dest_index = 0; dest_index < 3; dest_index++)
158
 
      {
159
 
        int src_channels = (src_index == 0) ? 3 : 4;
160
 
        int src_has_alpha = (src_index == 2);
161
 
        int dest_channels = (dest_index == 0) ? 3 : 4;
162
 
        int dest_has_alpha = (dest_index == 2);
163
 
        
164
 
        int src_rowstride = (src_channels*src_width + 3) & ~3;
165
 
        int dest_rowstride = (dest_channels *dest_width + 3) & ~3;
166
 
 
167
 
        int filter_level;
168
 
 
169
 
        src_buf = g_malloc(src_rowstride * src_height);
170
 
        memset (src_buf, 0x80, src_rowstride * src_height);
171
 
        
172
 
        dest_buf = g_malloc(dest_rowstride * dest_height);
173
 
        memset (dest_buf, 0x80, dest_rowstride * dest_height);
174
 
 
175
 
        for (filter_level = PIXOPS_INTERP_NEAREST ; filter_level <= PIXOPS_INTERP_HYPER; filter_level++)
176
 
          {
177
 
            printf ("src_channels = %d (%s); dest_channels = %d (%s); filter_level=",
178
 
                    src_channels, src_has_alpha ? "alpha" : "no alpha",
179
 
                    dest_channels, dest_has_alpha ? "alpha" : "no alpha");
180
 
            switch (filter_level)
181
 
              {
182
 
              case PIXOPS_INTERP_NEAREST:
183
 
                printf ("PIXOPS_INTERP_NEAREST\n");
184
 
                break;
185
 
              case PIXOPS_INTERP_TILES:
186
 
                printf ("PIXOPS_INTERP_TILES\n");
187
 
                break;
188
 
              case PIXOPS_INTERP_BILINEAR:
189
 
                printf ("PIXOPS_INTERP_BILINEAR\n");
190
 
                break;
191
 
              case PIXOPS_INTERP_HYPER:
192
 
                printf ("PIXOPS_INTERP_HYPER\n");
193
 
                break;
194
 
              }
195
 
 
196
 
            printf("\t\t\titers\ttotal\t\tmsecs/iter\tMpixels/sec\t\n");
197
 
 
198
 
 
199
 
            if (!(src_has_alpha && !dest_has_alpha))
200
 
              {
201
 
                start_timing ();
202
 
                for (i = 0; i < ITERS; i++)
203
 
                  {
204
 
                    _pixops_scale (dest_buf, dest_width, dest_height,
205
 
                                   dest_rowstride, dest_channels,
206
 
                                   dest_has_alpha, src_buf, src_width,
207
 
                                   src_height, src_rowstride, src_channels,
208
 
                                   src_has_alpha, 0, 0, 0, 0, 0, 0,
209
 
                                   (double)dest_width / src_width,
210
 
                                   (double)dest_height / src_height,
211
 
                                   filter_level);
212
 
                  }
213
 
                scale_times[src_index][dest_index][filter_level] =
214
 
                  stop_timing ("   scale\t\t", ITERS, dest_height * dest_width);
215
 
              }
216
 
 
217
 
            start_timing ();
218
 
            for (i = 0; i < ITERS; i++)
219
 
              {
220
 
                _pixops_composite (dest_buf, dest_width, dest_height,
221
 
                                   dest_rowstride, dest_channels,
222
 
                                   dest_has_alpha, src_buf, src_width,
223
 
                                   src_height, src_rowstride, src_channels,
224
 
                                   src_has_alpha, 0, 0, 0, 0, 0, 0,
225
 
                                   (double)dest_width / src_width,
226
 
                                   (double)dest_height / src_height,
227
 
                                   filter_level, 255);
228
 
              }
229
 
            composite_times[src_index][dest_index][filter_level] =
230
 
              stop_timing ("   composite\t\t", ITERS,
231
 
                           dest_height * dest_width);
232
 
 
233
 
            start_timing ();
234
 
            for (i = 0; i < ITERS; i++)
235
 
              {
236
 
                _pixops_composite_color (dest_buf, dest_width, dest_height,
237
 
                                         dest_rowstride, dest_channels,
238
 
                                         dest_has_alpha, src_buf, src_width,
239
 
                                         src_height, src_rowstride,
240
 
                                         src_channels, src_has_alpha, 0, 0,
241
 
                                         0, 0, 0, 0,
242
 
                                         (double)dest_width / src_width,
243
 
                                         (double)dest_height / src_height,
244
 
                                         filter_level, 255, 0, 0, 16,
245
 
                                         0xaaaaaa, 0x555555);
246
 
              }
247
 
            composite_color_times[src_index][dest_index][filter_level] =
248
 
              stop_timing ("   composite color\t", ITERS, dest_height * dest_width);
249
 
 
250
 
            printf ("\n");
251
 
          }
252
 
        printf ("\n");
253
 
 
254
 
        g_free (src_buf);
255
 
        g_free (dest_buf);
256
 
      }
257
 
 
258
 
  printf ("SCALE\n=====\n\n");
259
 
  dump_array (scale_times);
260
 
 
261
 
  printf ("COMPOSITE\n=========\n\n");
262
 
  dump_array (composite_times);
263
 
 
264
 
  printf ("COMPOSITE_COLOR\n===============\n\n");
265
 
  dump_array (composite_color_times);
266
 
  return 0;
267
 
}