From 76be04672cb5648cfe283a5b2cc713a619b1d4d6 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Tue, 27 Feb 2007 03:37:57 +0000 Subject: [PATCH] more comments on cairo's and our own woes --- src/display/canvas-arena.cpp | 10 ++++++++++ src/display/sp-canvas.cpp | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/display/canvas-arena.cpp b/src/display/canvas-arena.cpp index 3212d0bd2..a7615b3d7 100644 --- a/src/display/canvas-arena.cpp +++ b/src/display/canvas-arena.cpp @@ -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 diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index f716d383a..75ffeed84 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1560,7 +1560,13 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, x1 - x0, y1 - y0); } else { /* - CAIRO FIXME: after SPCanvasBuf is made 32bpp throughout, this rgb_draw below can be replaced with: +// CAIRO FIXME: after SPCanvasBuf is made 32bpp throughout, this rgb_draw below can be replaced with the below. +// Why this must not be done currently: +// - all canvas items (handles, nodes etc) paint themselves assuming 24bpp +// - cairo assumes bgra, but we have rgba, so r and b get swapped (until we paint all with cairo too) +// - it does not seem to be any faster; in fact since with 32bpp, buf contains less pixels, +// we need more bufs to paint a given area and as a result it's even a bit slower + cairo_surface_t* cst = cairo_image_surface_create_for_data ( buf.buf, CAIRO_FORMAT_RGB24, // unpacked, i.e. 32 bits! one byte is unused @@ -1570,7 +1576,6 @@ sp_canvas_paint_single_buffer (SPCanvas *canvas, int x0, int y0, int x1, int y1, cairo_t *ct = gdk_cairo_create(SP_CANVAS_WINDOW (canvas)); cairo_set_source_surface (ct, cst, x0 - canvas->x0, y0 - canvas->y0); cairo_paint (ct); - cairo_destroy (ct); cairo_surface_finish (cst); cairo_surface_destroy (cst); -- 2.30.2