Revision: 27493
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27493
Author:   blendix
Date:     2010-03-14 19:22:04 +0100 (Sun, 14 Mar 2010)

Log Message:
-----------
Remove SAT texture filter. It's not working, thought it was but that's
because the mipmap was not being refreshed. Also this will be problematic
to support when I add tile/mipmap cache, so would not rather not try to.
Can be added back afterwards if someone wants to make it work.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/imbuf/IMB_imbuf.h
    trunk/blender/source/blender/imbuf/intern/filter.c
    trunk/blender/source/blender/imbuf/intern/tiff.c
    trunk/blender/source/blender/makesdna/DNA_texture_types.h
    trunk/blender/source/blender/makesrna/intern/rna_texture.c
    trunk/blender/source/blender/render/intern/source/imagetexture.c

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_draw.c     
2010-03-14 18:08:12 UTC (rev 27492)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_draw.c     
2010-03-14 18:22:04 UTC (rev 27493)
@@ -1362,7 +1362,7 @@
                                int mip= 0;
 
                                if(ibuf->mipmap[0]==NULL)
-                                       IMB_makemipmap(ibuf, 0, 0);
+                                       IMB_makemipmap(ibuf, 0);
 
                                while(tzoom < 1.0f && mip<8 && 
ibuf->mipmap[mip]) {
                                        tzoom*= 2.0f;

Modified: trunk/blender/source/blender/imbuf/IMB_imbuf.h
===================================================================
--- trunk/blender/source/blender/imbuf/IMB_imbuf.h      2010-03-14 18:08:12 UTC 
(rev 27492)
+++ trunk/blender/source/blender/imbuf/IMB_imbuf.h      2010-03-14 18:22:04 UTC 
(rev 27493)
@@ -317,7 +317,7 @@
 void IMB_filter(struct ImBuf *ibuf);
 void IMB_filterN(struct ImBuf *out, struct ImBuf *in);
 void IMB_filter_extend(struct ImBuf *ibuf, char *mask);
-void IMB_makemipmap(struct ImBuf *ibuf, int use_filter, int SAT);
+void IMB_makemipmap(struct ImBuf *ibuf, int use_filter);
 
 /**
  *

Modified: trunk/blender/source/blender/imbuf/intern/filter.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/filter.c  2010-03-14 18:08:12 UTC 
(rev 27492)
+++ trunk/blender/source/blender/imbuf/intern/filter.c  2010-03-14 18:22:04 UTC 
(rev 27493)
@@ -371,114 +371,21 @@
        }
 }
 
-#if 0
 void IMB_makemipmap(ImBuf *ibuf, int use_filter)
 {
-       ImBuf *hbuf= ibuf;
-       int minsize, curmap=0;
-       
-       minsize= ibuf->x<ibuf->y?ibuf->x:ibuf->y;
-       
-       while(minsize>10 && curmap<IB_MIPMAP_LEVELS) {
-               if(use_filter) {
+       ImBuf *hbuf = ibuf;
+       int curmap = 0;
+       while (curmap < IB_MIPMAP_LEVELS) {
+               if (use_filter) {
                        ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 32, 
IB_rect, 0);
                        IMB_filterN(nbuf, hbuf);
-                       ibuf->mipmap[curmap]= IMB_onehalf(nbuf);
+                       ibuf->mipmap[curmap] = IMB_onehalf(nbuf);
                        IMB_freeImBuf(nbuf);
                }
-               else {
-                       ibuf->mipmap[curmap]= IMB_onehalf(hbuf);
-               }
-               hbuf= ibuf->mipmap[curmap];
-               
+               else ibuf->mipmap[curmap] = IMB_onehalf(hbuf);
+               hbuf = ibuf->mipmap[curmap];
+               if (hbuf->x == 1 && hbuf->y == 1) break;
                curmap++;
-               minsize= hbuf->x<hbuf->y?hbuf->x:hbuf->y;
        }
 }
-#endif
 
-void IMB_makemipmap(ImBuf *ibuf, int use_filter, int SAT)
-{
-       if (SAT) {
-               // to maximize precision subtract image average, use 
intermediate double SAT,
-               // only convert to float at the end
-               const double dv = 1.0/255.0;
-               double avg[4] = {0, 0, 0, 0};
-               const int x4 = ibuf->x << 2;
-               int x, y, i;
-               ImBuf* sbuf = IMB_allocImBuf(ibuf->x, ibuf->y, 32, 
IB_rectfloat, 0);
-               double *satp, *satbuf = 
MEM_callocN(sizeof(double)*ibuf->x*ibuf->y*4, "tmp SAT buf");
-               const double mf = ibuf->x*ibuf->y;
-               float* fp;
-               ibuf->mipmap[0] = sbuf;
-               if (ibuf->rect_float) {
-                       fp = ibuf->rect_float;
-                       for (y=0; y<ibuf->y; ++y)
-                               for (x=0; x<ibuf->x; ++x) {
-                                       avg[0] += *fp++;
-                                       avg[1] += *fp++;
-                                       avg[2] += *fp++;
-                                       avg[3] += *fp++;
-                               }
-               }
-               else {
-                       char* cp = (char*)ibuf->rect;
-                       for (y=0; y<ibuf->y; ++y)
-                               for (x=0; x<ibuf->x; ++x) {
-                                       avg[0] += *cp++ * dv;
-                                       avg[1] += *cp++ * dv;
-                                       avg[2] += *cp++ * dv;
-                                       avg[3] += *cp++ * dv;
-                               }
-               }
-               avg[0] /= mf;
-               avg[1] /= mf;
-               avg[2] /= mf;
-               avg[3] /= mf;
-               for (y=0; y<ibuf->y; ++y)
-                       for (x=0; x<ibuf->x; ++x) {
-                               const unsigned int p = (x + y*ibuf->x) << 2;
-                               char* cp = (char*)ibuf->rect + p;
-                               fp = ibuf->rect_float + p;
-                               satp = satbuf + p;
-                               for (i=0; i<4; ++i, ++cp, ++fp, ++satp) {
-                                       double sv = (ibuf->rect_float ? 
(double)*fp : (double)(*cp)*dv) - avg[i];
-                                       if (x > 0) sv += satp[-4];
-                                       if (y > 0) sv += satp[-x4];
-                                       if (x > 0 && y > 0) sv -= satp[-x4 - 4];
-                                       *satp = sv;
-                               }
-                       }
-               fp = sbuf->rect_float;
-               satp = satbuf;
-               for (y=0; y<ibuf->y; ++y)
-                       for (x=0; x<ibuf->x; ++x) {
-                               *fp++ = (float)*satp++;
-                               *fp++ = (float)*satp++;
-                               *fp++ = (float)*satp++;
-                               *fp++ = (float)*satp++;
-                       }
-               MEM_freeN(satbuf);
-               fp = &sbuf->rect_float[(sbuf->x - 1 + (sbuf->y - 1)*sbuf->x) << 
2];
-               fp[0] = avg[0];
-               fp[1] = avg[1];
-               fp[2] = avg[2];
-               fp[3] = avg[3];
-       }
-       else {
-               ImBuf *hbuf = ibuf;
-               int curmap = 0;
-               while (curmap < IB_MIPMAP_LEVELS) {
-                       if (use_filter) {
-                               ImBuf *nbuf= IMB_allocImBuf(hbuf->x, hbuf->y, 
32, IB_rect, 0);
-                               IMB_filterN(nbuf, hbuf);
-                               ibuf->mipmap[curmap] = IMB_onehalf(nbuf);
-                               IMB_freeImBuf(nbuf);
-                       }
-                       else ibuf->mipmap[curmap] = IMB_onehalf(hbuf);
-                       hbuf = ibuf->mipmap[curmap];
-                       if (hbuf->x == 1 && hbuf->y == 1) break;
-                       curmap++;
-               }
-       }
-}

Modified: trunk/blender/source/blender/imbuf/intern/tiff.c
===================================================================
--- trunk/blender/source/blender/imbuf/intern/tiff.c    2010-03-14 18:08:12 UTC 
(rev 27492)
+++ trunk/blender/source/blender/imbuf/intern/tiff.c    2010-03-14 18:22:04 UTC 
(rev 27493)
@@ -62,13 +62,13 @@
  * Local declarations. *
  ***********************/
 /* Reading and writing of an in-memory TIFF file. */
-tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n);
-tsize_t imb_tiff_WriteProc(thandle_t handle, tdata_t data, tsize_t n);
-toff_t  imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence);
-int     imb_tiff_CloseProc(thandle_t handle);
-toff_t  imb_tiff_SizeProc(thandle_t handle);
-int     imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize);
-void    imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size);
+static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n);
+static tsize_t imb_tiff_WriteProc(thandle_t handle, tdata_t data, tsize_t n);
+static toff_t  imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence);
+static int     imb_tiff_CloseProc(thandle_t handle);
+static toff_t  imb_tiff_SizeProc(thandle_t handle);
+static int     imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* 
psize);
+static void    imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t 
size);
 
 
 /* Structure for in-memory TIFF file. */
