00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef __RU_PolyFill__
00034 #define __RU_PolyFill__
00035
00036 #include "RU_API.h"
00037 #include <UT/UT_Endian.h>
00038 #include <UT/UT_Lock.h>
00039 #include <UT/UT_PtrArray.h>
00040 #include <UT/UT_Vector4.h>
00041
00042 #include <TIL/TIL_Tile.h>
00043
00044 #include <TIL/TIL_Pixel.h>
00045
00046 #include "RU_Feather.h"
00047
00048 enum RU_PolyFillMethod
00049 {
00050 RU_POLYFILL_NORMAL = 0,
00051 RU_POLYFILL_FEATHER
00052 };
00053
00054 class GEO_Detail;
00055
00056 class ru_Triangle;
00057 class ru_Bucket;
00058
00059 class ru_FeatherTriangle;
00060 class UT_BilinearSampleQuad2D;
00061
00062 class RU_API RU_PolyFill
00063 {
00064 public:
00065 RU_PolyFill(RU_PolyFillMethod method = RU_POLYFILL_NORMAL,
00066 int num_threads = 1);
00067
00068 ~RU_PolyFill();
00069
00070 void clearGeometry();
00071 void initialize(const GEO_Detail *gdp);
00072 void append(const GEO_Detail *gdp);
00073 void initializeFeather(const GEO_Detail *gdp);
00074 void addTriangle(float x0, float y0,
00075 float x1, float y1,
00076 float x2, float y2);
00077 void addFeatherTriangle(float x0, float y0,
00078 float x1, float y1,
00079 float x2, float y2,
00080 int quad_index);
00081
00082
00083
00084 void setResolution(int imagex, int imagey,
00085 int tilex, int tiley);
00086 void doSorting();
00087
00088
00089 void setSampling(int xs, int ys);
00090
00091
00092 void setDropoff(int size,float (*dropfunc)(float));
00093 void setDropoff(RU_FeatherDropoff dropoff)
00094 { myFeatherDropoff = dropoff; }
00095
00096
00097 void scanConvert(TIL_TileList *tilelist,
00098 int tx, int ty,
00099 const UT_Vector4 &color,
00100 int thread_index);
00101
00102 private:
00103 void scanConvertNormal(TIL_TileList *tilelist,
00104 int tx, int ty,
00105 const UT_Vector4 &color,
00106 int thread_index);
00107 void scanConvertFeather(TIL_TileList *tilelist,
00108 int tx, int ty,
00109 const UT_Vector4 &color,
00110 int thread_index);
00111
00112
00113
00114 void (RU_PolyFill::*myWritePixel)(void *data, int x, int y,
00115 int stride, float coverage,
00116 int thread);
00117
00118 void writePixel8(void *data, int x, int y,int stride, float coverage,
00119 int thread);
00120 void writePixel8F(void *data, int x, int y,int stride, float coverage,
00121 int thread);
00122 void writePixel16(void *data, int x, int y,int stride, float coverage,
00123 int thread);
00124 void writePixel16F(void *data, int x, int y,int stride, float coverage,
00125 int thread);
00126 void writePixel32(void *data, int x, int y,int stride, float coverage,
00127 int thread);
00128 void writePixel32F(void *data, int x, int y,int stride, float coverage,
00129 int thread);
00130 void writePixelFloat16(void *data, int x, int y,int stride, float coverage,
00131 int thread);
00132 void writePixelFloat(void *data, int x, int y,int stride, float coverage,
00133 int thread);
00134
00135 void clearAndDestroy();
00136
00137
00138 RU_PolyFillMethod myFillMethod;
00139 int myNumThreads;
00140 ru_Triangle *myTriangles;
00141 ru_Bucket *myBuckets;
00142 ru_FeatherTriangle *myFeatherTriangles;
00143 ru_Bucket *myFeatherBuckets;
00144 int myBucketCount;
00145 float *myPLeft, *myPBottom;
00146 float myXInc, myYInc;
00147 int myImageX, myImageY;
00148 int myXres, myYres;
00149 int myTileX, myTileY;
00150
00151
00152 int mySampleSize;
00153 float *mySamples;
00154 uint64 myFullMask;
00155 uint64 **myMaskBuffer;
00156 float myFullCount;
00157 UT_Lock mySampleLock;
00158
00159
00160 float **myFillBuffer;
00161 int myFeatherSize;
00162 float *myFeatherLUT;
00163 UT_BilinearSampleQuad2D *myFeatherQuads;
00164 RU_FeatherDropoff myFeatherDropoff;
00165
00166
00167 UT_Vector4 myColor;
00168 int myFastConvert;
00169 TIL_DataFormat myFormat;
00170 TIL_Pixel<unsigned char,0> *mySlow8;
00171 TIL_Pixel<unsigned char,1> *myFast8;
00172 TIL_Pixel<unsigned short,0> *mySlow16;
00173 TIL_Pixel<unsigned short,1> *myFast16;
00174 TIL_Pixel<unsigned int,0> *mySlow32;
00175 TIL_Pixel<unsigned int,1> *myFast32;
00176 };
00177
00178 #endif