~ubuntu-branches/ubuntu/precise/mutter/precise

« back to all changes in this revision

Viewing changes to src/compositor/meta-shadow-factory.c

  • Committer: Bazaar Package Importer
  • Author(s): Laurent Bigonville
  • Date: 2011-08-24 14:53:37 UTC
  • mfrom: (0.9.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110824145337-ciqrupsuyrbyfg3l
Tags: 3.1.4-0ubuntu1
* New upstream release
  - Fix Adwaita window decoration (LP: #828543)
* debian/control.in: Bump libclutter-1.0-dev build-dependency to 1.7.5
* debian/patches/03_link_gles2.patch: Refreshed
* debian/libmutter0.symbols: Adjust .symbols file

Show diffs side-by-side

added added

removed removed

Lines of Context:
120
120
/* The first element in this array also defines the default parameters
121
121
 * for newly created classes */
122
122
MetaShadowClassInfo default_shadow_classes[] = {
123
 
  { "normal",       { 12, -1, 0, 8, 255 }, { 6, -1, 0, 4, 255 } },
124
 
  { "dialog",       { 12, -1, 0, 8, 255 }, { 6, -1, 0, 4, 255 } },
125
 
  { "modal_dialog", { 12, -1, 0, 8, 255 }, { 6, -1, 0, 4, 255 } },
126
 
  { "utility",      { 12, -1, 0, 8, 255 }, { 6, -1, 0, 4, 255 } },
127
 
  { "border",       { 12, -1, 0, 8, 255 }, { 6, -1, 0, 4, 255 } },
128
 
  { "menu",         { 12, -1, 0, 8, 255 }, { 6, -1, 0, 4, 255 } },
129
 
 
130
 
  { "popup-menu",    { 6, -1, 0, 4, 255 }, { 6, -1, 0, 4, 255 } },
131
 
 
132
 
  { "dropdown-menu", { 6, 25, 0, 4, 255 }, { 6, 100, 0, 4, 255 } },
133
 
  { "attached",      { 6, 25, 0, 4, 255 }, { 6, 100, 0, 4, 255 } }
 
123
  { "normal",       { 6, -1, 0, 3, 255 }, { 3, -1, 0, 3, 128 } },
 
124
  { "dialog",       { 6, -1, 0, 3, 255 }, { 3, -1, 0, 3, 128 } },
 
125
  { "modal_dialog", { 6, -1, 0, 1, 255 }, { 3, -1, 0, 3, 128 } },
 
126
  { "utility",      { 3, -1, 0, 1, 255 }, { 3, -1, 0, 1, 128 } },
 
127
  { "border",       { 6, -1, 0, 3, 255 }, { 3, -1, 0, 3, 128 } },
 
128
  { "menu",         { 6, -1, 0, 3, 255 }, { 3, -1, 0, 0, 128 } },
 
129
 
 
130
  { "popup-menu",    { 1, -1, 0, 1, 128 }, { 1, -1, 0, 1, 128 } },
 
131
 
 
132
  { "dropdown-menu", { 1, 10, 0, 1, 128 }, { 1, 10, 0, 1, 128 } },
 
133
  { "attached",      { 2, 50, 0, 1, 255 }, { 1, 50, 0, 1, 128 } }
134
134
};
135
135
 
136
136
G_DEFINE_TYPE (MetaShadowFactory, meta_shadow_factory, G_TYPE_OBJECT);
189
189
 * @window_width: actual width of the region to paint a shadow for
190
190
 * @window_height: actual height of the region to paint a shadow for
191
191
 * @clip: (allow-none): if non-%NULL specifies the visible portion
192
 
 *   of the shadow. Drawing won't be strictly clipped to this region
193
 
 *   but it will be used to optimize what is drawn.
 
192
 *   of the shadow.
 
193
 * @clip_strictly: if %TRUE, drawing will be clipped strictly
 
194
 *   to @clip, otherwise, it will be only used to optimize
 
195
 *   drawing.
194
196
 *
195
197
 * Paints the shadow at the given position, for the specified actual
196
198
 * size of the region. (Since a #MetaShadow can be shared between
204
206
                   int             window_width,
205
207
                   int             window_height,
206
208
                   guint8          opacity,
207
 
                   cairo_region_t *clip)
 
209
                   cairo_region_t *clip,
 
210
                   gboolean        clip_strictly)
208
211
{
209
212
  float texture_width = cogl_texture_get_width (shadow->texture);
210
213
  float texture_height = cogl_texture_get_height (shadow->texture);
276
279
      dest_rect.y = dest_y[j];
277
280
      dest_rect.height = dest_y[j + 1] - dest_y[j];
278
281
 
 
282
      if (dest_rect.height == 0)
 
283
        continue;
 
284
 
279
285
      for (i = 0; i < n_x; i++)
280
286
        {
281
287
          cairo_region_overlap_t overlap;
283
289
          dest_rect.x = dest_x[i];
284
290
          dest_rect.width = dest_x[i + 1] - dest_x[i];
285
291
 
 
292
          if (dest_rect.width == 0)
 
293
            continue;
 
294
 
286
295
          if (clip)
287
296
            overlap = cairo_region_contains_rectangle (clip, &dest_rect);
288
297
          else
289
 
            overlap = CAIRO_REGION_OVERLAP_PART;
290
 
 
291
 
          if (overlap != CAIRO_REGION_OVERLAP_OUT)
292
 
            cogl_rectangle_with_texture_coords (dest_x[i], dest_y[j],
293
 
                                                dest_x[i + 1], dest_y[j + 1],
294
 
                                                src_x[i], src_y[j],
295
 
                                                src_x[i + 1], src_y[j + 1]);
 
298
            overlap = CAIRO_REGION_OVERLAP_IN;
 
299
 
 
300
          /* There's quite a bit of overhead from allocating a new
 
301
           * region in order to find an exact intersection and
 
302
           * generating more geometry - we make the assumption that
 
303
           * unless we have to clip strictly it will be cheaper to
 
304
           * just draw the entire rectangle.
 
305
           */
 
306
          if (overlap == CAIRO_REGION_OVERLAP_IN ||
 
307
              (overlap == CAIRO_REGION_OVERLAP_PART && !clip_strictly))
 
308
            {
 
309
              cogl_rectangle_with_texture_coords (dest_x[i], dest_y[j],
 
310
                                                  dest_x[i + 1], dest_y[j + 1],
 
311
                                                  src_x[i], src_y[j],
 
312
                                                  src_x[i + 1], src_y[j + 1]);
 
313
            }
 
314
          else if (overlap == CAIRO_REGION_OVERLAP_PART)
 
315
            {
 
316
              cairo_region_t *intersection;
 
317
              int n_rectangles, k;
 
318
 
 
319
              intersection = cairo_region_create_rectangle (&dest_rect);
 
320
              cairo_region_intersect (intersection, clip);
 
321
 
 
322
              n_rectangles = cairo_region_num_rectangles (intersection);
 
323
              for (k = 0; k < n_rectangles; k++)
 
324
                {
 
325
                  cairo_rectangle_int_t rect;
 
326
                  float src_x1, src_x2, src_y1, src_y2;
 
327
 
 
328
                  cairo_region_get_rectangle (intersection, k, &rect);
 
329
 
 
330
                  /* Separately linear interpolate X and Y coordinates in the source
 
331
                   * based on the destination X and Y coordinates */
 
332
 
 
333
                  src_x1 = (src_x[i] * (dest_rect.x + dest_rect.width - rect.x) +
 
334
                            src_x[i + 1] * (rect.x - dest_rect.x)) / dest_rect.width;
 
335
                  src_x2 = (src_x[i] * (dest_rect.x + dest_rect.width - (rect.x + rect.width)) +
 
336
                            src_x[i + 1] * (rect.x + rect.width - dest_rect.x)) / dest_rect.width;
 
337
 
 
338
                  src_y1 = (src_y[j] * (dest_rect.y + dest_rect.height - rect.y) +
 
339
                            src_y[j + 1] * (rect.y - dest_rect.y)) / dest_rect.height;
 
340
                  src_y2 = (src_y[j] * (dest_rect.y + dest_rect.height - (rect.y + rect.height)) +
 
341
                            src_y[j + 1] * (rect.y + rect.height - dest_rect.y)) / dest_rect.height;
 
342
 
 
343
                  cogl_rectangle_with_texture_coords (rect.x, rect.y,
 
344
                                                      rect.x + rect.width, rect.y + rect.height,
 
345
                                                      src_x1, src_y1, src_x2, src_y2);
 
346
                }
 
347
 
 
348
              cairo_region_destroy (intersection);
 
349
            }
296
350
        }
297
351
    }
298
352
}
317
371
                         cairo_rectangle_int_t *bounds)
318
372
{
319
373
  bounds->x = window_x - shadow->outer_border_left;
320
 
  bounds->y = window_x - shadow->outer_border_top;
 
374
  bounds->y = window_y - shadow->outer_border_top;
321
375
  bounds->width = window_width + shadow->outer_border_left + shadow->outer_border_right;
322
376
  bounds->height = window_height + shadow->outer_border_top + shadow->outer_border_bottom;
323
377
}