ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/RpictSimulManager.h
(Generate patch)

Comparing ray/src/rt/RpictSimulManager.h (file contents):
Revision 2.5 by greg, Wed Aug 21 23:32:24 2024 UTC vs.
Revision 2.9 by greg, Mon Sep 16 23:49:13 2024 UTC

# Line 43 | Line 43 | class PixelAccess {
43          long            rowStride;      // # values to next y position
44          int             dtyp;           // data type flags
45          RGBPRIMP        primp;          // color primaries if tristimulus
46 +        bool            swap2d;         // need to swap 16-bit depths?
47          const COLORV *  CF3(int x, int y) const {
48                                  return pbase.f + (rowStride*y + x)*3;
49                          }
# Line 67 | Line 68 | class PixelAccess {
68          COLRV *         SCB(int x, int y) {
69                                  return pbase.b + (rowStride*y + x)*(NCSAMP+1);
70                          }
71 +        void            EncodeDepth16(int x, int y, float z) {
72 +                                short * sp = dbase.s + rowStride*y + x;
73 +                                *sp = depth2code(z, refDepth);
74 +                                if (swap2d) swap16((char *)sp, 1);
75 +                        }
76 +        float           DecodeDepth16(int x, int y) const {
77 +                                short   sv = dbase.s[rowStride*y + x];
78 +                                if (swap2d) swap16((char *)&sv, 1);
79 +                                return code2depth(sv, refDepth);
80 +                        }
81   public:
82          double          refDepth;       // reference depth
83                          PixelAccess() {
84                                  refDepth = 1.;
85 +                                swap2d = !nativebigendian();
86                                  Init();
87                          }
88                          PixelAccess(COLORV *rp, int ystride, float *zp=NULL) {
89                                  refDepth = 1.;
90 +                                swap2d = !nativebigendian();
91                                  Init(rp, ystride, zp);
92                          }
93                          PixelAccess(COLRV *bp, int ystride, float *zp=NULL) {
94                                  refDepth = 1.;
95 +                                swap2d = !nativebigendian();
96                                  Init(bp, ystride, zp);
97                          }
98                          PixelAccess(COLRV *bp, int ystride, short *dp) {
99                                  refDepth = 1.;
100 +                                swap2d = !nativebigendian();
101                                  Init(bp, ystride, dp);
102                          }
103                          PixelAccess(COLORV *rp, int ystride, short *dp) {
104                                  refDepth = 1.;
105 +                                swap2d = !nativebigendian();
106                                  Init(rp, ystride, dp);
107                          }
108          void            Init() {
# Line 179 | Line 195 | class PixelAccess {
195                                          scolor_scolr(SCB(x,y), pv);
196                                  else
197                                          copyscolor(SCF(x,y), pv);
198 <                                if (RDTdepthT(dtyp) == RDTdfloat)
198 >                                if (DepthType() == RDTdfloat)
199                                          dbase.f[rowStride*y + x] = z;
200 <                                else if (RDTdepthT(dtyp) == RDTdshort)
201 <                                        dbase.s[rowStride*y + x] = depth2code(z, refDepth);
200 >                                else if (DepthType() == RDTdshort)
201 >                                        EncodeDepth16(x, y, z);
202                                  return true;
203                          }
204                          /// Retrieve pixel color (& depth) -- may convert either/both
# Line 197 | Line 213 | class PixelAccess {
213                                  else
214                                          copyscolor(pv, SCF(x,y));
215                                  if (!zp) return true;
216 <                                if (RDTdepthT(dtyp) == RDTdfloat)
216 >                                if (DepthType() == RDTdfloat)
217                                          *zp = dbase.f[rowStride*y + x];
218 <                                else if (RDTdepthT(dtyp) == RDTdshort)
219 <                                        *zp = code2depth(dbase.s[rowStride*y + x], refDepth);
218 >                                else if (DepthType() == RDTdshort)
219 >                                        *zp = DecodeDepth16(x, y);
220                                  else
221                                          *zp = .0f;
222                                  return true;
# Line 218 | Line 234 | class PixelAccess {
234                                          copyscolr(SCB(dx,dy), SCB(sx,sy));
235                                  else
236                                          copyscolor(SCF(dx,dy), SCF(sx,sy));
237 <                                switch (RDTdepthT(dtyp)) {
237 >                                switch (DepthType()) {
238                                  case RDTdfloat:
239                                          dbase.f[rowStride*dy + dx] =
240                                                          dbase.f[rowStride*sy + sx];
# Line 251 | Line 267 | class RpictSimulManager : protected RtraceSimulManager
267          COLORV *                barPix;                 // current render bar pixels
268          float *                 barDepth;               // current render bar depths
269          bool                    SetTile(const int ti[2]);
270 <        bool                    RenderRect();
270 >        bool                    RenderRect(const int x0 = 0, const int y0 = 0);
271          bool                    ComputePixel(int x, int y);
272 <        bool                    BelowSampThresh(int x, int y, const int noff[4][2]) const;
272 >        bool                    BelowSampThresh(const int x, const int y,
273 >                                                        const int noff[4][2]) const;
274          void                    FillSquare(const int x, const int y, const int noff[4][2]);
275          void                    NewBar(int ht = 0);
276          bool                    LowerBar(int v, int ytop);
# Line 294 | Line 311 | class RpictSimulManager : protected RtraceSimulManager
311                                          return RtraceSimulManager::AddHeader(ac, av);
312                                  }
313                                  /// Get header lines if any
314 <        const char *            GetHeader() const {
315 <                                        return RtraceSimulManager::GetHeader();
314 >        const char *            GetHeadStr() const {
315 >                                        return RtraceSimulManager::GetHeadStr();
316                                  }
317 +                                /// Look for specific header keyword, return value
318 +        const char *            GetHeadStr(const char *key, bool inOK = false) const {
319 +                                        return RtraceSimulManager::GetHeadStr(key, inOK);
320 +                                }
321                                  /// Set number of computation threads (0 => #cores)
322          int                     SetThreadCount(int nt = 0) {
323                                          return RtraceSimulManager::SetThreadCount(nt);
# Line 392 | Line 413 | class RpictSimulManager : protected RtraceSimulManager
413          RenderDataType          ResumeFrame(const char *pfname,
414                                                  const char *dfname=NULL);
415                                  /// Prepare new picture (and depth) output
416 <                                /// Writes current render size as resolution
416 >                                /// Called by RenderFrame() after NewFrame()
417          RenderDataType          NewOutput(FILE *pdfp[2], const char *pfname,
418                                                  RenderDataType dt=RDTrgbe,
419                                                  const char *dfname=NULL);
420                                  /// Reopen existing picture (and depth) file
421 +                                /// Called by ResumeFrame()
422                                  /// File pointers @ end of header (before res.)
423          RenderDataType          ReopenOutput(FILE *pdfp[2], const char *pfname,
424                                                  const char *dfname=NULL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines