summaryrefslogtreecommitdiff
path: root/src/meta/meta-shadow-factory.h
blob: 019e74cf63ccd6d990fcf52b254b298a0b2b4bea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
 * MetaShadowFactory:
 *
 * Create and cache shadow textures for arbitrary window shapes
 *
 * Copyright (C) 2010 Red Hat, Inc.
 *
 * 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.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __META_SHADOW_FACTORY_H__
#define __META_SHADOW_FACTORY_H__

#include <cairo.h>

#include "clutter/clutter.h"
#include "cogl/cogl.h"
#include "meta/meta-window-shape.h"

META_EXPORT
GType meta_shadow_get_type (void) G_GNUC_CONST;

/**
 * MetaShadowParams:
 * @radius: the radius (gaussian standard deviation) of the shadow
 * @top_fade: if >= 0, the shadow doesn't extend above the top
 *  of the shape, and fades out over the given number of pixels
 * @x_offset: horizontal offset of the shadow with respect to the
 *  shape being shadowed, in pixels
 * @y_offset: vertical offset of the shadow with respect to the
 *  shape being shadowed, in pixels
 * @opacity: opacity of the shadow, from 0 to 255
 *
 * Information about how to draw a particular style of shadow.
 */

typedef struct _MetaShadowParams MetaShadowParams;

struct _MetaShadowParams
{
  int radius;
  int top_fade;
  int x_offset;
  int y_offset;
  guint8 opacity;
};

#define META_TYPE_SHADOW_FACTORY (meta_shadow_factory_get_type ())

META_EXPORT
G_DECLARE_FINAL_TYPE (MetaShadowFactory,
                      meta_shadow_factory,
                      META, SHADOW_FACTORY,
                      GObject)

/**
 * MetaShadowFactory:
 *
 * Create window shadows. 
 * 
 * It caches shadows internally so that multiple shadows created for
 * the same shape with the same radius will share the same [struct@Meta.Shadow].
 */
META_EXPORT
MetaShadowFactory *meta_shadow_factory_get_default (void);

META_EXPORT
void meta_shadow_factory_set_params (MetaShadowFactory *factory,
                                     const char        *class_name,
                                     gboolean           focused,
                                     MetaShadowParams  *params);

META_EXPORT
void meta_shadow_factory_get_params (MetaShadowFactory *factory,
                                     const char        *class_name,
                                     gboolean           focused,
                                     MetaShadowParams  *params);

/**
 * MetaShadow:
 * 
 * Holds a shadow texture along with information about how to
 * apply that texture to draw a window texture. 
 * 
 * E.g., it knows how big the unscaled borders are on each
 * side of the shadow texture.
 */
typedef struct _MetaShadow MetaShadow;

META_EXPORT
MetaShadow *meta_shadow_ref         (MetaShadow            *shadow);

META_EXPORT
void        meta_shadow_unref       (MetaShadow            *shadow);

META_EXPORT
void        meta_shadow_paint       (MetaShadow            *shadow,
                                     CoglFramebuffer       *framebuffer,
                                     int                    window_x,
                                     int                    window_y,
                                     int                    window_width,
                                     int                    window_height,
                                     guint8                 opacity,
                                     cairo_region_t        *clip,
                                     gboolean               clip_strictly);

META_EXPORT
void        meta_shadow_get_bounds  (MetaShadow            *shadow,
                                     int                    window_x,
                                     int                    window_y,
                                     int                    window_width,
                                     int                    window_height,
                                     cairo_rectangle_int_t *bounds);

META_EXPORT
MetaShadowFactory *meta_shadow_factory_new (void);

META_EXPORT
MetaShadow *meta_shadow_factory_get_shadow (MetaShadowFactory *factory,
                                            MetaWindowShape   *shape,
                                            int                width,
                                            int                height,
                                            const char        *class_name,
                                            gboolean           focused);

#endif /* __META_SHADOW_FACTORY_H__ */