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/dropper-context.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/dropper-context.cpp') diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 5415fdc80..85649186d 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -36,6 +36,7 @@ #include "desktop-handles.h" #include "selection.h" #include "document.h" +#include "libnr/nr-pixblock.h" #include "pixmaps/cursor-dropper.xpm" -- cgit v1.2.3 From 498629f82d9453cb7222ab642b867c183fdf1666 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Thu, 5 Aug 2010 01:56:47 +0200 Subject: Wholesale cruft removal part 3 (bzr r9508.1.47) --- src/dropper-context.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/dropper-context.cpp') diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 85649186d..3898cd169 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -42,7 +42,6 @@ #include "dropper-context.h" #include "message-context.h" -//#include "libnr/nr-scale-translate-ops.h" static void sp_dropper_context_class_init(SPDropperContextClass *klass); static void sp_dropper_context_init(SPDropperContext *dc); -- cgit v1.2.3 From aa844be794b36b44b624e579db7f0945b5d3927b Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 14 Aug 2010 21:22:11 +0200 Subject: Completely remove NRPixBlock (bzr r9508.1.67) --- src/dropper-context.cpp | 74 +++++++++++++++++-------------------------------- 1 file changed, 25 insertions(+), 49 deletions(-) (limited to 'src/dropper-context.cpp') diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 3898cd169..88d1c4561 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -26,6 +26,7 @@ #include "display/canvas-bpath.h" #include "display/canvas-arena.h" #include "display/curve.h" +#include "display/cairo-utils.h" #include "svg/svg-color.h" #include "color.h" #include "color-rgba.h" @@ -36,7 +37,6 @@ #include "desktop-handles.h" #include "selection.h" #include "document.h" -#include "libnr/nr-pixblock.h" #include "pixmaps/cursor-dropper.xpm" @@ -202,7 +202,7 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv // otherwise, constantly calculate color no matter is any button pressed or not double rw = 0.0; - double W(0), R(0), G(0), B(0), A(0); + double R(0), G(0), B(0), A(0); if (dc->dragging) { // calculate average @@ -222,56 +222,32 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv sp_canvas_item_show(dc->area); /* Get buffer */ - const int x0 = (int) floor(dc->centre[Geom::X] - rw); - const int y0 = (int) floor(dc->centre[Geom::Y] - rw); - const int x1 = (int) ceil(dc->centre[Geom::X] + rw); - const int y1 = (int) ceil(dc->centre[Geom::Y] + rw); - - if ((x1 > x0) && (y1 > y0)) { - NRPixBlock pb; - nr_pixblock_setup_fast(&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, x0, y0, x1, y1, TRUE); - /* fixme: (Lauris) */ - sp_canvas_arena_render_pixblock(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), &pb); - for (int y = y0; y < y1; y++) { - const unsigned char *s = NR_PIXBLOCK_PX(&pb) + (y - y0) * pb.rs; - for (int x = x0; x < x1; x++) { - const double dx = x - dc->centre[Geom::X]; - const double dy = y - dc->centre[Geom::Y]; - const double w = exp(-((dx * dx) + (dy * dy)) / (rw * rw)); - W += w; - R += w * s[0]; - G += w * s[1]; - B += w * s[2]; - A += w * s[3]; - s += 4; - } - } - nr_pixblock_release(&pb); - - R = (R + 0.001) / (255.0 * W); - G = (G + 0.001) / (255.0 * W); - B = (B + 0.001) / (255.0 * W); - A = (A + 0.001) / (255.0 * W); - - R = CLAMP(R, 0.0, 1.0); - G = CLAMP(G, 0.0, 1.0); - B = CLAMP(B, 0.0, 1.0); - A = CLAMP(A, 0.0, 1.0); + Geom::Rect r(dc->centre, dc->centre); + r.expandBy(rw); + if (!r.hasZeroArea()) { + NRRectL area; + area.x0 = r[Geom::X].min(); + area.y0 = r[Geom::Y].min(); + area.x1 = r[Geom::X].max(); + area.y1 = r[Geom::Y].max(); + int w = area.x1 - area.x0; + int h = area.y1 - area.y0; + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area); + ink_cairo_surface_average_color_premul(s, R, G, B, A); + cairo_surface_destroy(s); } - } else { // pick single pixel - NRPixBlock pb; - int x = (int) floor(event->button.x); - int y = (int) floor(event->button.y); - nr_pixblock_setup_fast(&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, x, y, x+1, y+1, TRUE); - sp_canvas_arena_render_pixblock(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), &pb); - const unsigned char *s = NR_PIXBLOCK_PX(&pb); - - R = s[0] / 255.0; - G = s[1] / 255.0; - B = s[2] / 255.0; - A = s[3] / 255.0; + NRRectL area; + area.x0 = floor(event->button.x); + area.y0 = floor(event->button.y); + area.x1 = area.x0 + 1; + area.y1 = area.y0 + 1; + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); + sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area); + ink_cairo_surface_average_color_premul(s, R, G, B, A); + cairo_surface_destroy(s); } if (pick == SP_DROPPER_PICK_VISIBLE) { -- 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/dropper-context.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/dropper-context.cpp') diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index e30d6b1e8..9fbbcdc27 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -15,11 +15,10 @@ # include #endif -#include -#include -#include -#include -#include +#include +#include +#include +#include <2geom/transforms.h> #include "macros.h" #include "display/canvas-bpath.h" -- 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/dropper-context.cpp | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'src/dropper-context.cpp') diff --git a/src/dropper-context.cpp b/src/dropper-context.cpp index 9fbbcdc27..d91642bd2 100644 --- a/src/dropper-context.cpp +++ b/src/dropper-context.cpp @@ -225,25 +225,15 @@ static gint sp_dropper_context_root_handler(SPEventContext *event_context, GdkEv Geom::Rect r(dc->centre, dc->centre); r.expandBy(rw); if (!r.hasZeroArea()) { - NRRectL area; - area.x0 = r[Geom::X].min(); - area.y0 = r[Geom::Y].min(); - area.x1 = r[Geom::X].max(); - area.y1 = r[Geom::Y].max(); - int w = area.x1 - area.x0; - int h = area.y1 - area.y0; - cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h); + Geom::IntRect area = r.roundOutwards(); + cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, area.width(), area.height()); sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area); ink_cairo_surface_average_color_premul(s, R, G, B, A); cairo_surface_destroy(s); } } else { // pick single pixel - NRRectL area; - area.x0 = floor(event->button.x); - area.y0 = floor(event->button.y); - area.x1 = area.x0 + 1; - area.y1 = area.y0 + 1; + Geom::IntRect area = Geom::IntRect::from_xywh(floor(event->button.x), floor(event->button.y), 1, 1); cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1); sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area); ink_cairo_surface_average_color_premul(s, R, G, B, A); -- cgit v1.2.3