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.6 by greg, Wed Aug 21 23:52:24 2024 UTC vs.
Revision 2.11 by greg, Wed Oct 23 23:40:41 2024 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines