From 49a7927ecf31ace696e9e5770e8d6543c356db7a Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 28 Jul 2016 19:15:34 +0100 Subject: Finish removing GTK+ 2 fallbacks (bzr r15023.2.8) --- src/display/sp-canvas.cpp | 100 +++++----------------------------------------- 1 file changed, 10 insertions(+), 90 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 7d76fa043..9201168ef 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -322,13 +322,9 @@ void sp_canvas_item_dispose(GObject *object) if (item == item->canvas->_grabbed_item) { item->canvas->_grabbed_item = NULL; -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_device_ungrab(device, GDK_CURRENT_TIME); -#else - gdk_pointer_ungrab (GDK_CURRENT_TIME); -#endif } if (item == item->canvas->_focused_item) { @@ -617,9 +613,8 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, // fixme: Top hack (Lauris) // fixme: If we add key masks to event mask, Gdk will abort (Lauris) // fixme: But Canvas actualle does get key events, so all we need is routing these here -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_device_grab(device, getWindow(item->canvas), GDK_OWNERSHIP_NONE, @@ -627,11 +622,6 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, (GdkEventMask)(event_mask & (~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))), cursor, etime); -#else - gdk_pointer_grab( getWindow(item->canvas), FALSE, - (GdkEventMask)(event_mask & (~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))), - NULL, cursor, etime); -#endif item->canvas->_grabbed_item = item; item->canvas->_grabbed_event_mask = event_mask; @@ -658,13 +648,9 @@ void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime) item->canvas->_grabbed_item = NULL; -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_device_ungrab(device, etime); -#else - gdk_pointer_ungrab (etime); -#endif } /** @@ -913,16 +899,9 @@ void sp_canvas_class_init(SPCanvasClass *klass) widget_class->realize = SPCanvas::handle_realize; widget_class->unrealize = SPCanvas::handle_unrealize; - -#if GTK_CHECK_VERSION(3,0,0) widget_class->get_preferred_width = SPCanvas::handle_get_preferred_width; widget_class->get_preferred_height = SPCanvas::handle_get_preferred_height; widget_class->draw = SPCanvas::handle_draw; -#else - widget_class->size_request = SPCanvas::handle_size_request; - widget_class->expose_event = SPCanvas::handle_expose; -#endif - widget_class->size_allocate = SPCanvas::handle_size_allocate; widget_class->button_press_event = SPCanvas::handle_button; widget_class->button_release_event = SPCanvas::handle_button; @@ -980,13 +959,9 @@ void SPCanvas::shutdownTransients() if (_grabbed_item) { _grabbed_item = NULL; -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_device_ungrab(device, GDK_CURRENT_TIME); -#else - gdk_pointer_ungrab(GDK_CURRENT_TIME); -#endif } removeIdle(); } @@ -1053,10 +1028,6 @@ void SPCanvas::handle_realize(GtkWidget *widget) attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gdk_visual_get_system(); -#if !GTK_CHECK_VERSION(3,0,0) - attributes.colormap = gdk_colormap_get_system(); -#endif - attributes.event_mask = (gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | @@ -1073,11 +1044,7 @@ void SPCanvas::handle_realize(GtkWidget *widget) GDK_SCROLL_MASK | GDK_FOCUS_CHANGE_MASK); -#if GTK_CHECK_VERSION(3,0,0) gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; -#else - gint attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; -#endif GdkWindow *window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gtk_widget_set_window (widget, window); @@ -1086,18 +1053,8 @@ void SPCanvas::handle_realize(GtkWidget *widget) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/options/useextinput/value", true)) { gtk_widget_set_events(widget, attributes.event_mask); -#if !GTK_CHECK_VERSION(3,0,0) - gtk_widget_set_extension_events(widget, GDK_EXTENSION_EVENTS_ALL); - // TODO: Extension event stuff has been deprecated in GTK+ 3 -#endif } -#if !GTK_CHECK_VERSION(3,0,0) - // This does nothing in GTK+ 3 - GtkStyle *style = gtk_widget_get_style (widget); - gtk_widget_set_style (widget, gtk_style_attach (style, window)); -#endif - gtk_widget_set_realized (widget, TRUE); } @@ -1115,8 +1072,6 @@ void SPCanvas::handle_unrealize(GtkWidget *widget) (* GTK_WIDGET_CLASS(sp_canvas_parent_class)->unrealize)(widget); } - -#if GTK_CHECK_VERSION(3,0,0) void SPCanvas::handle_get_preferred_width(GtkWidget *widget, gint *minimum_width, gint *natural_width) { static_cast(SP_CANVAS (widget)); @@ -1130,16 +1085,6 @@ void SPCanvas::handle_get_preferred_height(GtkWidget *widget, gint *minimum_heig *minimum_height = 256; *natural_height = 256; } -#else -void SPCanvas::handle_size_request(GtkWidget *widget, GtkRequisition *req) -{ - static_cast(SP_CANVAS (widget)); - - req->width = 256; - req->height = 256; -} -#endif - void SPCanvas::handle_size_allocate(GtkWidget *widget, GtkAllocation *allocation) { @@ -1219,9 +1164,7 @@ int SPCanvas::emitEvent(GdkEvent *event) break; case GDK_SCROLL: mask = GDK_SCROLL_MASK; -#if GTK_CHECK_VERSION(3,0,0) mask |= GDK_SMOOTH_SCROLL_MASK; -#endif break; default: mask = 0; @@ -1503,13 +1446,9 @@ gint SPCanvas::handle_scroll(GtkWidget *widget, GdkEventScroll *event) } static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { -#if GTK_CHECK_VERSION(3,0,0) gdk_window_get_device_position(w, gdk_event_get_device((GdkEvent *)(event)), NULL, NULL, NULL); -#else - gdk_window_get_pointer(w, NULL, NULL, NULL); -#endif gdk_event_request_motions(event); } @@ -1746,16 +1685,12 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) // Save the mouse location gint x, y; -#if GTK_CHECK_VERSION(3,0,0) - GdkDeviceManager *dm = gdk_display_get_device_manager(gdk_display_get_default()); - GdkDevice *device = gdk_device_manager_get_client_pointer(dm); + auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + auto device = gdk_device_manager_get_client_pointer(dm); gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(this)), device, &x, &y, NULL); -#else - gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(this)), &x, &y, NULL); -#endif setup.mouse_loc = sp_canvas_window_to_world(this, Geom::Point(x,y)); @@ -1818,21 +1753,6 @@ gboolean SPCanvas::handle_draw(GtkWidget *widget, cairo_t *cr) { return TRUE; } -#if !GTK_CHECK_VERSION(3,0,0) -gboolean SPCanvas::handle_expose(GtkWidget *widget, GdkEventExpose *event) -{ - cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(widget)); - - gdk_cairo_region (cr, event->region); - cairo_clip (cr); - gboolean result = SPCanvas::handle_draw(widget, cr); - - cairo_destroy (cr); - - return result; -} -#endif - gint SPCanvas::handle_key_event(GtkWidget *widget, GdkEventKey *event) { -- cgit v1.2.3 From f2d2c7740567dcf2452c41d8332380708f557157 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 19 Oct 2016 12:50:29 +0200 Subject: Working with rotate preview (bzr r15142.1.15) --- src/display/sp-canvas.cpp | 169 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 166 insertions(+), 3 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 9201168ef..36d0b7e7c 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -27,15 +27,19 @@ #include "helper/sp-marshal.h" #include <2geom/rect.h> #include <2geom/affine.h> -#include "display/cairo-utils.h" #include "display/sp-canvas.h" #include "display/sp-canvas-group.h" +#include "display/rendermode.h" +#include "display/cairo-utils.h" +#include "display/cairo-templates.h" +#include "display/drawing-context.h" +#include "display/drawing-item.h" +#include "display/nr-filter-colormatrix.h" +#include "display/canvas-arena.h" #include "preferences.h" #include "inkscape.h" #include "sodipodi-ctrlrect.h" #include "cms-system.h" -#include "display/rendermode.h" -#include "display/cairo-utils.h" #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" #include "color.h" @@ -1945,6 +1949,165 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll } addIdle(); } +gdouble grayscale_value_matrix[20] = { + 0.21, 0.72, 0.072, 0, 0, + 0.21, 0.72, 0.072, 0, 0, + 0.21, 0.72, 0.072, 0, 0, + 0 , 0 , 0 , 1, 0 + }; +cairo_surface_t *surface_rotated; +cairo_surface_t *surface_origin; +cairo_surface_t *surface_measure; +double start_angle = 0; +bool started = false; +void SPCanvas::startRotateTo(double angle) +{ + if (!_backing_store || started) { + return; + } + start_angle = angle; + started = true; + GtkAllocation allocation; + gtk_widget_get_allocation(&_widget, &allocation); + int half_w = allocation.width/2; + int half_h = allocation.height/2; + int half_min = std::min(half_w,half_h); + cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); + cairo_t *cr = cairo_create(new_backing_store); + cairo_arc(cr, half_w, half_h, half_min-15, 0, 2*M_PI); + cairo_fill(cr); + cairo_set_operator(cr, CAIRO_OPERATOR_IN); + cairo_set_source_surface(cr, _backing_store, 0, 0); + cairo_paint(cr); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + cairo_arc(cr, half_w, half_h, half_min-16, 0, 2*M_PI); + cairo_set_source_rgba (cr, 1, 1, 1, 0.5); + cairo_stroke(cr); + cairo_destroy(cr); + surface_rotated = new_backing_store; + + cairo_surface_t *new_backing_store_measure = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); + cr = cairo_create(new_backing_store_measure); + cairo_arc(cr, half_w, half_h, half_min-15, 0, 2*M_PI); + cairo_set_source_rgba (cr, 1, 1, 1, 0.2); + cairo_fill(cr); + cairo_translate(cr, half_w, half_h); + for (gint x = 0; x < 360 ; x++){ + gint ang = 360 - x ;//+ 90; + if (ang > 180) { + ang -= 360; + } + double rot = (-180.0 + x - start_angle)*(M_PI/180.); + double dist = half_min-9; + gint inverse = 1; + if((x- start_angle) < 91 || (x- start_angle) > 270) { + inverse = -1; + } + if(x%10 == 0) { + cairo_rotate(cr, -rot); + cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size(cr, 10.0); + cairo_text_extents_t extents; + std::string s = std::to_string(ang) + "º"; + cairo_text_extents(cr, s.c_str(), &extents); + //std::cout << extents.width/2 << "extents.x_bearing\n"; + cairo_translate(cr, (extents.width/2) * inverse * -1, (dist + ((extents.height/2)* inverse))); + if((x- start_angle) < 91 || (x- start_angle) > 270) { + cairo_rotate(cr, 180*(M_PI/180.0)); + } + cairo_text_path(cr, s.c_str()); + if((x- start_angle) < 91 || (x- start_angle) > 270) { + cairo_rotate(cr, -180*(M_PI/180.0)); + } + cairo_translate(cr, (extents.width/2) * inverse , (dist + ((extents.height/2)* inverse)) * -1); + cairo_set_source_rgba (cr, 1, 1, 1, 1); + cairo_fill(cr); + cairo_rotate(cr, rot); + } + cairo_rotate(cr, x*(M_PI/180.)); + if(x%5 == 0) { + cairo_move_to(cr, 0, half_min-30); + cairo_line_to(cr, 0, half_min-17); + } else { + cairo_move_to(cr, 0, half_min-20); + cairo_line_to(cr, 0, half_min-15); + } + cairo_line_to(cr, 0, half_min-15); + cairo_set_source_rgba (cr, 0, 0, 0, 0.4); + cairo_set_line_width (cr,1); + cairo_stroke(cr); + cairo_rotate(cr, -x*(M_PI/180.)); + } + cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); + cairo_translate(cr, -half_w, -half_h); + cairo_arc(cr, half_w, half_h, half_min-30, 0, 2*M_PI); + cairo_set_source_rgba (cr, 1, 1, 1, 1); + cairo_fill(cr); + cairo_destroy(cr); + surface_measure = new_backing_store_measure; + + cairo_surface_t *new_backing_store_grey = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); + cr = cairo_create(new_backing_store_grey); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + cairo_set_source_surface(cr, _backing_store, 0, 0); + cairo_paint(cr); + Inkscape::Filters::FilterColorMatrix::ColorMatrixMatrix _grayscale_colormatrix = std::vector (grayscale_value_matrix, grayscale_value_matrix + 20); + cairo_surface_t *out = ink_cairo_surface_create_identical(new_backing_store_grey); + ink_cairo_surface_filter(new_backing_store_grey, out, _grayscale_colormatrix); + cairo_set_source_surface(cr, out, 0, 0); + cairo_surface_destroy(out); + cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); + cairo_paint(cr); + cairo_destroy(cr); + surface_origin = new_backing_store_grey; + +} + +void SPCanvas::endRotateTo() +{ + if (!_backing_store) { + return; + } + started = false; + surface_rotated = NULL; + surface_origin = NULL; + gtk_widget_queue_draw(GTK_WIDGET(this)); + dirtyAll(); + addIdle(); +} + +void SPCanvas::rotateTo(SPCanvasItem * item, double angle) +{ + if (!_backing_store) { + return; + } + GtkAllocation allocation; + gtk_widget_get_allocation(&_widget, &allocation); + cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); + cairo_t *cr = cairo_create(new_backing_store); + cairo_set_source_surface(cr, surface_origin, 0, 0); + cairo_paint(cr); + cairo_set_source_rgba (cr, 0, 0, 0, 0.5); + cairo_paint(cr); + cairo_pattern_t *source_pattern; + cairo_matrix_t matrix; + source_pattern = cairo_pattern_create_for_surface (surface_rotated); + cairo_matrix_init_identity (&matrix); + cairo_matrix_translate (&matrix, allocation.width/2.0, allocation.height/2.0); + cairo_matrix_rotate (&matrix, Geom::rad_from_deg(angle - start_angle) * -1); + cairo_matrix_translate (&matrix, -allocation.width/2.0, -allocation.height/2.0); + cairo_pattern_set_matrix (source_pattern, &matrix); + cairo_set_source(cr, source_pattern); + cairo_paint(cr); + cairo_set_source_surface(cr, surface_measure, 0, 0); + cairo_paint(cr); + cairo_destroy(cr); + cairo_surface_destroy(_backing_store); + _backing_store = new_backing_store; + cairo_pattern_destroy (source_pattern); + gtk_widget_queue_draw(GTK_WIDGET(this)); + addIdle(); +} void SPCanvas::updateNow() { -- cgit v1.2.3 From ab9795b860412f259eecc095225893b9b130bc42 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 19 Oct 2016 22:02:50 +0200 Subject: Styling rotate (bzr r15142.1.17) --- src/display/sp-canvas.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 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 36d0b7e7c..ae20cd92d 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1997,10 +1997,10 @@ void SPCanvas::startRotateTo(double angle) if (ang > 180) { ang -= 360; } - double rot = (-180.0 + x - start_angle)*(M_PI/180.); + double rot = (-180.0 + x)*(M_PI/180.); double dist = half_min-9; gint inverse = 1; - if((x- start_angle) < 91 || (x- start_angle) > 270) { + if((x) < 91 || (x) > 270) { inverse = -1; } if(x%10 == 0) { @@ -2012,11 +2012,11 @@ void SPCanvas::startRotateTo(double angle) cairo_text_extents(cr, s.c_str(), &extents); //std::cout << extents.width/2 << "extents.x_bearing\n"; cairo_translate(cr, (extents.width/2) * inverse * -1, (dist + ((extents.height/2)* inverse))); - if((x- start_angle) < 91 || (x- start_angle) > 270) { + if((x) < 91 || (x) > 270) { cairo_rotate(cr, 180*(M_PI/180.0)); } cairo_text_path(cr, s.c_str()); - if((x- start_angle) < 91 || (x- start_angle) > 270) { + if((x) < 91 || (x) > 270) { cairo_rotate(cr, -180*(M_PI/180.0)); } cairo_translate(cr, (extents.width/2) * inverse , (dist + ((extents.height/2)* inverse)) * -1); @@ -2043,6 +2043,21 @@ void SPCanvas::startRotateTo(double angle) cairo_arc(cr, half_w, half_h, half_min-30, 0, 2*M_PI); cairo_set_source_rgba (cr, 1, 1, 1, 1); cairo_fill(cr); + cairo_translate(cr, half_w, half_h); + cairo_set_operator(cr, CAIRO_OPERATOR_OVER); + cairo_rotate(cr, start_angle*(M_PI/180.)); + cairo_move_to(cr, 0, 0); + cairo_line_to(cr, 0, (half_min-17) * -1); + cairo_set_source_rgba (cr, 1, 1, 1, 0.25); + cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); + cairo_set_line_width (cr,5); + cairo_stroke(cr); + cairo_move_to(cr, 0, 0); + cairo_line_to(cr, 0, (half_min-17) * -1); + cairo_set_source_rgba (cr, 1, 0, 0, 0.9); + cairo_set_line_width (cr,1); + cairo_stroke(cr); + cairo_rotate(cr, -start_angle*(M_PI/180.)); cairo_destroy(cr); surface_measure = new_backing_store_measure; @@ -2083,6 +2098,9 @@ void SPCanvas::rotateTo(SPCanvasItem * item, double angle) } GtkAllocation allocation; gtk_widget_get_allocation(&_widget, &allocation); + int half_w = allocation.width/2; + int half_h = allocation.height/2; + int half_min = std::min(half_w,half_h); cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); cairo_t *cr = cairo_create(new_backing_store); cairo_set_source_surface(cr, surface_origin, 0, 0); @@ -2101,6 +2119,33 @@ void SPCanvas::rotateTo(SPCanvasItem * item, double angle) cairo_paint(cr); cairo_set_source_surface(cr, surface_measure, 0, 0); cairo_paint(cr); + cairo_translate(cr, half_w, half_h); + cairo_rotate(cr, angle*(M_PI/180.)); + cairo_move_to(cr, 0, 0); + cairo_line_to(cr, 0, (half_min-17) * -1); + cairo_set_source_rgba (cr, 1, 1, 1, 0.25); + cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); + cairo_set_line_width (cr,5); + cairo_stroke(cr); + cairo_move_to(cr, 0, 0); + cairo_line_to(cr, 0, (half_min-17) * -1); + cairo_set_source_rgba (cr, 1, 1, 1, 0.9); + cairo_set_line_width (cr,1); + cairo_stroke(cr); + cairo_move_to(cr, 0, 0); + cairo_line_to(cr, 0, (half_min-17) * -1); + cairo_set_source_rgba (cr, 1, 0, 0, 0.9); + const double dashed[] = {6.0, 3.0}; + int len = sizeof(dashed) / sizeof(dashed[0]); + cairo_set_dash(cr, dashed, len, 1); + cairo_stroke(cr); + cairo_translate(cr, -half_w, -half_h); + cairo_set_source_rgba (cr, 1, 1, 1, 0.25); + cairo_arc(cr, half_w, half_h, 7, 0, 2*M_PI); + cairo_fill(cr); + cairo_set_source_rgba (cr, 1, 0, 0, 0.7); + cairo_arc(cr, half_w, half_h, 5, 0, 2*M_PI); + cairo_fill(cr); cairo_destroy(cr); cairo_surface_destroy(_backing_store); _backing_store = new_backing_store; -- cgit v1.2.3 From 50c101849a9f591972b5478a7a83407558e7bff7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 23 Oct 2016 11:03:35 +0200 Subject: Add right click attempt (bzr r15142.1.20) --- src/display/sp-canvas.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 63 insertions(+), 5 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index ae20cd92d..745896dd7 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -43,6 +43,8 @@ #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" #include "color.h" +#include +#include using Inkscape::Debug::GdkEventLatencyTracker; @@ -1992,6 +1994,8 @@ void SPCanvas::startRotateTo(double angle) cairo_set_source_rgba (cr, 1, 1, 1, 0.2); cairo_fill(cr); cairo_translate(cr, half_w, half_h); + cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size(cr, 10.0); for (gint x = 0; x < 360 ; x++){ gint ang = 360 - x ;//+ 90; if (ang > 180) { @@ -2005,8 +2009,6 @@ void SPCanvas::startRotateTo(double angle) } if(x%10 == 0) { cairo_rotate(cr, -rot); - cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); - cairo_set_font_size(cr, 10.0); cairo_text_extents_t extents; std::string s = std::to_string(ang) + "º"; cairo_text_extents(cr, s.c_str(), &extents); @@ -2075,7 +2077,9 @@ void SPCanvas::startRotateTo(double angle) cairo_paint(cr); cairo_destroy(cr); surface_origin = new_backing_store_grey; - + gtk_widget_queue_draw(GTK_WIDGET(this)); + dirtyAll(); + addIdle(); } void SPCanvas::endRotateTo() @@ -2091,9 +2095,9 @@ void SPCanvas::endRotateTo() addIdle(); } -void SPCanvas::rotateTo(SPCanvasItem * item, double angle) +void SPCanvas::rotateTo(SPCanvasItem * item, double angle, bool widget) { - if (!_backing_store) { + if (!_backing_store || !started) { return; } GtkAllocation allocation; @@ -2146,6 +2150,60 @@ void SPCanvas::rotateTo(SPCanvasItem * item, double angle) cairo_set_source_rgba (cr, 1, 0, 0, 0.7); cairo_arc(cr, half_w, half_h, 5, 0, 2*M_PI); cairo_fill(cr); + cairo_translate(cr, half_w, half_h); + cairo_rotate(cr, -angle*(M_PI/180.)); + if (!widget) { + cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size(cr, 15.0); + cairo_text_extents_t extents; + std::ostringstream s; + s << _("Original angle ") << std::fixed << std::setprecision(2) << start_angle << "º"; + cairo_text_extents(cr, s.str().c_str(), &extents); + cairo_translate(cr, half_w - extents.width -15 ,-half_h + 25); + cairo_set_source_rgba (cr, 1, 1, 1, 1); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 25) *-1); + s.str(""); + s << _("New angle ") << std::fixed << std::setprecision(2) << angle << "º"; + cairo_text_extents(cr, s.str().c_str(), &extents); + cairo_translate(cr, half_w - extents.width -15 ,-half_h + 45); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 45) *-1); + s.str(""); + s << _("Gap ") << std::fixed << std::setprecision(2) << std::abs(start_angle-angle) << "º"; + cairo_text_extents(cr, s.str().c_str(), &extents); + cairo_translate(cr, half_w - extents.width -15 ,-half_h + 65); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 65) *-1); + cairo_translate(cr, -half_w + 10 ,-half_h + 25); + s.str(""); + cairo_set_font_size(cr, 12.0); + s << _("Normal mode, 1º round step"); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (-half_w +10) * -1 ,(-half_h + 25) * -1); + cairo_translate(cr, -half_w + 10 ,-half_h + 40); + s.str(""); + s << _("+CTRL, Fractional degrees"); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 40) * -1); + cairo_translate(cr, -half_w + 10 ,-half_h + 55); + s.str(""); + s << _("+SHIFT, 5º round step"); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 55) * -1); + cairo_translate(cr, -half_w + 10 ,-half_h + 70); + s.str(""); + s << _("+ALT, Reset"); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + //cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 60) * -1); + } cairo_destroy(cr); cairo_surface_destroy(_backing_store); _backing_store = new_backing_store; -- cgit v1.2.3 From 74edf9fcbc3106cccddb2a293275748fefa08f0b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 23 Oct 2016 20:04:23 +0200 Subject: Add right click rotation panning (bzr r15142.1.22) --- src/display/sp-canvas.cpp | 19 +++++++++++-------- 1 file changed, 11 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 2f6caadd3..115b8c613 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -2077,31 +2077,33 @@ void SPCanvas::startRotateTo(double angle) cairo_paint(cr); cairo_destroy(cr); surface_origin = new_backing_store_grey; - clearRotateTo(true); + gtk_widget_queue_draw(GTK_WIDGET(this)); + dirtyAll(); + addIdle(); } bool SPCanvas::endRotateTo() { - if (!started) { + if (!_backing_store || !started) { return false; } started = false; surface_rotated = NULL; surface_origin = NULL; - clearRotateTo(true); + gtk_widget_queue_draw(GTK_WIDGET(this)); + dirtyAll(); + addIdle(); return true; } -void SPCanvas::clearRotateTo(bool clear) +void SPCanvas::clearRotateTo() { if (!started) { return; } gtk_widget_queue_draw(GTK_WIDGET(this)); dirtyAll(); - if (clear) { - addIdle(); - } + addIdle(); } void SPCanvas::rotateTo(SPCanvasItem * item, double angle, bool widget) @@ -2217,7 +2219,8 @@ void SPCanvas::rotateTo(SPCanvasItem * item, double angle, bool widget) cairo_surface_destroy(_backing_store); _backing_store = new_backing_store; cairo_pattern_destroy (source_pattern); - clearRotateTo(false); + gtk_widget_queue_draw(GTK_WIDGET(this)); + addIdle(); } void SPCanvas::updateNow() -- cgit v1.2.3 From b65d3fdc9c15af81c5e433d8f1b714ef4ab61487 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 23 Oct 2016 21:18:11 +0200 Subject: Add right click rotation panning, some fixes (bzr r15142.1.23) --- src/display/sp-canvas.cpp | 113 ++++++++++++++++++++++++---------------------- 1 file changed, 60 insertions(+), 53 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 115b8c613..242a30248 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -2101,12 +2101,21 @@ void SPCanvas::clearRotateTo() if (!started) { return; } + GtkAllocation allocation; + gtk_widget_get_allocation(&_widget, &allocation); + cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); + cairo_t *cr = cairo_create(new_backing_store); + cairo_set_source(cr, _background); + cairo_paint(cr); + cairo_destroy(cr); + cairo_surface_destroy(_backing_store); + _backing_store = new_backing_store; gtk_widget_queue_draw(GTK_WIDGET(this)); dirtyAll(); addIdle(); } -void SPCanvas::rotateTo(SPCanvasItem * item, double angle, bool widget) +void SPCanvas::rotateTo(SPCanvasItem * item, double angle) { if (!_backing_store || !started) { return; @@ -2163,58 +2172,56 @@ void SPCanvas::rotateTo(SPCanvasItem * item, double angle, bool widget) cairo_fill(cr); cairo_translate(cr, half_w, half_h); cairo_rotate(cr, -angle*(M_PI/180.)); - if (!widget) { - cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); - cairo_set_font_size(cr, 15.0); - cairo_text_extents_t extents; - std::ostringstream s; - s << _("Original angle ") << std::fixed << std::setprecision(2) << start_angle << "º"; - cairo_text_extents(cr, s.str().c_str(), &extents); - cairo_translate(cr, half_w - extents.width -15 ,-half_h + 25); - cairo_set_source_rgba (cr, 1, 1, 1, 1); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 25) *-1); - s.str(""); - s << _("New angle ") << std::fixed << std::setprecision(2) << angle << "º"; - cairo_text_extents(cr, s.str().c_str(), &extents); - cairo_translate(cr, half_w - extents.width -15 ,-half_h + 45); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 45) *-1); - s.str(""); - s << _("Gap ") << std::fixed << std::setprecision(2) << std::abs(start_angle-angle) << "º"; - cairo_text_extents(cr, s.str().c_str(), &extents); - cairo_translate(cr, half_w - extents.width -15 ,-half_h + 65); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 65) *-1); - cairo_translate(cr, -half_w + 10 ,-half_h + 25); - s.str(""); - cairo_set_font_size(cr, 12.0); - s << _("Normal mode, 1º round step"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (-half_w +10) * -1 ,(-half_h + 25) * -1); - cairo_translate(cr, -half_w + 10 ,-half_h + 40); - s.str(""); - s << _("+CTRL, Fractional degrees"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 40) * -1); - cairo_translate(cr, -half_w + 10 ,-half_h + 55); - s.str(""); - s << _("+SHIFT, 5º round step"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 55) * -1); - cairo_translate(cr, -half_w + 10 ,-half_h + 70); - s.str(""); - s << _("+CTRL+SHIFT, Reset"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - //cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 60) * -1); - } + cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size(cr, 15.0); + cairo_text_extents_t extents; + std::ostringstream s; + s << _("Original angle ") << std::fixed << std::setprecision(2) << start_angle << "º"; + cairo_text_extents(cr, s.str().c_str(), &extents); + cairo_translate(cr, half_w - extents.width -15 ,-half_h + 25); + cairo_set_source_rgba (cr, 1, 1, 1, 1); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 25) *-1); + s.str(""); + s << _("New angle ") << std::fixed << std::setprecision(2) << angle << "º"; + cairo_text_extents(cr, s.str().c_str(), &extents); + cairo_translate(cr, half_w - extents.width -15 ,-half_h + 45); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 45) *-1); + s.str(""); + s << _("Gap ") << std::fixed << std::setprecision(2) << std::abs(start_angle-angle) << "º"; + cairo_text_extents(cr, s.str().c_str(), &extents); + cairo_translate(cr, half_w - extents.width -15 ,-half_h + 65); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 65) *-1); + cairo_translate(cr, -half_w + 10 ,-half_h + 25); + s.str(""); + cairo_set_font_size(cr, 12.0); + s << _("Normal mode, 1º round step"); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (-half_w +10) * -1 ,(-half_h + 25) * -1); + cairo_translate(cr, -half_w + 10 ,-half_h + 40); + s.str(""); + s << _("+CTRL, Fractional degrees"); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 40) * -1); + cairo_translate(cr, -half_w + 10 ,-half_h + 55); + s.str(""); + s << _("+SHIFT, 5º round step"); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 55) * -1); + cairo_translate(cr, -half_w + 10 ,-half_h + 70); + s.str(""); + s << _("+CTRL+SHIFT, Reset"); + cairo_text_path(cr, s.str().c_str()); + cairo_fill(cr); + //cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 60) * -1); cairo_destroy(cr); cairo_surface_destroy(_backing_store); _backing_store = new_backing_store; -- cgit v1.2.3 From 043578ee79ae7dccc1967a9e380d276c9f73ed46 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 25 Oct 2016 23:30:06 +0200 Subject: Some bug fixes and improvements (bzr r15142.1.25) --- src/display/sp-canvas.cpp | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 242a30248..c4d454cb9 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -2077,9 +2077,6 @@ void SPCanvas::startRotateTo(double angle) cairo_paint(cr); cairo_destroy(cr); surface_origin = new_backing_store_grey; - gtk_widget_queue_draw(GTK_WIDGET(this)); - dirtyAll(); - addIdle(); } bool SPCanvas::endRotateTo() @@ -2101,15 +2098,6 @@ void SPCanvas::clearRotateTo() if (!started) { return; } - GtkAllocation allocation; - gtk_widget_get_allocation(&_widget, &allocation); - cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); - cairo_t *cr = cairo_create(new_backing_store); - cairo_set_source(cr, _background); - cairo_paint(cr); - cairo_destroy(cr); - cairo_surface_destroy(_backing_store); - _backing_store = new_backing_store; gtk_widget_queue_draw(GTK_WIDGET(this)); dirtyAll(); addIdle(); -- cgit v1.2.3 From b539e66398261e60f2b9218ff72058e962fe832d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 26 Oct 2016 12:31:09 +0200 Subject: Add fadding from temporary rotate draw to real ones (bzr r15142.1.27) --- src/display/sp-canvas.cpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index c4d454cb9..f168cffe6 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1891,6 +1891,19 @@ SPCanvasGroup *SPCanvas::getRoot() return SP_CANVAS_GROUP(_root); } +gdouble grayscale_value_matrix[20] = { + 0.21, 0.72, 0.072, 0, 0, + 0.21, 0.72, 0.072, 0, 0, + 0.21, 0.72, 0.072, 0, 0, + 0 , 0 , 0 , 1, 0 + }; +cairo_surface_t *surface_rotated; +cairo_surface_t *surface_origin; +cairo_surface_t *surface_measure; +double start_angle = 0; +bool started = false; +bool rotated = false; + void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling) { GtkAllocation allocation; @@ -1913,9 +1926,14 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); // Paint the background cairo_translate(cr, -ix, -iy); + if (rotated) { + cairo_translate(cr, dx, dy); + rotated = false; + } cairo_set_source(cr, _background); cairo_paint(cr); // Copy the old backing store contents + cairo_set_source_surface(cr, _backing_store, _x0, _y0); cairo_rectangle(cr, _x0, _y0, allocation.width, allocation.height); cairo_clip(cr); @@ -1951,17 +1969,7 @@ void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scroll } addIdle(); } -gdouble grayscale_value_matrix[20] = { - 0.21, 0.72, 0.072, 0, 0, - 0.21, 0.72, 0.072, 0, 0, - 0.21, 0.72, 0.072, 0, 0, - 0 , 0 , 0 , 1, 0 - }; -cairo_surface_t *surface_rotated; -cairo_surface_t *surface_origin; -cairo_surface_t *surface_measure; -double start_angle = 0; -bool started = false; + void SPCanvas::startRotateTo(double angle) { if (!_backing_store || started) { @@ -2090,6 +2098,7 @@ bool SPCanvas::endRotateTo() gtk_widget_queue_draw(GTK_WIDGET(this)); dirtyAll(); addIdle(); + rotated = true; return true; } -- cgit v1.2.3 From 126cabd5f87ca04262879584dd4ec1ac923edacd Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 1 Nov 2016 18:01:07 +0100 Subject: Fix angle constrain, thanks to vlada, Mc and LiamW (bzr r15142.1.29) --- 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 e84303816..427cec20a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -2211,7 +2211,7 @@ void SPCanvas::rotateTo(double angle) cairo_translate(cr, -half_w + 10 ,-half_h + 55); s.str(""); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - s << _("+CTRL, ") << prefs->getInt("/options/rotationsnapsperpi/value", 15) << _("º round step"); + s << _("+CTRL, ") << 180.0/prefs->getInt("/options/rotationsnapsperpi/value", 12) << _("º round step"); cairo_text_path(cr, s.str().c_str()); cairo_fill(cr); cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 55) * -1); -- cgit v1.2.3 From 2848c20cfc7f196ba4205cffd2726445485a1df1 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 25 Dec 2016 19:26:50 +0000 Subject: sp-canvas: Gtkmmify to squash a few warnings (bzr r15353) --- src/display/sp-canvas.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 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 9201168ef..416c2c804 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -21,6 +21,8 @@ # include #endif +#include +#include #include #include @@ -61,6 +63,14 @@ struct SPCanvasGroupClass { SPCanvasItemClass parent_class; }; +static void ungrab_default_client_pointer(guint32 const time = GDK_CURRENT_TIME) +{ + auto const display = Gdk::Display::get_default(); + auto const dm = display->get_device_manager(); + auto const device = dm->get_client_pointer(); + device->ungrab(time); +} + /** * A group of items. */ @@ -321,10 +331,7 @@ void sp_canvas_item_dispose(GObject *object) if (item == item->canvas->_grabbed_item) { item->canvas->_grabbed_item = NULL; - - auto dm = gdk_display_get_device_manager(gdk_display_get_default()); - auto device = gdk_device_manager_get_client_pointer(dm); - gdk_device_ungrab(device, GDK_CURRENT_TIME); + ungrab_default_client_pointer(); } if (item == item->canvas->_focused_item) { @@ -647,10 +654,7 @@ void sp_canvas_item_ungrab(SPCanvasItem *item, guint32 etime) } item->canvas->_grabbed_item = NULL; - - auto dm = gdk_display_get_device_manager(gdk_display_get_default()); - auto device = gdk_device_manager_get_client_pointer(dm); - gdk_device_ungrab(device, etime); + ungrab_default_client_pointer(etime); } /** @@ -959,9 +963,7 @@ void SPCanvas::shutdownTransients() if (_grabbed_item) { _grabbed_item = NULL; - auto dm = gdk_display_get_device_manager(gdk_display_get_default()); - auto device = gdk_device_manager_get_client_pointer(dm); - gdk_device_ungrab(device, GDK_CURRENT_TIME); + ungrab_default_client_pointer(); } removeIdle(); } @@ -1685,11 +1687,12 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) // Save the mouse location gint x, y; - auto dm = gdk_display_get_device_manager(gdk_display_get_default()); - auto device = gdk_device_manager_get_client_pointer(dm); + auto const display = Gdk::Display::get_default(); + auto const dm = display->get_device_manager(); + auto const device = dm->get_client_pointer(); gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(this)), - device, + device->gobj(), &x, &y, NULL); setup.mouse_loc = sp_canvas_window_to_world(this, Geom::Point(x,y)); -- cgit v1.2.3 From 58808234db8381a86518229e176f429f440ff93f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 7 Feb 2017 18:34:57 +0000 Subject: Fix some new Gdk deprecations (bzr r15491) --- 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 68eae0a65..41d136ee9 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1034,7 +1034,7 @@ void SPCanvas::handle_realize(GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gdk_visual_get_system(); + attributes.visual = gdk_screen_get_system_visual(gdk_screen_get_default()); attributes.event_mask = (gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK | -- cgit v1.2.3 From 06be77e76584d2a419ce942fd3f6db891f318c7d Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 7 Feb 2017 19:19:46 +0000 Subject: Fix Gdk deprecations (bzr r15492) --- src/display/sp-canvas.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 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 41d136ee9..623e417c6 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -48,6 +48,10 @@ #include #include +#if GTK_CHECK_VERSION(3,20,0) +# include +#endif + using Inkscape::Debug::GdkEventLatencyTracker; // gtk_check_version returns non-NULL on failure @@ -72,8 +76,14 @@ struct SPCanvasGroupClass { static void ungrab_default_client_pointer(guint32 const time = GDK_CURRENT_TIME) { auto const display = Gdk::Display::get_default(); + +#if GTK_CHECK_VERSION(3,20,0) + auto const seat = display->get_default_seat(); + auto const device = seat->get_pointer(); +#else auto const dm = display->get_device_manager(); auto const device = dm->get_client_pointer(); +#endif device->ungrab(time); } @@ -625,9 +635,16 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, // fixme: Top hack (Lauris) // fixme: If we add key masks to event mask, Gdk will abort (Lauris) - // fixme: But Canvas actualle does get key events, so all we need is routing these here - auto dm = gdk_display_get_device_manager(gdk_display_get_default()); + // fixme: But Canvas actually does get key events, so all we need is routing these here + auto display = gdk_display_get_default(); +#if GTK_CHECK_VERSION(3,20,0) + auto seat = gdk_display_get_default_seat(display); + auto device = gdk_seat_get_pointer(seat); +#else + auto dm = gdk_display_get_device_manager(display); auto device = gdk_device_manager_get_client_pointer(dm); +#endif + gdk_device_grab(device, getWindow(item->canvas), GDK_OWNERSHIP_NONE, @@ -1694,8 +1711,14 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) gint x, y; auto const display = Gdk::Display::get_default(); + +#if GTK_CHECK_VERSION(3,20,0) + auto const seat = display->get_default_seat(); + auto const device = seat->get_pointer(); +#else auto const dm = display->get_device_manager(); auto const device = dm->get_client_pointer(); +#endif gdk_window_get_device_position(gtk_widget_get_window(GTK_WIDGET(this)), device->gobj(), -- cgit v1.2.3 From 5d9c07e014cf054a8936478f6d097805cb2a84f6 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 26 Feb 2017 17:58:40 +0000 Subject: sp-canvas: Migrate to seat_grab (bzr r15548) --- src/display/sp-canvas.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 623e417c6..9cc9e51a2 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -78,13 +78,13 @@ static void ungrab_default_client_pointer(guint32 const time = GDK_CURRENT_TIME) auto const display = Gdk::Display::get_default(); #if GTK_CHECK_VERSION(3,20,0) - auto const seat = display->get_default_seat(); - auto const device = seat->get_pointer(); + auto const seat = display->get_default_seat(); + seat->ungrab(); #else auto const dm = display->get_device_manager(); auto const device = dm->get_client_pointer(); -#endif device->ungrab(time); +#endif } /** @@ -639,11 +639,17 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, auto display = gdk_display_get_default(); #if GTK_CHECK_VERSION(3,20,0) auto seat = gdk_display_get_default_seat(display); - auto device = gdk_seat_get_pointer(seat); + gdk_seat_grab(seat, + getWindow(item->canvas), + GDK_SEAT_CAPABILITY_ALL_POINTING, + FALSE, + cursor, + NULL, + NULL, + NULL); #else auto dm = gdk_display_get_device_manager(display); auto device = gdk_device_manager_get_client_pointer(dm); -#endif gdk_device_grab(device, getWindow(item->canvas), @@ -652,6 +658,7 @@ int sp_canvas_item_grab(SPCanvasItem *item, guint event_mask, GdkCursor *cursor, (GdkEventMask)(event_mask & (~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK))), cursor, etime); +#endif item->canvas->_grabbed_item = item; item->canvas->_grabbed_event_mask = event_mask; -- cgit v1.2.3 From 014489163050d8abe9e5c4949fb80f3c21b1c17b Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 13 Mar 2017 15:22:22 +0100 Subject: Replace rectangle based zooming by affine based zooming. This allows a rotation to be included in the drawing to window mapping. General code cleanup. Added documentation. Any change to zooming behavior is probably a bug. (bzr r15592) --- src/display/sp-canvas.cpp | 8 +++++++- 1 file changed, 7 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 9cc9e51a2..61602e880 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1937,10 +1937,16 @@ double start_angle = 0; bool started = false; bool rotated = false; -void SPCanvas::scrollTo(double cx, double cy, unsigned int clear, bool is_scrolling) +/** + * Scroll screen to point 'c'. 'c' is measured in screen pixels. + */ +void SPCanvas::scrollTo( Geom::Point const &c, unsigned int clear, bool is_scrolling) { GtkAllocation allocation; + double cx = c[Geom::X]; + double cy = c[Geom::Y]; + int ix = (int) round(cx); // ix and iy are the new canvas coordinates (integer screen pixels) int iy = (int) round(cy); // cx might be negative, so (int)(cx + 0.5) will not do! int dx = ix - _x0; // dx and dy specify the displacement (scroll) of the -- cgit v1.2.3 From f47466c701b2256b2ce232f6d311d2be47136eab Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 20 Mar 2017 21:12:31 +0100 Subject: Implement rotation via desktop to window affine. Remove rotation via viewbox. Still some work to do... (bzr r15603) --- src/display/sp-canvas.cpp | 291 +--------------------------------------------- 1 file changed, 1 insertion(+), 290 deletions(-) (limited to 'src/display/sp-canvas.cpp') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 61602e880..f27038593 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -33,11 +33,6 @@ #include "display/sp-canvas-group.h" #include "display/rendermode.h" #include "display/cairo-utils.h" -#include "display/cairo-templates.h" -#include "display/drawing-context.h" -#include "display/drawing-item.h" -#include "display/nr-filter-colormatrix.h" -#include "display/canvas-arena.h" #include "preferences.h" #include "inkscape.h" #include "sodipodi-ctrlrect.h" @@ -45,8 +40,6 @@ #include "debug/gdk-event-latency-tracker.h" #include "desktop.h" #include "color.h" -#include -#include #if GTK_CHECK_VERSION(3,20,0) # include @@ -1924,19 +1917,6 @@ SPCanvasGroup *SPCanvas::getRoot() return SP_CANVAS_GROUP(_root); } -gdouble grayscale_value_matrix[20] = { - 0.21, 0.72, 0.072, 0, 0, - 0.21, 0.72, 0.072, 0, 0, - 0.21, 0.72, 0.072, 0, 0, - 0 , 0 , 0 , 1, 0 - }; -cairo_surface_t *surface_rotated; -cairo_surface_t *surface_origin; -cairo_surface_t *surface_measure; -double start_angle = 0; -bool started = false; -bool rotated = false; - /** * Scroll screen to point 'c'. 'c' is measured in screen pixels. */ @@ -1965,14 +1945,10 @@ void SPCanvas::scrollTo( Geom::Point const &c, unsigned int clear, bool is_scrol cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); // Paint the background cairo_translate(cr, -ix, -iy); - if (rotated) { - cairo_translate(cr, dx, dy); - rotated = false; - } cairo_set_source(cr, _background); cairo_paint(cr); + // Copy the old backing store contents - cairo_set_source_surface(cr, _backing_store, _x0, _y0); cairo_rectangle(cr, _x0, _y0, allocation.width, allocation.height); cairo_clip(cr); @@ -2009,271 +1985,6 @@ void SPCanvas::scrollTo( Geom::Point const &c, unsigned int clear, bool is_scrol addIdle(); } -void SPCanvas::startRotateTo(double angle) -{ - if (!_backing_store || started) { - return; - } - start_angle = angle; - started = true; - GtkAllocation allocation; - gtk_widget_get_allocation(&_widget, &allocation); - int half_w = allocation.width/2; - int half_h = allocation.height/2; - int half_min = std::min(half_w,half_h); - - cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); - cairo_t *cr = cairo_create(new_backing_store); - cairo_arc(cr, half_w, half_h, half_min-15, 0, 2*M_PI); - cairo_fill(cr); - cairo_set_operator(cr, CAIRO_OPERATOR_IN); - cairo_set_source_surface(cr, _backing_store, 0, 0); - cairo_paint(cr); - cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_arc(cr, half_w, half_h, half_min-16, 0, 2*M_PI); - cairo_set_source_rgba (cr, 1, 1, 1, 0.5); - cairo_stroke(cr); - cairo_destroy(cr); - surface_rotated = new_backing_store; - - cairo_surface_t *new_backing_store_measure = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); - cr = cairo_create(new_backing_store_measure); - cairo_arc(cr, half_w, half_h, half_min-15, 0, 2*M_PI); - cairo_set_source_rgba (cr, 1, 1, 1, 0.2); - cairo_fill(cr); - cairo_translate(cr, half_w, half_h); - cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); - cairo_set_font_size(cr, 10.0); - for (gint x = 0; x < 360 ; x++){ - gint ang = 360 - x ;//+ 90; - if (ang > 180) { - ang -= 360; - } - double rot = (-180.0 + x)*(M_PI/180.); - double dist = half_min-9; - gint inverse = 1; - if((x) < 91 || (x) > 270) { - inverse = -1; - } - if(x%10 == 0) { - cairo_rotate(cr, -rot); - cairo_text_extents_t extents; - std::string s = std::to_string(ang) + "º"; - cairo_text_extents(cr, s.c_str(), &extents); - //std::cout << extents.width/2 << "extents.x_bearing\n"; - cairo_translate(cr, (extents.width/2) * inverse * -1, (dist + ((extents.height/2)* inverse))); - if((x) < 91 || (x) > 270) { - cairo_rotate(cr, 180*(M_PI/180.0)); - } - cairo_text_path(cr, s.c_str()); - if((x) < 91 || (x) > 270) { - cairo_rotate(cr, -180*(M_PI/180.0)); - } - cairo_translate(cr, (extents.width/2) * inverse , (dist + ((extents.height/2)* inverse)) * -1); - cairo_set_source_rgba (cr, 1, 1, 1, 1); - cairo_fill(cr); - cairo_rotate(cr, rot); - } - cairo_rotate(cr, x*(M_PI/180.)); - if(x%5 == 0) { - cairo_move_to(cr, 0, half_min-30); - cairo_line_to(cr, 0, half_min-17); - } else { - cairo_move_to(cr, 0, half_min-20); - cairo_line_to(cr, 0, half_min-15); - } - cairo_line_to(cr, 0, half_min-15); - cairo_set_source_rgba (cr, 0, 0, 0, 0.4); - cairo_set_line_width (cr,1); - cairo_stroke(cr); - cairo_rotate(cr, -x*(M_PI/180.)); - } - cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR); - cairo_translate(cr, -half_w, -half_h); - cairo_arc(cr, half_w, half_h, half_min-30, 0, 2*M_PI); - cairo_set_source_rgba (cr, 1, 1, 1, 1); - cairo_fill(cr); - cairo_translate(cr, half_w, half_h); - cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_rotate(cr, start_angle*(M_PI/180.)); - cairo_move_to(cr, 0, 0); - cairo_line_to(cr, 0, (half_min-17) * -1); - cairo_set_source_rgba (cr, 1, 1, 1, 0.25); - cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); - cairo_set_line_width (cr,5); - cairo_stroke(cr); - cairo_move_to(cr, 0, 0); - cairo_line_to(cr, 0, (half_min-17) * -1); - cairo_set_source_rgba (cr, 1, 0, 0, 0.9); - cairo_set_line_width (cr,1); - cairo_stroke(cr); - cairo_rotate(cr, -start_angle*(M_PI/180.)); - cairo_destroy(cr); - surface_measure = new_backing_store_measure; - - cairo_surface_t *new_backing_store_grey = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); - cr = cairo_create(new_backing_store_grey); - cairo_set_operator(cr, CAIRO_OPERATOR_OVER); - cairo_set_source_surface(cr, _backing_store, 0, 0); - cairo_paint(cr); - Inkscape::Filters::FilterColorMatrix::ColorMatrixMatrix _grayscale_colormatrix = std::vector (grayscale_value_matrix, grayscale_value_matrix + 20); - cairo_surface_t *out = ink_cairo_surface_create_identical(new_backing_store_grey); - ink_cairo_surface_filter(new_backing_store_grey, out, _grayscale_colormatrix); - cairo_set_source_surface(cr, out, 0, 0); - cairo_surface_destroy(out); - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_paint(cr); - cairo_destroy(cr); - surface_origin = new_backing_store_grey; -} - -bool SPCanvas::endRotateTo() -{ - if (!_backing_store || !started) { - return false; - } - started = false; - surface_rotated = NULL; - surface_origin = NULL; - gtk_widget_queue_draw(GTK_WIDGET(this)); - dirtyAll(); - addIdle(); - rotated = true; - return true; -} - -void SPCanvas::clearRotateTo() -{ - if (!started) { - return; - } - gtk_widget_queue_draw(GTK_WIDGET(this)); - dirtyAll(); - addIdle(); -} - -void SPCanvas::rotateTo(double angle) -{ - if (!_backing_store || !started) { - return; - } - GtkAllocation allocation; - gtk_widget_get_allocation(&_widget, &allocation); - int half_w = allocation.width/2; - int half_h = allocation.height/2; - int half_min = std::min(half_w,half_h); - cairo_surface_t *new_backing_store = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, allocation.width, allocation.height); - cairo_t *cr = cairo_create(new_backing_store); - cairo_set_source_surface(cr, surface_origin, 0, 0); - cairo_paint(cr); - cairo_set_source_rgba (cr, 0, 0, 0, 0.5); - cairo_paint(cr); - cairo_pattern_t *source_pattern; - cairo_matrix_t matrix; - source_pattern = cairo_pattern_create_for_surface (surface_rotated); - cairo_matrix_init_identity (&matrix); - cairo_matrix_translate (&matrix, allocation.width/2.0, allocation.height/2.0); - cairo_matrix_rotate (&matrix, Geom::rad_from_deg(angle - start_angle) * -1); - cairo_matrix_translate (&matrix, -allocation.width/2.0, -allocation.height/2.0); - cairo_pattern_set_matrix (source_pattern, &matrix); - cairo_set_source(cr, source_pattern); - cairo_paint(cr); - cairo_set_source_surface(cr, surface_measure, 0, 0); - cairo_paint(cr); - cairo_translate(cr, half_w, half_h); - cairo_rotate(cr, angle*(M_PI/180.)); - cairo_move_to(cr, 0, 0); - cairo_line_to(cr, 0, (half_min-17) * -1); - cairo_set_source_rgba (cr, 1, 1, 1, 0.25); - cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); - cairo_set_line_width (cr,5); - cairo_stroke(cr); - cairo_move_to(cr, 0, 0); - cairo_line_to(cr, 0, (half_min-17) * -1); - cairo_set_source_rgba (cr, 1, 1, 1, 0.9); - cairo_set_line_width (cr,1); - cairo_stroke(cr); - cairo_move_to(cr, 0, 0); - cairo_line_to(cr, 0, (half_min-17) * -1); - cairo_set_source_rgba (cr, 1, 0, 0, 0.9); - const double dashed[] = {6.0, 3.0}; - int len = sizeof(dashed) / sizeof(dashed[0]); - cairo_set_dash(cr, dashed, len, 1); - cairo_stroke(cr); - cairo_translate(cr, -half_w, -half_h); - cairo_set_source_rgba (cr, 1, 1, 1, 0.25); - cairo_arc(cr, half_w, half_h, 7, 0, 2*M_PI); - cairo_fill(cr); - cairo_set_source_rgba (cr, 1, 0, 0, 0.7); - cairo_arc(cr, half_w, half_h, 5, 0, 2*M_PI); - cairo_fill(cr); - cairo_translate(cr, half_w, half_h); - cairo_rotate(cr, -angle*(M_PI/180.)); - cairo_select_font_face(cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL); - cairo_set_font_size(cr, 15.0); - cairo_text_extents_t extents; - std::ostringstream s; - s << _("Original angle ") << std::fixed << std::setprecision(2) << start_angle << "º"; - cairo_text_extents(cr, s.str().c_str(), &extents); - cairo_translate(cr, half_w - extents.width -15 ,-half_h + 25); - cairo_set_source_rgba (cr, 1, 1, 1, 1); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 25) *-1); - s.str(""); - s << _("New angle ") << std::fixed << std::setprecision(2) << angle << "º"; - cairo_text_extents(cr, s.str().c_str(), &extents); - cairo_translate(cr, half_w - extents.width -15 ,-half_h + 45); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 45) *-1); - s.str(""); - s << _("Gap ") << std::fixed << std::setprecision(2) << std::abs(start_angle-angle) << "º"; - cairo_text_extents(cr, s.str().c_str(), &extents); - cairo_translate(cr, half_w - extents.width -15 ,-half_h + 65); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (half_w - extents.width -15) *-1 ,(-half_h + 65) *-1); - cairo_translate(cr, -half_w + 10 ,-half_h + 25); - s.str(""); - cairo_set_font_size(cr, 12.0); - s << _("Normal mode, 1º round step"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (-half_w +10) * -1 ,(-half_h + 25) * -1); - cairo_translate(cr, -half_w + 10 ,-half_h + 40); - s.str(""); - s << _("+ALT, Fractional degrees"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 40) * -1); - cairo_translate(cr, -half_w + 10 ,-half_h + 55); - s.str(""); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - s << _("+CTRL, ") << 180.0/prefs->getInt("/options/rotationsnapsperpi/value", 12) << _("º round step"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 55) * -1); - cairo_translate(cr, -half_w + 10 ,-half_h + 70); - s.str(""); - s << _("+SHIFT, Reset"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 70) * -1); - cairo_translate(cr, -half_w + 10 ,-half_h + 85); - s.str(""); - s << _("+CTRL+SHIFT, 0º"); - cairo_text_path(cr, s.str().c_str()); - cairo_fill(cr); - //cairo_translate(cr, (-half_w + 10) * -1 ,(-half_h + 60) * -1); - cairo_destroy(cr); - cairo_surface_destroy(_backing_store); - _backing_store = new_backing_store; - cairo_pattern_destroy (source_pattern); - gtk_widget_queue_draw(GTK_WIDGET(this)); - addIdle(); -} - void SPCanvas::updateNow() { if (_need_update) { -- cgit v1.2.3 From 3de63445fe736ca7c67cdce96426f6e5e3b8ebf4 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 30 Mar 2017 11:41:29 +0200 Subject: Add canvas-rotate for rapid previewing canvas rotation. Add canvas-debug for study of canvas tiling. (bzr r15612) --- src/display/sp-canvas.cpp | 9 +++++---- 1 file changed, 5 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 f27038593..74aa4807a 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1507,7 +1507,7 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect buf.buf = NULL; buf.buf_rowstride = 0; buf.rect = paint_rect; - buf.visible_rect = canvas_rect; + buf.canvas_rect = canvas_rect; buf.is_empty = true; // create temporary surface @@ -1571,7 +1571,7 @@ void SPCanvas::paintSingleBuffer(Geom::IntRect const &paint_rect, Geom::IntRect } struct PaintRectSetup { - Geom::IntRect big_rect; + Geom::IntRect canvas_rect; GTimeVal start_time; int max_pixels; Geom::Point mouse_loc; @@ -1630,7 +1630,7 @@ int SPCanvas::paintRectInternal(PaintRectSetup const *setup, Geom::IntRect const gdk_window_begin_paint_rect(window, &r); */ - paintSingleBuffer(this_rect, setup->big_rect, bw); + paintSingleBuffer(this_rect, setup->canvas_rect, bw); //gdk_window_end_paint(window); return 1; } @@ -1695,6 +1695,7 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) gtk_widget_get_allocation(GTK_WIDGET(this), &allocation); + // Find window rectangle in 'world coordinates'. Geom::IntRect canvas_rect = Geom::IntRect::from_xywh(_x0, _y0, allocation.width, allocation.height); Geom::IntRect paint_rect(xx0, yy0, xx1, yy1); @@ -1705,7 +1706,7 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) paint_rect = *area; PaintRectSetup setup; - setup.big_rect = paint_rect; + setup.canvas_rect = canvas_rect; // Save the mouse location gint x, y; -- cgit v1.2.3 From f27f16912ec71d7567c71891badb6adb543411e9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 30 Mar 2017 21:14:41 +0200 Subject: Add preference that allows user to increase the canvas tile size. A larger tile size vastly speeds up rendering for drawings with heavy filter use by reducing the need to recalculate filter effects that cross multiple tiles. (bzr r15614) --- src/display/sp-canvas.cpp | 8 +++++++- 1 file changed, 7 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 74aa4807a..d04c81ecb 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1727,10 +1727,16 @@ bool SPCanvas::paintRect(int xx0, int yy0, int xx1, int yy1) setup.mouse_loc = sp_canvas_window_to_world(this, Geom::Point(x,y)); + static unsigned tile_multiplier = 0; + if (tile_multiplier == 0) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + tile_multiplier = prefs->getIntLimited("/options/rendering/tile-multiplier", 1, 1, 64); + } + if (_rendermode != Inkscape::RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients // 256K is the cached buffer and we need 4 channels - setup.max_pixels = 65536; // 256K/4 + setup.max_pixels = 65536 * tile_multiplier; // 256K/4 } else { // paths only, so 1M works faster // 1M is the cached buffer and we need 4 channels -- cgit v1.2.3