From 917de2bab458d51b4149a1b794cbb1b6b9562171 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Tue, 22 Jun 2010 23:36:47 +0200 Subject: Initial Cairo rendering commit: solid shapes, gradients, opacity and patterns (bzr r9508.1.1) --- src/display/sp-canvas.cpp | 53 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index c6778c8c5..29a5cd740 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1649,18 +1649,32 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, buf.visible_rect.y0 = draw_y1; buf.visible_rect.x1 = draw_x2; buf.visible_rect.y1 = draw_y2; - GdkColor *color = &widget->style->bg[GTK_STATE_NORMAL]; - buf.bg_color = (((color->red & 0xff00) << 8) - | (color->green & 0xff00) - | (color->blue >> 8)); buf.is_empty = true; - - buf.ct = nr_create_cairo_context_canvasbuf (&(buf.visible_rect), &buf); + //buf.bg_color = &widget->style->bg[GTK_STATE_NORMAL]; + //buf.ct = nr_create_cairo_context_canvasbuf (&(buf.visible_rect), &buf); + buf.ct = gdk_cairo_create(widget->window); + + // fix coordinates, clip all drawing to the tile and clear the background + // TODO: the translation is done to remain compatible with legacy code. + // Fix the code so it doesn't refer to buf.rect and remove the translation. + cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0); // ? + cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + //cairo_set_line_width(buf.ct, 3); + //cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1); + //cairo_stroke_preserve(buf.ct); + cairo_clip(buf.ct); + + gdk_cairo_set_source_color(buf.ct, &widget->style->bg[GTK_STATE_NORMAL]); + cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE); + //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + cairo_paint(buf.ct); + cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER); if (canvas->root->flags & SP_CANVAS_ITEM_VISIBLE) { SP_CANVAS_ITEM_GET_CLASS (canvas->root)->render (canvas->root, &buf); } +#if 0 #if ENABLE_LCMS cmsHTRANSFORM transf = 0; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -1702,22 +1716,22 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, // use gdk_draw_rgb_image_dithalign, for unfortunately gdk can only handle 24 bpp, which cairo // cannot handle at all. Still, this way is currently faster even despite the blit with squeeze. -///#define CANVAS_OUTPUT_VIA_CAIRO +//#define CANVAS_OUTPUT_VIA_CAIRO #ifdef CANVAS_OUTPUT_VIA_CAIRO - buf.cst = cairo_image_surface_create_for_data ( + cairo_surface_t *cst = cairo_image_surface_create_for_data ( buf.buf, CAIRO_FORMAT_ARGB32, // unpacked, i.e. 32 bits! one byte is unused x1 - x0, y1 - y0, buf.buf_rowstride ); cairo_t *window_ct = gdk_cairo_create(SP_CANVAS_WINDOW (canvas)); - cairo_set_source_surface (window_ct, buf.cst, x0 - canvas->x0, y0 - canvas->y0); + cairo_set_source_surface (window_ct, cst, x0 - canvas->x0, y0 - canvas->y0); cairo_paint (window_ct); cairo_destroy (window_ct); - cairo_surface_finish (buf.cst); - cairo_surface_destroy (buf.cst); + cairo_surface_finish (cst); + cairo_surface_destroy (cst); #else @@ -1746,11 +1760,12 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, nr_pixblock_release (&b4); #endif } +#endif - cairo_surface_t *cst = cairo_get_target(buf.ct); + //cairo_surface_t *cst = cairo_get_target(buf.ct); cairo_destroy (buf.ct); - cairo_surface_finish (cst); - cairo_surface_destroy (cst); + //cairo_surface_finish (cst); + //cairo_surface_destroy (cst); if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { nr_pixelstore_256K_free (buf.buf); @@ -1816,11 +1831,21 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) if (bw * bh < setup->max_pixels) { // We are small enough + GdkRectangle r; + r.x = this_rect.x0 - setup->canvas->x0; + r.y = this_rect.y0 - setup->canvas->y0; + r.width = this_rect.x1 - this_rect.x0; + r.height = this_rect.y1 - this_rect.y0; + + GdkWindow *window = GTK_WIDGET(setup->canvas)->window; + gdk_window_begin_paint_rect(window, &r); + sp_canvas_paint_single_buffer (setup->canvas, this_rect.x0, this_rect.y0, this_rect.x1, this_rect.y1, setup->big_rect.x0, setup->big_rect.y0, setup->big_rect.x1, setup->big_rect.y1, bw); + gdk_window_end_paint(window); return 1; } -- cgit v1.2.3 From 31f84a59da72b31b932833ce1af7d78f0a67e185 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 26 Jun 2010 03:02:06 +0200 Subject: Implement clipping (slightly incorrect) and masking (bzr r9508.1.4) --- src/display/sp-canvas.cpp | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 29a5cd740..31e80d1f9 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1650,19 +1650,20 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, buf.visible_rect.x1 = draw_x2; buf.visible_rect.y1 = draw_y2; buf.is_empty = true; - //buf.bg_color = &widget->style->bg[GTK_STATE_NORMAL]; - //buf.ct = nr_create_cairo_context_canvasbuf (&(buf.visible_rect), &buf); - buf.ct = gdk_cairo_create(widget->window); + //buf.ct = gdk_cairo_create(widget->window); + + // create temporary surface + cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x1 - x0, y1 - y0); + buf.ct = cairo_create(imgs); + //cairo_translate(buf.ct, -x0, -y0); // fix coordinates, clip all drawing to the tile and clear the background - // TODO: the translation is done to remain compatible with legacy code. - // Fix the code so it doesn't refer to buf.rect and remove the translation. - cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0); // ? - cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + //cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0); + //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); //cairo_set_line_width(buf.ct, 3); //cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1); //cairo_stroke_preserve(buf.ct); - cairo_clip(buf.ct); + //cairo_clip(buf.ct); gdk_cairo_set_source_color(buf.ct, &widget->style->bg[GTK_STATE_NORMAL]); cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE); @@ -1762,8 +1763,21 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, } #endif + // output to X + cairo_destroy(buf.ct); + + cairo_t *xct = gdk_cairo_create(widget->window); + cairo_translate(xct, x0 - canvas->x0, y0 - canvas->y0); + cairo_rectangle(xct, 0, 0, x1-x0, y1-y0); + cairo_clip(xct); + cairo_set_source_surface(xct, imgs, 0, 0); + cairo_set_operator(xct, CAIRO_OPERATOR_SOURCE); + cairo_paint(xct); + cairo_destroy(xct); + cairo_surface_destroy(imgs); + //cairo_surface_t *cst = cairo_get_target(buf.ct); - cairo_destroy (buf.ct); + //cairo_destroy (buf.ct); //cairo_surface_finish (cst); //cairo_surface_destroy (cst); @@ -1831,21 +1845,21 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) if (bw * bh < setup->max_pixels) { // We are small enough - GdkRectangle r; + /*GdkRectangle r; r.x = this_rect.x0 - setup->canvas->x0; r.y = this_rect.y0 - setup->canvas->y0; r.width = this_rect.x1 - this_rect.x0; r.height = this_rect.y1 - this_rect.y0; GdkWindow *window = GTK_WIDGET(setup->canvas)->window; - gdk_window_begin_paint_rect(window, &r); + gdk_window_begin_paint_rect(window, &r);*/ sp_canvas_paint_single_buffer (setup->canvas, this_rect.x0, this_rect.y0, this_rect.x1, this_rect.y1, setup->big_rect.x0, setup->big_rect.y0, setup->big_rect.x1, setup->big_rect.y1, bw); - gdk_window_end_paint(window); + //gdk_window_end_paint(window); return 1; } -- cgit v1.2.3 From 13b15b7b977eecbededd1734f5ab001f0c44d21f Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 30 Jun 2010 00:41:48 +0200 Subject: Consolidate Cairo utils in display/cairo-utils.h. Fix icons harder. (bzr r9508.1.8) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 31e80d1f9..571b573e1 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -42,7 +42,7 @@ #endif // ENABLE_LCMS #include "display/rendermode.h" #include "libnr/nr-blit.h" -#include "display/inkscape-cairo.h" +#include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" #include "sp-namedview.h" -- cgit v1.2.3 From e83b5a202a9e028e3407123cddafa06510756b66 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 4 Jul 2010 02:56:02 +0200 Subject: Remove some cruft (bzr r9508.1.10) --- src/display/sp-canvas.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 571b573e1..4c74af6d9 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1630,17 +1630,12 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, { GtkWidget *widget = GTK_WIDGET (canvas); - SPCanvasBuf buf; - if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { - buf.buf = nr_pixelstore_256K_new (FALSE, 0); - } else { - buf.buf = nr_pixelstore_1M_new (FALSE, 0); - } - // Mark the region clean sp_canvas_mark_rect(canvas, x0, y0, x1, y1, 0); - buf.buf_rowstride = sw * 4; + SPCanvasBuf buf; + buf.buf = NULL; + buf.buf_rowstride = 0; buf.rect.x0 = x0; buf.rect.y0 = y0; buf.rect.x1 = x1; -- cgit v1.2.3 From 30884b9e814d7baaa2299803e8cb76cf203ca084 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 4 Aug 2010 05:45:58 +0200 Subject: Wholesale cruft removal part 1 (bzr r9508.1.44) --- src/display/sp-canvas.cpp | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 4c74af6d9..8be585a43 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -20,8 +20,6 @@ # include "config.h" #endif -#include - #include #include #include @@ -33,7 +31,6 @@ #include #include "display-forward.h" #include <2geom/matrix.h> -#include #include "preferences.h" #include "inkscape.h" #include "sodipodi-ctrlrect.h" @@ -41,7 +38,6 @@ #include "color-profile-fns.h" #endif // ENABLE_LCMS #include "display/rendermode.h" -#include "libnr/nr-blit.h" #include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" @@ -1758,6 +1754,7 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, } #endif + // output to X cairo_destroy(buf.ct); @@ -1775,12 +1772,6 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, //cairo_destroy (buf.ct); //cairo_surface_finish (cst); //cairo_surface_destroy (cst); - - if (canvas->rendermode != Inkscape::RENDERMODE_OUTLINE) { - nr_pixelstore_256K_free (buf.buf); - } else { - nr_pixelstore_1M_free (buf.buf); - } } struct PaintRectSetup { -- cgit v1.2.3 From 77dc5f1acd4a6b66b2d6fc5c81f7e5c61ef95785 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 5 Aug 2010 02:49:51 +0200 Subject: Wholesale cruft removal part 4; fix crash when rendering guides (bzr r9508.1.48) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 8be585a43..bfd007cfe 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -318,7 +318,7 @@ sp_canvas_item_invoke_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **a if (SP_CANVAS_ITEM_GET_CLASS (item)->point) return SP_CANVAS_ITEM_GET_CLASS (item)->point (item, p, actual_item); - return NR_HUGE; + return Geom::infinity(); } /** -- cgit v1.2.3 From 88b520a809dea1e5a6ca21bcbad962bc58deb0c3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 8 Apr 2011 04:42:29 +0200 Subject: Fix color-managed view (bzr r9508.1.74) --- src/display/sp-canvas.cpp | 107 +++++++++------------------------------------- 1 file changed, 21 insertions(+), 86 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 43f33b74e..a67a0fed8 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +# include #endif #include @@ -1651,6 +1651,8 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, //buf.ct = gdk_cairo_create(widget->window); // create temporary surface + int w = x1 - x0; + int h = y1 - y0; cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x1 - x0, y1 - y0); buf.ct = cairo_create(imgs); //cairo_translate(buf.ct, -x0, -y0); @@ -1673,97 +1675,30 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, SP_CANVAS_ITEM_GET_CLASS (canvas->root)->render (canvas->root, &buf); } -#if 0 -#if ENABLE_LCMS - cmsHTRANSFORM transf = 0; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); - if ( fromDisplay ) { - transf = Inkscape::colorprofile_get_display_per( canvas->cms_key ? *(canvas->cms_key) : "" ); - } else { - transf = Inkscape::colorprofile_get_display_transform(); - } -#endif // ENABLE_LCMS + // output to X + cairo_destroy(buf.ct); - if (buf.is_empty) { #if ENABLE_LCMS - if ( transf && canvas->enable_cms_display_adj ) { - cmsDoTransform( transf, &buf.bg_color, &buf.bg_color, 1 ); + if (canvas->enable_cms_display_adj) { + cmsHTRANSFORM transf = 0; + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); + if ( fromDisplay ) { + transf = Inkscape::colorprofile_get_display_per( canvas->cms_key ? *(canvas->cms_key) : "" ); + } else { + transf = Inkscape::colorprofile_get_display_transform(); } -#endif // ENABLE_LCMS - gdk_rgb_gc_set_foreground (canvas->pixmap_gc, buf.bg_color); - gdk_draw_rectangle (SP_CANVAS_WINDOW (canvas), - canvas->pixmap_gc, - TRUE, - x0 - canvas->x0, y0 - canvas->y0, - x1 - x0, y1 - y0); - } else { - -#if ENABLE_LCMS - if ( transf && canvas->enable_cms_display_adj ) { - for ( gint yy = 0; yy < (y1 - y0); yy++ ) { - guchar* p = buf.buf + (buf.buf_rowstride * yy); - cmsDoTransform( transf, p, p, (x1 - x0) ); + + if (transf) { + unsigned char *px = cairo_image_surface_get_data(imgs); + int stride = cairo_image_surface_get_stride(imgs); + for (int i=0; ix0, y0 - canvas->y0); - cairo_paint (window_ct); - cairo_destroy (window_ct); - cairo_surface_finish (cst); - cairo_surface_destroy (cst); - -#else - - NRPixBlock b3; - nr_pixblock_setup_fast (&b3, NR_PIXBLOCK_MODE_R8G8B8, x0, y0, x1, y1, TRUE); - - NRPixBlock b4; - nr_pixblock_setup_extern (&b4, NR_PIXBLOCK_MODE_R8G8B8A8P, x0, y0, x1, y1, - buf.buf, - buf.buf_rowstride, - FALSE, FALSE); - - // this does the 32->24 squishing, using an assembler routine: - nr_blit_pixblock_pixblock (&b3, &b4); - - gdk_draw_rgb_image_dithalign (SP_CANVAS_WINDOW (canvas), - canvas->pixmap_gc, - x0 - canvas->x0, y0 - canvas->y0, - x1 - x0, y1 - y0, - GDK_RGB_DITHER_MAX, - NR_PIXBLOCK_PX(&b3), - sw * 3, - x0 - canvas->x0, y0 - canvas->y0); - - nr_pixblock_release (&b3); - nr_pixblock_release (&b4); -#endif } -#endif - - - // output to X - cairo_destroy(buf.ct); +#endif // ENABLE_LCMS cairo_t *xct = gdk_cairo_create(widget->window); cairo_translate(xct, x0 - canvas->x0, y0 - canvas->y0); -- cgit v1.2.3 From 4f42f4c32b6d26e7af28c46901ff5fef8b6280b7 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 8 Apr 2011 22:25:52 +0200 Subject: Add missing flush() / mark_dirty() calls around CMS transform (bzr r9508.1.75) --- src/display/sp-canvas.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index a67a0fed8..105a9a0ff 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1690,12 +1690,14 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, } if (transf) { + cairo_surface_flush(imgs); unsigned char *px = cairo_image_surface_get_data(imgs); int stride = cairo_image_surface_get_stride(imgs); for (int i=0; i Date: Tue, 17 May 2011 23:25:49 -0700 Subject: Made dependencies explicit and bumped versions. (bzr r10208) --- src/display/sp-canvas.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 2d1e57092..0d450362a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -47,12 +47,9 @@ using Inkscape::Debug::GdkEventLatencyTracker; -// GTK_CHECK_VERSION returns false on failure -#define HAS_GDK_EVENT_REQUEST_MOTIONS GTK_CHECK_VERSION(2, 12, 0) - // gtk_check_version returns non-NULL on failure static bool const HAS_BROKEN_MOTION_HINTS = - true || gtk_check_version(2, 12, 0) != NULL || !HAS_GDK_EVENT_REQUEST_MOTIONS; + true || gtk_check_version(2, 12, 0) != NULL; // Define this to visualize the regions to be redrawn //#define DEBUG_REDRAW 1; @@ -1599,9 +1596,7 @@ sp_canvas_scroll (GtkWidget *widget, GdkEventScroll *event) static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { gdk_window_get_pointer(w, NULL, NULL, NULL); -#if HAS_GDK_EVENT_REQUEST_MOTIONS gdk_event_request_motions(event); -#endif } /** -- cgit v1.2.3 From a622000f4859173bb7ac484b86cefe9fa4f169e4 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 18 May 2011 21:43:01 -0700 Subject: Revert version bump so win devlibs can catch up. (bzr r10210) --- src/display/sp-canvas.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 0d450362a..2d1e57092 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -47,9 +47,12 @@ using Inkscape::Debug::GdkEventLatencyTracker; +// GTK_CHECK_VERSION returns false on failure +#define HAS_GDK_EVENT_REQUEST_MOTIONS GTK_CHECK_VERSION(2, 12, 0) + // gtk_check_version returns non-NULL on failure static bool const HAS_BROKEN_MOTION_HINTS = - true || gtk_check_version(2, 12, 0) != NULL; + true || gtk_check_version(2, 12, 0) != NULL || !HAS_GDK_EVENT_REQUEST_MOTIONS; // Define this to visualize the regions to be redrawn //#define DEBUG_REDRAW 1; @@ -1596,7 +1599,9 @@ sp_canvas_scroll (GtkWidget *widget, GdkEventScroll *event) static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { gdk_window_get_pointer(w, NULL, NULL, NULL); +#if HAS_GDK_EVENT_REQUEST_MOTIONS gdk_event_request_motions(event); +#endif } /** -- cgit v1.2.3 From 9865291b790f185d7ec2271c58e8653c9d4bb295 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 19 May 2011 22:01:27 -0700 Subject: Reinstating version bump. (bzr r10215) --- src/display/sp-canvas.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 2d1e57092..0d450362a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -47,12 +47,9 @@ using Inkscape::Debug::GdkEventLatencyTracker; -// GTK_CHECK_VERSION returns false on failure -#define HAS_GDK_EVENT_REQUEST_MOTIONS GTK_CHECK_VERSION(2, 12, 0) - // gtk_check_version returns non-NULL on failure static bool const HAS_BROKEN_MOTION_HINTS = - true || gtk_check_version(2, 12, 0) != NULL || !HAS_GDK_EVENT_REQUEST_MOTIONS; + true || gtk_check_version(2, 12, 0) != NULL; // Define this to visualize the regions to be redrawn //#define DEBUG_REDRAW 1; @@ -1599,9 +1596,7 @@ sp_canvas_scroll (GtkWidget *widget, GdkEventScroll *event) static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { gdk_window_get_pointer(w, NULL, NULL, NULL); -#if HAS_GDK_EVENT_REQUEST_MOTIONS gdk_event_request_motions(event); -#endif } /** -- cgit v1.2.3 From f3756ff85a32f4b2a0771d0ac3bd78a69535395f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 3 Jun 2011 11:44:52 +0100 Subject: Use generic headers in preparation for GTK+ 3 transition Fixed bugs: - https://launchpad.net/bugs/792263 (bzr r10252.1.1) --- src/display/sp-canvas.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 0d450362a..ff1bf32c6 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -20,9 +20,7 @@ #include -#include -#include -#include +#include #include -- cgit v1.2.3 From 9a8e6cfdc2f8052638e6816e0ffdd36e1b253a6c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 12 Jun 2011 18:23:46 +0100 Subject: Replace deprecated GTK_WIDGET_(UN)SET_FLAGS macros (bzr r10277.1.1) --- src/display/sp-canvas.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ff1bf32c6..ad2a45eea 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1020,9 +1020,9 @@ sp_canvas_class_init (SPCanvasClass *klass) static void sp_canvas_init (SPCanvas *canvas) { - GTK_WIDGET_UNSET_FLAGS (canvas, GTK_NO_WINDOW); - GTK_WIDGET_UNSET_FLAGS (canvas, GTK_DOUBLE_BUFFERED); - GTK_WIDGET_SET_FLAGS (canvas, GTK_CAN_FOCUS); + gtk_widget_set_has_window (GTK_WIDGET (canvas), TRUE); + gtk_widget_set_double_buffered (GTK_WIDGET (canvas), FALSE); + gtk_widget_set_can_focus (GTK_WIDGET (canvas), TRUE); canvas->pick_event.type = GDK_LEAVE_NOTIFY; canvas->pick_event.crossing.x = 0; @@ -1176,7 +1176,7 @@ sp_canvas_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); + gtk_widget_set_realized (widget, TRUE); canvas->pixmap_gc = gdk_gc_new (SP_CANVAS_WINDOW (canvas)); } @@ -2022,7 +2022,7 @@ sp_canvas_crossing (GtkWidget *widget, GdkEventCrossing *event) static gint sp_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event) { - GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS); + gtk_widget_grab_focus (widget); SPCanvas *canvas = SP_CANVAS (widget); @@ -2039,8 +2039,6 @@ sp_canvas_focus_in (GtkWidget *widget, GdkEventFocus *event) static gint sp_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) { - GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS); - SPCanvas *canvas = SP_CANVAS (widget); if (canvas->focused_item) -- cgit v1.2.3 From a1f1e29a8a207ea7ef4be583a050778cf2875217 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 13 Jun 2011 01:28:49 +0100 Subject: Replace deprecated GtkSignal (bzr r10282.1.1) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ad2a45eea..20c21a8c3 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1360,7 +1360,7 @@ emit_event (SPCanvas *canvas, GdkEvent *event) while (item && !finished) { gtk_object_ref (GTK_OBJECT (item)); - gtk_signal_emit (GTK_OBJECT (item), item_signals[ITEM_EVENT], &ev, &finished); + g_signal_emit (G_OBJECT (item), item_signals[ITEM_EVENT], 0, &ev, &finished); SPCanvasItem *parent = item->parent; gtk_object_unref (GTK_OBJECT (item)); item = parent; -- cgit v1.2.3 From 2402528197627887e374dd2a4269dfdeb19acc58 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 15 Jun 2011 01:13:10 +0100 Subject: Clean up deprecated GTK_WIDGET API (bzr r10302.1.2) --- src/display/sp-canvas.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 20c21a8c3..e2220282d 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -537,7 +537,7 @@ sp_canvas_item_grab (SPCanvasItem *item, guint event_mask, GdkCursor *cursor, gu { g_return_val_if_fail (item != NULL, -1); g_return_val_if_fail (SP_IS_CANVAS_ITEM (item), -1); - g_return_val_if_fail (GTK_WIDGET_MAPPED (item->canvas), -1); + g_return_val_if_fail (gtk_widget_get_mapped (GTK_WIDGET (item->canvas)), -1); if (item->canvas->grabbed_item) return -1; @@ -628,7 +628,7 @@ sp_canvas_item_grab_focus (SPCanvasItem *item) { g_return_if_fail (item != NULL); g_return_if_fail (SP_IS_CANVAS_ITEM (item)); - g_return_if_fail (GTK_WIDGET_CAN_FOCUS (GTK_WIDGET (item->canvas))); + g_return_if_fail (gtk_widget_get_can_focus (GTK_WIDGET (item->canvas))); SPCanvasItem *focused_item = item->canvas->focused_item; @@ -1241,7 +1241,7 @@ sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) widget->allocation = *allocation; - if (GTK_WIDGET_REALIZED (widget)) { + if (gtk_widget_get_realized (widget)) { gdk_window_move_resize (widget->window, widget->allocation.x, widget->allocation.y, widget->allocation.width, widget->allocation.height); @@ -1967,7 +1967,7 @@ sp_canvas_expose (GtkWidget *widget, GdkEventExpose *event) { SPCanvas *canvas = SP_CANVAS (widget); - if (!GTK_WIDGET_DRAWABLE (widget) || + if (!gtk_widget_is_drawable (widget) || (event->window != SP_CANVAS_WINDOW (canvas))) return FALSE; @@ -2121,7 +2121,7 @@ do_update (SPCanvas *canvas) } /* Paint if able to */ - if (GTK_WIDGET_DRAWABLE (canvas)) { + if (gtk_widget_is_drawable ( GTK_WIDGET (canvas))) { return paint (canvas); } @@ -2205,7 +2205,7 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, // scrolling without zoom; redraw only the newly exposed areas if ((dx != 0) || (dy != 0)) { canvas->is_scrolling = is_scrolling; - if (GTK_WIDGET_REALIZED (canvas)) { + if (gtk_widget_get_realized (GTK_WIDGET (canvas))) { gdk_window_scroll (SP_CANVAS_WINDOW (canvas), -dx, -dy); } } @@ -2254,7 +2254,7 @@ sp_canvas_request_redraw (SPCanvas *canvas, int x0, int y0, int x1, int y1) g_return_if_fail (canvas != NULL); g_return_if_fail (SP_IS_CANVAS (canvas)); - if (!GTK_WIDGET_DRAWABLE (canvas)) return; + if (!gtk_widget_is_drawable ( GTK_WIDGET (canvas))) return; if ((x0 >= x1) || (y0 >= y1)) return; bbox.x0 = x0; -- cgit v1.2.3 From 8640e3a8755e772cc7982a9d6f8a47c6ee0dae00 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 22 Jun 2011 03:07:58 -0700 Subject: Warning cleanup. (bzr r10339) --- src/display/sp-canvas.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index c84452c07..472c9ada5 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1620,8 +1620,7 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) return status; } -static void -sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, int draw_x1, int draw_y1, int draw_x2, int draw_y2, int sw) +static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int x1, int y1, int draw_x1, int draw_y1, int draw_x2, int draw_y2, int /*sw*/) { GtkWidget *widget = GTK_WIDGET (canvas); -- cgit v1.2.3 From ab143333746e25648b253f13c0539adff089b1b6 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 24 Jun 2011 00:22:07 +0200 Subject: Remove more of libnr (bzr r10347.1.2) --- src/display/sp-canvas.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 472c9ada5..977452834 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -2306,13 +2306,15 @@ Geom::Rect SPCanvas::getViewbox() const } /** - * Return canvas window coordinates as IRect (a rectangle defined by integers). + * Return canvas window coordinates as integer rectangle. */ -NR::IRect SPCanvas::getViewboxIntegers() const +Geom::IntRect SPCanvas::getViewboxIntegers() const { GtkWidget const *w = GTK_WIDGET(this); - return NR::IRect(NR::IPoint(x0, y0), - NR::IPoint(x0 + w->allocation.width, y0 + w->allocation.height)); + Geom::IntRect ret; + ret.setMin(Geom::IntPoint(x0, y0)); + ret.setMax(Geom::IntPoint(x0 + w->allocation.width, y0 + w->allocation.height)); + return ret; } inline int sp_canvas_tile_floor(int x) -- cgit v1.2.3 From 4d8bf28dbebbc70325c75c0501ed192ae330c63b Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 24 Jun 2011 11:23:41 +0100 Subject: Switch to GObject (bzr r10350.1.3) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 472c9ada5..0d56b0175 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -169,7 +169,7 @@ sp_canvas_item_init (SPCanvasItem *item) * Constructs new SPCanvasItem on SPCanvasGroup. */ SPCanvasItem * -sp_canvas_item_new (SPCanvasGroup *parent, GtkType type, gchar const *first_arg_name, ...) +sp_canvas_item_new (SPCanvasGroup *parent, GType type, gchar const *first_arg_name, ...) { va_list args; -- cgit v1.2.3 From cb302be5567e13d38c794debb7a68bbf5f4abd1e Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 2 Jul 2011 12:17:50 +0100 Subject: GTK+ cleaning: gtk_type_new (bzr r10390.1.3) --- src/display/sp-canvas.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 0d56b0175..ecc3051cc 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -177,7 +177,7 @@ sp_canvas_item_new (SPCanvasGroup *parent, GType type, gchar const *first_arg_na g_return_val_if_fail (SP_IS_CANVAS_GROUP (parent), NULL); g_return_val_if_fail (gtk_type_is_a (type, sp_canvas_item_get_type ()), NULL); - SPCanvasItem *item = SP_CANVAS_ITEM (gtk_type_new (type)); + SPCanvasItem *item = SP_CANVAS_ITEM (g_object_new (type, NULL)); va_start (args, first_arg_name); sp_canvas_item_construct (item, parent, first_arg_name, args); @@ -1025,7 +1025,7 @@ sp_canvas_init (SPCanvas *canvas) canvas->pick_event.crossing.y = 0; /* Create the root item as a special case */ - canvas->root = SP_CANVAS_ITEM (gtk_type_new (sp_canvas_group_get_type ())); + canvas->root = SP_CANVAS_ITEM (g_object_new (sp_canvas_group_get_type (), NULL)); canvas->root->canvas = canvas; gtk_object_ref (GTK_OBJECT (canvas->root)); @@ -1125,7 +1125,7 @@ static void track_latency(GdkEvent const *event) { GtkWidget * sp_canvas_new_aa (void) { - SPCanvas *canvas = (SPCanvas *)gtk_type_new (sp_canvas_get_type ()); + SPCanvas *canvas = (SPCanvas *)g_object_new (sp_canvas_get_type (), NULL); return (GtkWidget *) canvas; } @@ -1464,9 +1464,6 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event) && (canvas->current_item != NULL) && !canvas->left_grabbed_item) { GdkEvent new_event; - SPCanvasItem *item; - - item = canvas->current_item; new_event = canvas->pick_event; new_event.type = GDK_LEAVE_NOTIFY; -- cgit v1.2.3 From 32cbae2ea15712efd9a36f43f7690268c1767e52 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 11:43:53 +0100 Subject: GTK+ cleanup: gtk_type_class (bzr r10407) --- src/display/sp-canvas.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ecc3051cc..e1f165003 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -727,7 +727,7 @@ sp_canvas_group_class_init (SPCanvasGroupClass *klass) GtkObjectClass *object_class = (GtkObjectClass *) klass; SPCanvasItemClass *item_class = (SPCanvasItemClass *) klass; - group_parent_class = (SPCanvasItemClass*)gtk_type_class (sp_canvas_item_get_type ()); + group_parent_class = (SPCanvasItemClass*)g_type_class_peek_parent (klass); object_class->destroy = sp_canvas_group_destroy; @@ -989,7 +989,7 @@ sp_canvas_class_init (SPCanvasClass *klass) GtkObjectClass *object_class = (GtkObjectClass *) klass; GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; - canvas_parent_class = (GtkWidgetClass *)gtk_type_class (GTK_TYPE_WIDGET); + canvas_parent_class = (GtkWidgetClass *)g_type_class_peek_parent (klass); object_class->destroy = sp_canvas_destroy; -- cgit v1.2.3 From 1cbae999d86d7804a6c9cfe8a6f8de7c4a8a4c2c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 3 Jul 2011 12:48:35 +0100 Subject: GTK+ cleanup: gtk_object_sink (bzr r10411) --- src/display/sp-canvas.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index e1f165003..3e8a4880c 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -884,7 +884,7 @@ static void group_add (SPCanvasGroup *group, SPCanvasItem *item) { gtk_object_ref (GTK_OBJECT (item)); - gtk_object_sink (GTK_OBJECT (item)); + g_object_ref_sink (item); if (!group->items) { group->items = g_list_append (group->items, item); @@ -1029,7 +1029,7 @@ sp_canvas_init (SPCanvas *canvas) canvas->root->canvas = canvas; gtk_object_ref (GTK_OBJECT (canvas->root)); - gtk_object_sink (GTK_OBJECT (canvas->root)); + g_object_ref_sink (canvas->root); canvas->need_repick = TRUE; -- cgit v1.2.3 From a3e406b2ceafb8fb6b44db0a7816a083d7b3c8ee Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 9 Jul 2011 02:52:06 +0200 Subject: Add SPCanvasArena caching layer. Currently breaks for clipped groups that contain filtered objects (Cairo clipping bug?) (bzr r10347.1.6) --- src/display/sp-canvas.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 23c6a430e..29729ef6c 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -691,6 +691,7 @@ static void sp_canvas_group_destroy (GtkObject *object); static void sp_canvas_group_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static double sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static void sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf); +static void sp_canvas_group_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area); static SPCanvasItemClass *group_parent_class; @@ -734,6 +735,7 @@ sp_canvas_group_class_init (SPCanvasGroupClass *klass) item_class->update = sp_canvas_group_update; item_class->render = sp_canvas_group_render; item_class->point = sp_canvas_group_point; + item_class->visible_area_changed = sp_canvas_group_visible_area_changed; } /** @@ -877,6 +879,20 @@ sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf) } } +static void +sp_canvas_group_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area) +{ + SPCanvasGroup *group = SP_CANVAS_GROUP (item); + + for (GList *list = group->items; list; list = list->next) { + SPCanvasItem *child = (SPCanvasItem *)list->data; + if (child->flags & SP_CANVAS_ITEM_VISIBLE) { + if (SP_CANVAS_ITEM_GET_CLASS (child)->visible_area_changed) + SP_CANVAS_ITEM_GET_CLASS (child)->visible_area_changed (child, old_area, new_area); + } + } +} + /** * Adds an item to a canvas group. */ @@ -1218,8 +1234,16 @@ sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) { SPCanvas *canvas = SP_CANVAS (widget); + Geom::IntRect old_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + widget->allocation.width, widget->allocation.height); + Geom::IntRect new_area = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + allocation->width, allocation->height); + /* Schedule redraw of new region */ sp_canvas_resize_tiles(canvas,canvas->x0,canvas->y0,canvas->x0+allocation->width,canvas->y0+allocation->height); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed (canvas->root, old_area, new_area); + if (allocation->width > widget->allocation.width) { sp_canvas_request_redraw (canvas, canvas->x0 + widget->allocation.width, @@ -2152,12 +2176,17 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, int dx = ix - canvas->x0; // dx and dy specify the displacement (scroll) of the int dy = iy - canvas->y0; // canvas w.r.t its previous position + Geom::IntRect old_area = canvas->getViewboxIntegers(); + Geom::IntRect new_area = old_area + Geom::IntPoint(dx, dy); + canvas->dx0 = cx; // here the 'd' stands for double, not delta! canvas->dy0 = cy; canvas->x0 = ix; canvas->y0 = iy; sp_canvas_resize_tiles (canvas, canvas->x0, canvas->y0, canvas->x0+canvas->widget.allocation.width, canvas->y0+canvas->widget.allocation.height); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed (canvas->root, old_area, new_area); if (!clear) { // scrolling without zoom; redraw only the newly exposed areas @@ -2170,7 +2199,6 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, } else { // scrolling as part of zoom; do nothing here - the next do_update will perform full redraw } - } /** -- cgit v1.2.3 From 2994e0b96e7d5d6d198b3d8139e4134f9d454229 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sat, 9 Jul 2011 02:18:40 -0700 Subject: Next step in refactoring color management. More to come. (bzr r10429) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 3e8a4880c..ea39d3435 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1683,7 +1683,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int int stride = cairo_image_surface_get_stride(imgs); for (int i=0; i Date: Sun, 10 Jul 2011 00:13:05 -0700 Subject: Refactored to abstract lcms usage more. Added CMSSystem class. (bzr r10437) --- src/display/sp-canvas.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ea39d3435..37998437d 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -30,9 +30,7 @@ #include "preferences.h" #include "inkscape.h" #include "sodipodi-ctrlrect.h" -#if ENABLE_LCMS -#include "color-profile-fns.h" -#endif // ENABLE_LCMS +#include "cms-system.h" #include "display/rendermode.h" #include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" @@ -1672,9 +1670,9 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); if ( fromDisplay ) { - transf = Inkscape::colorprofile_get_display_per( canvas->cms_key ? *(canvas->cms_key) : "" ); + transf = Inkscape::CMSSystem::getDisplayPer( canvas->cms_key ? *(canvas->cms_key) : "" ); } else { - transf = Inkscape::colorprofile_get_display_transform(); + transf = Inkscape::CMSSystem::getDisplayTransform(); } if (transf) { @@ -1683,7 +1681,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int int stride = cairo_image_surface_get_stride(imgs); for (int i=0; i Date: Thu, 14 Jul 2011 20:55:37 +0200 Subject: Remove useless pixmap_gc variable (bzr r10347.1.14) --- src/display/sp-canvas.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index f6446bdd7..d7f34969f 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1061,7 +1061,7 @@ sp_canvas_init (SPCanvas *canvas) #if ENABLE_LCMS canvas->enable_cms_display_adj = false; - canvas->cms_key = new Glib::ustring(""); + new (&canvas->cms_key) Glib::ustring(""); #endif // ENABLE_LCMS canvas->is_scrolling = false; @@ -1121,6 +1121,8 @@ sp_canvas_destroy (GtkObject *object) shutdown_transients (canvas); + canvas->cms_key.~ustring(); + if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object); } @@ -1150,8 +1152,6 @@ sp_canvas_new_aa (void) static void sp_canvas_realize (GtkWidget *widget) { - SPCanvas *canvas = SP_CANVAS (widget); - GdkWindowAttr attributes; attributes.window_type = GDK_WINDOW_CHILD; attributes.x = widget->allocation.x; @@ -1187,8 +1187,6 @@ sp_canvas_realize (GtkWidget *widget) widget->style = gtk_style_attach (widget->style, widget->window); gtk_widget_set_realized (widget, TRUE); - - canvas->pixmap_gc = gdk_gc_new (SP_CANVAS_WINDOW (canvas)); } /** @@ -1205,9 +1203,6 @@ sp_canvas_unrealize (GtkWidget *widget) shutdown_transients (canvas); - gdk_gc_destroy (canvas->pixmap_gc); - canvas->pixmap_gc = NULL; - if (GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (* GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (widget); } @@ -1626,7 +1621,7 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) if (event->window != SP_CANVAS_WINDOW (canvas)) return FALSE; - if (canvas->pixmap_gc == NULL) // canvas being deleted + if (canvas->root == NULL) // canvas being deleted return FALSE; canvas->state = event->state; @@ -1694,7 +1689,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool fromDisplay = prefs->getBool( "/options/displayprofile/from_display"); if ( fromDisplay ) { - transf = Inkscape::CMSSystem::getDisplayPer( canvas->cms_key ? *(canvas->cms_key) : "" ); + transf = Inkscape::CMSSystem::getDisplayPer( canvas->cms_key ); } else { transf = Inkscape::CMSSystem::getDisplayTransform(); } @@ -1881,16 +1876,6 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1) rect.x1 = MIN (rect.x1, canvas->x0/*draw_x1*/ + GTK_WIDGET (canvas)->allocation.width); rect.y1 = MIN (rect.y1, canvas->y0/*draw_y1*/ + GTK_WIDGET (canvas)->allocation.height); -#ifdef DEBUG_REDRAW - // paint the area to redraw yellow - gdk_rgb_gc_set_foreground (canvas->pixmap_gc, 0xFFFF00); - gdk_draw_rectangle (SP_CANVAS_WINDOW (canvas), - canvas->pixmap_gc, - TRUE, - rect.x0 - canvas->x0, rect.y0 - canvas->y0, - rect.x1 - rect.x0, rect.y1 - rect.y0); -#endif - PaintRectSetup setup; setup.canvas = canvas; @@ -2088,7 +2073,7 @@ paint (SPCanvas *canvas) static int do_update (SPCanvas *canvas) { - if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop during interrupted display! + if (!canvas->root) // canvas may have already be destroyed by closing desktop during interrupted display! return TRUE; if (canvas->drawing_disabled) -- cgit v1.2.3 From 662d4502604f027a0d0fd2b1f8613de8e0d04668 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 16 Jul 2011 23:53:24 +1000 Subject: fix for building with cmake and building without lcms works again. (bzr r10459) --- src/display/sp-canvas.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index d7f34969f..71f608118 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1120,9 +1120,9 @@ sp_canvas_destroy (GtkObject *object) } shutdown_transients (canvas); - +#if ENABLE_LCMS canvas->cms_key.~ustring(); - +#endif if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object); } -- cgit v1.2.3 From 905b8a96963f78358abfd109c0c49758c6fe4e9d Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 28 Jul 2011 07:04:08 +0200 Subject: Per-item render cache. Cache some offscreen data to facilitate smoother navigation. (bzr r10347.1.20) --- src/display/sp-canvas.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 71f608118..7d6727ff3 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -689,7 +689,7 @@ static void sp_canvas_group_destroy (GtkObject *object); static void sp_canvas_group_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags); static double sp_canvas_group_point (SPCanvasItem *item, Geom::Point p, SPCanvasItem **actual_item); static void sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf); -static void sp_canvas_group_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area); +static void sp_canvas_group_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_area); static SPCanvasItemClass *group_parent_class; @@ -733,7 +733,7 @@ sp_canvas_group_class_init (SPCanvasGroupClass *klass) item_class->update = sp_canvas_group_update; item_class->render = sp_canvas_group_render; item_class->point = sp_canvas_group_point; - item_class->visible_area_changed = sp_canvas_group_visible_area_changed; + item_class->viewbox_changed = sp_canvas_group_viewbox_changed; } /** @@ -878,15 +878,15 @@ sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf) } static void -sp_canvas_group_visible_area_changed (SPCanvasItem *item, Geom::IntRect const &old_area, Geom::IntRect const &new_area) +sp_canvas_group_viewbox_changed (SPCanvasItem *item, Geom::IntRect const &new_area) { SPCanvasGroup *group = SP_CANVAS_GROUP (item); for (GList *list = group->items; list; list = list->next) { SPCanvasItem *child = (SPCanvasItem *)list->data; if (child->flags & SP_CANVAS_ITEM_VISIBLE) { - if (SP_CANVAS_ITEM_GET_CLASS (child)->visible_area_changed) - SP_CANVAS_ITEM_GET_CLASS (child)->visible_area_changed (child, old_area, new_area); + if (SP_CANVAS_ITEM_GET_CLASS (child)->viewbox_changed) + SP_CANVAS_ITEM_GET_CLASS (child)->viewbox_changed (child, new_area); } } } @@ -1234,8 +1234,8 @@ sp_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) /* Schedule redraw of new region */ sp_canvas_resize_tiles(canvas,canvas->x0,canvas->y0,canvas->x0+allocation->width,canvas->y0+allocation->height); - if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed) - SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed (canvas->root, old_area, new_area); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed (canvas->root, new_area); if (allocation->width > widget->allocation.width) { sp_canvas_request_redraw (canvas, @@ -1655,6 +1655,15 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int buf.is_empty = true; //buf.ct = gdk_cairo_create(widget->window); + /* + cairo_t *xctt = gdk_cairo_create(widget->window); + cairo_translate(xctt, x0 - canvas->x0, y0 - canvas->y0); + cairo_set_source_rgb(xctt, 1,0,0); + cairo_rectangle(xctt, 0, 0, x1-x0, y1-y0); + cairo_fill(xctt); + cairo_destroy(xctt); + //*/ + // create temporary surface int w = x1 - x0; int h = y1 - y0; @@ -2168,8 +2177,8 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, canvas->y0 = iy; sp_canvas_resize_tiles (canvas, canvas->x0, canvas->y0, canvas->x0+canvas->widget.allocation.width, canvas->y0+canvas->widget.allocation.height); - if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed) - SP_CANVAS_ITEM_GET_CLASS (canvas->root)->visible_area_changed (canvas->root, old_area, new_area); + if (SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed) + SP_CANVAS_ITEM_GET_CLASS (canvas->root)->viewbox_changed (canvas->root, new_area); if (!clear) { // scrolling without zoom; redraw only the newly exposed areas -- cgit v1.2.3 From ac0bc3b7583e5b45ed6ec97923170a77b5648d2e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 27 Aug 2011 14:36:15 +0200 Subject: Update 2Geom. Remove all use of NRRectL. (bzr r10582.1.3) --- src/display/sp-canvas.cpp | 154 ++++++++++++++++++---------------------------- 1 file changed, 61 insertions(+), 93 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 7d6727ff3..a4c8500ed 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -866,10 +866,10 @@ sp_canvas_group_render (SPCanvasItem *item, SPCanvasBuf *buf) for (GList *list = group->items; list; list = list->next) { SPCanvasItem *child = (SPCanvasItem *)list->data; if (child->flags & SP_CANVAS_ITEM_VISIBLE) { - if ((child->x1 < buf->rect.x1) && - (child->y1 < buf->rect.y1) && - (child->x2 > buf->rect.x0) && - (child->y2 > buf->rect.y0)) { + if ((child->x1 < buf->rect.right()) && + (child->y1 < buf->rect.bottom()) && + (child->x2 > buf->rect.left()) && + (child->y2 > buf->rect.top())) { if (SP_CANVAS_ITEM_GET_CLASS (child)->render) SP_CANVAS_ITEM_GET_CLASS (child)->render (child, buf); } @@ -963,8 +963,8 @@ static gint sp_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event); static GtkWidgetClass *canvas_parent_class; static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int nb); -static void sp_canvas_dirty_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb); -static void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8_t val); +static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area); +static void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val); static int do_update (SPCanvas *canvas); /** @@ -1634,46 +1634,38 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) return status; } -static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int x1, int y1, int draw_x1, int draw_y1, int draw_x2, int draw_y2, int /*sw*/) +static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const &paint_rect, Geom::IntRect const &canvas_rect, int /*sw*/) { GtkWidget *widget = GTK_WIDGET (canvas); // Mark the region clean - sp_canvas_mark_rect(canvas, x0, y0, x1, y1, 0); + sp_canvas_mark_rect(canvas, paint_rect, 0); SPCanvasBuf buf; buf.buf = NULL; buf.buf_rowstride = 0; - buf.rect.x0 = x0; - buf.rect.y0 = y0; - buf.rect.x1 = x1; - buf.rect.y1 = y1; - buf.visible_rect.x0 = draw_x1; - buf.visible_rect.y0 = draw_y1; - buf.visible_rect.x1 = draw_x2; - buf.visible_rect.y1 = draw_y2; + buf.rect = paint_rect; + buf.visible_rect = canvas_rect; buf.is_empty = true; //buf.ct = gdk_cairo_create(widget->window); /* cairo_t *xctt = gdk_cairo_create(widget->window); - cairo_translate(xctt, x0 - canvas->x0, y0 - canvas->y0); + cairo_translate(xctt, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); cairo_set_source_rgb(xctt, 1,0,0); - cairo_rectangle(xctt, 0, 0, x1-x0, y1-y0); + cairo_rectangle(xctt, 0, 0, paint_rect.width(), paint_rect.height()); cairo_fill(xctt); cairo_destroy(xctt); //*/ // create temporary surface - int w = x1 - x0; - int h = y1 - y0; - cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, x1 - x0, y1 - y0); + cairo_surface_t *imgs = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, paint_rect.width(), paint_rect.height()); buf.ct = cairo_create(imgs); //cairo_translate(buf.ct, -x0, -y0); // fix coordinates, clip all drawing to the tile and clear the background - //cairo_translate(buf.ct, x0 - canvas->x0, y0 - canvas->y0); - //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + //cairo_translate(buf.ct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); + //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rect.height()); //cairo_set_line_width(buf.ct, 3); //cairo_set_source_rgba(buf.ct, 1.0, 0.0, 0.0, 0.1); //cairo_stroke_preserve(buf.ct); @@ -1681,7 +1673,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int gdk_cairo_set_source_color(buf.ct, &widget->style->bg[GTK_STATE_NORMAL]); cairo_set_operator(buf.ct, CAIRO_OPERATOR_SOURCE); - //cairo_rectangle(buf.ct, 0, 0, x1 - x0, y1 - y0); + //cairo_rectangle(buf.ct, 0, 0, paint_rect.width(), paint_rec.height()); cairo_paint(buf.ct); cairo_set_operator(buf.ct, CAIRO_OPERATOR_OVER); @@ -1707,9 +1699,9 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int cairo_surface_flush(imgs); unsigned char *px = cairo_image_surface_get_data(imgs); int stride = cairo_image_surface_get_stride(imgs); - for (int i=0; iwindow); - cairo_translate(xct, x0 - canvas->x0, y0 - canvas->y0); - cairo_rectangle(xct, 0, 0, x1-x0, y1-y0); + cairo_translate(xct, paint_rect.left() - canvas->x0, paint_rect.top() - canvas->y0); + cairo_rectangle(xct, 0, 0, paint_rect.width(), paint_rect.height()); cairo_clip(xct); cairo_set_source_surface(xct, imgs, 0, 0); cairo_set_operator(xct, CAIRO_OPERATOR_SOURCE); @@ -1734,7 +1726,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, int x0, int y0, int struct PaintRectSetup { SPCanvas* canvas; - NRRectL big_rect; + Geom::IntRect big_rect; GTimeVal start_time; int max_pixels; Geom::Point mouse_loc; @@ -1747,7 +1739,7 @@ struct PaintRectSetup { * @return true if the drawing completes */ static int -sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) +sp_canvas_paint_rect_internal (PaintRectSetup const *setup, Geom::IntRect const &this_rect) { GTimeVal now; g_get_current_time (&now); @@ -1782,8 +1774,8 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) } // Find the optimal buffer dimensions - int bw = this_rect.x1 - this_rect.x0; - int bh = this_rect.y1 - this_rect.y0; + int bw = this_rect.width(); + int bh = this_rect.height(); if ((bw < 1) || (bh < 1)) return 0; @@ -1799,16 +1791,12 @@ sp_canvas_paint_rect_internal (PaintRectSetup const *setup, NRRectL this_rect) gdk_window_begin_paint_rect(window, &r);*/ sp_canvas_paint_single_buffer (setup->canvas, - this_rect.x0, this_rect.y0, - this_rect.x1, this_rect.y1, - setup->big_rect.x0, setup->big_rect.y0, - setup->big_rect.x1, setup->big_rect.y1, bw); + this_rect, setup->big_rect, bw); //gdk_window_end_paint(window); return 1; } - NRRectL lo = this_rect; - NRRectL hi = this_rect; + Geom::IntRect lo, hi; /* This test determines the redraw strategy: @@ -1826,13 +1814,12 @@ faster. The default for now is the strips mode. */ if (bw < bh || bh < 2 * TILE_SIZE) { - // to correctly calculate the mean of two ints, we need to sum them into a larger int type - int mid = ((long long) this_rect.x0 + (long long) this_rect.x1) / 2; + int mid = this_rect[Geom::X].middle(); // Make sure that mid lies on a tile boundary mid = (mid / TILE_SIZE) * TILE_SIZE; - lo.x1 = mid; - hi.x0 = mid; + lo = Geom::IntRect(this_rect.left(), this_rect.top(), mid, this_rect.bottom()); + hi = Geom::IntRect(mid, this_rect.top(), this_rect.right(), this_rect.bottom()); if (setup->mouse_loc[Geom::X] < mid) { // Always paint towards the mouse first @@ -1843,13 +1830,12 @@ The default for now is the strips mode. && sp_canvas_paint_rect_internal(setup, lo); } } else { - // to correctly calculate the mean of two ints, we need to sum them into a larger int type - int mid = ((long long) this_rect.y0 + (long long) this_rect.y1) / 2; + int mid = this_rect[Geom::Y].middle(); // Make sure that mid lies on a tile boundary mid = (mid / TILE_SIZE) * TILE_SIZE; - lo.y1 = mid; - hi.y0 = mid; + lo = Geom::IntRect(this_rect.left(), this_rect.top(), this_rect.right(), mid); + hi = Geom::IntRect(this_rect.left(), mid, this_rect.right(), this_rect.bottom()); if (setup->mouse_loc[Geom::Y] < mid) { // Always paint towards the mouse first @@ -1873,22 +1859,19 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1) { g_return_val_if_fail (!canvas->need_update, false); - NRRectL rect; - rect.x0 = xx0; - rect.x1 = xx1; - rect.y0 = yy0; - rect.y1 = yy1; + Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + GTK_WIDGET (canvas)->allocation.width, GTK_WIDGET (canvas)->allocation.height); + Geom::IntRect paint_rect(xx0, yy0, xx1, yy1); - // Clip rect-to-draw by the current visible area - rect.x0 = MAX (rect.x0, canvas->x0); - rect.y0 = MAX (rect.y0, canvas->y0); - rect.x1 = MIN (rect.x1, canvas->x0/*draw_x1*/ + GTK_WIDGET (canvas)->allocation.width); - rect.y1 = MIN (rect.y1, canvas->y0/*draw_y1*/ + GTK_WIDGET (canvas)->allocation.height); + Geom::OptIntRect area = paint_rect & canvas_rect; + if (!area || area->hasZeroArea()) return 0; + + paint_rect = *area; PaintRectSetup setup; setup.canvas = canvas; - setup.big_rect = rect; + setup.big_rect = paint_rect; // Save the mouse location gint x, y; @@ -1909,7 +1892,7 @@ sp_canvas_paint_rect (SPCanvas *canvas, int xx0, int yy0, int xx1, int yy1) g_get_current_time(&(setup.start_time)); // Go - return sp_canvas_paint_rect_internal(&setup, rect); + return sp_canvas_paint_rect_internal(&setup, paint_rect); } /** @@ -1950,14 +1933,11 @@ sp_canvas_expose (GtkWidget *widget, GdkEventExpose *event) gdk_region_get_rectangles (event->region, &rects, &n_rects); for (int i = 0; i < n_rects; i++) { - NRRectL rect; - - rect.x0 = rects[i].x + canvas->x0; - rect.y0 = rects[i].y + canvas->y0; - rect.x1 = rect.x0 + rects[i].width; - rect.y1 = rect.y0 + rects[i].height; + Geom::IntRect r = Geom::IntRect::from_xywh( + rects[i].x + canvas->x0, rects[i].y + canvas->y0, + rects[i].width, rects[i].height); - sp_canvas_request_redraw (canvas, rect.x0, rect.y0, rect.x1, rect.y1); + sp_canvas_request_redraw (canvas, r.left(), r.top(), r.right(), r.bottom()); } if (n_rects > 0) @@ -2225,30 +2205,21 @@ sp_canvas_request_update (SPCanvas *canvas) void sp_canvas_request_redraw (SPCanvas *canvas, int x0, int y0, int x1, int y1) { - NRRectL bbox; - NRRectL visible; - NRRectL clip; - g_return_if_fail (canvas != NULL); g_return_if_fail (SP_IS_CANVAS (canvas)); if (!gtk_widget_is_drawable ( GTK_WIDGET (canvas))) return; if ((x0 >= x1) || (y0 >= y1)) return; - bbox.x0 = x0; - bbox.y0 = y0; - bbox.x1 = x1; - bbox.y1 = y1; - - visible.x0 = canvas->x0; - visible.y0 = canvas->y0; - visible.x1 = visible.x0 + GTK_WIDGET (canvas)->allocation.width; - visible.y1 = visible.y0 + GTK_WIDGET (canvas)->allocation.height; - - nr_rect_l_intersect (&clip, &bbox, &visible); - - sp_canvas_dirty_rect(canvas, clip.x0, clip.y0, clip.x1, clip.y1); - add_idle (canvas); + Geom::IntRect bbox(x0, y0, x1, y1); + Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(canvas->x0, canvas->y0, + GTK_WIDGET (canvas)->allocation.width, GTK_WIDGET (canvas)->allocation.height); + + Geom::OptIntRect clip = bbox & canvas_rect; + if (clip) { + sp_canvas_dirty_rect(canvas, *clip); + add_idle (canvas); + } } /** @@ -2386,24 +2357,21 @@ static void sp_canvas_resize_tiles(SPCanvas* canvas, int nl, int nt, int nr, int /* * Helper that queues a canvas rectangle for redraw */ -static void sp_canvas_dirty_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb) { +static void sp_canvas_dirty_rect(SPCanvas* canvas, Geom::IntRect const &area) { canvas->need_redraw = TRUE; - sp_canvas_mark_rect(canvas, nl, nt, nr, nb, 1); + sp_canvas_mark_rect(canvas, area, 1); } /** * Helper that marks specific canvas rectangle as clean (val == 0) or dirty (otherwise) */ -void sp_canvas_mark_rect(SPCanvas* canvas, int nl, int nt, int nr, int nb, uint8_t val) +void sp_canvas_mark_rect(SPCanvas* canvas, Geom::IntRect const &area, uint8_t val) { - if ( nl >= nr || nt >= nb ) { - return; - } - int tl=sp_canvas_tile_floor(nl); - int tt=sp_canvas_tile_floor(nt); - int tr=sp_canvas_tile_ceil(nr); - int tb=sp_canvas_tile_ceil(nb); + int tl=sp_canvas_tile_floor(area.left()); + int tt=sp_canvas_tile_floor(area.top()); + int tr=sp_canvas_tile_ceil(area.right()); + int tb=sp_canvas_tile_ceil(area.bottom()); if ( tl >= canvas->tRight || tr <= canvas->tLeft || tt >= canvas->tBottom || tb <= canvas->tTop ) return; if ( tl < canvas->tLeft ) tl=canvas->tLeft; if ( tr > canvas->tRight ) tr=canvas->tRight; -- cgit v1.2.3 From 3eeddc1ea8ac49828c23e7406bf52b8f7e0c7812 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 15 Sep 2011 20:21:22 +0200 Subject: Fix typo that causes crashes when color management is enabled. (bzr r10628) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index a4c8500ed..e6f973faf 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1701,7 +1701,7 @@ static void sp_canvas_paint_single_buffer(SPCanvas *canvas, Geom::IntRect const int stride = cairo_image_surface_get_stride(imgs); for (int i=0; i Date: Tue, 4 Oct 2011 12:04:58 -0700 Subject: Cleaned up display-forward.h, including many redundant usages. (bzr r10666) --- src/display/sp-canvas.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index e6f973faf..9e942ec35 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -23,7 +23,6 @@ #include "helper/sp-marshal.h" #include -#include "display-forward.h" #include <2geom/affine.h> #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" -- cgit v1.2.3 From 2633767789e4264b13ef91a684accf734fb4e94f Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Wed, 26 Oct 2011 21:55:51 -0700 Subject: Fixing more broken and split doc comments. (bzr r10697) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 9e942ec35..8aa3b2a6d 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1,4 +1,4 @@ -/** \file +/* * Port of GnomeCanvas for Inkscape needs * * Authors: -- cgit v1.2.3 From 9584665e133abbdbf213c8caa7da668d7afd290c Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 14 Dec 2011 13:55:18 +0000 Subject: Get rid of deprecated gtk_type_is_a (bzr r10772) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 8aa3b2a6d..d00ba38ef 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -172,7 +172,7 @@ sp_canvas_item_new (SPCanvasGroup *parent, GType type, gchar const *first_arg_na g_return_val_if_fail (parent != NULL, NULL); g_return_val_if_fail (SP_IS_CANVAS_GROUP (parent), NULL); - g_return_val_if_fail (gtk_type_is_a (type, sp_canvas_item_get_type ()), NULL); + g_return_val_if_fail (g_type_is_a (type, sp_canvas_item_get_type ()), NULL); SPCanvasItem *item = SP_CANVAS_ITEM (g_object_new (type, NULL)); -- cgit v1.2.3 From cf6be892c0250b2a21faf3224a54df100bb9c7b5 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Wed, 14 Dec 2011 14:00:58 +0000 Subject: Get rid of deprecated gtk_idle* (bzr r10773) --- src/display/sp-canvas.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index d00ba38ef..add69401b 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1073,7 +1073,7 @@ static void remove_idle (SPCanvas *canvas) { if (canvas->idle_id) { - gtk_idle_remove (canvas->idle_id); + g_source_remove (canvas->idle_id); canvas->idle_id = 0; } } @@ -2118,7 +2118,8 @@ add_idle (SPCanvas *canvas) if (canvas->idle_id != 0) return; - canvas->idle_id = gtk_idle_add_priority (sp_canvas_update_priority, idle_handler, canvas); + canvas->idle_id = g_idle_add_full (sp_canvas_update_priority, idle_handler, + canvas, NULL); } /** -- cgit v1.2.3