diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2010-07-07 18:49:40 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2010-07-07 18:49:40 +0000 |
| commit | a7a57737691a21d824fcdf5641046cb0187580fd (patch) | |
| tree | 4dcccb5b8f9d9a2af9dc2d9c2efcf7077d68787d /src/display/canvas-grid.cpp | |
| parent | Fix group opacity (diff) | |
| download | inkscape-a7a57737691a21d824fcdf5641046cb0187580fd.tar.gz inkscape-a7a57737691a21d824fcdf5641046cb0187580fd.zip | |
Grid rendering
(bzr r9508.1.14)
Diffstat (limited to 'src/display/canvas-grid.cpp')
| -rw-r--r-- | src/display/canvas-grid.cpp | 149 |
1 files changed, 87 insertions, 62 deletions
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index a79a6b610..5dae228b4 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -13,25 +13,23 @@ #define INKSCAPE_CANVAS_GRID_C -#include "sp-canvas-util.h" -#include "util/mathfns.h" -#include "display-forward.h" -#include <libnr/nr-pixops.h> +#include "desktop.h" #include "desktop-handles.h" +#include "display/cairo-utils.h" +#include "display/canvas-axonomgrid.h" +#include "display/canvas-grid.h" +#include "display/display-forward.h" +#include "display/sp-canvas-util.h" +#include "document.h" #include "helper/units.h" -#include "svg/svg-color.h" -#include "xml/node-event-vector.h" -#include "sp-object.h" - -#include "sp-namedview.h" #include "inkscape.h" -#include "desktop.h" - -#include "../document.h" +#include "libnr/nr-pixops.h" #include "preferences.h" - -#include "canvas-grid.h" -#include "canvas-axonomgrid.h" +#include "sp-namedview.h" +#include "sp-object.h" +#include "svg/svg-color.h" +#include "util/mathfns.h" +#include "xml/node-event-vector.h" namespace Inkscape { @@ -830,65 +828,86 @@ CanvasXYGrid::Update (Geom::Matrix const &affine, unsigned int /*flags*/) static void grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba) { - if ((y >= buf->rect.y0) && (y < buf->rect.y1)) { - guint r, g, b, a; - gint x0, x1, x; - guchar *p; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - x0 = MAX (buf->rect.x0, xs); - x1 = MIN (buf->rect.x1, xe + 1); - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; - for (x = x0; x < x1; x++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += 4; - } + if ((y < buf->rect.y0) || (y >= buf->rect.y1)) + return; + + cairo_move_to(buf->ct, 0.5 + xs, 0.5 + y); + cairo_line_to(buf->ct, 0.5 + xe, 0.5 + y); + ink_cairo_set_source_rgba32(buf->ct, rgba); + cairo_stroke(buf->ct); +#if 0 + guint r, g, b, a; + gint x0, x1, x; + guchar *p; + r = NR_RGBA32_R (rgba); + g = NR_RGBA32_G (rgba); + b = NR_RGBA32_B (rgba); + a = NR_RGBA32_A (rgba); + x0 = MAX (buf->rect.x0, xs); + x1 = MIN (buf->rect.x1, xe + 1); + p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 4; + for (x = x0; x < x1; x++) { + p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); + p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); + p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); + p += 4; } +#endif } static void grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba) { - if ((x >= buf->rect.x0) && (x < buf->rect.x1)) { - guint r, g, b, a; - gint y0, y1, y; - guchar *p; - r = NR_RGBA32_R(rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - y0 = MAX (buf->rect.y0, ys); - y1 = MIN (buf->rect.y1, ye + 1); - p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - for (y = y0; y < y1; y++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += buf->buf_rowstride; - } + if ((x < buf->rect.x0) || (x >= buf->rect.x1)) + return; + + cairo_move_to(buf->ct, 0.5 + x, 0.5 + ys); + cairo_line_to(buf->ct, 0.5 + x, 0.5 + ye); + ink_cairo_set_source_rgba32(buf->ct, rgba); + cairo_stroke(buf->ct); + #if 0 + guint r, g, b, a; + gint y0, y1, y; + guchar *p; + r = NR_RGBA32_R(rgba); + g = NR_RGBA32_G (rgba); + b = NR_RGBA32_B (rgba); + a = NR_RGBA32_A (rgba); + y0 = MAX (buf->rect.y0, ys); + y1 = MIN (buf->rect.y1, ye + 1); + p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; + for (y = y0; y < y1; y++) { + p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); + p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); + p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); + p += buf->buf_rowstride; } + #endif } static void grid_dot (SPCanvasBuf *buf, gint x, gint y, guint32 rgba) { - if ( (y >= buf->rect.y0) && (y < buf->rect.y1) - && (x >= buf->rect.x0) && (x < buf->rect.x1) ) { - guint r, g, b, a; - guchar *p; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - } + if ( (y < buf->rect.y0) || (y >= buf->rect.y1) + || (x < buf->rect.x0) || (x >= buf->rect.x1) ) + return; + + cairo_rectangle(buf->ct, x, y, 1, 1); + ink_cairo_set_source_rgba32(buf->ct, rgba); + cairo_fill(buf->ct); + +#if 0 + guint r, g, b, a; + guchar *p; + r = NR_RGBA32_R (rgba); + g = NR_RGBA32_G (rgba); + b = NR_RGBA32_B (rgba); + a = NR_RGBA32_A (rgba); + p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 4; + p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); + p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); + p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); +#endif } void @@ -909,6 +928,11 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) _empcolor = empcolor; } + cairo_save(buf->ct); + cairo_translate(buf->ct, -buf->rect.x0, -buf->rect.y0); + cairo_set_line_width(buf->ct, 1.0); + cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE); + if (!render_dotted) { gint ylinenum; gdouble y; @@ -960,6 +984,7 @@ CanvasXYGrid::Render (SPCanvasBuf *buf) } } + cairo_restore(buf->ct); } CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SnapManager *sm, Geom::Coord const d) : LineSnapper(sm, d) |
