Code

Rename LPE: mirror reflect --> mirror symmetry
[inkscape.git] / src / display / nr-filter-specularlighting.cpp
index 3f459f164dbba5ecaef49062c2979fdcdcecb903..3a14eb78f8af798a300b4f498bb91a9e927a8be4 100644 (file)
@@ -60,7 +60,12 @@ do {\
 }while(0)
 
 int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) {
-    NRPixBlock *in = filter_get_alpha(slot.get(_input));
+    NRPixBlock *in = slot.get(_input);
+    if (!in) {
+        g_warning("Missing source image for feSpecularLighting (in=%d)", _input);
+        return 1;
+    }
+
     NRPixBlock *out = new NRPixBlock;
 
     //Fvector *L = NULL; //vector to the light
@@ -81,7 +86,7 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) {
     Fvector L, N, LC, H;
     gdouble inter;
 
-    nr_pixblock_setup_fast(out, in->mode,
+    nr_pixblock_setup_fast(out, NR_PIXBLOCK_MODE_R8G8B8A8N,
             in->area.x0, in->area.y0, in->area.x1, in->area.y1,
             true);
     unsigned char *data_i = NR_PIXBLOCK_PX (in);
@@ -103,7 +108,8 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) {
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]);
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]);
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]);
-                data_o[j++] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]);
+                data_o[j] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]);
+                ++j;
             }
             out->empty = FALSE;
             delete dl;
@@ -130,7 +136,8 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) {
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]);
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]);
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]);
-                data_o[j++] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]);
+                data_o[j] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]);
+                ++j;
             }
             out->empty = FALSE;
             delete pl;
@@ -157,7 +164,8 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) {
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]);
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]);
                 data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_BLUE]);
-                data_o[j++] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]);
+                data_o[j] = MAX(MAX(data_o[j-3], data_o[j-2]), data_o[j-1]);
+                ++j;
             }
             out->empty = FALSE;
             delete sl;
@@ -175,8 +183,8 @@ int FilterSpecularLighting::render(FilterSlot &slot, FilterUnits const &units) {
 
     //finishing
     slot.set(_output, out);
-    nr_pixblock_release(in);
-    delete in;
+    //nr_pixblock_release(in);
+    //delete in;
     return 0;
 }