summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2748588)
raw | patch | inline | side by side (parent: 2748588)
author | buliabyak <buliabyak@users.sourceforge.net> | |
Tue, 24 Jun 2008 02:28:57 +0000 (02:28 +0000) | ||
committer | buliabyak <buliabyak@users.sourceforge.net> | |
Tue, 24 Jun 2008 02:28:57 +0000 (02:28 +0000) |
src/display/inkscape-cairo.cpp | patch | blob | history | |
src/display/inkscape-cairo.h | patch | blob | history |
index f97129031d8d4d81d2680eb56820d2d66bb57e90..063b56ae57829fe3d1bb9badcd4110a9d7a32873 100644 (file)
#include <libnr/nr-convert2geom.h>
#include "../style.h"
#include "nr-arena.h"
+#include "sp-canvas.h"
#include <2geom/pathvector.h>
#include <2geom/matrix.h>
#include <2geom/point.h>
/** Creates a cairo context to render to the given pixblock on the given area */
cairo_t *
-nr_create_cairo_context (NRRectL *area, NRPixBlock *pb)
+nr_create_cairo_context_for_data (NRRectL *area, NRRectL *buf_area, unsigned char *px, unsigned int rowstride)
{
- if (!nr_rect_l_test_intersect (&pb->area, area))
+ if (!nr_rect_l_test_intersect (buf_area, area))
return NULL;
NRRectL clip;
- nr_rect_l_intersect (&clip, &pb->area, area);
- unsigned char *dpx = NR_PIXBLOCK_PX (pb) + (clip.y0 - pb->area.y0) * pb->rs + NR_PIXBLOCK_BPP (pb) * (clip.x0 - pb->area.x0);
+ nr_rect_l_intersect (&clip, buf_area, area);
+ unsigned char *dpx = px + (clip.y0 - buf_area->y0) * rowstride + 4 * (clip.x0 - buf_area->x0);
int width = area->x1 - area->x0;
int height = area->y1 - area->y0;
// even though cairo cannot draw in nonpremul mode, select ARGB32 for R8G8B8A8N as the closest; later eliminate R8G8B8A8N everywhere
cairo_surface_t* cst = cairo_image_surface_create_for_data
(dpx,
- ((pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8P || pb->mode == NR_PIXBLOCK_MODE_R8G8B8A8N) ? CAIRO_FORMAT_ARGB32 : (pb->mode == NR_PIXBLOCK_MODE_R8G8B8? CAIRO_FORMAT_RGB24 : CAIRO_FORMAT_A8)),
+ CAIRO_FORMAT_ARGB32,
width,
height,
- pb->rs);
+ rowstride);
cairo_t *ct = cairo_create (cst);
return ct;
}
+/** Creates a cairo context to render to the given SPCanvasBuf on the given area */
+cairo_t *
+nr_create_cairo_context_canvasbuf (NRRectL *area, SPCanvasBuf *b)
+{
+ return nr_create_cairo_context_for_data (&(b->rect), &(b->rect), b->buf, b->buf_rowstride);
+}
+
+
+/** Creates a cairo context to render to the given NRPixBlock on the given area */
+cairo_t *
+nr_create_cairo_context (NRRectL *area, NRPixBlock *pb)
+{
+ return nr_create_cairo_context_for_data (area, &(pb->area), NR_PIXBLOCK_PX (pb), pb->rs);
+}
+
/** Feeds path-creating calls to the cairo context translating them from the SPCurve, with the given transform and shift */
void
feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width)
index 58235523fed0174159bad888bc7bb7a0616826ab..40cc77e7608f697554b4e8e059269015a5390be6 100644 (file)
#include <2geom/forward.h>
+class SPCanvasBuf;
+
+cairo_t *nr_create_cairo_context_canvasbuf (NRRectL *area, SPCanvasBuf *b);
cairo_t *nr_create_cairo_context (NRRectL *area, NRPixBlock *pb);
void feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width);
void feed_path_to_cairo (cairo_t *ct, Geom::Path const &path, Geom::Matrix trans, NR::Maybe<NR::Rect> area, bool optimize_stroke, double stroke_width);