[shotwell/wip/transparent-background: 1/2] WIP
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/transparent-background: 1/2] WIP
- Date: Thu, 20 Apr 2017 20:33:56 +0000 (UTC)
commit 44b746bd8268d87a543acbdb380aac5d00a46bf2
Author: Jens Georg <mail jensge org>
Date: Thu Apr 20 21:44:50 2017 +0200
WIP
configure.ac | 2 +-
src/Page.vala | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 81 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 028cbc7..7087bb9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,7 +105,7 @@ dnl Check for required packages
dnl ***********************************************************************
PKG_CHECK_MODULES(SHOTWELL, [
gee-0.8 >= 0.8.5
- gexiv2 >= 0.10.4
+ gexiv2 >= 0.10.3
gio-unix-2.0 >= 2.20
glib-2.0 >= 2.40.0
gmodule-2.0 >= 2.24.0
diff --git a/src/Page.vala b/src/Page.vala
index bdeee6b..b5eb953 100644
--- a/src/Page.vala
+++ b/src/Page.vala
@@ -2060,7 +2060,32 @@ public abstract class SinglePhotoPage : Page {
int draw_y = (pixmap_dim.height - view_rect.height) / 2;
draw_y = draw_y.clamp(0, int.MAX);
-
+ if (zoomed.get_has_alpha()) {
+ if (background_surface == null) {
+ background_surface = get_window().create_similar_surface(Cairo.Content.COLOR_ALPHA,
+ 16, 16);
+ var ctx2 = new Cairo.Context(background_surface);
+ ctx2.set_operator(Cairo.Operator.SOURCE);
+ set_source_color_from_string(ctx2, "#808080");
+ ctx2.rectangle(0,0,8,8);
+ ctx2.rectangle(8,8,8,8);
+ ctx2.fill();
+ set_source_color_from_string(ctx2, "#cccccc");
+ ctx2.rectangle(0,8,8,8);
+ ctx2.rectangle(8,0,8,8);
+ ctx2.fill();
+ }
+
+ warning ("\n=====================> dkdkjdkjdkjdkj\n");
+
+ pixmap_ctx.set_source_surface(background_surface, 0, 0);
+ pixmap_ctx.get_source().set_extend(Cairo.Extend.REPEAT);
+ pixmap_ctx.rectangle(draw_x, draw_y,
+ zoomed.width,
+ zoomed.height);
+ pixmap_ctx.fill();
+ }
+
Gdk.cairo_set_source_pixbuf(pixmap_ctx, zoomed, draw_x, draw_y);
pixmap_ctx.paint();
}
@@ -2249,13 +2274,35 @@ public abstract class SinglePhotoPage : Page {
// when the resize is completed, do a high-quality repaint
repaint();
}
+
+ private Cairo.Surface? background_surface = null;
private bool on_canvas_exposed(Cairo.Context exposed_ctx) {
// draw pixmap onto canvas unless it's not been instantiated, in which case draw black
// (so either old image or contents of another page is not left on screen)
- if (pixmap != null)
+ if (pixmap != null) {
+ /*if (pixmap.has_alpha)*/ {
+ if (background_surface == null) {
+ background_surface = get_window().create_similar_surface(Cairo.Content.COLOR_ALPHA,
+ 16, 16);
+ var ctx = new Cairo.Context(background_surface);
+ ctx.set_operator(Cairo.Operator.SOURCE);
+ set_source_color_from_string(ctx, "#808080");
+ ctx.rectangle(0,0,8,8);
+ ctx.rectangle(8,8,8,8);
+ ctx.fill();
+ set_source_color_from_string(ctx, "#cccccc");
+ ctx.rectangle(0,8,8,8);
+ ctx.rectangle(8,0,8,8);
+ ctx.fill();
+ }
+ exposed_ctx.set_source_surface(background_surface, 0, 0);
+ exposed_ctx.get_source().set_extend(Cairo.Extend.REPEAT);
+ exposed_ctx.rectangle(0, 0, get_allocated_width(), get_allocated_height());
+ exposed_ctx.paint();
+ }
exposed_ctx.set_source_surface(pixmap, 0, 0);
- else
+ } else
set_source_color_from_string(exposed_ctx, "#000");
exposed_ctx.rectangle(0, 0, get_allocated_width(), get_allocated_height());
@@ -2280,10 +2327,38 @@ public abstract class SinglePhotoPage : Page {
} else if (!transition_clock.paint(ctx, ctx_dim.width, ctx_dim.height)) {
// transition is not running, so paint the full image on a black background
set_source_color_from_string(ctx, "#000");
-
+
ctx.rectangle(0, 0, pixmap_dim.width, pixmap_dim.height);
ctx.fill();
-
+
+ warning ("\n====> scaled %d %d %d %d\n", scaled_pos.x,
+ scaled_pos.y,
+ scaled.width, scaled.height);
+
+ if (scaled.has_alpha) {
+ if (background_surface == null) {
+ background_surface = get_window().create_similar_surface(Cairo.Content.COLOR_ALPHA,
+ 16, 16);
+ var ctx2 = new Cairo.Context(background_surface);
+ ctx2.set_operator(Cairo.Operator.SOURCE);
+ set_source_color_from_string(ctx2, "#808080");
+ ctx2.rectangle(0,0,8,8);
+ ctx2.rectangle(8,8,8,8);
+ ctx2.fill();
+ set_source_color_from_string(ctx2, "#cccccc");
+ ctx2.rectangle(0,8,8,8);
+ ctx2.rectangle(8,0,8,8);
+ ctx2.fill();
+ }
+
+ ctx.set_source_surface(background_surface, 0, 0);
+ ctx.get_source().set_extend(Cairo.Extend.REPEAT);
+ ctx.rectangle(scaled_pos.x, scaled_pos.y,
+ scaled.width,
+ scaled.height);
+ ctx.fill();
+ }
+
Gdk.cairo_set_source_pixbuf(ctx, scaled, scaled_pos.x, scaled_pos.y);
ctx.paint();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]