Merge lp:~tghs/inkscape/widget_icon_background_render into lp:~inkscape.dev/inkscape/trunk

Proposed by Tim Sheridan
Status: Merged
Approved by: jazzynico
Approved revision: 15445
Merged at revision: 15446
Proposed branch: lp:~tghs/inkscape/widget_icon_background_render
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 55 lines (+16/-1)
3 files modified
AUTHORS (+1/-0)
src/extension/internal/cairo-render-context.cpp (+1/-1)
src/widgets/icon.cpp (+14/-0)
To merge this branch: bzr merge lp:~tghs/inkscape/widget_icon_background_render
Reviewer Review Type Date Requested Status
jazzynico (community) testing Approve
Martin Owens code Approve
Review via email: mp+315514@code.launchpad.net

Description of the change

Render document background in Icon widget

This fixes bug #1537497.

To post a comment you must log in.
Revision history for this message
Martin Owens (doctormo) wrote :

Looks good to me.

review: Approve (code)
Revision history for this message
jazzynico (jazzynico) wrote :

Tested successfully on Xubuntu 16.04, lp:inkscape rev. 15445.

review: Approve (testing)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AUTHORS'
2--- AUTHORS 2016-10-08 06:16:53 +0000
3+++ AUTHORS 2017-01-24 21:46:33 +0000
4@@ -145,6 +145,7 @@
5 Tom von Schwerdtner
6 Danilo Šegan
7 Abhishek Sharma
8+Tim Sheridan
9 Shivaken
10 Michael Sloan
11 John Smith
12
13=== modified file 'src/extension/internal/cairo-render-context.cpp'
14--- src/extension/internal/cairo-render-context.cpp 2016-09-27 08:51:26 +0000
15+++ src/extension/internal/cairo-render-context.cpp 2017-01-24 21:46:33 +0000
16@@ -865,7 +865,7 @@
17 cairo_scale(_cr, Inkscape::Util::Quantity::convert(1, "px", "pt"), Inkscape::Util::Quantity::convert(1, "px", "pt"));
18 } else if (cairo_surface_get_content(_surface) != CAIRO_CONTENT_ALPHA) {
19 // set background color on non-alpha surfaces
20- // TODO: bgcolor should be derived from SPDocument
21+ // TODO: bgcolor should be derived from SPDocument (see IconImpl)
22 cairo_set_source_rgb(_cr, 1.0, 1.0, 1.0);
23 cairo_rectangle(_cr, 0, 0, _width, _height);
24 cairo_fill(_cr);
25
26=== modified file 'src/widgets/icon.cpp'
27--- src/widgets/icon.cpp 2016-08-04 11:26:03 +0000
28+++ src/widgets/icon.cpp 2017-01-24 21:46:33 +0000
29@@ -35,6 +35,7 @@
30 #include "display/drawing.h"
31 #include "io/sys.h"
32 #include "sp-root.h"
33+#include "sp-namedview.h"
34 #include "util/units.h"
35
36 #include "icon.h"
37@@ -1163,6 +1164,19 @@
38 CAIRO_FORMAT_ARGB32, psize, psize, stride);
39 Inkscape::DrawingContext dc(s, ua.min());
40
41+ SPNamedView *nv = sp_document_namedview(doc, NULL);
42+ float bg_r = SP_RGBA32_R_F(nv->pagecolor);
43+ float bg_g = SP_RGBA32_G_F(nv->pagecolor);
44+ float bg_b = SP_RGBA32_B_F(nv->pagecolor);
45+ float bg_a = SP_RGBA32_A_F(nv->pagecolor);
46+
47+ cairo_t *cr = cairo_create(s);
48+ cairo_set_source_rgba(cr, bg_r, bg_g, bg_b, bg_a);
49+ cairo_rectangle(cr, 0, 0, psize, psize);
50+ cairo_fill(cr);
51+ cairo_save(cr);
52+ cairo_destroy(cr);
53+
54 drawing.render(dc, ua);
55 cairo_surface_destroy(s);
56