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 } },
130
{ "popup-menu", { 6, -1, 0, 4, 255 }, { 6, -1, 0, 4, 255 } },
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 } },
130
{ "popup-menu", { 1, -1, 0, 1, 128 }, { 1, -1, 0, 1, 128 } },
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 } }
136
136
G_DEFINE_TYPE (MetaShadowFactory, meta_shadow_factory, G_TYPE_OBJECT);
283
289
dest_rect.x = dest_x[i];
284
290
dest_rect.width = dest_x[i + 1] - dest_x[i];
292
if (dest_rect.width == 0)
287
296
overlap = cairo_region_contains_rectangle (clip, &dest_rect);
289
overlap = CAIRO_REGION_OVERLAP_PART;
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],
295
src_x[i + 1], src_y[j + 1]);
298
overlap = CAIRO_REGION_OVERLAP_IN;
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.
306
if (overlap == CAIRO_REGION_OVERLAP_IN ||
307
(overlap == CAIRO_REGION_OVERLAP_PART && !clip_strictly))
309
cogl_rectangle_with_texture_coords (dest_x[i], dest_y[j],
310
dest_x[i + 1], dest_y[j + 1],
312
src_x[i + 1], src_y[j + 1]);
314
else if (overlap == CAIRO_REGION_OVERLAP_PART)
316
cairo_region_t *intersection;
319
intersection = cairo_region_create_rectangle (&dest_rect);
320
cairo_region_intersect (intersection, clip);
322
n_rectangles = cairo_region_num_rectangles (intersection);
323
for (k = 0; k < n_rectangles; k++)
325
cairo_rectangle_int_t rect;
326
float src_x1, src_x2, src_y1, src_y2;
328
cairo_region_get_rectangle (intersection, k, &rect);
330
/* Separately linear interpolate X and Y coordinates in the source
331
* based on the destination X and Y coordinates */
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;
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;
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);
348
cairo_region_destroy (intersection);