summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-06-12 17:07:19 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-06-12 17:07:19 +0800
commit35ebebff37565c61a5b4c524002f247bb1553c50 (patch)
treed203dd4d98f94ffbfcf4f1e9d37ffac228c0e187
parentd3f0e89e459af0e9ccff6e9a457f896d2e6f7f65 (diff)
downloadcompositionkit-35ebebff37565c61a5b4c524002f247bb1553c50.tar.gz
compositionkit-35ebebff37565c61a5b4c524002f247bb1553c50.tar.bz2
Nuke fading. We don't need it
-rw-r--r--compositor/compositor.c76
-rw-r--r--compositor/compositor.h13
-rw-r--r--compositor/inputdevice.c30
-rw-r--r--compositor/output.c52
-rw-r--r--compositor/sprite.c32
5 files changed, 32 insertions, 171 deletions
diff --git a/compositor/compositor.c b/compositor/compositor.c
index 1a7b4d3..5d14ecc 100644
--- a/compositor/compositor.c
+++ b/compositor/compositor.c
@@ -58,29 +58,6 @@ wlsc_compositor_damage_all(struct wlsc_compositor *compositor)
wlsc_output_damage(output);
}
-static void
-fade_frame(struct wlsc_animation *animation,
- struct wlsc_output *output, uint32_t msecs)
-{
- struct wlsc_compositor *compositor =
- container_of(animation,
- struct wlsc_compositor, fade.animation);
-
- wlsc_spring_update(&compositor->fade.spring, msecs);
- if (wlsc_spring_done(&compositor->fade.spring)) {
- if (compositor->fade.spring.current > 0.999) {
- compositor->state = WLSC_COMPOSITOR_SLEEPING;
- compositor->shell->lock(compositor->shell);
- }
- compositor->fade.spring.current =
- compositor->fade.spring.target;
- wl_list_remove(&animation->link);
- wl_list_init(&animation->link);
- }
-
- wlsc_output_damage(output);
-}
-
static int
repaint(void *data)
{
@@ -129,26 +106,6 @@ wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor)
compositor->repaint_on_timeout = 1;
}
-WL_EXPORT void
-wlsc_compositor_fade(struct wlsc_compositor *compositor, float tint)
-{
- int done;
-
- done = wlsc_spring_done(&compositor->fade.spring);
- compositor->fade.spring.target = tint;
- if (wlsc_spring_done(&compositor->fade.spring))
- return;
-
- if (done)
- compositor->fade.spring.timestamp =
- wlsc_compositor_get_time();
-
- wlsc_compositor_damage_all(compositor);
- if (wl_list_empty(&compositor->fade.animation.link))
- wl_list_insert(compositor->animation_list.prev,
- &compositor->fade.animation.link);
-}
-
static void
surface_destroy(struct wl_client *client,
struct wl_surface *surface)
@@ -259,32 +216,6 @@ terminate_binding(struct wl_input_device *device, uint32_t time,
wl_display_terminate(compositor->wl_display);
}
-WL_EXPORT void
-wlsc_compositor_wake(struct wlsc_compositor *compositor)
-{
- if (compositor->idle_inhibit)
- return;
-
- wlsc_compositor_fade(compositor, 0.0);
- compositor->state = WLSC_COMPOSITOR_ACTIVE;
-
- wl_event_source_timer_update(compositor->idle_source,
- option_idle_time * 1000);
-}
-
-static int
-idle_handler(void *data)
-{
- struct wlsc_compositor *compositor = data;
-
- if (compositor->idle_inhibit)
- return 1;
-
- wlsc_compositor_fade(compositor, 1.0);
-
- return 1;
-}
-
WL_EXPORT int
wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
{
@@ -327,9 +258,6 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
wl_list_init(&ec->output_list);
wl_list_init(&ec->binding_list);
wl_list_init(&ec->animation_list);
- wlsc_spring_init(&ec->fade.spring, 0.8, 0.0, 0.0);
- ec->fade.animation.frame = fade_frame;
- wl_list_init(&ec->fade.animation.link);
wlsc_compositor_add_binding(ec, KEY_BACKSPACE, 0,
MODIFIER_CTRL | MODIFIER_ALT,
@@ -337,8 +265,6 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
wlsc_create_pointer_images(ec);
- //screenshooter_create(ec);
-
glActiveTexture(GL_TEXTURE0);
if (wlsc_shader_init(&ec->texture_shader,
@@ -350,8 +276,6 @@ wlsc_compositor_init(struct wlsc_compositor *ec, struct wl_display *display)
return -1;
loop = wl_display_get_event_loop(ec->wl_display);
- ec->idle_source = wl_event_loop_add_timer(loop, idle_handler, ec);
- wl_event_source_timer_update(ec->idle_source, option_idle_time * 1000);
ec->timer_source = wl_event_loop_add_timer(loop, repaint, ec);
pixman_region32_init(&ec->damage_region);
diff --git a/compositor/compositor.h b/compositor/compositor.h
index bfc82a8..343e93e 100644
--- a/compositor/compositor.h
+++ b/compositor/compositor.h
@@ -175,13 +175,8 @@ struct wlsc_compositor {
struct wl_list surface_list;
struct wl_list binding_list;
struct wl_list animation_list;
- struct {
- struct wlsc_spring spring;
- struct wlsc_animation animation;
- } fade;
uint32_t state;
- struct wl_event_source *idle_source;
uint32_t idle_inhibit;
/* Repaint state. */
@@ -287,13 +282,9 @@ wlsc_output_damage(struct wlsc_output *output);
void
wlsc_compositor_schedule_repaint(struct wlsc_compositor *compositor);
void
-wlsc_compositor_fade(struct wlsc_compositor *compositor, float tint);
-void
wlsc_compositor_damage_all(struct wlsc_compositor *compositor);
void
wlsc_compositor_unlock(struct wlsc_compositor *compositor);
-void
-wlsc_compositor_wake(struct wlsc_compositor *compositor);
struct wlsc_binding;
typedef void (*wlsc_binding_handler_t)(struct wl_input_device *device,
@@ -409,6 +400,10 @@ struct wlsc_sprite *
wlsc_create_sprite_from_png(struct wlsc_compositor *ec,
const char *filename, uint32_t usage);
+struct wlsc_sprite *
+wlsc_create_sprite_from_pixel_data (struct wlsc_compositor *ec, int32_t width, int32_t height,
+ uint32_t stride, uint32_t usage, unsigned char *pixels);
+
static const struct {
const char *filename;
int hotspot_x, hotspot_y;
diff --git a/compositor/inputdevice.c b/compositor/inputdevice.c
index 7483351..bc87b41 100644
--- a/compositor/inputdevice.c
+++ b/compositor/inputdevice.c
@@ -155,8 +155,6 @@ notify_motion(struct wl_input_device *device, uint32_t time, int x, int y)
int x_valid = 0, y_valid = 0;
int min_x = INT_MAX, min_y = INT_MAX, max_x = INT_MIN, max_y = INT_MIN;
- wlsc_compositor_wake(ec);
-
wl_list_for_each(output, &ec->output_list, link) {
if (output->x <= x && x <= output->x + output->width)
x_valid = 1;
@@ -224,20 +222,6 @@ struct wlsc_binding {
struct wl_list link;
};
-void
-wlsc_compositor_idle_inhibit(struct wlsc_compositor *compositor)
-{
- wlsc_compositor_wake(compositor);
- compositor->idle_inhibit++;
-}
-
-static void
-wlsc_compositor_idle_release(struct wlsc_compositor *compositor)
-{
- compositor->idle_inhibit--;
- wlsc_compositor_wake(compositor);
-}
-
WL_EXPORT void
notify_button(struct wl_input_device *device,
uint32_t time, int32_t button, int32_t state)
@@ -249,11 +233,6 @@ notify_button(struct wl_input_device *device,
struct wlsc_surface *surface =
(struct wlsc_surface *) device->pointer_focus;
- if (state)
- wlsc_compositor_idle_inhibit(compositor);
- else
- wlsc_compositor_idle_release(compositor);
-
if (state && surface && device->grab == NULL) {
wlsc_surface_activate(surface, wd, time);
wl_input_device_start_grab(device,
@@ -349,11 +328,6 @@ notify_key(struct wl_input_device *device,
uint32_t *k, *end;
struct wlsc_binding *b;
- if (state)
- wlsc_compositor_idle_inhibit(compositor);
- else
- wlsc_compositor_idle_release(compositor);
-
wl_list_for_each(b, &compositor->binding_list, link) {
if (b->key == key &&
b->modifier == wd->modifier_state) {
@@ -436,16 +410,12 @@ notify_keyboard_focus(struct wl_input_device *device,
wd->modifier_state = 0;
end = device->keys.data + device->keys.size;
for (k = device->keys.data; k < end; k++) {
- wlsc_compositor_idle_inhibit(compositor);
update_modifier_state(wd, *k, 1);
}
wl_input_device_set_keyboard_focus(&wd->input_device,
&es->surface, time);
} else {
- end = device->keys.data + device->keys.size;
- for (k = device->keys.data; k < end; k++)
- wlsc_compositor_idle_release(compositor);
wd->modifier_state = 0;
wl_input_device_set_keyboard_focus(&wd->input_device,
diff --git a/compositor/output.c b/compositor/output.c
index 3ba9c26..1e0c3fd 100644
--- a/compositor/output.c
+++ b/compositor/output.c
@@ -57,8 +57,6 @@ wlsc_output_finish_frame(struct wlsc_output *output, int msecs)
output->finished = 1;
- //global_buffer += 1;
-
wl_event_source_timer_update(compositor->timer_source, 5);
compositor->repaint_on_timeout = 1;
@@ -78,35 +76,6 @@ wlsc_output_damage(struct wlsc_output *output)
output->width, output->height);
wlsc_compositor_schedule_repaint(compositor);
}
-
-static void
-fade_output(struct wlsc_output *output,
- GLfloat tint, pixman_region32_t *region)
-{
- struct wlsc_compositor *compositor = output->compositor;
- struct wlsc_surface surface;
- GLfloat color[4] = { 0.0, 0.0, 0.0, tint };
-
- surface.compositor = compositor;
- surface.x = output->x;
- surface.y = output->y;
- surface.width = output->width;
- surface.height = output->height;
- surface.texture = GL_NONE;
- surface.transform = NULL;
-
- if (tint <= 1.0)
- surface.visual =
- &compositor->compositor.premultiplied_argb_visual;
- else
- surface.visual = &compositor->compositor.rgb_visual;
-
- glUseProgram(compositor->solid_shader.program);
- glUniformMatrix4fv(compositor->solid_shader.proj_uniform,
- 1, GL_FALSE, output->matrix.d);
- glUniform4fv(compositor->solid_shader.color_uniform, 1, color);
- wlsc_surface_draw(&surface, output, region);
-}
WL_EXPORT void
wlsc_output_repaint(struct wlsc_output *output)
@@ -125,13 +94,6 @@ wlsc_output_repaint(struct wlsc_output *output)
1, GL_FALSE, output->matrix.d);
glUniform1i(ec->texture_shader.tex_uniform, 0);
- GLint h = glGetUniformLocation (ec->texture_shader.program, "amount");
-
- //if (h)
- //{
- //glUniform1f (h, DEG2RAD (global_buffer));
- //}
-
pixman_region32_init(&new_damage);
pixman_region32_init(&total_damage);
pixman_region32_intersect_rect(&new_damage,
@@ -145,7 +107,7 @@ wlsc_output_repaint(struct wlsc_output *output)
pixman_region32_copy(&output->previous_damage_region, &new_damage);
hw_cursor = NULL;
- if (ec->focus && ec->fade.spring.current < 0.001) {
+ if (ec->focus) {
hw_cursor = (struct wlsc_input_device *) ec->input_device;
if (output->set_hardware_cursor(output, hw_cursor) < 0)
hw_cursor = NULL;
@@ -175,8 +137,6 @@ wlsc_output_repaint(struct wlsc_output *output)
if (output->background)
wlsc_surface_draw(output->background,
output, &total_damage);
- else
- fade_output(output, 1.0, &total_damage);
glUseProgram(ec->texture_shader.program);
wl_list_for_each_reverse(es, &ec->surface_list, link) {
@@ -197,9 +157,6 @@ wlsc_output_repaint(struct wlsc_output *output)
wlsc_surface_draw(eid->sprite, output,
&total_damage);
}
-
- if (ec->fade.spring.current > 0.001)
- fade_output(output, ec->fade.spring.current, &total_damage);
}
static void
@@ -267,8 +224,11 @@ background_create(struct wlsc_output *output, const char *filename)
sprite = wlsc_create_sprite_from_png(output->compositor, filename, 0);
if (sprite == NULL) {
- free(background);
- return NULL;
+ unsigned char pixels[4] = { 0x0, 0x0, 0x0, 0xff };
+ sprite = wlsc_create_sprite_from_pixel_data (output->compositor, 1, 1, 0, 0, pixels);
+
+ if (sprite == NULL)
+ return NULL;
}
wlsc_sprite_attach(sprite, &background->surface);
diff --git a/compositor/sprite.c b/compositor/sprite.c
index a6b9a50..52d1dbe 100644
--- a/compositor/sprite.c
+++ b/compositor/sprite.c
@@ -41,17 +41,11 @@
#include "compositor.h"
struct wlsc_sprite *
-wlsc_create_sprite_from_png(struct wlsc_compositor *ec,
- const char *filename, uint32_t usage)
+wlsc_create_sprite_from_pixel_data (struct wlsc_compositor *ec, int32_t width, int32_t height,
+ uint32_t stride, uint32_t usage, unsigned char *pixels)
{
- uint32_t *pixels;
struct wlsc_sprite *sprite;
- int32_t width, height;
- uint32_t stride;
-
- fprintf (stderr, "loading image %s\n", filename);
- pixels = wlsc_load_image(filename, &width, &height, &stride);
if (pixels == NULL)
return NULL;
@@ -81,12 +75,30 @@ wlsc_create_sprite_from_png(struct wlsc_compositor *ec,
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
} else {
- fprintf (stderr, "doing glTI2D\n");
glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, width, height, 0,
GL_BGRA_EXT, GL_UNSIGNED_BYTE, pixels);
}
- free(pixels);
+ return sprite;
+}
+
+
+struct wlsc_sprite *
+wlsc_create_sprite_from_png(struct wlsc_compositor *ec,
+ const char *filename, uint32_t usage)
+{
+ uint32_t *pixels;
+ struct wlsc_sprite *sprite;
+ int32_t width, height;
+ uint32_t stride;
+
+ pixels = wlsc_load_image(filename, &width, &height, &stride);
+ if (pixels == NULL)
+ return NULL;
+
+ sprite = wlsc_create_sprite_from_pixel_data (ec, width, height, stride, usage, (unsigned char *) pixels);
+
+ free (pixels);
return sprite;
}