Code

Fixed background access problems introduced in previous revision
authorkiirala <kiirala@users.sourceforge.net>
Thu, 7 Jun 2007 17:52:46 +0000 (17:52 +0000)
committerkiirala <kiirala@users.sourceforge.net>
Thu, 7 Jun 2007 17:52:46 +0000 (17:52 +0000)
src/display/nr-arena-item.cpp
src/display/nr-filter-slot.cpp

index a4fdcf5bc93fcc4fee527fde396240b7c030d324..d98bbaf3ab580a68bc44a55778d799efeacdf1e3 100644 (file)
@@ -414,10 +414,9 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area
 
         /* If background access is used, save the pixblock address.
          * This address is set to NULL at the end of this block */
-        if (item->background_new) {
+        if (item->background_new ||
+            (item->parent && item->parent->background_pb)) {
             item->background_pb = &ipb;
-        } else if (item->parent && item->parent->background_pb) {
-            item->background_pb = item->parent->background_pb;
         }
         ipb.visible_area = pb->visible_area;
         unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, &ipb, flags);
@@ -540,9 +539,6 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area
                 nr_blit_pixblock_pixblock_mask (dpb, &ipb, &mpb);
             }
             nr_pixblock_release (&mpb);
-            /* This pointer wouldn't be valid outside this block, so clear it */
-            item->background_pb = NULL;
-
         } else {
             if (item->render_opacity) { // opacity was already rendered in, just copy to dpb here
                 nr_blit_pixblock_pixblock(dpb, &ipb);
@@ -552,6 +548,8 @@ nr_arena_item_invoke_render (cairo_t *ct, NRArenaItem *item, NRRectL const *area
         }
         nr_pixblock_release (&ipb);
         dpb->empty = FALSE;
+        /* This pointer wouldn't be valid outside this block, so clear it */
+        item->background_pb = NULL;
     } else {
         /* Just render */
         unsigned int state = NR_ARENA_ITEM_VIRTUAL (item, render) (ct, item, &carea, dpb, flags);
index 250aee10b8537b9661397d81e30cdf4b20bfe958..32fc00f9950ddecbd326164fc94cba9fdcec6d85 100644 (file)
 #include <assert.h>
 
 #include "display/nr-arena-item.h"
-#include "libnr/nr-pixblock.h"
 #include "display/nr-filter-types.h"
 #include "display/nr-filter-slot.h"
+#include "libnr/nr-pixblock.h"
+#include "libnr/nr-blit.h"
 
 namespace NR {
 
@@ -71,7 +72,16 @@ NRPixBlock *FilterSlot::get(int slot_nr)
             NRPixBlock *pb;
             pb = nr_arena_item_get_background(_arena_item);
             if (pb) {
-                this->set(NR_FILTER_BACKGROUNDIMAGE, pb);
+                NRPixBlock *bg = new NRPixBlock;
+                nr_pixblock_setup_fast(bg, pb->mode,
+                                       pb->area.x0, pb->area.y0,
+                                       pb->area.x1, pb->area.y1, true);
+                bool empty = pb->empty;
+                pb->empty = false;
+                nr_blit_pixblock_pixblock(bg, pb);
+                pb->empty = empty;
+                bg->empty = false;
+                this->set(NR_FILTER_BACKGROUNDIMAGE, bg);
             } else {
                 NRPixBlock *source = this->get(NR_FILTER_SOURCEGRAPHIC);
                 pb = new NRPixBlock();