[pinpoint] Add a new background scaling type, 'stretch'
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pinpoint] Add a new background scaling type, 'stretch'
- Date: Fri, 20 May 2011 13:05:52 +0000 (UTC)
commit ba73a2584ea201874020fdf14c682a8ea671a7bf
Author: Chris Lord <chris linux intel com>
Date: Sun Mar 6 08:33:48 2011 -0800
Add a new background scaling type, 'stretch'
Add a new background scaling type that will stretch the image to fill the
screen, regardless of aspect ratio.
pinpoint.c | 22 ++++++++++++++--------
pinpoint.h | 7 +++++--
pp-cairo.c | 18 +++++++++---------
pp-clutter.c | 6 +++---
4 files changed, 31 insertions(+), 22 deletions(-)
---
diff --git a/pinpoint.c b/pinpoint.c
index 5d78a1b..757823a 100644
--- a/pinpoint.c
+++ b/pinpoint.c
@@ -191,7 +191,8 @@ pp_get_background_position_scale (PinPointPoint *point,
float bg_height,
float *bg_x,
float *bg_y,
- float *bg_scale)
+ float *bg_scale_x,
+ float *bg_scale_y)
{
float w_scale = stage_width / bg_width;
float h_scale = stage_height / bg_height;
@@ -199,19 +200,23 @@ pp_get_background_position_scale (PinPointPoint *point,
switch (point->bg_scale)
{
case PP_BG_FILL:
- *bg_scale = (w_scale > h_scale) ? w_scale : h_scale;
+ *bg_scale_x = *bg_scale_y = (w_scale > h_scale) ? w_scale : h_scale;
break;
case PP_BG_FIT:
- *bg_scale = (w_scale < h_scale) ? w_scale : h_scale;
+ *bg_scale_x = *bg_scale_y = (w_scale < h_scale) ? w_scale : h_scale;
break;
case PP_BG_UNSCALED:
- *bg_scale = (w_scale < h_scale) ? w_scale : h_scale;
- if (*bg_scale > 1.0)
- *bg_scale = 1.0;
+ *bg_scale_x = *bg_scale_y = (w_scale < h_scale) ? w_scale : h_scale;
+ if (*bg_scale_x > 1.0)
+ *bg_scale_x = *bg_scale_y = 1.0;
+ break;
+ case PP_BG_STRETCH:
+ *bg_scale_x = w_scale;
+ *bg_scale_y = h_scale;
break;
}
- *bg_x = (stage_width - bg_width * *bg_scale) / 2;
- *bg_y = (stage_height - bg_height * *bg_scale) / 2;
+ *bg_x = (stage_width - bg_width * *bg_scale_x) / 2;
+ *bg_y = (stage_height - bg_height * *bg_scale_y) / 2;
}
void
@@ -347,6 +352,7 @@ parse_setting (PinPointPoint *point,
IF_PREFIX("transition=") point->transition = char;
IF_EQUAL("fill") point->bg_scale = PP_BG_FILL;
IF_EQUAL("fit") point->bg_scale = PP_BG_FIT;
+ IF_EQUAL("stretch") point->bg_scale = PP_BG_STRETCH;
IF_EQUAL("unscaled") point->bg_scale = PP_BG_UNSCALED;
IF_EQUAL("center") point->position = CLUTTER_GRAVITY_CENTER;
IF_EQUAL("top") point->position = CLUTTER_GRAVITY_NORTH;
diff --git a/pinpoint.h b/pinpoint.h
index 5d84d2e..cb02d39 100644
--- a/pinpoint.h
+++ b/pinpoint.h
@@ -53,7 +53,8 @@ typedef enum
{
PP_BG_UNSCALED,
PP_BG_FIT, /* default value */
- PP_BG_FILL
+ PP_BG_FILL,
+ PP_BG_STRETCH
} PPBackgroundScale;
#define PINPOINT_RENDERER(renderer) ((PinPointRenderer *) renderer)
@@ -119,7 +120,9 @@ pp_get_background_position_scale (PinPointPoint *point,
float bg_height,
float *bg_x,
float *bg_y,
- float *bg_scale);
+ float *bg_scale_x,
+ float *bg_scale_y);
+
void
pp_get_text_position_scale (PinPointPoint *point,
float stage_width,
diff --git a/pp-cairo.c b/pp-cairo.c
index 427f7a3..d1cf2d6 100644
--- a/pp-cairo.c
+++ b/pp-cairo.c
@@ -310,7 +310,7 @@ _cairo_render_background (CairoRenderer *renderer,
case PP_BG_IMAGE:
{
cairo_surface_t *surface;
- float bg_x, bg_y, bg_width, bg_height, bg_scale;
+ float bg_x, bg_y, bg_width, bg_height, bg_scale_x, bg_scale_y;
surface = _cairo_get_surface (renderer, point->bg);
if (surface == NULL)
@@ -324,11 +324,11 @@ _cairo_render_background (CairoRenderer *renderer,
A4_LS_WIDTH, A4_LS_HEIGHT,
bg_width, bg_height,
&bg_x, &bg_y,
- &bg_scale);
+ &bg_scale_x, &bg_scale_y);
cairo_save (renderer->ctx);
cairo_translate (renderer->ctx, bg_x, bg_y);
- cairo_scale (renderer->ctx, bg_scale, bg_scale);
+ cairo_scale (renderer->ctx, bg_scale_x, bg_scale_y);
cairo_set_source_surface (renderer->ctx, surface, 0., 0.);
cairo_paint (renderer->ctx);
cairo_restore (renderer->ctx);
@@ -339,7 +339,7 @@ _cairo_render_background (CairoRenderer *renderer,
#ifdef USE_CLUTTER_GST
GdkPixbuf *pixbuf;
cairo_surface_t *surface;
- float bg_x, bg_y, bg_width, bg_height, bg_scale;
+ float bg_x, bg_y, bg_width, bg_height, bg_scale_x, bg_scale_y;
GCancellable* cancellable = g_cancellable_new ();
pixbuf = gst_video_thumbnailer_get_shot (point->bg, cancellable);
@@ -356,11 +356,11 @@ _cairo_render_background (CairoRenderer *renderer,
A4_LS_WIDTH, A4_LS_HEIGHT,
bg_width, bg_height,
&bg_x, &bg_y,
- &bg_scale);
+ &bg_scale_x, &bg_scale_y);
cairo_save (renderer->ctx);
cairo_translate (renderer->ctx, bg_x, bg_y);
- cairo_scale (renderer->ctx, bg_scale, bg_scale);
+ cairo_scale (renderer->ctx, bg_scale_x, bg_scale_y);
cairo_set_source_surface (renderer->ctx, surface, 0., 0.);
cairo_paint (renderer->ctx);
cairo_restore (renderer->ctx);
@@ -372,7 +372,7 @@ _cairo_render_background (CairoRenderer *renderer,
{
RsvgHandle *svg = _cairo_get_svg (renderer, point->bg);
RsvgDimensionData dim;
- float bg_x, bg_y, bg_scale;
+ float bg_x, bg_y, bg_scale_x, bg_scale_y;
if (svg == NULL)
break;
@@ -383,11 +383,11 @@ _cairo_render_background (CairoRenderer *renderer,
A4_LS_WIDTH, A4_LS_HEIGHT,
dim.width, dim.height,
&bg_x, &bg_y,
- &bg_scale);
+ &bg_scale_x, &bg_scale_y);
cairo_save (renderer->ctx);
cairo_translate (renderer->ctx, bg_x, bg_y);
- cairo_scale (renderer->ctx, bg_scale, bg_scale);
+ cairo_scale (renderer->ctx, bg_scale_x, bg_scale_y);
rsvg_handle_render_cairo (svg, renderer->ctx);
cairo_restore (renderer->ctx);
diff --git a/pp-clutter.c b/pp-clutter.c
index 4ce634d..7de1c65 100644
--- a/pp-clutter.c
+++ b/pp-clutter.c
@@ -768,7 +768,7 @@ show_slide (ClutterRenderer *renderer, gboolean backwards)
if (data->background)
{
- float bg_x, bg_y, bg_width, bg_height, bg_scale;
+ float bg_x, bg_y, bg_width, bg_height, bg_scale_x, bg_scale_y;
if (CLUTTER_IS_RECTANGLE (data->background))
{
clutter_actor_get_size (renderer->stage, &bg_width, &bg_height);
@@ -783,9 +783,9 @@ show_slide (ClutterRenderer *renderer, gboolean backwards)
clutter_actor_get_width (renderer->stage),
clutter_actor_get_height (renderer->stage),
bg_width, bg_height,
- &bg_x, &bg_y, &bg_scale);
+ &bg_x, &bg_y, &bg_scale_x, &bg_scale_y);
- clutter_actor_set_scale (data->background, bg_scale, bg_scale);
+ clutter_actor_set_scale (data->background, bg_scale_x, bg_scale_y);
clutter_actor_set_position (data->background, bg_x, bg_y);
#ifdef USE_CLUTTER_GST
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]