@@ -86,11 +86,11 @@
  *****************************/
 
 
-void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size)
+static void imb_tiff_DummyUnmapProc(thandle_t fd, tdata_t base, toff_t size)
 {
 }
 
-int imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) 
+static int imb_tiff_DummyMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize) 
 {
             return (0);
 }
@@ -105,7 +105,7 @@
  * @return: Number of bytes actually read.
  *      0 = EOF.
  */
-tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
+static tsize_t imb_tiff_ReadProc(thandle_t handle, tdata_t data, tsize_t n)
 {
        tsize_t nRemaining, nCopy;
        struct ImbTIFFMemFile* mfile;
@@ -147,7 +147,7 @@
  * NOTE: The current Blender implementation should not need this function.  It
  *       is simply a stub.
  */
-tsize_t imb_tiff_WriteProc(thandle_t handle, tdata_t data, tsize_t n)
+static tsize_t imb_tiff_WriteProc(thandle_t handle, tdata_t data, tsize_t n)
 {
        printf("imb_tiff_WriteProc: this function should not be called.\n");
        return (-1);
@@ -169,7 +169,7 @@
  * @return: Resulting offset location within the file, measured in bytes from
  *          the beginning of the file.  (-1) indicates an error.
  */
-toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence)
+static toff_t imb_tiff_SeekProc(thandle_t handle, toff_t ofs, int whence)
 {
        struct ImbTIFFMemFile *mfile;
        toff_t new_offset;
@@ -216,7 +216,7 @@
  *
  * @return: 0
  */
-int imb_tiff_CloseProc(thandle_t handle)
+static int imb_tiff_CloseProc(thandle_t handle)
 {
        struct ImbTIFFMemFile *mfile;
 
@@ -242,7 +242,7 @@
  *
  * @return: Size of file (in bytes).
  */
-toff_t imb_tiff_SizeProc(thandle_t handle)
+static toff_t imb_tiff_SizeProc(thandle_t handle)
 {
        struct ImbTIFFMemFile* mfile;
 

Modified: trunk/blender/source/blender/makesdna/DNA_texture_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_texture_types.h   2010-03-14 
18:08:12 UTC (rev 27492)
+++ trunk/blender/source/blender/makesdna/DNA_texture_types.h   2010-03-14 
18:22:04 UTC (rev 27493)
@@ -335,8 +335,6 @@
 #define TXF_EWA                        1
 #define TXF_FELINE             2
 #define TXF_AREA               3
-// TXF_SAT only available when mipmaps disabled
-#define TXF_SAT                        4
 
 /* imaflag unused, only for version check */
 #define TEX_FIELDS_            8

Modified: trunk/blender/source/blender/makesrna/intern/rna_texture.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_texture.c  2010-03-14 
18:08:12 UTC (rev 27492)
+++ trunk/blender/source/blender/makesrna/intern/rna_texture.c  2010-03-14 
18:22:04 UTC (rev 27493)
@@ -48,7 +48,6 @@
        {TXF_EWA, "EWA", 0, "EWA", ""},
        {TXF_FELINE, "FELINE", 0, "FELINE", ""},
        {TXF_AREA, "AREA", 0, "Area", ""},
-       {TXF_SAT, "SAT", 0, "SAT (4x mem)", ""},
        {0, NULL, 0, NULL, NULL}};
 
 EnumPropertyItem texture_type_items[] = {
@@ -327,28 +326,10 @@
        if(value) tex->imaflag |= TEX_MIPMAP;
        else tex->imaflag &= ~TEX_MIPMAP;
 
-       if((tex->imaflag & TEX_MIPMAP) && tex->texfilter == TXF_SAT)
+       if(tex->imaflag & TEX_MIPMAP)
                tex->texfilter = TXF_EWA;
 }
 
-static EnumPropertyItem *rna_ImageTexture_filter_itemf(bContext *C, PointerRNA 
*ptr, int *free)
-{
-       Tex *tex= (Tex*)ptr->data;
-       EnumPropertyItem *item= NULL;
-       int totitem= 0;
-
-       RNA_enum_items_add_value(&item, &totitem, texture_filter_items, 
TXF_BOX);
-       RNA_enum_items_add_value(&item, &totitem, texture_filter_items, 
TXF_EWA);
-       RNA_enum_items_add_value(&item, &totitem, texture_filter_items, 
TXF_FELINE);
-       RNA_enum_items_add_value(&item, &totitem, texture_filter_items, 
TXF_AREA);
-       if(tex->imaflag & TEX_MIPMAP)
-               RNA_enum_items_add_value(&item, &totitem, texture_filter_items, 
TXF_SAT);
-       
-       *free= 1;
-
-       return item;
-}
-
 static void rna_Envmap_source_update(Main *bmain, Scene *scene, PointerRNA 
*ptr)
 {
        Tex *tex= ptr->id.data;
@@ -695,7 +676,6 @@
        prop= RNA_def_property(srna, "filter", PROP_ENUM, PROP_NONE);
        RNA_def_property_enum_sdna(prop, NULL, "texfilter");
        RNA_def_property_enum_items(prop, texture_filter_items);
-       RNA_def_property_enum_funcs(prop, NULL, NULL, 
"rna_ImageTexture_filter_itemf");
        RNA_def_property_ui_text(prop, "Filter", "Texture filter to use for 
sampling image");
        RNA_def_property_update(prop, 0, "rna_Texture_update");
        


@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to