Code

API change: render methods now take a cairo_t (not yet used)
[inkscape.git] / src / display / canvas-arena.cpp
index 7b3e5bc94b2f11d042044dd5d473fced36f74ace..00203024cebf1459dbbeff5709d7428230dc439a 100644 (file)
@@ -200,6 +200,16 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf)
        bh = buf->rect.y1 - buf->rect.y0;
        if ((bw < 1) || (bh < 1)) return;
 
+       // FIXME: currently this function is a huge waste. It receives a buffer but creates a new one and loops 
+       // within the large one, doing arena painting in several blocks. This just makes no sense because the 
+       // buf that we are given is already only a strip of the screen, created by one iteration of a loop in
+       // sp_canvas_paint_rect_internal. With the current numbers, this function's buffer is always 1/4 
+       // smaller than the one we get, because they both are the same number of bytes but
+       // buf uses 3 bytes per pixel (24bpp, packed) while the pixblock created here uses 4 bytes (32bpp).
+       // Eventually I want to switch buf to using 4 bytes (see comment in canvas.cpp) and then remove 
+       // from here the sw/sh calculation, the loop, and creating the intermediate buffer, allowing arena 
+       // just render into buf in one go.  
+
        if (arena->arena->rendermode != RENDERMODE_OUTLINE) { // use 256K as a compromise to not slow down gradients
                /* 256K is the cached buffer and we need 4 channels */
                if (bw * bh < 65536) { // 256K/4
@@ -238,8 +248,15 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf)
                }
        }
 
-/* fixme: RGB transformed bitmap blit is not implemented (Lauris) */
-/* And even if it would be, unless it uses MMX there is little reason to go RGB */
+/*
+This define chooses between two modes: When on, arena renders into a temporary 
+32bpp buffer, and the result is then squished into the SPCanvasBuf. When off, arena 
+renders directly to SPCanvasBuf. However currently this gives no speed advantage, 
+perhaps because the lack of squishing is offset by the need for arena items to render 
+to the inconvenient (and probably slower) 24bpp buffer. When SPCanvasBuf is 
+switched to 32bpp and cairo drawing, however, this define should be removed to 
+streamline rendering. 
+*/
 #define STRICT_RGBA
 
        for (y = buf->rect.y0; y < buf->rect.y1; y += sh) {
@@ -261,6 +278,7 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf)
                        pb.empty = FALSE;
 #endif
 
+// CAIRO FIXME: switch this to R8G8B8A8P and 4 * ...
                        nr_pixblock_setup_extern (&cb, NR_PIXBLOCK_MODE_R8G8B8, area.x0, area.y0, area.x1, area.y1,
                                                  buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + 3 * (x - buf->rect.x0),
                                                  buf->buf_rowstride,
@@ -269,13 +287,14 @@ sp_canvas_arena_render (SPCanvasItem *item, SPCanvasBuf *buf)
 #ifdef STRICT_RGBA
             pb.visible_area = buf->visible_rect; 
                        if (pb.data.px != NULL) {
-                           nr_arena_item_invoke_render (arena->root, &area, &pb, 0);
+                               nr_arena_item_invoke_render (NULL, arena->root, &area, &pb, 0);
+                               // this does the 32->24 squishing, using an assembler routine:
                            nr_blit_pixblock_pixblock (&cb, &pb);
                        }
                        nr_pixblock_release (&pb);
 #else
-            cb.visible_area = buf->visible_rect; 
-                       nr_arena_item_invoke_render (arena->root, &area, &cb, 0);
+                       cb.visible_area = buf->visible_rect; 
+                       nr_arena_item_invoke_render (NULL, arena->root, &area, &cb, 0);
 #endif
 
                        nr_pixblock_release (&cb);
@@ -439,6 +458,6 @@ sp_canvas_arena_render_pixblock (SPCanvasArena *ca, NRPixBlock *pb)
        area.x1 = pb->area.x1;
        area.y1 = pb->area.y1;
 
-       nr_arena_item_invoke_render (ca->root, &area, pb, 0);
+       nr_arena_item_invoke_render (NULL, ca->root, &area, pb, 0);
 }