示例#1
0
bool IMemStream::seekg(POV_LONG posi, unsigned int whence)
{
    if(!fail)
    {
        switch(whence)
        {
            case seek_set:
                if (posi < formalStart)
                    fail = true;
                else if (posi - formalStart <= size)
                    pos = posi - formalStart;
                else
                    fail = true;
                break;
            case seek_cur:
                if ((posi <= size) && (pos <= size-posi))
                    pos += posi;
                else
                    fail = true;
                break;
            case seek_end:
                if (posi <= size)
                    pos = size - posi;
                else
                    fail = true;
                break;
            default:
                POV_ASSERT(false);
                break;
        }
    }
    return !fail;
}
示例#2
0
UCS2String TemporaryFile::SuggestName()
{
    POV_ASSERT(!gTempPath.empty());

    // TODO FIXME - This allows only one temporary file per process!
    // TODO FIXME - Avoid converting back and forth between UCS-2 and system-specific encoding.
    char str [POV_FILENAME_BUFFER_CHARS + 1] = "";
    std::snprintf(str, POV_FILENAME_BUFFER_CHARS + 1, "%spov%d", UCS2toSysString(gTempPath).c_str(), int(getpid()));
    return SysToUCS2String(str);
}
示例#3
0
POV_ULONG Timer::GetThreadTime () const
{
    FILETIME    ct;
    FILETIME    et;
    __int64     kt;
    __int64     ut;
    BOOL        success;

    POV_ASSERT (mCPUTimeSupported);

    success = GetThreadTimes (mThreadHandle, &ct, &et,
                              reinterpret_cast<FILETIME *>(&kt),
                              reinterpret_cast<FILETIME *>(&ut));

    POV_ASSERT (success);
    if (!success)
        return 0;

    return ((kt + ut) / 10000);
}
示例#4
0
SimpleGammaCurvePtr GetGammaCurve(GammaTypeId type, float param)
{
    switch (type)
    {
        case kPOVList_GammaType_Neutral:    return NeutralGammaCurve::Get();
        case kPOVList_GammaType_PowerLaw:   return PowerLawGammaCurve::GetByDecodingGamma(param);
        case kPOVList_GammaType_SRGB:       return SRGBGammaCurve::Get();
        case kPOVList_GammaType_BT709:      return BT709GammaCurve::Get();
        case kPOVList_GammaType_BT1361:     return BT1361GammaCurve::Get();
        case kPOVList_GammaType_BT2020:     return BT2020GammaCurve::Get();
        default:                            POV_ASSERT (false);
    }
}
示例#5
0
void Delay(unsigned int msec)
{
#if defined(HAVE_NANOSLEEP)
    timespec ts;
    ts.tv_sec = msec / 1000;
    ts.tv_nsec = (POV_ULONG) (1000000) * (msec % 1000);
    nanosleep(&ts, NULL);
#elif defined(HAVE_USLEEP)
    POV_ASSERT(msec < 1000); // On some systems, usleep() does not support sleeping for 1 second or more.
    usleep (msec * (useconds_t)1000);
#else
#error Bad compile-time configuration.
#endif
}
示例#6
0
Timer::Timer () :
    // TODO - sources on the internet indicate that GetThreadTimes() and GetProcessTimes() have been
    //        around as early as NT 3.1. Is there a reason we're only making use of it in NT 4.0 and
    //        later Windows versions?
    mThreadHandle (NULL),
    mCPUTimeSupported (WindowsVersionDetector().IsNTVersion (4,0))
{
    if (mCPUTimeSupported)
    {
        if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), GetCurrentProcess (),
                              &mThreadHandle, 0, TRUE, DUPLICATE_SAME_ACCESS))
        {
            POV_ASSERT (false);
            mThreadHandle = NULL;
        }
    }
    Reset ();
}
示例#7
0
static void Interp(const ImageData *image, DBL xcoor, DBL ycoor, RGBFTColour& colour, int *index, bool premul)
{
    int iycoor, ixcoor, i;
    int Corners_Index[4];
    RGBFTColour Corner_Colour[4];
    DBL Corner_Factors[4];

    xcoor += 0.5;
    ycoor += 0.5;

    iycoor = (int)ycoor;
    ixcoor = (int)xcoor;

    no_interpolation(image, (DBL)ixcoor,     (DBL)iycoor,     Corner_Colour[0], &Corners_Index[0], premul);
    no_interpolation(image, (DBL)ixcoor - 1, (DBL)iycoor,     Corner_Colour[1], &Corners_Index[1], premul);
    no_interpolation(image, (DBL)ixcoor,     (DBL)iycoor - 1, Corner_Colour[2], &Corners_Index[2], premul);
    no_interpolation(image, (DBL)ixcoor - 1, (DBL)iycoor - 1, Corner_Colour[3], &Corners_Index[3], premul);

    if(image->Interpolation_Type == BILINEAR)
        bilinear(Corner_Factors, xcoor, ycoor);
    else if(image->Interpolation_Type == NORMALIZED_DIST)
        norm_dist(Corner_Factors, xcoor, ycoor);
    else
        POV_ASSERT(false);

    // We're using double precision for the colors here to avoid higher-than-1.0 results due to rounding errors,
    // which would otherwise lead to stray dot artifacts when clamped to [0..1] range for a color_map or similar.
    // (Note that strictly speaking we don't avoid such rounding errors, but rather make them small enough that
    // subsequent rounding to single precision will take care of them.)
    PreciseRGBFTColour temp_colour;
    DBL temp_index = 0;
    for (i = 0; i < 4; i ++)
    {
        temp_colour += PreciseRGBFTColour(Corner_Colour[i]) * Corner_Factors[i];
        temp_index  += Corners_Index[i]                     * Corner_Factors[i];
    }
    colour = RGBFTColour(temp_colour);
    *index = (int)temp_index;
}
示例#8
0
文件: object.cpp 项目: atlaste/povray
double ObjectBase::GetPotential (const Vector3d& p, bool subtractThreshold, TraceThreadData *threaddata) const
{
    POV_ASSERT (false);
    return 0.0;
}
示例#9
0
void AVXFMA4DNoise(Vector3d& result, const Vector3d& EPoint) { POV_ASSERT(false); }
示例#10
0
DBL AVXFMA4Noise(const Vector3d& EPoint, int noise_generator) { POV_ASSERT(false); return 0.0; }
示例#11
0
void AVX2FMA3NoiseInit() { POV_ASSERT(false); }
示例#12
0
Timer::Timer () :
    mWallTimeUseClockGettimeMonotonic (false),
    mWallTimeUseClockGettimeRealtime (false),
    mWallTimeUseGettimeofday (false),
    mProcessTimeUseGetrusageSelf (false),
    mProcessTimeUseClockGettimeProcess (false),
    mProcessTimeUseFallback (false),
    mThreadTimeUseGetrusageThread (false),
    mThreadTimeUseGetrusageLwp (false),
    mThreadTimeUseClockGettimeThread (false),
    mThreadTimeUseFallback (false)
{
    // Figure out which timer source to use for wall clock time.
    bool haveWallTime = false;
#if defined(HAVE_DECL_CLOCK_MONOTONIC) && HAVE_DECL_CLOCK_MONOTONIC
    if (!haveWallTime)
        haveWallTime = mWallTimeUseClockGettimeMonotonic = ClockGettimeMillisec(mWallTimeStart, CLOCK_MONOTONIC);
#endif
    // we prefer CLOCK_MONOTONIC over CLOCK_REALTIME because the former will not be affected if someone adjusts the
    // system's real-time clock.
#if defined(HAVE_DECL_CLOCK_REALTIME) && HAVE_DECL_CLOCK_REALTIME
    if (!haveWallTime)
        haveWallTime = mWallTimeUseClockGettimeRealtime = ClockGettimeMillisec(mWallTimeStart, CLOCK_REALTIME);
#endif
    // TODO - Find out if there is some rationale behind the preference of clock_gettime() over
    //        gettimeofday(), and document it here.
    if (!haveWallTime)
        haveWallTime = mWallTimeUseGettimeofday = GettimeofdayMillisec(mWallTimeStart);
    // FIXME: add fallback, using ftime(), or time() + a counter for ms, or maybe boost::date_time
    if (!haveWallTime)
    {
        POV_ASSERT(false);
        mWallTimeStart = 0;
    }

    // Figure out which timer source to use for per-process CPU time.
    bool haveProcessTime = false;
#if defined(HAVE_DECL_RUSAGE_SELF) && HAVE_DECL_RUSAGE_SELF
    if (!haveProcessTime)
        haveProcessTime = mProcessTimeUseGetrusageSelf = GetrusageMillisec(mProcessTimeStart, RUSAGE_SELF);
#endif
    // We prefer getrusage() over clock_gettime() because the latter may be inaccurate on systems
    // with multiple physical processors.
#if defined(HAVE_DECL_CLOCK_PROCESS_CPUTIME_ID) && HAVE_DECL_CLOCK_PROCESS_CPUTIME_ID
    if (!haveProcessTime)
        haveProcessTime = mProcessTimeUseClockGettimeProcess = ClockGettimeMillisec(mProcessTimeStart, CLOCK_PROCESS_CPUTIME_ID);
#endif
    if (!haveProcessTime)
    {
        haveProcessTime = mProcessTimeUseFallback = haveWallTime;
        mProcessTimeStart = mWallTimeStart;
    }

    // Figure out which timer source to use for per-thread CPU time.
    bool haveThreadTime = false;
#if defined(HAVE_DECL_RUSAGE_THREAD) && HAVE_DECL_RUSAGE_THREAD
    if (!haveThreadTime)
        haveThreadTime = mThreadTimeUseGetrusageThread = GetrusageMillisec(mThreadTimeStart, RUSAGE_THREAD);
#elif defined(HAVE_DECL_RUSAGE_LWP) && HAVE_DECL_RUSAGE_LWP // should be alias of RUSAGE_THREAD on systems that support both
    if (!haveThreadTime)
        haveThreadTime = mThreadTimeUseGetrusageLwp = GetrusageMillisec(mThreadTimeStart, RUSAGE_LWP);
#endif
    // We prefer getrusage() over clock_gettime() because the latter may be inaccurate on systems
    // with multiple physical processors.
#if defined(HAVE_DECL_CLOCK_THREAD_CPUTIME_ID) && HAVE_DECL_CLOCK_THREAD_CPUTIME_ID
    if (!haveThreadTime)
        haveThreadTime = mThreadTimeUseClockGettimeThread = ClockGettimeMillisec(mThreadTimeStart, CLOCK_THREAD_CPUTIME_ID);
#endif
    if (!haveThreadTime)
    {
        haveThreadTime = mThreadTimeUseFallback = haveProcessTime;
        mThreadTimeStart = mProcessTimeStart;
    }
}